java - OSGi to solve pluggable architecture -



java - OSGi to solve pluggable architecture -

i have java app (that should deploy executable jar) takes json file input, this:

"appconfig": { "fizzclass": "com.me.myorg.fizzimpl" // lots of other configs }

the config allows user specify fizzclass utilize (for something, doesn't matter what) @ runtime. thing is, want app take plugins; is, can (dynamically, @ runtime) add together jars app, perhaps other fizz implementations may packaged, , user can specify these newly-available impls in config files. instance, perhaps app has public class fizzimpl implements fizz in it. let's develops plugin, foo-plugin.jar contains public class foofizz implements fizz. now, after deployed plugin app, end user pass app next config:

"appconfig": { "fizzclass": "com.some.other.foo.foofizz" // lots of other configs }

...without getting classnotfoundexceptions, etc. because foofizz on app's runtime classpath.

osgi feels perfect solution this. i'm trying understand apache felix's architecture. understanding deploy app jar include felix jar dependency it, gives me access plugin architecture. have require plugin developers bundle jars osgi bundles. first, if statements mis-led or incorrect, please begin correcting understanding of how java jar taps felix osgi runtime!

assuming i'm more or less right in understanding, question is: in order develop plugins app, follow normal instructions packaging bundles, or there special "trick" tapping felix's plugin architecture?

a way implement plugin architecture in osgi utilize osgi services. bundle fizz interface , else forms api 1 bundle. utilize sec bundle fizzimpl , utilize activator or e.g. design publish impl instance osgi service. lastly part main application needs bind service , phone call service using interface. default setup.

then can create bundle alternative implementation , publish service. distinguish 2 services can specify properties when publishing service.

then in main application can utilize configurable filter bind service matches filter. can switch impl changing filter.

i used approach in cxf xkms implement ldap based backend xkms can switched else. design file ldap impl: https://github.com/apache/cxf/blob/master/services/xkms/xkms-x509-repo-ldap/src/main/resources/osgi-inf/blueprint/blueprint.xml

and design xml main application: https://github.com/apache/cxf/blob/master/services/xkms/xkms-osgi/src/main/resources/osgi-inf/blueprint/blueprint.xml

and lastly part java code bind service using configurate filter: https://github.com/apache/cxf/blob/master/services/xkms/xkms-service/src/main/java/org/apache/cxf/xkms/service/certificaterepoproxyfactory.java

java osgi apache-felix modularity

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -