I am improving the usability of JBoss XTS by providing annotation support. I have one class level annotation that when applied to a JAX-WS service implementation, indicates to the middleware to carry out a few pieces of work, removing a lot of burden from the developer.

One of these "pieces of work" is to add two handlers to the JAX-WS handler chain. Using CDI I can intercept the calls to the service, but this occurs after the handler chain has been invoked. I was thinking that at some point in the deployment process, I could query the Service Impl class for the required annotation, and if found, setup the appropriate handler chain.

first of all, I moved this discussion to the development section of the forum.

Now, I see some alternatives for you to achieve what you need:

1) The user is supposed to specify handlers either using JAXWS annotation (@HandlerChain) or through the jbossws endpoint configurations (@EndpointConfig and then provide a configuration file with handlers specification in the deployment or reference a configuration in the AS7 domain). So the first option is asking users to properly annotate endpoint classes, not sure this is acceptable for your use case.

2) You could make sure a webservices.xml descriptor (JSR-109) is added to the deployment and specify the handlers in there. The descriptor is parsed during the Phase.PARSE in AS7.

3) You could also hook in a little bit later then what you'd do for 2) and modify the jbossws spi metadata that are created after parsing the webservices.xml descriptor. To be honest, you'd need actually create them most of the time, given it's not that common to have webservices.xml for JAXWS deployments. Btw, there's a little bug I just discovered here, I'm going to fix it later today or tomorrow.

4) Another alternative is using the Apache CXF API, but that would bind you to implementation details of cxf and still require some changes in jbossws for you to hook into the proper point in the endpoint publish process.. so not really a good option.

3) You could also hook in a little bit later then what you'd do for 2) and modify the jbossws spi metadata that are created after parsing the webservices.xml descriptor. To be honest, you'd need actually create them most of the time, given it's not that common to have webservices.xml for JAXWS deployments. Btw, there's a little bug I just discovered here, I'm going to fix it later today or tomorrow.

Actually this would be better then 2) because you could *add* stuff over metadata info coming from a webservices.xml a user already provided.

Thanks for the reply. I was in two minds whether to post on the dev or user section. I'll stick to the dev section in future, for issues like this.

1) & 2) arn't really an option as:

A. They don't remove the burden from the developer.

B. Different handlers will be deployed depending on the annotation. This is not something I want the user to have to understand or remember to do.

4) Doesn't sound like a good idea, due to the reasons you mention.

3) Sounds most promising. I have the following questions:

A. Will this require any changes to jbossws?

B. Will the code I plug in have access to the service implementation class? I will need to pull off the annotations to decide what to do with the handler chain. I don't need access to the actual instance.

C. Would I need to do anything special, in the situation where the developer has included a webservices.xml for an unrelated purpose?

To be clear, I think I need two things:

1) Access to the handlerchain in order to insert my own handler.

2) Access to the service impl class so that I can read off the annotations.

B. Will the code I plug in have access to the service implementation class? I will need to pull off the annotations to decide what to do with the handler chain. I don't need access to the actual instance.

Well, you can get access to the annotations attached to a given class by looking into the AS7 jandex annotation index. You just need to have your code run in the proper phase / sequence order, iow you'll need to have the annotation index already created and the webservices install processors not run yet (so that the ws deployers already see the metadata that have been modified by you).

C. Would I need to do anything special, in the situation where the developer has included a webservices.xml for an unrelated purpose?

I've been looking at the code, and I have a rough idea of where I need to begin.

1) I think I need to impliment an AbstractDeploymentAspect and specify it in jbossws-cxf-config-as7.xml? Is there another place that I can specify my AbstractDeploymentAspect impl as I'd prefer not to require the JBossWS code to be changed. I'm sure you wouldn't want me to do that either.

2) When registering my AbstractDeploymentAspect impl, I need to specify that I depend on some other AbstractDeploymentAspect implimentations. This will ensure my code is invoked at the right time.

3) My impl of AbstractDeploymentAspect should query the Deployment object to find out what services are being deployed.

4) I then look up the service classes in jandex and obtain for my annotations.

5) I make some call on the Deployment object to specify the handler(s) I wish to add to the handler chain. This handler is put in place when the MetadataBuilder is invoked from DescriptorDeploymentAspect.

you shouldn't (need) to play with the JBossWS integration deployment aspects. Your additional deployer (DeploymentUnitProcessor (DUP) in AS7) would likely live in the AS7 XTS subsystem and use the JBossWS SPI to modify the org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData that is created during Phase.PARSE of AS7.

I would wire that new DUP into the deployers chain after the Phase.PARSE_JBOSS_WEBSERVICES_XML, so once the WebservicesDescriptorDeploymentProcessor and JBossWebservicesDescriptorDeploymentProcessor have run. Those two basically create the WebservicesMetaData into the deployment unit if a webservices.xml is found in the deployment. You'd need to update that object or create it if the webservices.xml was not in the deployment. Once that's done, the jboss-as7 / jbossws deployment can go on as is and your additional info will be considered.

I've finally got all my EAP 6.0 issues off my plate (for now), so I can return to this.

I've implimented a DeploymentActivator and it is succesfully registering a DeploymentUnitProcessor when the XTS subsytem boots, I've even got it reading off the annotations, looking for the one I am interested in. I'm now ready to add a handler to the handler chain.

The problem I have is with getting the DeploymentUnitProcessor#deploy method be invoked after WSHandlerChainAnnotationProcessor#deploy. My understanding was that I should add an entry to Phase:

I've added it after PARSE_JAXWS_HANDLER_CHAIN_ANNOTATION and set the value as above. I was thinking the value represented the order in which they should be invoked. However, I've tried changing the values and the ordering does not change. My TXFramework DUP is always invoked before the WSHandlerChainAnnotationProcessor DUP. I've tried to find out where else in the code, the ordering is impossed and I'm having no luck. Can you point me at the code that sets the order?

I'm at the point where I think I have correctly configured the metadata to include the handler. In my example, I have an existing handler (org.my.simple.server.MyServerHandler) defined by a @HandlerChain annotation on the WS impl. I then add another Handler (org.jboss.as.xts.TXFrameworkHandler) to the mapping at deployment time in my DUP.

I put a breakpoint in WSIntegrationProcessorJAXWS_HANDLER#processAnnotation, on the following line:

So, it looks to me like I have setup the WSEndpointHandlersMapping correctly. However, The only handler that is invoked is the MyServerHandler. I've tried removing this handler from the set, in my DUP, and it is still invoked. This suggests to me that I'm either adding the wrong informtion, or doing it too late.

The order in which the relevent (IMO) DUPS are invoked is as follows:

WSHandlerChainAnnotationProcessor

TXFrameworkDeploymentProcessor (mine)

WSIntegrationProcessorJAXWS_HANDLER

WSRefAnnotationProcessor

In particular, here's the relavent (IMO) Phase priorities:

public static final int PARSE_WEBSERVICES_XML

= 0x2050;

public static final int PARSE_JBOSS_WEBSERVICES_XML

= 0x2051;

public static final int PARSE_JAXWS_EJB_INTEGRATION

= 0x2052;

public static final int PARSE_JAXRPC_POJO_INTEGRATION

= 0x2053;

public static final int PARSE_JAXRPC_EJB_INTEGRATION

= 0x2054;

public static final int PARSE_JAXWS_HANDLER_CHAIN_ANNOTATION

= 0x2055;

public static final int PARSE_TXFRAMEWORK_HANDLERS

= 0x2056;

public static final int PARSE_WS_JMS_INTEGRATION

= 0x2057;

public static final int PARSE_JAXWS_ENDPOINT_CREATE_COMPONENT_DESCRIPTIONS

= 0x2058;

public static final int PARSE_JAXWS_HANDLER_CREATE_COMPONENT_DESCRIPTIONS

= 0x2059;

Do you have any idea why the WSEndpointHandlersMapping seems to be ignored?

What you should still do are the changes I described in my previous posts, ie. modify the WebServicesMetaData (in the handlerchain section) to include your own handler. See https://community.jboss.org/message/641748#641748message #8 (Dec 15, 2011 6:30 AM)