-
1. Re: Start jbpm6.0 on jetty-distribution-7.6.13.v20130916
marshalslee Jan 17, 2014 8:37 AM (in response to marshalslee)After move JBPM6 to jetty-7.6.13.v20130916 ,I was tried to start JBPM6 on Karaf-2.2.3,failed.How to say,too much issues,such as the import package of the PAX-WEB is not fit to load the modified jetty.xml, the WELD ,Errai CDI,Bitronix and that i was not able to packaging such hundreds of jars in jbpm/web-info/lib.So I was trying to start JBPM6 by(not on) Karaf-2.2.3.The steps as follow:
1.Make a perfect jetty.home directory that could run JBPM6 .
2.Create a jar(here ,named as run.jar) instead of start.jar in jetty.home.Make sure you can start jetty no matter where the run.jar is located.
3.Create a bundle(named as jetty-bundle.jar which could start by karaf) contains all files in jetty.home and run.jar as resource.
4.when the bundle doStart(),unpackage the resource to somewhere,better in system.java.io.tmpdir
5.Create a classloader(Loader A) to load run.jar(of course you know the its location ),and starts the Main-Class or some other way to start jetty.
6.In former 5 steps,only a jetty started with JBPM6. How to enjoy the OSGI environment ?So I create a bundle (named communication-bundle.jar),This bundle will create an instance When osgi-bundle startup.
jetty-bundle.jar will import it and get the instance,and send to another communication.jar loaded by Loader A,but osgi-classloader. And then,we know,jetty-start will create a classloader(Loader B) to load jar in jetty.home/lib/*.So
Trying to set communication-instance to communication.jar in (Loader B).
Loader B is the classloader of the webapps. Thus, we could could get osgi service instance by communication instance and register a service but only method invoke allowed.
Bad: Hard to control the service life cycle in SOGI framwork.
communication.jar
------Config.class
some final function name,because communication instance is as a Object type and invoked by ServiceManager accorrd function name.
------ServiceManager
private static ServiceManager _superInstance;//will be setted by parent class,who create the classloader.So in common,_superInstance is not null.
some function to do method.invoke( _superInstance , params)
------ServiceManagerCreater.create
create an communication instance by osgi.activator
------Tools
public static passTo(Classloader cl)
class=cl.loadClass("package.ServiceManager");
method=class.getMethod("set",Objec.class);
//ServiceManager.getSuperInstance() will return instance in current classloader
//method.invoke(null,ServiceManager.getSuperInstance()) will set the instance to ServiceManager in sub-classloader
method.invoke(null,ServiceManager.getSuperInstance())
------
------other class to define how to invoke a service
Final,we can enjoy osgi environment in JBPM6 ,even not very convenietnt.