<?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="" MadCap:InPreviewMode="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" MadCap:PathToHelpSystem="../../../../" MadCap:HelpSystemFileName="index.xml" MadCap:SearchType="Stem"> <head><title>Connecting To Db4o </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="../../../Resources/Stylesheets/OnlineStyle.css" rel="stylesheet" /> <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> <script src="../../../SkinSupport/MadCapAll.js" type="text/javascript"> </script> </head> <body> <p class="MCWebHelpFramesetLink" style="display: none;"><a href="../../../../index_CSH.html#platform_specific_issues/database_for_osgi/eclipse_plug-in_with_db4o_service/connecting_to_db4o.htm" style="">Open topic with navigation</a> </p> <p> <script type="text/javascript">/*<![CDATA[*/document.write('<a href="' + location.href +'">'); document.write("Direct Link"); document.write('</a>');/*]]>*/</script> </p> <p> </p> <h1>Connecting To Db4o</h1> <p>The only thing left - is a connection to the db4o_osgi plug-in. It can be established upon the plug-in start and terminated upon the plug-in stop:</p> <pre class="prettyprint" xml:space="preserve">Activator.java: start /** * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(BundleContext) * Obtains a db4o_osgi service reference and registers it with Db4oProvider */ public void start(BundleContext context) throws Exception { super.start(context); ServiceReference serviceRef = context. getServiceReference(Db4oService.class.getName()); Db4oService db4oService = (Db4oService)context.getService(serviceRef); Db4oProvider.Initialize(db4oService); }</pre> <pre class="prettyprint" xml:space="preserve">Activator.java: stop /** * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(BundleContext) * Unregisters the db4o_osgi service from Db4oProvider */ public void stop(BundleContext context) throws Exception { Db4oProvider.UnInitialize(); plugin = null; super.stop(context); }</pre> <p MadCap:conditions="Primary.Online">Download example code:</p> <script type="text/javascript" src="../../../SkinSupport/MadCapBodyEnd.js"> </script> </body> </html>