tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anthony Fryer <apfr...@hotmail.com>
Subject Re: Use single JAXBContext for multiple web services
Date Sun, 15 Jun 2014 11:25:51 GMT
I implemented using the ResourceAsService wrapper as you suggested and it
works.  I think that ResourceAsService could be useful enough to be included
in tomee.

My ResourceAsService class is....

public class ResourceAsService {
	private String resourceId;

	public String getResourceId() {
		return resourceId;
	}

	public void setResourceId(String resourceId) {
		this.resourceId = resourceId;
	}
	
	public Object get() throws Exception {
		if (resourceId == null) {
			throw new IllegalArgumentException("Please specify a resourceId");
		}
		
		return
SystemInstance.get().getComponent(ContainerSystem.class).getJNDIContext().lookup("openejb:Resource/"
+ resourceId);
	}

}

My resources.xml now looks like this...

<resources>
   
   <Resource id="myJAXBContextResource"
class-name="com.virginaustralia.service.GlobalJAXBContext"
factory-name="getJAXBContext"/>

   <Service id="myJAXBContextService"
class-name="au.com.cyberavenue.cxf.ResourceAsService" factory-name="get">
      resourceId = myJAXBContextResource
   </Service>
   
   <Service id="myJAXBDataBinding"
class-name="org.apache.cxf.jaxb.JAXBDataBinding" constructor="jaxbContext">
      jaxbContext = $myJAXBContextService
   </Service>
     
</resources> 

And my GlobalJAXBContext class has gone back to this...

public class GlobalJAXBContext {
	
	public static JAXBContext getJAXBContext() {
		try {
			return JAXBContext.newInstance(new Class[] {
							com.virginaustralia.model.schema.utility.ObjectFactory.class,
						
com.virginaustralia.service.contract.departure_management.ObjectFactory.class
});
		} catch (JAXBException e) {
			e.printStackTrace();
		}
		
		return null;
	}
}

and everything boots up quickly like before.  Thanks for the suggestion.

As for documentation...i would if i get time from my project.  Is there
documention on how to contribute?



--
View this message in context: http://openejb.979440.n4.nabble.com/Use-single-JAXBContext-for-multiple-web-services-tp4670019p4670024.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Mime
View raw message