db4o Developer Community
Developer Community db4o open source object database, native to Java and .NET
Register   |  Login
  Search
  • Forums
  • Documentation
  • Resources
  • Downloads
  • Blogs
  • About

What is db4o?

Tags

  • benchmark
  • db4o-7.12
  • db4o-7.13
  • db4o-8.0
  • documentation
  • maven
  • Poleposition
  • release notes
  • source code

Archive

  • July, 2010 ( 2 )
  • June, 2010 ( 2 )
  • May, 2010 ( 5 )
  • February, 2010 ( 1 )
  • January, 2010 ( 3 )
  • November, 2009 ( 3 )
  • October, 2009 ( 6 )
  • September, 2009 ( 1 )
  • August, 2009 ( 3 )
  • June, 2009 ( 4 )
  • May, 2009 ( 3 )
  • March, 2009 ( 5 )
  • February, 2009 ( 1 )
  • January, 2009 ( 4 )
  • December, 2008 ( 1 )
  • November, 2008 ( 4 )
  • October, 2008 ( 2 )
  • September, 2008 ( 3 )
  • August, 2008 ( 3 )
  • July, 2008 ( 4 )
  • June, 2008 ( 3 )
  • May, 2008 ( 2 )
  • April, 2008 ( 5 )
  • February, 2008 ( 5 )
  • January, 2008 ( 6 )
  • December, 2007 ( 1 )
  • November, 2007 ( 4 )
  • October, 2007 ( 4 )
  • September, 2007 ( 3 )
  • August, 2007 ( 2 )
  • July, 2007 ( 2 )
  • June, 2007 ( 1 )
  • May, 2007 ( 6 )
  • April, 2007 ( 3 )
  • March, 2007 ( 3 )
  • February, 2007 ( 1 )
  • January, 2007 ( 1 )
  • December, 2006 ( 3 )
  • November, 2006 ( 10 )
  • October, 2006 ( 2 )
  • September, 2006 ( 2 )
  • August, 2006 ( 2 )
  • July, 2006 ( 4 )
  • June, 2006 ( 5 )
  • May, 2006 ( 6 )
  • April, 2006 ( 4 )
  • February, 2006 ( 3 )
  • Home
  • Rss Feed

Implications of instrumenting assemblies for Transparent Activation / Persistence in db4o - Part I

Posted @ 7/14/2008 2:28 PM By Adriano Verona
Posted in | 1 Comments

As the popular saying  tell us, there's no such thing as free lunch. It is no different for work related subjects.

When we introduced Transparent Activation (TA) concept we knew that it could make developer's life easier (by presenting a simpler model for object life cycle): developers would not be required to think about activation depths again; just let db4o activate your objects when it's need.

IMHO, it was a great improvement since it not only simplifies developer's life as well brings some performance gains also (once objects get activated only when needed there's no wasted time activating objects not needed). But this was not without coasts: to benefit from this simpler model, developers were required to implement IActivatable interface for each object that they wanted to be TA. Also, once enabled, any non TA aware object will be fully activated at retrieval time.

Time passed and we introduced  a way relieve developers from the need to implement Activatable interface, i.e, to make classes TA aware with no effort from developers. This is accomplished through a technique called instrumentation in which we dive into byte code level doing something like:

  1. Find each type declared in a specific assembly (.net) / jar or class (java)
  2. Analise each type found in step 1 to check whether it is a potential candidate for TA or not
  3. If we found a potential candidate for TA
    • Make the type to implement IActivatable interface
    • Implement IActivatable methods
    • Ensure that the object will be activated prior to any field access by inspecting each field access in this type and inserting the required Activate() / activate() call prior to it.
  4. Save the binary component

A pretty straight approach, I'd say.

But even when using instrumentation there are some implications that developers should be aware of. To illustrate, think about assembly signing; this is a process in which a developer "seals" an assembly contents by digitally signing it (the whole concept is beyond this post).

Basically, by signing an assembly a developer is providing ways to administrators to selectively grant access to assemblies based on the private key (related to the public key) used to sign it; also, signed assemblies are tamper resistant which means that changes (in byte code level) don't go unnoticed.

By the above description it's clear that instrumenting  a signed assembly turns it invalid afterward (since its contents gets changed) and any tentative of loading it will fail with a invalid signature error.

So, after instrumenting signed assemblies you will need to sign them again but, IMHO, you should never, ever, instrument assemblies that are not under your control, so I'd suggest you to just change your build scripts so instrumentation takes place prior to signing.

To help developers detect this, starting from version 7.4.52 Db4oTool will emit an warning when asked to instrument (whether for TA/TP or Native Queries optimizations) a signed/delay signed assembly.

Just for the sake of completeness I've included the following walk through on how to create assemblies that are instrumented and signed (for a in depth discussion on signing assemblies please, read this).

VS Project Properties VS Project Properties 2
  1. In Visual Studio, open project properties window and select signing tab.

  2. Select Sign the assembly;

  3. Expand Choose a strong name key file drop down listbox and either, select a previously created key or create a new one by selecting option;

  4. Select Delay sign only checkbox;

  5. Save your project and build

  6. Instrument your assembly (either running Db4oTool or through Db4oToolEnhancerMSBuildTask)

  7. After instrumentation, run sn tool as follows to finish the sign process:

    sn -Ra myassembly.dll mykey.snk
That's it! Your assembly is instrumented and signed.

In the next post I'll address some other implications / pitfalls regarding instrumentation for TA/TP.

Thoughts?

 Share |
Return TopTrackbackPrintPermalink
Previous Entry: db4o-7.4 Development Release
Next Entry: Performance Contest - for one more month

Comments

Was it good for you, too?Join the discussion » ,but you need to login first before you make comments.
    On processing, please waiting for ...
    Copyright ©2000-2010 by Versant Corp.
    Privacy Policy