[jboss-user] [JBoss Web Services] - Deploying ws with custom JAXBContext
Artem Oboturov
do-not-reply at jboss.com
Wed Aug 4 06:22:22 EDT 2010
Artem Oboturov [http://community.jboss.org/people/ArtemOboturov] replied to the discussion
"Deploying ws with custom JAXBContext"
To view the discussion, visit: http://community.jboss.org/message/555845#555845
--------------------------------------------------------------
Example below is based on http://weblogs.java.net/blog/jitu/archive/2008/08/control_of_jaxb.html http://weblogs.java.net/blog/jitu/archive/2008/08/control_of_jaxb.html.
Specify custom JAXBContextFactory on top of your webserice. Create new JAXBRIContext and pass an annotation processor to it. BaseJAXBContextFactory is under your control.
At least jaxws-rt 2.1.5 must be used internally by jboss.
Hope this will help.
@WebService(....)
@UsesJAXBContext(BaseJAXBContextFactory.class)
public class YourWebServiceBean
{
....
}
public class BaseJAXBContextFactory implements JAXBContextFactory
{
@Override
public JAXBRIContext createJAXBContext(SEIModel seiModel, List<Class> classes, List<TypeReference> typeReferences) throws JAXBException
{
Class[] arg = classes.toArray(new Class[classes.size()]);
JAXBRIContext context = JAXBRIContext.newInstance(
arg,
typeReferences,
null,
seiModel.getTargetNamespace(),
false,
null // TODO: annotation processor should be put there
);
return (JAXBRIContext)Proxy.newProxyInstance(getClass().getClassLoader(),
new Class[]{ JAXBRIContext.class },
new JAXBContextInvocationHandler());
}
}
public class JAXBContextInvocationHandler implements InvocationHandler
{
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
Object object = method.invoke(context, args);
return object;
}
}
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/555845#555845]
Start a new discussion in JBoss Web Services at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2044]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100804/cb816f3a/attachment-0001.html
More information about the jboss-user
mailing list