You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Dean Hiller <de...@xsoftware.biz> on 2004/11/27 22:02:18 UTC
complicated classloader/JAXBContext question
This may be more of a frustration with the JAXB spec, but I may want to add something to JaxME to get around it(if you let me)...
short description of the problem:
I need to dynamically add JAXB objects/packages to the JAXBContext after it was already created so I only need one marshaller. Services are hot deployed and want to register new packages with the one and only one marshaller.
long description of the problem:
I am using osgi as my container which plays alot of classloader games including keeping every service in it's own classloader. I have been developing an xml broker/object router. The xml broker has one server socket that clients send xml to so they can talk to all currently deployed services. Naturally, I only want on unmarshaller so when I get xml, I just call unmarshal. Otherwise, I would have to go through a list of unmarshallers(one for every service)....This is definitely not optimal for a platform. When a service deploys, it wants to register new JAXB objects with the one unmarshaller/marshaller that the xml broker has. It is purely hot deploy. When xml comes into the xml broker, the xml broker tries to unmarshal the message and if it succeeds, forwards it to the correct service. If it fails, it replies that a service for that message does is not deployed. Creating a new JAXBContext each time a new svc is deployed is out of the question also as that would result in downtime of other services which should not be affected by deploying a new non-related service.
thanks for any pointers here. If there is something I am missing in JAXB, please let me know. If not, a point in the right direction on JaxME would be great as I would love to add this behavior without affecting the JAXB compliance if possible. ie. I would be using the JaxME api's in this one case. I would much prefer sticking with JAXB apis, but this may not be possible at this time.
I have used Castor in the past which got around the class loader problems because I was able to call Resolver.addDescriptor(XXXX.class) which allowed me to dynamically add new objects and also got around class loader problems.
thanks,
dean
Re: complicated classloader/JAXBContext question
Posted by Jochen Wiedmann <jo...@freenet.de>.
Hi, Dean,
Dean Hiller wrote:
> I need to dynamically add JAXB objects/packages to the JAXBContext
> after it was already created so I only need one marshaller. Services
> are hot deployed and want to register new packages with the one and only
> one marshaller.
as you have worked out for yourself, this is impossible with the current
implementation. However, the reason is simply, because we currently
adhere to the specification: Technically it is possible and even
relatively simple: The method JAXBContextImpl.init() scans the list of
package names for Configuration.xml files, adding the contents to the
internal data. Basically you simply need to extract the part from
init(), which looks into one package and then make the method public.
In your special case, it might also make sense, to make the context
store a classloader per package and use that for loading classes. (The
JAXB specification demands a single classloader only, so this is
unsupported for now.)
Jochen
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org