Short introduction. There is a production system where some independent clients “invent” some objects with some properties and behavior – one can assign some values to these objects, launch them into action and read their state upon/while execution.
Everything’s via web interface: client logs in, assigns values, injects objects, launches container and sees his objects mutating.
Everything is based on client’s JAXB-compliant schema. Schema is compiled into Java classes and packaged as client’s jar. (Many thanks to stackoverflow members who helped me to do it on the fly).
And here is the problem: they want webservice (SOAP) doing all they currently do via web-interface. And, of course, with wsdl types according to JAXB schema they dynamically change and deploy on the daily basis 🙁
Actually, all the operations they do via web are:
- Start/stop application container (common task, not a problem)
- Inject client-defined object into container
- Retrieve objects of specific type from container
“3” is not an issue once “2” is ok. But “2” is driving me mad and I need your advice BEFORE I start doing something. In terms of WebService my question is: How do I publish WS endpoint with following method, assuming that argument type is defined by client’s JAXB schema:
@WebMethod
public void inject(UserDefinedObject obj) {
getAppContainer().inject(obj); // that's all I have to implement
}
Here are approaches I’m thinking of:
-
Use Object as argument:
public void inject(Object obj);and codeServletFilterto modify xml request/response according to client’s schema. But I’m not sure WS servlet will not check method signature and throw exceptions in that case. Another question is whether I will have access to request’s xml from within that method to perform JAXB unmarshalling. -
As I’m already compiling client jars, I could also compile webservice endpoints and deploy them dynamically as OSGI bundles. I’m absolutely new to OSGI, too many questions here: is it possible at all, what about my ear, do I need to make all as OSGI, how to communicate with EJB, etc, etc.
-
More googling, but I’m afraid Brin & Page will start charging me.
Any other ideas?
Finally decided in favour of OSGi option as described in solution to correct way to turn EAR module into OSGi bundle. Once my admin war was pulled out of ear, turned into OSGi bundle and therefore gained access to BundleContext, it’s is possible to dynamically deploy/undeploy client’s personal webservics on the fly:
Not sure this solution is applicable to other, non-OSGi based app servers. I suppose some extra OSGI configuration will be required to make it work smoothly in interaction with remaining part of EAR.