How do I use my Eclipse OSGi Java plug-in in another project? -


this new me , bit complex. created plug-in project in eclipse standard osgi framework. aim connect h2 db bundle. here activator.java: package dbservice;

import java.sql.connection; import java.sql.drivermanager;  import org.osgi.framework.bundleactivator; import org.osgi.framework.bundlecontext;  public class activator implements bundleactivator {  private static bundlecontext context; private connection conn=null;  static bundlecontext getcontext() {     return context; }   public void start(bundlecontext bundlecontext) throws exception {     activator.context = bundlecontext;     class.forname("org.h2.driver");     conn = drivermanager.getconnection("jdbc:h2:~/test","sa","123456");     system.out.print("connection opened..."); }  public void stop(bundlecontext bundlecontext) throws exception {     activator.context = null;     conn.close();     system.out.print("connection closed..."); }  } 

i run project within osgi framework. working there. question is, how use bundle in project?

the question want provide other bundles. if want provide generic way access database can provide datasource. in case recommend use pax-jdbc-config heavy lifting you.

another options aries transactioncontrol bit easier use makes user code depend on transaction control api.

if want provide higher level service best choice. create interface service , implement interface in bundle. export object osgi service. other bundles can pick service. recommend use declarative services offering , consuming services. see this example.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -