tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: Use single JAXBContext for multiple web services
Date Sun, 15 Jun 2014 17:27:10 GMT
About the doc: the site is http://svn.apache.org/repos/asf/tomee/site/trunk/
all the content is in "content" (yeah I know ;)). Add a page if you want
and link it where you judge it useful. Then just send us a patch on a jira
and we'll apply it.

PS: I'll add @xxx to link from a Service an existing resource instead of
using a wrapper the user needs to know



Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-06-15 13:25 GMT+02:00 Anthony Fryer <apfryer@hotmail.com>:

> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message