1 /*
2 * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3 * the spring framework, http://el4j.sf.net
4 * Copyright (C) 2006 by ELCA Informatique SA, Av. de la Harpe 22-24,
5 * 1000 Lausanne, Switzerland, http://www.elca.ch
6 *
7 * EL4J is published under the GNU Lesser General Public License (LGPL)
8 * Version 2.1. See http://www.gnu.org/licenses/
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * For alternative licensing, please contact info@elca.ch
16 */
17 package ch.elca.el4j.services.remoting.protocol;
18
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import javax.xml.bind.JAXBContext;
23 import javax.xml.ws.handler.Handler;
24 import javax.xml.ws.handler.HandlerResolver;
25 import javax.xml.ws.handler.PortInfo;
26
27 import org.springframework.beans.MutablePropertyValues;
28
29 import ch.elca.el4j.services.remoting.protocol.jaxws.JaxwsContextHandler;
30
31 /**
32 * This class is an extension to the default JAX-WS SOAP class (using Spring) and provides the
33 * ability to transfer the implicit context inside the SOAP header using Jaxb
34 * to serialize the parameters and context.
35 *
36 * @svnLink $Revision: 3878 $;$Date: 2009-08-04 15:06:35 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/remoting_jaxws/src/main/java/ch/elca/el4j/services/remoting/protocol/JaxwsSpringSoapHeaderContextPassing.java $
37 *
38 * @author Stefan Wismer (SWI)
39 */
40 public class JaxwsSpringSoapHeaderContextPassing extends JaxwsSpring {
41 /**
42 * The {@link JAXBContext} instance used to serialize the several
43 * Objects in the implicit context.
44 */
45 private JAXBContext m_contextPassingContext = null;
46
47 /** {@inheritDoc} */
48 @Override
49 protected void adaptProxyServiceProperties(MutablePropertyValues props) {
50 super.adaptProxyServiceProperties(props);
51
52 // If context passing is enabled, add a handler
53 if (getImplicitContextPassingRegistry() != null) {
54 // Enable implicit context passing
55 props.addPropertyValue("handlerResolver", new HandlerResolver() {
56 @SuppressWarnings("unchecked")
57 public List<Handler> getHandlerChain(PortInfo portInfo) {
58 List<Handler> list = new ArrayList<Handler>();
59 list.add(new JaxwsContextHandler(
60 getImplicitContextPassingRegistry(),
61 m_contextPassingContext));
62 return list;
63 }
64 });
65 }
66 }
67
68 /**
69 * Get the {@link JAXBContext} used to serialize the implicit context.
70 * @return The used {@link JAXBContext}
71 */
72 public JAXBContext getContextPassingContext() {
73 return m_contextPassingContext;
74 }
75
76 /**
77 * Set the {@link JAXBContext} used to serialize the implicit context.
78 * @param context The {@link JAXBContext} to use
79 */
80 public void setContextPassingContext(JAXBContext context) {
81 m_contextPassingContext = context;
82 }
83 }