dman Cool ;) On Wed, Oct 28, 2009 at 8:01 PM, Jacek Laskowski <[email protected]> wrote: > Hi, > > I moved on to handle deploying ejbs to osgified openejb and see if I > could access it from a bundle. I couldn't even think of it and how > simple it could be, but believe it or not it works now! You can deploy > them and access from bundles. > > The idea is to deploy a ejb and expose business interfaces as osgi > services. In fact, osgi services are not that different from the way > application servers handle ejbs. That's exactly the same. It's just a > separation of your interface and implementation so the only dependency > of a bundlized ejb client is to import ejb interfaces. Nothing unusual > in Java EE and so is in OSGi. > > So, now the set of the required bundles is as follows: > > [ 0] [Active ] [ 0] System Bundle > [ 1] [Active ] [ 1] > file:/c:/openejb-osgi/felix-framework-2.0.1/bundle/org.apache.felix.bundlerepository-1.4.2.jar > [ 2] [Active ] [ 1] > file:/c:/openejb-osgi/felix-framework-2.0.1/bundle/org.apache.felix.shell-1.4.1.jar > [ 3] [Active ] [ 1] > file:/c:/openejb-osgi/felix-framework-2.0.1/bundle/org.apache.felix.shell.tui-1.4.1.jar > [ 4] [Active ] [ 1] > file:C:/.m2/org/apache/openejb/openejb-core/3.1.2-SNAPSHOT/openejb-core-3.1.2-SNAPSHOT.jar > [ 5] [Resolved ] [ 1] > http://repo2.maven.org/maven2/org/apache/geronimo/specs/geronimo-annotation_1.0_spec/1.1.1/geronimo-annotation_1.0_spec-1.1.1.jar > [ 7] [Resolved ] [ 1] > http://repo2.maven.org/maven2/org/apache/geronimo/specs/geronimo-jta_1.1_spec/1.1.1/geronimo-jta_1.1_spec-1.1.1.jar > [ 8] [Resolved ] [ 1] > http://repo2.maven.org/maven2/org/apache/geronimo/specs/geronimo-interceptor_3.0_spec/1.0.1/geronimo-interceptor_3.0_spec-1.0.1.jar > [ 9] [Resolved ] [ 1] > http://repo2.maven.org/maven2/org/apache/geronimo/specs/geronimo-javamail_1.4_spec/1.6/geronimo-javamail_1.4_spec-1.6.jar > [ 10] [Resolved ] [ 1] > http://repo2.maven.org/maven2/org/apache/geronimo/specs/geronimo-j2ee-management_1.1_spec/1.0.1/geronimo-j2ee-management_1.1_spec-1.0.1.jar > [ 11] [Resolved ] [ 1] > http://repo2.maven.org/maven2/org/apache/geronimo/specs/geronimo-jpa_3.0_spec/1.1.1/geronimo-jpa_3.0_spec-1.1.1.jar > [ 12] [Resolved ] [ 1] > http://repo2.maven.org/maven2/org/apache/geronimo/specs/geronimo-j2ee-connector_1.5_spec/2.0.0/geronimo-j2ee-connector_1.5_spec-2.0.0.jar > [ 13] [Resolved ] [ 1] > http://repo2.maven.org/maven2/org/apache/geronimo/specs/geronimo-jacc_1.1_spec/1.0.2/geronimo-jacc_1.1_spec-1.0.2.jar > [ 14] [Resolved ] [ 1] > http://repo2.maven.org/maven2/org/apache/servicemix/bundles/org.apache.servicemix.bundles.wsdl4j/1.6.1_1/org.apache.servicemix.bundles.wsdl4j-1.6.1_1.jar > [ 16] [Resolved ] [ 1] > http://repo2.maven.org/maven2/org/ops4j/pax/logging/pax-logging-api/1.4/pax-logging-api-1.4.jar > [ 17] [Resolved ] [ 1] > http://download.eclipse.org/tools/orbit/downloads/drops/R20090825191606/bundles/org.apache.commons.cli_1.0.0.v20080604-1500.jar > [ 18] [Resolved ] [ 1] > http://download.eclipse.org/tools/orbit/downloads/drops/R20090825191606/bundles/org.apache.commons.lang_2.4.0.v20081016-1030.jar > [ 19] [Resolved ] [ 1] > http://download.eclipse.org/tools/orbit/downloads/drops/R20090825191606/bundles/org.apache.commons.logging_1.1.1.v200904062255.jar > [ 20] [Resolved ] [ 1] > http://repo2.maven.org/maven2/org/apache/geronimo/components/geronimo-connector/2.1.3/geronimo-connector-2.1.3.jar > [ 21] [Resolved ] [ 1] > http://repo2.maven.org/maven2/org/apache/geronimo/components/geronimo-transaction/2.1.3/geronimo-transaction-2.1.3.jar > [ 22] [Resolved ] [ 1] > file:C:\.m2\org\apache\openejb\openejb-api\3.1.2-SNAPSHOT\openejb-api-3.1.2-SNAPSHOT.jar > [ 23] [Resolved ] [ 1] > file:C:\.m2\org\apache\openejb\openejb-javaagent\3.1.2-SNAPSHOT\openejb-javaagent-3.1.2-SNAPSHOT.jar > [ 24] [Resolved ] [ 1] > file:C:/.m2/org/apache/openejb/openejb-jee/3.1.2-SNAPSHOT/openejb-jee-3.1.2-SNAPSHOT.jar > [ 25] [Resolved ] [ 1] > file:C:/.m2/org/apache/openejb/openejb-loader/3.1.2-SNAPSHOT/openejb-loader-3.1.2-SNAPSHOT.jar > [ 27] [Resolved ] [ 1] > file:C:\.m2\org\apache\xbean\xbean-asm-shaded\3.7-SNAPSHOT\xbean-asm-shaded-3.7-SNAPSHOT.jar > [ 29] [Resolved ] [ 1] > file:C:\.m2\org\apache\xbean\xbean-naming\3.7-SNAPSHOT\xbean-naming-3.7-SNAPSHOT.jar > [ 30] [Resolved ] [ 1] > file:C:\.m2\org\apache\xbean\xbean-reflect\3.7-SNAPSHOT\xbean-reflect-3.7-SNAPSHOT.jar > [ 32] [Resolved ] [ 1] > http://repo2.maven.org/maven2/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar > [ 35] [Active ] [ 1] > http://repo1.maven.org/maven2/org/ops4j/pax/url/pax-url-wrap/1.1.2/pax-url-wrap-1.1.2.jar > [ 36] [Resolved ] [ 1] > wrap:http://repo2.maven.org/maven2/org/apache/activemq/activemq-core/4.1.1/activemq-core-4.1.1.jar > [ 37] [Resolved ] [ 1] > wrap:http://repo2.maven.org/maven2/org/apache/activemq/activemq-ra/4.1.1/activemq-ra-4.1.1.jar > [ 40] [Active ] [ 1] > file:C:\projs\sandbox\openejb-osgi-v1\wynik5\plugins\ejb_stateless_1.0.0.jar > [ 44] [Resolved ] [ 1] > file:C:\.m2\org\apache\xbean\xbean-finder-shaded\3.7-SNAPSHOT\xbean-finder-shaded-3.7-SNAPSHOT-bundle.jar > [ 48] [Resolved ] [ 1] > file:C:\.m2\org\apache\geronimo\specs\geronimo-ejb_3.1_spec\1.0.0-EA1-SNAPSHOT\geronimo-ejb_3.1_spec-1.0.0-EA1-SNAPSHOT.jar > [ 50] [Active ] [ 1] > file:C:\.m2\org\apache\openejb\openejb-core-osgi\3.1.2-SNAPSHOT\openejb-core-osgi-3.1.2-SNAPSHOT.jar > [ 52] [Active ] [ 1] > file:C:\projs\sandbox\openejb-osgi-v1\wynik5\plugins\ejb_client_1.0.0.jar > > The client (id: 52) looks as follows: > > package ejb_client; > > import org.osgi.framework.BundleActivator; > import org.osgi.framework.BundleContext; > import org.osgi.framework.ServiceReference; > > import ejb.BusinessInterface; > > public class Activator implements BundleActivator { > > public void start(BundleContext context) throws Exception { > System.out.println("Starting the ejb client"); > > ServiceReference serviceReference = > context.getServiceReference("ejb.BusinessInterface"); > BusinessInterface businessIntf = (BusinessInterface) > context.getService(serviceReference); > String result = businessIntf.execute("Hello from " + > context.getBundle().getSymbolicName()); > System.out.println(result); > } > > public void stop(BundleContext context) throws Exception { > System.out.println("Stoping the ejb client..."); > } > > } > > with its MANIFEST.MF: > > Manifest-Version: 1.0 > Bundle-ManifestVersion: 2 > Bundle-Name: Ejb_client > Bundle-SymbolicName: ejb_client > Bundle-Version: 1.0.0 > Bundle-Activator: ejb_client.Activator > Import-Package: ejb, > javax.naming, > javax.transaction, > org.apache.openejb.client, > org.osgi.framework;version="1.3.0" > Bundle-RequiredExecutionEnvironment: JavaSE-1.6 > Require-Bundle: org.apache.openejb.core;bundle-version="3.1.2" > > The rest is in the repo. Ask questions for more information. Give it a > try so you can really feel what I feel :) > > I'll be polishing it (no pun intended) to handle more complex use > cases in the coming days. > > Jacek > > -- > Jacek Laskowski > Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl >
-- Thanks - Mohammad Nour - LinkedIn: http://www.linkedin.com/in/mnour ---- "Life is like riding a bicycle. To keep your balance you must keep moving" - Albert Einstein "Writing clean code is what you must do in order to call yourself a professional. There is no reasonable excuse for doing anything less than your best." - Clean Code: A Handbook of Agile Software Craftsmanship
