Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 2e9c43658e374d290a2de15d25134ac8 > files > 407

db4o-doc-8.0-1.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="2" MadCap:lastHeight="120" MadCap:lastWidth="624" MadCap:disableMasterStylesheet="true" MadCap:tocPath="Advanced Features|Enhancement Tools" MadCap:InPreviewMode="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" MadCap:PathToHelpSystem="../../../../../" MadCap:HelpSystemFileName="index.xml" MadCap:SearchType="Stem">
    <head><title>Load Time Enhancement	</title>
        <script type="text/javascript">/* <![CDATA[ */
window.onload = function(){
	var pathToFlash = $('html').attr('MadCap:PathToHelpSystem') + 'Content/Resources/Code/ZeroClipboard.swf';
	ZeroClipboard.setMoviePath(pathToFlash);
			
	function bindToClipBord(element,content){
		var clip = new ZeroClipboard.Client();
		clip.setText(content);
		clip.glue(element);
	};
		
	if(location.protocol==='file:'){
		$('.copylink-marker').remove();
	} else{
			$('.copylink-marker').each(function(){
				var text = $(this).parent().parent().children('.prettyprint').html();
				$(this).hover(function(){
					bindToClipBord(this,text);
				},
				function(){});
			});	
	}		
	prettyPrint();	
};
                /* ]]> */</script>
        <link href="../../../../SkinSupport/MadCap.css" rel="stylesheet" />
        <link href="../../../../Resources/Stylesheets/OnlineStyle.css" rel="stylesheet" />
        <script src="../../../../SkinSupport/MadCapAll.js">
        </script>
        <script src="../../../../Resources/Code/prettify.js">
        </script>
        <script src="../../../../Resources/Code/lang-vb.js">
        </script>
        <script src="../../../../Resources/Code/jquery.min.js">
        </script>
        <script src="../../../../Resources/Code/ZeroClipboard.js">
        </script>
    </head>
    <body>
        <p class="MCWebHelpFramesetLink" style="display: none;"><a href="../../../../../index_CSH.html#advanced_topics/enhancement_tools/enhancement_for_java/complex_example/load_time_enhancement.htm" style="">Open topic with navigation</a>
        </p>
        <div class="MCBreadcrumbsBox"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="../../../../advanced_topics.htm">Advanced Features</a><span class="MCBreadcrumbsDivider"> &gt; </span><a class="MCBreadcrumbsLink" href="../../../enhancement_tools.htm">Enhancement Tools</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Load Time Enhancement</span>
        </div>
        <p>
            <script type="text/javascript">/*<![CDATA[*/document.write('<a href="' + location.href +'">');
				document.write("Direct Link");
			document.write('</a>');/*]]>*/</script>
        </p>
        <p>
        </p>
        <h1>Load Time Enhancement</h1>
        <p>Its possible to enhance you classes at runtime. This mechanism uses the Java class loading mechanism. Instead of using the regular class-loader, the application needs to use a db4o-classloader which enhanced the classes when loaded.</p>
        <p>The enable load time enhancement, you need to create a special launcher for your application. This launcher sets up the class-loader and then starts the application.</p>
        <p>The db4o instrumenting classloader has following configuration options available:</p>
        <ul>
            <li value="1">A <i>ClassFilter</i> specifies which classes should be instrumented. In the example, we are using a filter that will only accept classes whose fully qualified name starts with a given prefix. The instrumentation API already comes with a variety of other filter implementations, and it's easy to create custom filters.</li>
            <li value="2">A sequence of <i>ClassEdits</i>. A ClassEdit is a single instrumentation step. In the example, we are applying two steps: First, we preoptimize all Native Query Predicates, then we instrument for Transparent <span class="MCPopup"><a href="javascript:void(0);" class="MCPopupSpot" onclick="FMCPopup( event, this ); return false;" MadCap:src="../../../../basics/activation.htm">Activation<img style="border: none;margin-left: 5px;" src="../../../../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../../../../SkinSupport/ExpandingOpen.gif" class="MCExpandingIcon" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../../../../SkinSupport/ExpandingOpen.gif' ); }" /></a></span>. Note that the order of steps is significant: Switching the order would leave the generated <span class="MCTextPopup"><a href="javascript:void(0);" class="MCTextPopupSpot" onclick="FMCTextPopup( event, this ); return false;">NQ<img style="border: none;margin-left: 5px;" src="../../../../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../../../../SkinSupport/ExpandingOpen.gif" class="MCExpandingIcon" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../../../../SkinSupport/ExpandingOpen.gif' ); }" /></a><span class="MCTextPopupBody" style="display: none; ">Native Query</span></span> optimization code unaware of <span class="MCTextPopup"><a href="javascript:void(0);" class="MCTextPopupSpot" onclick="FMCTextPopup( event, this ); return false;">TA<img style="border: none;margin-left: 5px;" src="../../../../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../../../../SkinSupport/ExpandingOpen.gif" class="MCExpandingIcon" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../../../../SkinSupport/ExpandingOpen.gif' ); }" /></a><span class="MCTextPopupBody" style="display: none; ">Transparent Activation</span></span>. The db4otools package provides a convenience launcher with a hardwired sequence for combined NQ/TA instrumentation.</li>
            <li value="3">The <i>classpath</i> for the instrumented classes, represented by a sequence of URLs. This must contain all classes "reachable" from the classes to be instrumented - the easiest way probably is to provide the full application class path here. The classes to be instrumented need not be listed here, they are implicitly added to this classpath, anyway.  </li>
        </ul>
        <p>A start of your application might look like this:</p>
        <pre class="prettyprint" xml:space="preserve">EnhancerStarter.java: main
public static void main(String[] args) throws Exception  { 
    //&#160;use a class-filter to only enhance certain classes
    ClassFilter filter = new ByNameClassFilter("yourpackages.datamodel.", true);
    // specify which enhancements you need.&#160;Typically the native-query
    // optimisation and tranparent activation support
    BloatClassEdit[] edits =  { new TranslateNQToSODAEdit() , new InjectTransparentActivationEdit(filter) };
    //&#160;specify the where the jars &amp; classes of your project are
    URL[] urls =  { new File("/work/workspaces/db4o/tatest/bin").toURI().toURL() };
    //&#160;the launch the application
    Db4oInstrumentationLauncher.launch(edits, urls, EnhancerMain.class.getName(), args);
  }</pre>
        <p>Try this code now - if everything is correct you will see
that the objects are getting activated as they are requested. NQ info also
should say that the queries are preoptimized.</p>
        <p>Note that for load time instrumentation to work, the application code has to make sure db4o operates on the appropriate classloader for the persistent model classes.</p>
        <p>This means that you need to set explicitly the class-loader for the reflection. Set the thread-context class loader in the db4o configuration. </p>
        <p>Don't forget that you still need to <a href="../../../../basics/activation_concept/transparent_activation_framework.htm">enable transparent activation</a> /&#160;<a href="../../../../basics/update_concept/transparent_persistence.htm">persistence</a> in order to use it.</p>
        <p style="font-weight: bold;">&#160;</p>
        <script type="text/javascript" src="../../../../SkinSupport/MadCapBodyEnd.js">
        </script>
    </body>
</html>