JBossWS SVN: r13148 - framework/trunk/src/main/java/org/jboss/wsf/framework/serviceref.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-18 08:41:36 -0400 (Mon, 18 Oct 2010)
New Revision: 13148
Modified:
framework/trunk/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandler.java
Log:
refactoring - adding new SPI methods
Modified: framework/trunk/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandler.java
===================================================================
--- framework/trunk/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandler.java 2010-10-18 12:35:54 UTC (rev 13147)
+++ framework/trunk/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandler.java 2010-10-18 12:41:36 UTC (rev 13148)
@@ -23,6 +23,7 @@
import javax.naming.Context;
import javax.naming.NamingException;
+import javax.naming.Referenceable;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.SPIProviderResolver;
@@ -44,6 +45,8 @@
*/
public class DefaultServiceRefHandler implements ServiceRefHandler
{
+ @Override
+ @Deprecated
public void bindServiceRef(final Context encCtx, final String encName, final UnifiedVirtualFile ignored,
final ClassLoader loader, final ServiceRefMetaData serviceRefMD) throws NamingException
{
@@ -53,6 +56,15 @@
this.getBinder(bindingType).setupServiceRef(encCtx, encName, null, serviceRefUMDM, loader);
}
+
+ @Override
+ public Referenceable createReferenceable(UnifiedServiceRefMetaData serviceRef, ClassLoader loader)
+ {
+ final Type bindingType = getServiceRefType(serviceRef, loader);
+
+ return this.getBinder(bindingType).createReferenceable(serviceRef, loader);
+ }
+
private ServiceRefBinder getBinder(final Type binderType)
{
final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
14 years, 2 months
JBossWS SVN: r13147 - common/trunk/src/main/java/org/jboss/wsf/common/serviceref.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-18 08:35:54 -0400 (Mon, 18 Oct 2010)
New Revision: 13147
Added:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinder.java
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXRPC.java
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java
Log:
refactoring - adding new SPI methods
Added: common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinder.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinder.java 2010-10-18 12:35:54 UTC (rev 13147)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.wsf.common.serviceref;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.Referenceable;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.naming.Util;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
+
+/**
+ * Abstract service ref binder.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+abstract class AbstractServiceRefBinder implements ServiceRefBinder
+{
+ private static final Logger log = Logger.getLogger(AbstractServiceRefBinder.class);
+
+ @Deprecated
+ public final void setupServiceRef(final Context encCtx, final String encName, final AnnotatedElement ignored,
+ final UnifiedServiceRefMetaData serviceRef, final ClassLoader loader) throws NamingException
+ {
+ final Referenceable jndiReferenceable = this.createReferenceable(serviceRef, loader);
+ this.bind(encCtx, encName, jndiReferenceable);
+ }
+
+ public abstract Referenceable createReferenceable(final UnifiedServiceRefMetaData serviceRef,
+ final ClassLoader loader);
+
+ private void bind(final Context encCtx, final String encName, final Referenceable jndiReferenceable)
+ throws NamingException
+ {
+ final String jndiFullName = encCtx.getNameInNamespace() + "/" + encName;
+
+ log.info("binding service reference to [jndi=" + jndiFullName + "]");
+ Util.bind(encCtx, encName, jndiReferenceable);
+ }
+}
Modified: common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXRPC.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXRPC.java 2010-10-18 12:32:46 UTC (rev 13146)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXRPC.java 2010-10-18 12:35:54 UTC (rev 13147)
@@ -21,41 +21,27 @@
*/
package org.jboss.wsf.common.serviceref;
-import java.lang.reflect.AnnotatedElement;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
import javax.naming.Referenceable;
-import org.jboss.logging.Logger;
-import org.jboss.util.naming.Util;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
/**
- * Binds a JAXRPC Service object in the client's ENC for every service-ref element in the
- * deployment descriptor.
+ * Binds a JAXRPC service object factory to the client's ENC.
*
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
-public abstract class AbstractServiceRefBinderJAXRPC implements ServiceRefBinder
+public abstract class AbstractServiceRefBinderJAXRPC extends AbstractServiceRefBinder
{
- // logging support
- private static Logger log = Logger.getLogger(AbstractServiceRefBinderJAXRPC.class);
-
- /**
- * Binds a Service into the callers ENC for every service-ref element
- */
- public void setupServiceRef(Context encCtx, String encName, AnnotatedElement ignored,
- UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException
+ public final Referenceable createReferenceable(final UnifiedServiceRefMetaData serviceRef, final ClassLoader ignored)
{
- String externalName = encCtx.getNameInNamespace() + "/" + encName;
- log.info("setupServiceRef [jndi=" + externalName + "]");
-
- // Do not use rebind, the binding should be unique
- Referenceable ref = this.createReferenceable(serviceRef);
- Util.bind(encCtx, encName, ref);
+ return this.createJAXRPCReferenceable(serviceRef);
}
- protected abstract Referenceable createReferenceable(UnifiedServiceRefMetaData serviceRef);
+ /**
+ * Template method for creating stack specific JAXRPC referenceables.
+ *
+ * @param serviceRef service reference UMDM
+ * @return stack specific JAXRPC JNDI referenceable
+ */
+ protected abstract Referenceable createJAXRPCReferenceable(final UnifiedServiceRefMetaData serviceRef);
}
Modified: common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java 2010-10-18 12:32:46 UTC (rev 13146)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java 2010-10-18 12:35:54 UTC (rev 13147)
@@ -31,8 +31,6 @@
import java.util.List;
import javax.jws.HandlerChain;
-import javax.naming.Context;
-import javax.naming.NamingException;
import javax.naming.Referenceable;
import javax.xml.namespace.QName;
import javax.xml.ws.RespectBinding;
@@ -43,23 +41,18 @@
import javax.xml.ws.soap.Addressing;
import javax.xml.ws.soap.MTOM;
-import org.jboss.logging.Logger;
-import org.jboss.util.naming.Util;
import org.jboss.wsf.spi.WSFException;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
/**
- * Binds a JAXWS Service object in the client's ENC.
+ * Binds a JAXWS service object factory to the client's ENC.
*
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
-public abstract class AbstractServiceRefBinderJAXWS implements ServiceRefBinder
+public abstract class AbstractServiceRefBinderJAXWS extends AbstractServiceRefBinder
{
- private static Logger log = Logger.getLogger(AbstractServiceRefBinderJAXWS.class);
-
- public void setupServiceRef(Context encCtx, String encName, AnnotatedElement ignored,
- UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException
+ public final Referenceable createReferenceable(final UnifiedServiceRefMetaData serviceRef, final ClassLoader loader)
{
WebServiceRef wsref = null;
@@ -119,7 +112,7 @@
{
for (WebServiceRef aux : wsrefList)
{
- if (encName.endsWith("/" + aux.name()))
+ if (serviceRef.getServiceRefName().endsWith("/" + aux.name()))
{
wsref = aux;
break;
@@ -127,7 +120,7 @@
}
}
- Class targetClass = null;
+ Class<?> targetClass = null;
if (anElement instanceof Field)
{
targetClass = ((Field) anElement).getType();
@@ -143,9 +136,6 @@
}
String targetClassName = (targetClass != null ? targetClass.getName() : null);
- String externalName = encCtx.getNameInNamespace() + "/" + encName;
- if (log.isDebugEnabled())
- log.debug("setupServiceRef [jndi=" + externalName + ",target=" + targetClassName + "]");
String serviceImplClass = null;
@@ -195,13 +185,13 @@
}
catch (MalformedURLException ex)
{
- Class declaringClass = null;
+ Class<?> declaringClass = null;
if (anElement instanceof Field)
declaringClass = ((Field) anElement).getDeclaringClass();
else if (anElement instanceof Method)
declaringClass = ((Method) anElement).getDeclaringClass();
else if (anElement instanceof Class)
- declaringClass = (Class) anElement;
+ declaringClass = (Class<?>) anElement;
handlerChain = declaringClass.getPackage().getName().replace('.', '/') + "/" + handlerChain;
}
@@ -214,7 +204,7 @@
{
try
{
- Class serviceClass = loader.loadClass(serviceImplClass);
+ Class<?> serviceClass = loader.loadClass(serviceImplClass);
if (serviceClass.getAnnotation(WebServiceClient.class) != null)
{
WebServiceClient clientDecl = (WebServiceClient) serviceClass.getAnnotation(WebServiceClient.class);
@@ -250,11 +240,17 @@
serviceRef.setRespectBindingEnabled(respectBindingAnnotation.enabled());
}
- Referenceable serviceReferenceable = this.createReferenceable(serviceImplClass, targetClassName, serviceRef);
- Util.bind(encCtx, encName, serviceReferenceable);
-
+ return this.createJAXWSReferenceable(serviceImplClass, targetClassName, serviceRef);
}
- protected abstract Referenceable createReferenceable(String serviceImplClass, String targetClassName,
- UnifiedServiceRefMetaData serviceRef);
+ /**
+ * Template method for creating stack specific JAXWS referenceables.
+ *
+ * @param serviceImplClass service implementation class name
+ * @param targetClassName target class name
+ * @param serviceRef service reference UMDM
+ * @return stack specific JAXWS JNDI referenceable
+ */
+ protected abstract Referenceable createJAXWSReferenceable(final String serviceImplClass,
+ final String targetClassName, final UnifiedServiceRefMetaData serviceRef);
}
14 years, 2 months
JBossWS SVN: r13146 - spi/trunk/src/main/java/org/jboss/wsf/spi/serviceref.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-18 08:32:46 -0400 (Mon, 18 Oct 2010)
New Revision: 13146
Modified:
spi/trunk/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefBinder.java
spi/trunk/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefHandler.java
Log:
refactoring - adding new SPI methods
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefBinder.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefBinder.java 2010-10-18 10:07:13 UTC (rev 13145)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefBinder.java 2010-10-18 12:32:46 UTC (rev 13146)
@@ -25,6 +25,7 @@
import javax.naming.Context;
import javax.naming.NamingException;
+import javax.naming.Referenceable;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
@@ -32,9 +33,15 @@
* Creates a ServiceReferenceable and binds it to JNDI.
*
* @author Heiko.Braun(a)jboss.com
- * Created: Jul 11, 2007
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
public interface ServiceRefBinder
{
+ /**
+ * @deprecated use {@link #createReferenceable(UnifiedServiceRefMetaData, ClassLoader)} instead
+ */
+ @Deprecated
void setupServiceRef(Context encCtx, String encName, AnnotatedElement anElement, UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException;
+ Referenceable createReferenceable(final UnifiedServiceRefMetaData serviceRef,
+ final ClassLoader loader);
}
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefHandler.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefHandler.java 2010-10-18 10:07:13 UTC (rev 13145)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefHandler.java 2010-10-18 12:32:46 UTC (rev 13146)
@@ -23,17 +23,36 @@
import javax.naming.Context;
import javax.naming.NamingException;
+import javax.naming.Referenceable;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
/**
- * An implementation of this interface handles all service-ref binding concerns
+ * An implementation of this interface handles all service-ref binding concerns.
*
* @author Thomas.Diesler(a)jboss.org
- * @since 05-May-2004
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
public interface ServiceRefHandler
{
- enum Type {JAXRPC, JAXWS};
- void bindServiceRef(Context encCtx, String encName, UnifiedVirtualFile vfsRoot, ClassLoader loader, ServiceRefMetaData sref) throws NamingException;
+ enum Type {
+ JAXRPC, JAXWS
+ };
+
+ /**
+ * @deprecated use {@link #createReferenceable(org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData, ClassLoader)} instead
+ */
+ @Deprecated
+ void bindServiceRef(Context encCtx, String encName, UnifiedVirtualFile vfsRoot, ClassLoader loader,
+ ServiceRefMetaData sref) throws NamingException;
+
+ /**
+ * Creates JNDI referenceable representing this <b>serviceRef</b>.
+ *
+ * @param serviceRefUMDM service reference UMDM
+ * @param loader class loader
+ * @return JNDI referenceable
+ */
+ Referenceable createReferenceable(UnifiedServiceRefMetaData serviceRefUMDM, ClassLoader loader);
}
14 years, 2 months
JBossWS SVN: r13145 - spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-18 06:07:13 -0400 (Mon, 18 Oct 2010)
New Revision: 13145
Modified:
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java
Log:
[JBWS-3140][JBWS-3141] implement proper parsing of <addressing> & <respect-binding> elements
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java 2010-10-18 08:58:38 UTC (rev 13144)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java 2010-10-18 10:07:13 UTC (rev 13145)
@@ -53,6 +53,9 @@
// The URL to the webservices.xml descriptor
private URL descriptorURL;
+
+ private boolean processingAddressingElement;
+ private boolean processingRespectBindingElement;
public WebservicesFactory(URL descriptorURL)
{
@@ -178,7 +181,18 @@
return new UnifiedHandlerMetaData(null);
else if ("handler-chains".equals(localName))
return new UnifiedHandlerChainsMetaData();
- else return null;
+ // @Addressing related elements
+ else if ("addressing".equals(localName)) {
+ processingAddressingElement = true;
+ processingRespectBindingElement = false;
+ }
+ // @RespectBinding related elements
+ else if ("respect-binding".equals(localName)) {
+ processingAddressingElement = false;
+ processingRespectBindingElement = true;
+ }
+
+ return null;
}
/**
@@ -293,19 +307,21 @@
portComponent.setProtocolBinding(value);
// @Addressing related elements
else if (localName.equals("enabled"))
- portComponent.setAddressingEnabled(Boolean.valueOf(value));
- else if (localName.equals("required"))
+ {
+ if (processingAddressingElement)
+ portComponent.setAddressingEnabled(Boolean.valueOf(value));
+ if (processingRespectBindingElement)
+ portComponent.setRespectBindingEnabled(Boolean.valueOf(value));
+ }
+ else if (localName.equals("required") && processingAddressingElement)
portComponent.setAddressingRequired(Boolean.valueOf(value));
- else if (localName.equals("responses"))
+ else if (localName.equals("responses") && processingAddressingElement)
portComponent.setAddressingResponses(value);
// @MTOM related elements
else if (localName.equals("enable-mtom"))
portComponent.setMtomEnabled(Boolean.valueOf(value));
else if (localName.equals("mtom-threshold"))
portComponent.setMtomThreshold(Integer.valueOf(value));
- // @RespectBinding related elements
- else if (localName.equals("respect-binding"))
- portComponent.setRespectBindingEnabled(Boolean.valueOf(value));
}
/**
14 years, 2 months
JBossWS SVN: r13144 - spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-18 04:58:38 -0400 (Mon, 18 Oct 2010)
New Revision: 13144
Modified:
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/PortComponentMetaData.java
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java
Log:
[JBWS-3140][JBWS-3141] implementing parsing of <addressing> <enable-mtom> <mtom-threshold> & <respect-binding> elements and updated MD accordingly
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/PortComponentMetaData.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/PortComponentMetaData.java 2010-10-18 07:39:48 UTC (rev 13143)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/PortComponentMetaData.java 2010-10-18 08:58:38 UTC (rev 13144)
@@ -77,7 +77,16 @@
// -----------------------------------------
// JAX-WS additions
- private boolean enableMtom;
+ // The optional <adressing> element
+ private boolean addressingEnabled;
+ private boolean addressingRequired;
+ private String addressingResponses = "ALL";
+ // The optional <enable-mtom> element
+ private boolean mtomEnabled;
+ // The optional <mtom-threshold> element
+ private int mtomThreshold;
+ // @RespectBinding annotation metadata
+ private boolean respectBindingEnabled;
private QName wsdlService;
private String protocolBinding;
private UnifiedHandlerChainsMetaData handlerChains;
@@ -180,16 +189,77 @@
this.secureWSDLAccess = secureWSDLAccess;
}
+ /**
+ * @deprecated Use {@link #isMtomEnabled()} instead.
+ */
+ @Deprecated
public boolean isEnableMtom()
{
- return enableMtom;
+ return mtomEnabled;
}
+ /**
+ * @deprecated Use {@link #setMtomEnabled(boolean)} instead.
+ */
+ @Deprecated
public void setEnableMtom(boolean enableMtom)
{
- this.enableMtom = enableMtom;
+ this.mtomEnabled = enableMtom;
}
+ public void setAddressingEnabled(final boolean addressingEnabled) {
+ this.addressingEnabled = addressingEnabled;
+ }
+
+ public boolean isAddressingEnabled() {
+ return this.addressingEnabled;
+ }
+
+ public void setAddressingRequired(final boolean addressingRequired) {
+ this.addressingRequired = addressingRequired;
+ }
+
+ public boolean isAddressingRequired() {
+ return this.addressingRequired;
+ }
+
+ public void setAddressingResponses(final String responsesTypes)
+ {
+ if (!"ANONYMOUS".equals(responsesTypes) && !"NON_ANONYMOUS".equals(responsesTypes) && !"ALL".equals(responsesTypes))
+ throw new IllegalArgumentException("Only ALL, ANONYMOUS or NON_ANONYMOUS strings are allowed");
+
+ this.addressingResponses = responsesTypes;
+ }
+
+ public String getAddressingResponses() {
+ return this.addressingResponses;
+ }
+
+ public void setMtomEnabled(final boolean mtomEnabled) {
+ this.mtomEnabled = mtomEnabled;
+ }
+
+ public boolean isMtomEnabled() {
+ return this.mtomEnabled;
+ }
+
+ public void setMtomThreshold(final int mtomThreshold)
+ {
+ this.mtomThreshold = mtomThreshold;
+ }
+
+ public int getMtomThreshold() {
+ return this.mtomThreshold;
+ }
+
+ public void setRespectBindingEnabled(final boolean respectBindingEnabled) {
+ this.respectBindingEnabled = respectBindingEnabled;
+ }
+
+ public boolean isRespectBindingEnabled() {
+ return this.respectBindingEnabled;
+ }
+
public QName getWsdlService()
{
return wsdlService;
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java 2010-10-18 07:39:48 UTC (rev 13143)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java 2010-10-18 08:58:38 UTC (rev 13144)
@@ -291,9 +291,21 @@
portComponent.setWsdlService(navigator.resolveQName(value));
else if (localName.equals("protocol-binding"))
portComponent.setProtocolBinding(value);
+ // @Addressing related elements
+ else if (localName.equals("enabled"))
+ portComponent.setAddressingEnabled(Boolean.valueOf(value));
+ else if (localName.equals("required"))
+ portComponent.setAddressingRequired(Boolean.valueOf(value));
+ else if (localName.equals("responses"))
+ portComponent.setAddressingResponses(value);
+ // @MTOM related elements
else if (localName.equals("enable-mtom"))
- portComponent.setEnableMtom(Boolean.valueOf(value));
-
+ portComponent.setMtomEnabled(Boolean.valueOf(value));
+ else if (localName.equals("mtom-threshold"))
+ portComponent.setMtomThreshold(Integer.valueOf(value));
+ // @RespectBinding related elements
+ else if (localName.equals("respect-binding"))
+ portComponent.setRespectBindingEnabled(Boolean.valueOf(value));
}
/**
14 years, 2 months
JBossWS SVN: r13143 - stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2010-10-18 03:39:48 -0400 (Mon, 18 Oct 2010)
New Revision: 13143
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFNonSpringServletExt.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java
Log:
[JBWS-3149]:Set MaximalAlternativeSelector to server side policy engine
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFNonSpringServletExt.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFNonSpringServletExt.java 2010-10-15 14:14:14 UTC (rev 13142)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFNonSpringServletExt.java 2010-10-18 07:39:48 UTC (rev 13143)
@@ -32,6 +32,8 @@
import org.apache.cxf.transport.servlet.ServletContextResourceResolver;
import org.apache.cxf.transport.servlet.ServletController;
import org.apache.cxf.transport.servlet.ServletTransportFactory;
+import org.apache.cxf.ws.policy.PolicyEngine;
+import org.apache.cxf.ws.policy.selector.MaximalAlternativeSelector;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.stack.cxf.configuration.BusHolder;
import org.jboss.wsf.stack.cxf.transport.ServletHelper;
@@ -65,6 +67,12 @@
//register the InstrumentManagementImpl
ServletHelper.registerInstrumentManger(bus, getServletContext());
+
+ //set MaximalAlternativeSelecltor
+ if (bus.getExtension(PolicyEngine.class) != null)
+ {
+ bus.getExtension(PolicyEngine.class).setAlternativeSelector(new MaximalAlternativeSelector());
+ }
}
private void updateAvailableBusWithServletInfo(ServletConfig servletConfig)
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java 2010-10-15 14:14:14 UTC (rev 13142)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java 2010-10-18 07:39:48 UTC (rev 13143)
@@ -32,6 +32,8 @@
import org.apache.cxf.transport.servlet.ServletContextResourceResolver;
import org.apache.cxf.transport.servlet.ServletController;
import org.apache.cxf.transport.servlet.ServletTransportFactory;
+import org.apache.cxf.ws.policy.PolicyEngine;
+import org.apache.cxf.ws.policy.selector.MaximalAlternativeSelector;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.stack.cxf.configuration.BusHolder;
import org.jboss.wsf.stack.cxf.transport.ServletHelper;
@@ -64,6 +66,12 @@
//register the InstrumentManagementImpl
ServletHelper.registerInstrumentManger(bus, getServletContext());
+
+ //set MaximalAlternativeSelecltor
+ if (bus.getExtension(PolicyEngine.class) != null)
+ {
+ bus.getExtension(PolicyEngine.class).setAlternativeSelector(new MaximalAlternativeSelector());
+ }
}
private void updateAvailableBusWithServletInfo(ServletConfig servletConfig)
14 years, 2 months
JBossWS SVN: r13142 - stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-15 10:14:14 -0400 (Fri, 15 Oct 2010)
New Revision: 13142
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java
Log:
refactoring
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java 2010-10-15 14:13:35 UTC (rev 13141)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java 2010-10-15 14:14:14 UTC (rev 13142)
@@ -21,136 +21,52 @@
*/
package org.jboss.wsf.stack.cxf.client.serviceref;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.net.URL;
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.LinkedList;
-import java.util.List;
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-import javax.naming.spi.ObjectFactory;
-import javax.xml.namespace.QName;
-import javax.xml.ws.RespectBindingFeature;
import javax.xml.ws.Service;
-import javax.xml.ws.WebServiceFeature;
-import javax.xml.ws.soap.AddressingFeature;
-import javax.xml.ws.soap.MTOMFeature;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.configuration.Configurer;
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.WSFException;
+import org.jboss.wsf.common.serviceref.AbstractServiceObjectFactoryJAXWS;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringBusFactory;
/**
- * This ServiceObjectFactory reconstructs a javax.xml.ws.Service
- * for a given WSDL when the webservice client does a JNDI lookup.
+ * {@inheritDoc}
*
- * @see CXFServiceReferenceableJAXWS
- *
* @author Thomas.Diesler(a)jboss.com
* @author Richard.Opalka(a)jboss.com
* @author alessio.soldano(a)jboss.com
*/
-public class CXFServiceObjectFactoryJAXWS implements ObjectFactory
+public final class CXFServiceObjectFactoryJAXWS extends AbstractServiceObjectFactoryJAXWS
{
- protected final Logger log = Logger.getLogger(CXFServiceObjectFactoryJAXWS.class);
+ private static final ThreadLocal<Bus> busAssociation = new ThreadLocal<Bus>();
- /**
- * Creates an object using the location or reference information specified.
- * <p/>
- *
- * @param obj The possibly null object containing location or reference
- * information that can be used in creating an object.
- * @param name The name of this object relative to <code>nameCtx</code>,
- * or null if no name is specified.
- * @param nameCtx The context relative to which the <code>name</code>
- * parameter is specified, or null if <code>name</code> is
- * relative to the default initial context.
- * @param environment The possibly null environment that is used in
- * creating the object.
- * @return The object created; null if an object cannot be created.
- * @throws Exception if this object factory encountered an exception
- * while attempting to create an object, and no other object factories are
- * to be tried.
- * @see javax.naming.spi.NamingManager#getObjectInstance
- * @see javax.naming.spi.NamingManager#getURLContext
- */
- @SuppressWarnings(value = "unchecked")
- public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable environment)
- throws Exception
+ @Override
+ protected void init(final UnifiedServiceRefMetaData serviceRefUMDM)
{
- try
- {
- // references
- final Reference ref = (Reference) obj;
- final UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
- // class names
- final String serviceImplClass = this.getServiceClassName(ref, serviceRef);
- final String targetClassName = this.getTargetClassName(ref, serviceRef, serviceImplClass);
- // class instances
- final Class<?> serviceClass = this.getClass(serviceImplClass);
- final Class<?> targetClass = this.getClass(targetClassName);
- // clean thread local bus before constructing Service
- BusFactory.setThreadDefaultBus(null);
- try
- {
- // construct service
- final Bus bus = this.createNewBus(serviceRef);
- final Service serviceInstance = this.instantiateService(serviceRef, serviceClass);
- if (serviceRef.getHandlerChain() != null)
- {
- serviceInstance.setHandlerResolver(new CXFHandlerResolverImpl(bus, serviceRef.getHandlerChain(),
- serviceInstance.getClass()));
- }
- // construct port
- final boolean instantiatePort = targetClassName != null && !targetClassName.equals(serviceImplClass);
- if (instantiatePort)
- {
- final QName portQName = this.getPortQName(targetClassName, serviceImplClass, serviceRef);
- final WebServiceFeature[] portFeatures = this.getFeatures(targetClassName, serviceImplClass, serviceRef);
-
- return instantiatePort(serviceClass, targetClass, serviceInstance, portQName, portFeatures);
- }
-
- return serviceInstance;
- }
- finally
- {
- BusFactory.setThreadDefaultBus(null);
- }
- }
- catch (Exception ex)
- {
- WSFException.rethrow("Cannot create service", ex);
- }
-
- return null;
+ BusFactory.setThreadDefaultBus(null);
+ busAssociation.set(this.createNewBus(serviceRefUMDM));
}
- private Class<?> getClass(final String className) throws ClassNotFoundException
+ @Override
+ protected void configure(final UnifiedServiceRefMetaData serviceRefUMDM, final Service service)
{
- if (className != null)
+ if (serviceRefUMDM.getHandlerChain() != null)
{
- return Thread.currentThread().getContextClassLoader().loadClass(className);
+ service.setHandlerResolver(new CXFHandlerResolverImpl(busAssociation.get(), serviceRefUMDM.getHandlerChain(),
+ service.getClass()));
}
+ }
- return null;
+ @Override
+ protected void destroy(final UnifiedServiceRefMetaData serviceRefUMDM)
+ {
+ busAssociation.set(null);
+ BusFactory.setThreadDefaultBus(null);
}
private Bus createNewBus(final UnifiedServiceRefMetaData serviceRefMD)
@@ -169,297 +85,12 @@
bus = threadBus != null ? threadBus : BusFactory.newInstance().createBus();
}
- //Add extension to configure stub properties using the UnifiedServiceRefMetaData
Configurer configurer = bus.getExtension(Configurer.class);
bus.setExtension(new CXFServiceRefStubPropertyConfigurer(serviceRefMD, configurer), Configurer.class);
return bus;
}
- private String getServiceClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD)
- {
- String serviceClassName = serviceRefMD.getServiceImplClass();
- if (serviceClassName == null)
- serviceClassName = (String) ref.get(CXFServiceReferenceableJAXWS.SERVICE_IMPL_CLASS).getContent();
-
- return serviceClassName;
- }
-
- private String getTargetClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD,
- final String serviceImplClass)
- {
- String targetClassName = serviceRefMD.getServiceRefType();
- if (targetClassName == null)
- targetClassName = (String) ref.get(CXFServiceReferenceableJAXWS.TARGET_CLASS_NAME).getContent();
-
- if (Service.class.getName().equals(targetClassName))
- targetClassName = serviceImplClass;
-
- return targetClassName;
- }
-
- private Object instantiatePort(final Class<?> serviceClass, final Class<?> targetClass, final Service target,
- final QName portQName, final WebServiceFeature[] features) throws NoSuchMethodException,
- InstantiationException, IllegalAccessException, InvocationTargetException
- {
- Object retVal = null;
-
- Object port = null;
- if (serviceClass != Service.class)
- {
- for (Method method : serviceClass.getDeclaredMethods())
- {
- String methodName = method.getName();
- Class<?> retType = method.getReturnType();
- if (methodName.startsWith("get") && targetClass.isAssignableFrom(retType))
- {
- port = method.invoke(target, new Object[0]);
- retVal = port;
- break;
- }
- }
- }
-
- if (port == null)
- {
- Method method = getMethodFor(portQName, features, serviceClass);
- Object[] args = getArgumentsFor(portQName, features, targetClass);
- port = method.invoke(target, args);
- retVal = port;
- }
-
- return retVal;
- }
-
- private Service instantiateService(final UnifiedServiceRefMetaData serviceRefMD, final Class<?> serviceClass)
- throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
- {
- final WebServiceFeature[] features = getFeatures(serviceRefMD);
- final URL wsdlURL = serviceRefMD.getWsdlLocation();
- final QName serviceQName = serviceRefMD.getServiceQName();
-
- Service target = null;
- if (serviceClass == Service.class)
- {
- // Generic javax.xml.ws.Service
- if (wsdlURL != null)
- {
- if (features != null)
- {
- target = Service.create(wsdlURL, serviceQName, features);
- }
- else
- {
- target = Service.create(wsdlURL, serviceQName);
- }
- }
- else
- {
- throw new IllegalArgumentException("Cannot create generic javax.xml.ws.Service without wsdlLocation: "
- + serviceRefMD);
- }
- }
- else
- {
- // Generated javax.xml.ws.Service subclass
- if (wsdlURL != null)
- {
- if (features != null)
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {URL.class, QName.class, WebServiceFeature[].class});
- target = (Service) ctor.newInstance(new Object[]
- {wsdlURL, serviceQName, features});
- }
- else
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {URL.class, QName.class});
- target = (Service) ctor.newInstance(new Object[]
- {wsdlURL, serviceQName});
- }
- }
- else
- {
- if (features != null)
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {WebServiceFeature[].class});
- target = (Service) ctor.newInstance(new Object[]
- {features});
- }
- else
- {
- target = (Service) serviceClass.newInstance();
- }
- }
- }
-
- return target;
- }
-
- private WebServiceFeature[] getFeatures(final String targetClassName, final String serviceClassName,
- final UnifiedServiceRefMetaData serviceRefMD)
- {
- if (targetClassName != null && !targetClassName.equals(serviceClassName))
- {
- final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
- for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
- {
- if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
- {
- return getFeatures(portComponentRefMD);
- }
- }
- }
-
- return null;
- }
-
- private QName getPortQName(final String targetClassName, final String serviceClassName,
- final UnifiedServiceRefMetaData serviceRefMD)
- {
- if (targetClassName != null && !targetClassName.equals(serviceClassName))
- {
- final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
- for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
- {
- if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
- {
- return portComponentRefMD.getPortQName();
- }
- }
- }
-
- return null;
- }
-
- private Method getMethodFor(final QName portQName, final WebServiceFeature[] features, final Class<?> serviceClass)
- throws NoSuchMethodException
- {
- if ((portQName == null) && (features == null))
- return serviceClass.getMethod("getPort", new Class[]
- {Class.class});
- if ((portQName != null) && (features == null))
- return serviceClass.getMethod("getPort", new Class[]
- {QName.class, Class.class});
- if ((portQName == null) && (features != null))
- return serviceClass.getMethod("getPort", new Class[]
- {Class.class, WebServiceFeature[].class});
- if ((portQName != null) && (features != null))
- return serviceClass.getMethod("getPort", new Class[]
- {QName.class, Class.class, WebServiceFeature[].class});
-
- throw new IllegalStateException();
- }
-
- private Object[] getArgumentsFor(final QName portQName, final WebServiceFeature[] features,
- final Class<?> targetClass) throws NoSuchMethodException
- {
- if ((portQName == null) && (features == null))
- return new Object[]
- {targetClass};
- if ((portQName != null) && (features == null))
- return new Object[]
- {portQName, targetClass};
- if ((portQName == null) && (features != null))
- return new Object[]
- {targetClass, features};
- if ((portQName != null) && (features != null))
- return new Object[]
- {portQName, targetClass, features};
-
- throw new IllegalStateException();
- }
-
- private WebServiceFeature[] getFeatures(final UnifiedServiceRefMetaData serviceRef)
- {
- List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
-
- // configure @Addressing feature
- if (serviceRef.isAddressingEnabled())
- {
- final boolean required = serviceRef.isAddressingRequired();
- final String refResponses = serviceRef.getAddressingResponses();
- AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
- if ("ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.ANONYMOUS;
- if ("NON_ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.NON_ANONYMOUS;
-
- features.add(new AddressingFeature(true, required, responses));
- }
-
- // configure @MTOM feature
- if (serviceRef.isMtomEnabled())
- {
- features.add(new MTOMFeature(true, serviceRef.getMtomThreshold()));
- }
-
- // configure @RespectBinding feature
- if (serviceRef.isRespectBindingEnabled())
- {
- features.add(new RespectBindingFeature(true));
- }
-
- WebServiceFeature[] wsFeatures = features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
- {});
- return wsFeatures;
- }
-
- private WebServiceFeature[] getFeatures(final UnifiedPortComponentRefMetaData portComponentRefMD)
- {
- List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
- // configure @Addressing feature
- if (portComponentRefMD.isAddressingEnabled())
- {
- final boolean required = portComponentRefMD.isAddressingRequired();
- final String refResponses = portComponentRefMD.getAddressingResponses();
- AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
- if ("ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.ANONYMOUS;
- if ("NON_ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.NON_ANONYMOUS;
-
- features.add(new AddressingFeature(true, required, responses));
- }
-
- // configure @MTOM feature
- if (portComponentRefMD.isMtomEnabled())
- {
- features.add(new MTOMFeature(true, portComponentRefMD.getMtomThreshold()));
- }
-
- // configure @RespectBinding feature
- if (portComponentRefMD.isRespectBindingEnabled())
- {
- features.add(new RespectBindingFeature(true));
- }
-
- return features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
- {});
- }
-
- private UnifiedServiceRefMetaData unmarshallServiceRef(final Reference ref) throws ClassNotFoundException,
- NamingException
- {
- final UnifiedServiceRefMetaData sref;
- final RefAddr refAddr = ref.get(CXFServiceReferenceableJAXWS.SERVICE_REF_META_DATA);
- final ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) refAddr.getContent());
- try
- {
- ObjectInputStream ois = new ObjectInputStream(bais);
- sref = (UnifiedServiceRefMetaData) ois.readObject();
- ois.close();
- }
- catch (IOException e)
- {
- throw new NamingException("Cannot unmarshall service ref meta data, cause: " + e.toString());
- }
-
- return sref;
- }
-
private URL getCXFConfiguration(final UnifiedVirtualFile vfsRoot)
{
URL url = null;
14 years, 2 months
JBossWS SVN: r13141 - stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-15 10:13:35 -0400 (Fri, 15 Oct 2010)
New Revision: 13141
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceObjectFactoryJAXWS.java
Log:
refactoring
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceObjectFactoryJAXWS.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceObjectFactoryJAXWS.java 2010-10-15 14:10:52 UTC (rev 13140)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceObjectFactoryJAXWS.java 2010-10-15 14:13:35 UTC (rev 13141)
@@ -21,136 +21,42 @@
*/
package org.jboss.ws.core.jaxws.client;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-import javax.xml.namespace.QName;
-import javax.xml.ws.RespectBindingFeature;
import javax.xml.ws.Service;
-import javax.xml.ws.WebServiceFeature;
-import javax.xml.ws.soap.AddressingFeature;
-import javax.xml.ws.soap.MTOMFeature;
-import org.jboss.logging.Logger;
import org.jboss.ws.core.ConfigProvider;
-import org.jboss.ws.core.client.ServiceObjectFactory;
-import org.jboss.wsf.spi.WSFException;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
+import org.jboss.wsf.common.serviceref.AbstractServiceObjectFactoryJAXWS;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
/**
- * This ServiceObjectFactory reconstructs a javax.xml.ws.Service
- * for a given WSDL when the webservice client does a JNDI lookup.
+ * {@inheritDoc}
*
* @author Thomas.Diesler(a)jboss.org
* @author Richard.Opalka(a)jboss.org
- * @since 24-Oct-2004
+ * @author alessio.soldano(a)jboss.com
*/
-public class NativeServiceObjectFactoryJAXWS extends ServiceObjectFactory
+public final class NativeServiceObjectFactoryJAXWS extends AbstractServiceObjectFactoryJAXWS
{
- // provide logging
- private static final Logger log = Logger.getLogger(NativeServiceObjectFactoryJAXWS.class);
+ private static final ThreadLocal<UnifiedServiceRefMetaData> serviceRefAssociation = new ThreadLocal<UnifiedServiceRefMetaData>();
- // The ServiceRefMetaData association
- private static ThreadLocal<UnifiedServiceRefMetaData> serviceRefAssociation = new ThreadLocal<UnifiedServiceRefMetaData>();
-
- /**
- * Creates an object using the location or reference information specified.
- * <p/>
- *
- * @param obj The possibly null object containing location or reference
- * information that can be used in creating an object.
- * @param name The name of this object relative to <code>nameCtx</code>,
- * or null if no name is specified.
- * @param nameCtx The context relative to which the <code>name</code>
- * parameter is specified, or null if <code>name</code> is
- * relative to the default initial context.
- * @param environment The possibly null environment that is used in
- * creating the object.
- * @return The object created; null if an object cannot be created.
- * @throws Exception if this object factory encountered an exception
- * while attempting to create an object, and no other object factories are
- * to be tried.
- * @see javax.naming.spi.NamingManager#getObjectInstance
- * @see javax.naming.spi.NamingManager#getURLContext
- */
- @SuppressWarnings(value = "unchecked")
- public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable environment)
- throws Exception
+ public static UnifiedServiceRefMetaData getServiceRefAssociation()
{
- try
- {
- // references
- final Reference ref = (Reference) obj;
- final UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
- // class names
- final String serviceImplClass = this.getServiceClassName(ref, serviceRef);
- final String targetClassName = this.getTargetClassName(ref, serviceRef, serviceImplClass);
- // class instances
- final Class<?> serviceClass = this.getClass(serviceImplClass);
- final Class<?> targetClass = this.getClass(targetClassName);
- final Service serviceInstance;
- try
- {
- // Associate the ServiceRefMetaData with this thread
- serviceRefAssociation.set(serviceRef);
- // construct service
- serviceInstance = this.instantiateService(serviceRef, serviceClass);
- }
- finally
- {
- serviceRefAssociation.set(null);
- }
- // Configure the service
- configureService(serviceInstance, serviceRef);
- // construct port
- final boolean instantiatePort = targetClassName != null && !targetClassName.equals(serviceImplClass);
- if (instantiatePort)
- {
- final QName portQName = this.getPortQName(targetClassName, serviceImplClass, serviceRef);
- final WebServiceFeature[] portFeatures = this.getFeatures(targetClassName, serviceImplClass, serviceRef);
-
- return instantiatePort(serviceClass, targetClass, serviceInstance, portQName, portFeatures);
- }
-
- return serviceInstance;
- }
- catch (Exception ex)
- {
- WSFException.rethrow("Cannot create service", ex);
- }
-
- return null;
+ return serviceRefAssociation.get();
}
- public static UnifiedServiceRefMetaData getServiceRefAssociation()
+ @Override
+ protected void init(final UnifiedServiceRefMetaData serviceRefUMDM)
{
- return serviceRefAssociation.get();
+ serviceRefAssociation.set(serviceRefUMDM);
}
- private void configureService(final Service service, final UnifiedServiceRefMetaData serviceRef)
+ @Override
+ protected void configure(final UnifiedServiceRefMetaData serviceRefUMDM, final Service service)
{
- final String configFile = serviceRef.getConfigFile();
- final String configName = serviceRef.getConfigName();
+ final String configFile = serviceRefUMDM.getConfigFile();
+ final String configName = serviceRefUMDM.getConfigName();
if (service instanceof ConfigProvider)
{
- if(log.isDebugEnabled()) log.debug("Configure Service: [configName=" + configName + ",configFile=" + configFile + "]");
-
- final ConfigProvider cp = (ConfigProvider)service;
+ final ConfigProvider cp = (ConfigProvider) service;
if (configName != null || configFile != null)
{
cp.setConfigName(configName, configFile);
@@ -158,297 +64,9 @@
}
}
- private Class<?> getClass(final String className) throws ClassNotFoundException
+ @Override
+ protected void destroy(final UnifiedServiceRefMetaData serviceRefUMDM)
{
- if (className != null)
- {
- return SecurityActions.getContextClassLoader().loadClass(className);
- }
-
- return null;
+ serviceRefAssociation.set(null);
}
-
- private String getServiceClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD)
- {
- String serviceClassName = serviceRefMD.getServiceImplClass();
- if (serviceClassName == null)
- serviceClassName = (String) ref.get(NativeServiceReferenceableJAXWS.SERVICE_IMPL_CLASS).getContent();
-
- return serviceClassName;
- }
-
- private String getTargetClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD,
- final String serviceImplClass)
- {
- String targetClassName = serviceRefMD.getServiceRefType();
- if (targetClassName == null)
- targetClassName = (String) ref.get(NativeServiceReferenceableJAXWS.TARGET_CLASS_NAME).getContent();
-
- if (Service.class.getName().equals(targetClassName))
- targetClassName = serviceImplClass;
-
- return targetClassName;
- }
-
- private Object instantiatePort(final Class<?> serviceClass, final Class<?> targetClass, final Service target,
- final QName portQName, final WebServiceFeature[] features) throws NoSuchMethodException,
- InstantiationException, IllegalAccessException, InvocationTargetException
- {
- Object retVal = null;
-
- Object port = null;
- if (serviceClass != Service.class)
- {
- for (Method method : serviceClass.getDeclaredMethods())
- {
- String methodName = method.getName();
- Class<?> retType = method.getReturnType();
- if (methodName.startsWith("get") && targetClass.isAssignableFrom(retType))
- {
- port = method.invoke(target, new Object[0]);
- retVal = port;
- break;
- }
- }
- }
-
- if (port == null)
- {
- Method method = getMethodFor(portQName, features, serviceClass);
- Object[] args = getArgumentsFor(portQName, features, targetClass);
- port = method.invoke(target, args);
- retVal = port;
- }
-
- return retVal;
- }
-
- private Service instantiateService(final UnifiedServiceRefMetaData serviceRefMD, final Class<?> serviceClass)
- throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
- {
- final WebServiceFeature[] features = getFeatures(serviceRefMD);
- final URL wsdlURL = serviceRefMD.getWsdlLocation();
- final QName serviceQName = serviceRefMD.getServiceQName();
-
- Service target = null;
- if (serviceClass == Service.class)
- {
- // Generic javax.xml.ws.Service
- if (wsdlURL != null)
- {
- if (features != null)
- {
- target = Service.create(wsdlURL, serviceQName, features);
- }
- else
- {
- target = Service.create(wsdlURL, serviceQName);
- }
- }
- else
- {
- throw new IllegalArgumentException("Cannot create generic javax.xml.ws.Service without wsdlLocation: "
- + serviceRefMD);
- }
- }
- else
- {
- // Generated javax.xml.ws.Service subclass
- if (wsdlURL != null)
- {
- if (features != null)
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {URL.class, QName.class, WebServiceFeature[].class});
- target = (Service) ctor.newInstance(new Object[]
- {wsdlURL, serviceQName, features});
- }
- else
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {URL.class, QName.class});
- target = (Service) ctor.newInstance(new Object[]
- {wsdlURL, serviceQName});
- }
- }
- else
- {
- if (features != null)
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {WebServiceFeature[].class});
- target = (Service) ctor.newInstance(new Object[]
- {features});
- }
- else
- {
- target = (Service) serviceClass.newInstance();
- }
- }
- }
-
- return target;
- }
-
- private WebServiceFeature[] getFeatures(final String targetClassName, final String serviceClassName,
- final UnifiedServiceRefMetaData serviceRefMD)
- {
- if (targetClassName != null && !targetClassName.equals(serviceClassName))
- {
- final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
- for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
- {
- if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
- {
- return getFeatures(portComponentRefMD);
- }
- }
- }
-
- return null;
- }
-
- private QName getPortQName(final String targetClassName, final String serviceClassName,
- final UnifiedServiceRefMetaData serviceRefMD)
- {
- if (targetClassName != null && !targetClassName.equals(serviceClassName))
- {
- final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
- for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
- {
- if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
- {
- return portComponentRefMD.getPortQName();
- }
- }
- }
-
- return null;
- }
-
- private Method getMethodFor(final QName portQName, final WebServiceFeature[] features, final Class<?> serviceClass)
- throws NoSuchMethodException
- {
- if ((portQName == null) && (features == null))
- return serviceClass.getMethod("getPort", new Class[]
- {Class.class});
- if ((portQName != null) && (features == null))
- return serviceClass.getMethod("getPort", new Class[]
- {QName.class, Class.class});
- if ((portQName == null) && (features != null))
- return serviceClass.getMethod("getPort", new Class[]
- {Class.class, WebServiceFeature[].class});
- if ((portQName != null) && (features != null))
- return serviceClass.getMethod("getPort", new Class[]
- {QName.class, Class.class, WebServiceFeature[].class});
-
- throw new IllegalStateException();
- }
-
- private Object[] getArgumentsFor(final QName portQName, final WebServiceFeature[] features,
- final Class<?> targetClass) throws NoSuchMethodException
- {
- if ((portQName == null) && (features == null))
- return new Object[]
- {targetClass};
- if ((portQName != null) && (features == null))
- return new Object[]
- {portQName, targetClass};
- if ((portQName == null) && (features != null))
- return new Object[]
- {targetClass, features};
- if ((portQName != null) && (features != null))
- return new Object[]
- {portQName, targetClass, features};
-
- throw new IllegalStateException();
- }
-
- private WebServiceFeature[] getFeatures(final UnifiedServiceRefMetaData serviceRef)
- {
- List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
-
- // configure @Addressing feature
- if (serviceRef.isAddressingEnabled())
- {
- final boolean required = serviceRef.isAddressingRequired();
- final String refResponses = serviceRef.getAddressingResponses();
- AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
- if ("ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.ANONYMOUS;
- if ("NON_ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.NON_ANONYMOUS;
-
- features.add(new AddressingFeature(true, required, responses));
- }
-
- // configure @MTOM feature
- if (serviceRef.isMtomEnabled())
- {
- features.add(new MTOMFeature(true, serviceRef.getMtomThreshold()));
- }
-
- // configure @RespectBinding feature
- if (serviceRef.isRespectBindingEnabled())
- {
- features.add(new RespectBindingFeature(true));
- }
-
- WebServiceFeature[] wsFeatures = features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
- {});
- return wsFeatures;
- }
-
- private WebServiceFeature[] getFeatures(final UnifiedPortComponentRefMetaData portComponentRefMD)
- {
- List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
- // configure @Addressing feature
- if (portComponentRefMD.isAddressingEnabled())
- {
- final boolean required = portComponentRefMD.isAddressingRequired();
- final String refResponses = portComponentRefMD.getAddressingResponses();
- AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
- if ("ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.ANONYMOUS;
- if ("NON_ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.NON_ANONYMOUS;
-
- features.add(new AddressingFeature(true, required, responses));
- }
-
- // configure @MTOM feature
- if (portComponentRefMD.isMtomEnabled())
- {
- features.add(new MTOMFeature(true, portComponentRefMD.getMtomThreshold()));
- }
-
- // configure @RespectBinding feature
- if (portComponentRefMD.isRespectBindingEnabled())
- {
- features.add(new RespectBindingFeature(true));
- }
-
- return features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
- {});
- }
-
- private UnifiedServiceRefMetaData unmarshallServiceRef(final Reference ref) throws ClassNotFoundException,
- NamingException
- {
- final UnifiedServiceRefMetaData sref;
- final RefAddr refAddr = ref.get(NativeServiceReferenceableJAXWS.SERVICE_REF_META_DATA);
- final ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) refAddr.getContent());
- try
- {
- ObjectInputStream ois = new ObjectInputStream(bais);
- sref = (UnifiedServiceRefMetaData) ois.readObject();
- ois.close();
- }
- catch (IOException e)
- {
- throw new NamingException("Cannot unmarshall service ref meta data, cause: " + e.toString());
- }
-
- return sref;
- }
}
14 years, 2 months
JBossWS SVN: r13140 - common/trunk/src/main/java/org/jboss/wsf/common/serviceref.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-15 10:10:52 -0400 (Fri, 15 Oct 2010)
New Revision: 13140
Added:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceObjectFactoryJAXWS.java
Log:
refactoring
Added: common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceObjectFactoryJAXWS.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceObjectFactoryJAXWS.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceObjectFactoryJAXWS.java 2010-10-15 14:10:52 UTC (rev 13140)
@@ -0,0 +1,429 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.serviceref;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+import javax.xml.namespace.QName;
+import javax.xml.ws.RespectBindingFeature;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.soap.AddressingFeature;
+import javax.xml.ws.soap.MTOMFeature;
+
+import org.jboss.wsf.spi.WSFException;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+/**
+ * This ServiceObjectFactory reconstructs a javax.xml.ws.Service
+ * for a given WSDL when the webservice client does a JNDI lookup.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public abstract class AbstractServiceObjectFactoryJAXWS implements ObjectFactory
+{
+ /**
+ * Creates an object using the location or reference information specified.
+ * <p/>
+ *
+ * @param obj The possibly null object containing location or reference
+ * information that can be used in creating an object.
+ * @param name The name of this object relative to <code>nameCtx</code>,
+ * or null if no name is specified.
+ * @param nameCtx The context relative to which the <code>name</code>
+ * parameter is specified, or null if <code>name</code> is
+ * relative to the default initial context.
+ * @param environment The possibly null environment that is used in
+ * creating the object.
+ * @return The object created; null if an object cannot be created.
+ * @throws Exception if this object factory encountered an exception
+ * while attempting to create an object, and no other object factories are
+ * to be tried.
+ * @see javax.naming.spi.NamingManager#getObjectInstance
+ * @see javax.naming.spi.NamingManager#getURLContext
+ */
+ @SuppressWarnings("rawtypes")
+ public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable environment)
+ throws Exception
+ {
+ try
+ {
+ // references
+ final Reference ref = (Reference) obj;
+ final UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
+ // class names
+ final String serviceImplClass = this.getServiceClassName(ref, serviceRef);
+ final String targetClassName = this.getTargetClassName(ref, serviceRef, serviceImplClass);
+ // class instances
+ final Class<?> serviceClass = this.getClass(serviceImplClass);
+ final Class<?> targetClass = this.getClass(targetClassName);
+ final Service serviceInstance;
+
+ this.init(serviceRef);
+ try
+ {
+ serviceInstance = this.instantiateService(serviceRef, serviceClass);
+ this.configure(serviceRef, serviceInstance);
+
+ // construct port
+ final boolean instantiatePort = targetClassName != null && !targetClassName.equals(serviceImplClass);
+ if (instantiatePort)
+ {
+ final QName portQName = this.getPortQName(targetClassName, serviceImplClass, serviceRef);
+ final WebServiceFeature[] portFeatures = this.getFeatures(targetClassName, serviceImplClass, serviceRef);
+
+ return instantiatePort(serviceClass, targetClass, serviceInstance, portQName, portFeatures);
+ }
+ }
+ finally
+ {
+ this.destroy(serviceRef);
+ }
+
+ return serviceInstance;
+ }
+ catch (Exception ex)
+ {
+ WSFException.rethrow("Cannot create service", ex);
+ }
+
+ return null;
+ }
+
+ protected abstract void init(final UnifiedServiceRefMetaData serviceRefUMDM);
+
+ protected abstract void configure(final UnifiedServiceRefMetaData serviceRefUMDM, final Service service);
+
+ protected abstract void destroy(final UnifiedServiceRefMetaData serviceRefUMDM);
+
+ private Class<?> getClass(final String className) throws ClassNotFoundException
+ {
+ if (className != null)
+ {
+ return Thread.currentThread().getContextClassLoader().loadClass(className);
+ }
+
+ return null;
+ }
+
+ private String getServiceClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ String serviceClassName = serviceRefMD.getServiceImplClass();
+ if (serviceClassName == null)
+ serviceClassName = (String) ref.get(AbstractServiceReferenceableJAXWS.SERVICE_IMPL_CLASS).getContent();
+
+ return serviceClassName;
+ }
+
+ private String getTargetClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD,
+ final String serviceImplClass)
+ {
+ String targetClassName = serviceRefMD.getServiceRefType();
+ if (targetClassName == null)
+ targetClassName = (String) ref.get(AbstractServiceReferenceableJAXWS.TARGET_CLASS_NAME).getContent();
+
+ if (Service.class.getName().equals(targetClassName))
+ targetClassName = serviceImplClass;
+
+ return targetClassName;
+ }
+
+ private Object instantiatePort(final Class<?> serviceClass, final Class<?> targetClass, final Service target,
+ final QName portQName, final WebServiceFeature[] features) throws NoSuchMethodException,
+ InstantiationException, IllegalAccessException, InvocationTargetException
+ {
+ Object retVal = null;
+
+ Object port = null;
+ if (serviceClass != Service.class)
+ {
+ for (Method method : serviceClass.getDeclaredMethods())
+ {
+ String methodName = method.getName();
+ Class<?> retType = method.getReturnType();
+ if (methodName.startsWith("get") && targetClass.isAssignableFrom(retType))
+ {
+ port = method.invoke(target, new Object[0]);
+ retVal = port;
+ break;
+ }
+ }
+ }
+
+ if (port == null)
+ {
+ Method method = getMethodFor(portQName, features, serviceClass);
+ Object[] args = getArgumentsFor(portQName, features, targetClass);
+ port = method.invoke(target, args);
+ retVal = port;
+ }
+
+ return retVal;
+ }
+
+ private Service instantiateService(final UnifiedServiceRefMetaData serviceRefMD, final Class<?> serviceClass)
+ throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
+ {
+ final WebServiceFeature[] features = getFeatures(serviceRefMD);
+ final URL wsdlURL = serviceRefMD.getWsdlLocation();
+ final QName serviceQName = serviceRefMD.getServiceQName();
+
+ Service target = null;
+ if (serviceClass == Service.class)
+ {
+ // Generic javax.xml.ws.Service
+ if (wsdlURL != null)
+ {
+ if (features != null)
+ {
+ target = Service.create(wsdlURL, serviceQName, features);
+ }
+ else
+ {
+ target = Service.create(wsdlURL, serviceQName);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot create generic javax.xml.ws.Service without wsdlLocation: "
+ + serviceRefMD);
+ }
+ }
+ else
+ {
+ // Generated javax.xml.ws.Service subclass
+ if (wsdlURL != null)
+ {
+ if (features != null)
+ {
+ Constructor<?> ctor = serviceClass.getConstructor(new Class[]
+ {URL.class, QName.class, WebServiceFeature[].class});
+ target = (Service) ctor.newInstance(new Object[]
+ {wsdlURL, serviceQName, features});
+ }
+ else
+ {
+ Constructor<?> ctor = serviceClass.getConstructor(new Class[]
+ {URL.class, QName.class});
+ target = (Service) ctor.newInstance(new Object[]
+ {wsdlURL, serviceQName});
+ }
+ }
+ else
+ {
+ if (features != null)
+ {
+ Constructor<?> ctor = serviceClass.getConstructor(new Class[]
+ {WebServiceFeature[].class});
+ target = (Service) ctor.newInstance(new Object[]
+ {features});
+ }
+ else
+ {
+ target = (Service) serviceClass.newInstance();
+ }
+ }
+ }
+
+ return target;
+ }
+
+ private WebServiceFeature[] getFeatures(final String targetClassName, final String serviceClassName,
+ final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ if (targetClassName != null && !targetClassName.equals(serviceClassName))
+ {
+ final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
+ for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
+ {
+ if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
+ {
+ return getFeatures(portComponentRefMD);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private QName getPortQName(final String targetClassName, final String serviceClassName,
+ final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ if (targetClassName != null && !targetClassName.equals(serviceClassName))
+ {
+ final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
+ for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
+ {
+ if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
+ {
+ return portComponentRefMD.getPortQName();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private Method getMethodFor(final QName portQName, final WebServiceFeature[] features, final Class<?> serviceClass)
+ throws NoSuchMethodException
+ {
+ if ((portQName == null) && (features == null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {Class.class});
+ if ((portQName != null) && (features == null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {QName.class, Class.class});
+ if ((portQName == null) && (features != null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {Class.class, WebServiceFeature[].class});
+ if ((portQName != null) && (features != null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {QName.class, Class.class, WebServiceFeature[].class});
+
+ throw new IllegalStateException();
+ }
+
+ private Object[] getArgumentsFor(final QName portQName, final WebServiceFeature[] features,
+ final Class<?> targetClass) throws NoSuchMethodException
+ {
+ if ((portQName == null) && (features == null))
+ return new Object[]
+ {targetClass};
+ if ((portQName != null) && (features == null))
+ return new Object[]
+ {portQName, targetClass};
+ if ((portQName == null) && (features != null))
+ return new Object[]
+ {targetClass, features};
+ if ((portQName != null) && (features != null))
+ return new Object[]
+ {portQName, targetClass, features};
+
+ throw new IllegalStateException();
+ }
+
+ private WebServiceFeature[] getFeatures(final UnifiedServiceRefMetaData serviceRef)
+ {
+ List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
+
+ // configure @Addressing feature
+ if (serviceRef.isAddressingEnabled())
+ {
+ final boolean required = serviceRef.isAddressingRequired();
+ final String refResponses = serviceRef.getAddressingResponses();
+ AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
+ if ("ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.ANONYMOUS;
+ if ("NON_ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.NON_ANONYMOUS;
+
+ features.add(new AddressingFeature(true, required, responses));
+ }
+
+ // configure @MTOM feature
+ if (serviceRef.isMtomEnabled())
+ {
+ features.add(new MTOMFeature(true, serviceRef.getMtomThreshold()));
+ }
+
+ // configure @RespectBinding feature
+ if (serviceRef.isRespectBindingEnabled())
+ {
+ features.add(new RespectBindingFeature(true));
+ }
+
+ WebServiceFeature[] wsFeatures = features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
+ {});
+ return wsFeatures;
+ }
+
+ private WebServiceFeature[] getFeatures(final UnifiedPortComponentRefMetaData portComponentRefMD)
+ {
+ List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
+ // configure @Addressing feature
+ if (portComponentRefMD.isAddressingEnabled())
+ {
+ final boolean required = portComponentRefMD.isAddressingRequired();
+ final String refResponses = portComponentRefMD.getAddressingResponses();
+ AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
+ if ("ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.ANONYMOUS;
+ if ("NON_ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.NON_ANONYMOUS;
+
+ features.add(new AddressingFeature(true, required, responses));
+ }
+
+ // configure @MTOM feature
+ if (portComponentRefMD.isMtomEnabled())
+ {
+ features.add(new MTOMFeature(true, portComponentRefMD.getMtomThreshold()));
+ }
+
+ // configure @RespectBinding feature
+ if (portComponentRefMD.isRespectBindingEnabled())
+ {
+ features.add(new RespectBindingFeature(true));
+ }
+
+ return features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
+ {});
+ }
+
+ private UnifiedServiceRefMetaData unmarshallServiceRef(final Reference ref) throws ClassNotFoundException,
+ NamingException
+ {
+ final UnifiedServiceRefMetaData sref;
+ final RefAddr refAddr = ref.get(AbstractServiceReferenceableJAXWS.SERVICE_REF_META_DATA);
+ final ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) refAddr.getContent());
+ try
+ {
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ sref = (UnifiedServiceRefMetaData) ois.readObject();
+ ois.close();
+ }
+ catch (IOException e)
+ {
+ throw new NamingException("Cannot unmarshall service ref meta data, cause: " + e.toString());
+ }
+
+ return sref;
+ }
+}
14 years, 2 months
JBossWS SVN: r13139 - in stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client: serviceref and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-15 09:04:27 -0400 (Fri, 15 Oct 2010)
New Revision: 13139
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFHandlerResolverImpl.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefStubPropertyConfigurer.java
Removed:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/HandlerResolverImpl.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceRefStubPropertyConfigurer.java
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderFactoryImpl.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceReferenceableJAXWS.java
Log:
refactoring
Deleted: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/HandlerResolverImpl.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/HandlerResolverImpl.java 2010-10-15 12:47:32 UTC (rev 13138)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/HandlerResolverImpl.java 2010-10-15 13:04:27 UTC (rev 13139)
@@ -1,378 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.wsf.stack.cxf.client;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.namespace.QName;
-import javax.xml.ws.WebServiceException;
-import javax.xml.ws.handler.Handler;
-import javax.xml.ws.handler.HandlerResolver;
-import javax.xml.ws.handler.LogicalHandler;
-import javax.xml.ws.handler.PortInfo;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.common.injection.ResourceInjector;
-import org.apache.cxf.helpers.XMLUtils;
-import org.apache.cxf.jaxws.handler.HandlerChainBuilder;
-import org.apache.cxf.jaxws.javaee.PortComponentHandlerType;
-import org.apache.cxf.resource.DefaultResourceManager;
-import org.apache.cxf.resource.ResourceManager;
-import org.apache.cxf.resource.ResourceResolver;
-import org.jboss.logging.Logger;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Handler resolver for CXF integration
- * @author richard.opalka(a)jboss.com
- */
-public final class HandlerResolverImpl extends HandlerChainBuilder implements HandlerResolver
-{
-
- private static final Logger log = Logger.getLogger(HandlerResolverImpl.class);
- private final Map<PortInfo, List<Handler>> handlerMap = new HashMap<PortInfo, List<Handler>>();
- private final String handlerFile;
- private static JAXBContext context;
- private final Class<?> clazz;
- private final ClassLoader classLoader;
- private final Bus bus;
-
- public HandlerResolverImpl(Bus bus, String handlerFile, Class<?> clazz)
- {
- super();
- this.handlerFile = handlerFile;
- this.clazz = clazz;
- this.classLoader = clazz.getClassLoader();
- this.bus = bus;
- }
-
- public List<Handler> getHandlerChain(PortInfo portInfo)
- {
- List<Handler> handlerChain = handlerMap.get(portInfo);
- if (handlerChain == null) {
- QName portQName = portInfo.getPortName();
- QName serviceQName = portInfo.getServiceName();
- String bindingId = portInfo.getBindingID();
- handlerChain = createHandlerChain(portInfo, portQName, serviceQName, bindingId);
- handlerMap.put(portInfo, handlerChain);
- }
-
- for (Handler h : handlerChain) {
- configHandler(h);
- }
-
- return handlerChain;
- }
-
- /**
- * JAX-WS section 9.3.1: The runtime MUST then carry out any injections
- * requested by the handler, typically via the javax .annotation.Resource
- * annotation. After all the injections have been carried out, including in
- * the case where no injections were requested, the runtime MUST invoke the
- * method carrying a javax.annotation .PostConstruct annotation, if present.
- */
- private void configHandler(Handler handler) {
- if (handler != null) {
- ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
- List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
- resourceManager = new DefaultResourceManager(resolvers);
-// resourceManager.addResourceResolver(new WebContextEntriesResourceResolver());
- ResourceInjector injector = new ResourceInjector(resourceManager);
- injector.inject(handler);
- injector.construct(handler);
- }
- }
-
- private InputStream getInputStream()
- {
- return this.getInputStream(this.handlerFile, this.clazz);
- }
-
- public List<Handler> createHandlerChain(PortInfo portInfo, QName portQName, QName serviceQName, String bindingID) {
- List<Handler> chain = new ArrayList<Handler>();
- InputStream is = getInputStream();
- try {
-
- if (is == null) {
- throw new WebServiceException("Handler config file not found: " + handlerFile);
- }
-
- Document doc = XMLUtils.parse(is);
- Element el = doc.getDocumentElement();
- if (!"http://java.sun.com/xml/ns/javaee".equals(el.getNamespaceURI())
- || !"handler-chains".equals(el.getLocalName())) {
-
- String xml = XMLUtils.toString(el);
- throw new WebServiceException("{http://java.sun.com/xml/ns/javaee}handler-chains element expected");
- }
- chain = new ArrayList<Handler>();
- Node node = el.getFirstChild();
- while (node != null) {
- if (node instanceof Element) {
- el = (Element)node;
- if (!el.getNamespaceURI().equals("http://java.sun.com/xml/ns/javaee")
- || !el.getLocalName().equals("handler-chain")) {
-
- String xml = XMLUtils.toString(el);
- throw new WebServiceException("{http://java.sun.com/xml/ns/javaee}handler-chain element expected");
- }
- processHandlerChainElement(el, chain, portQName, serviceQName, bindingID);
- }
- node = node.getNextSibling();
- }
- } catch (WebServiceException e) {
- throw e;
- } catch (Exception e) {
- throw new WebServiceException("No handler chain found", e);
- }
- finally
- {
- if (is != null)
- {
- try { is.close(); } catch (IOException ioe) {};
- }
- }
- assert chain != null;
- return sortHandlers(chain);
- }
-
- private void processHandlerChainElement(Element el, List<Handler> chain,
- QName portQName, QName serviceQName, String bindingID) {
- Node node = el.getFirstChild();
- while (node != null) {
- Node cur = node;
- node = node.getNextSibling();
- if (cur instanceof Element) {
- el = (Element)cur;
- if (!el.getNamespaceURI().equals("http://java.sun.com/xml/ns/javaee")) {
- String xml = XMLUtils.toString(el);
- throw new WebServiceException("Invalid element in handler: " + xml);
- }
- String name = el.getLocalName();
- if ("port-name-pattern".equals(name)) {
- if (!patternMatches(el, portQName)) {
- return;
- }
- } else if ("service-name-pattern".equals(name)) {
- if (!patternMatches(el, serviceQName)) {
- return;
- }
- } else if ("protocol-bindings".equals(name)) {
- if (!protocolMatches(el, bindingID)) {
- return;
- }
- } else if ("handler".equals(name)) {
- processHandlerElement(el, chain);
- }
- }
- }
- }
- private boolean protocolMatches(Element el, String id) {
- if (id == null) {
- return true;
- }
- String name = el.getTextContent().trim();
- if ("##SOAP11_HTTP".equals(name)) {
- return "http://schemas.xmlsoap.org/wsdl/soap/http".contains(id)
- || "http://schemas.xmlsoap.org/soap/".contains(id);
- } else if ("##SOAP11_HTTP_MTOM".equals(name)) {
- return "http://schemas.xmlsoap.org/wsdl/soap/http?mtom=true".contains(id)
- || "http://schemas.xmlsoap.org/soap/?mtom=true".contains(id);
- } else if ("##SOAP12_HTTP".equals(name)) {
- return "http://www.w3.org/2003/05/soap/bindings/HTTP/".contains(id)
- || "http://schemas.xmlsoap.org/wsdl/soap12/".contains(id);
- } else if ("##SOAP12_HTTP_MTOM".equals(name)) {
- return "http://www.w3.org/2003/05/soap/bindings/HTTP/?mtom=true".contains(id)
- || "http://schemas.xmlsoap.org/wsdl/soap12/?mtom=true".contains(id);
- } else if ("##XML_HTTP".equals(name)) {
- name = "http://www.w3.org/2004/08/wsdl/http";
- }
- return name.contains(id);
- }
- private boolean patternMatches(Element el, QName comp) {
- if (comp == null) {
- return true;
- }
- String namePattern = el.getTextContent().trim();
- if ("*".equals(namePattern)) {
- return true;
- }
- if (!namePattern.contains(":")) {
- throw new WebServiceException("Not a qname pattern: " + namePattern);
- }
- String localPart = namePattern.substring(namePattern.indexOf(':') + 1,
- namePattern.length());
- String pfx = namePattern.substring(0, namePattern.indexOf(':'));
- String ns = el.lookupNamespaceURI(pfx);
- if (ns == null) {
- ns = pfx;
- }
- if (!ns.equals(comp.getNamespaceURI())) {
- return false;
- }
- if (localPart.contains("*")) {
- //wildcard pattern matching
- return Pattern.matches(localPart, comp.getLocalPart());
- } else if (!localPart.equals(comp.getLocalPart())) {
- return false;
- }
- return true;
- }
-
- public List<Handler> sortHandlers(List<Handler> handlers) {
-
- List<LogicalHandler> logicalHandlers = new ArrayList<LogicalHandler>();
- List<Handler> protocolHandlers = new ArrayList<Handler>();
-
- for (Handler handler : handlers) {
- if (handler instanceof LogicalHandler) {
- logicalHandlers.add((LogicalHandler)handler);
- } else {
- protocolHandlers.add(handler);
- }
- }
-
- List<Handler> sortedHandlers = new ArrayList<Handler>();
- sortedHandlers.addAll(logicalHandlers);
- sortedHandlers.addAll(protocolHandlers);
- return sortedHandlers;
- }
-
- private InputStream getInputStream(String filename, Class<?> wsClass)
- {
- URL fileURL = null;
- log.debug("processHandlerChain [" + filename + "] on: " + wsClass.getName());
-
- // Try the filename as URL
- try
- {
- fileURL = new URL(filename);
- }
- catch (MalformedURLException ex)
- {
- // ignore
- }
-
- // Try the filename as File
- if (fileURL == null)
- {
- try
- {
- File file = new File(filename);
- if (file.exists())
- fileURL = file.toURI().toURL();
- }
- catch (MalformedURLException e)
- {
- // ignore
- }
- }
-
- // Try the filename as Resource
- if (fileURL == null)
- {
- log.debug(wsClass.getProtectionDomain().getCodeSource());
- log.debug(wsClass.getClassLoader());
- fileURL = wsClass.getClassLoader().getResource(filename);
- }
-
- // Try the filename relative to class
- if (fileURL == null)
- {
- String filepath = filename;
- String packagePath = wsClass.getPackage().getName().replace('.', '/');
- String resourcePath = packagePath + "/" + filepath;
- while (filepath.startsWith("../"))
- {
- packagePath = packagePath.substring(0, packagePath.lastIndexOf("/"));
- filepath = filepath.substring(3);
- resourcePath = packagePath + "/" + filepath;
- }
- fileURL = wsClass.getClassLoader().getResource(resourcePath);
- }
-
- if (fileURL == null)
- throw new WebServiceException("Cannot resolve handler file '" + filename + "' on " + wsClass.getName());
-
- try
- {
- return fileURL.openStream();
- }
- catch (IOException ioe)
- {
- throw new WebServiceException(ioe);
- }
- }
-
- private void processHandlerElement(Element el, List<Handler> chain) {
- try {
- JAXBContext ctx = getContextForPortComponentHandlerType();
- PortComponentHandlerType pt = ctx.createUnmarshaller()
- .unmarshal(el, PortComponentHandlerType.class).getValue();
- chain.addAll(buildHandlerChain(pt, classLoader));
- } catch (JAXBException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- private static synchronized JAXBContext getContextForPortComponentHandlerType()
- throws JAXBException {
- if (context == null) {
- context = JAXBContext.newInstance(PortComponentHandlerType.class);
- }
- return context;
- }
-
-}
Added: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFHandlerResolverImpl.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFHandlerResolverImpl.java (rev 0)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFHandlerResolverImpl.java 2010-10-15 13:04:27 UTC (rev 13139)
@@ -0,0 +1,376 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.client.serviceref;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.HandlerResolver;
+import javax.xml.ws.handler.LogicalHandler;
+import javax.xml.ws.handler.PortInfo;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.injection.ResourceInjector;
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.jaxws.handler.HandlerChainBuilder;
+import org.apache.cxf.jaxws.javaee.PortComponentHandlerType;
+import org.apache.cxf.resource.DefaultResourceManager;
+import org.apache.cxf.resource.ResourceManager;
+import org.apache.cxf.resource.ResourceResolver;
+import org.jboss.logging.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Handler resolver for CXF integration
+ * @author richard.opalka(a)jboss.com
+ */
+final class CXFHandlerResolverImpl extends HandlerChainBuilder implements HandlerResolver
+{
+
+ private static final Logger log = Logger.getLogger(CXFHandlerResolverImpl.class);
+ private final Map<PortInfo, List<Handler>> handlerMap = new HashMap<PortInfo, List<Handler>>();
+ private final String handlerFile;
+ private static JAXBContext context;
+ private final Class<?> clazz;
+ private final ClassLoader classLoader;
+ private final Bus bus;
+
+ public CXFHandlerResolverImpl(Bus bus, String handlerFile, Class<?> clazz)
+ {
+ super();
+ this.handlerFile = handlerFile;
+ this.clazz = clazz;
+ this.classLoader = clazz.getClassLoader();
+ this.bus = bus;
+ }
+
+ public List<Handler> getHandlerChain(PortInfo portInfo)
+ {
+ List<Handler> handlerChain = handlerMap.get(portInfo);
+ if (handlerChain == null) {
+ QName portQName = portInfo.getPortName();
+ QName serviceQName = portInfo.getServiceName();
+ String bindingId = portInfo.getBindingID();
+ handlerChain = createHandlerChain(portInfo, portQName, serviceQName, bindingId);
+ handlerMap.put(portInfo, handlerChain);
+ }
+
+ for (Handler h : handlerChain) {
+ configHandler(h);
+ }
+
+ return handlerChain;
+ }
+
+ /**
+ * JAX-WS section 9.3.1: The runtime MUST then carry out any injections
+ * requested by the handler, typically via the javax .annotation.Resource
+ * annotation. After all the injections have been carried out, including in
+ * the case where no injections were requested, the runtime MUST invoke the
+ * method carrying a javax.annotation .PostConstruct annotation, if present.
+ */
+ private void configHandler(Handler handler) {
+ if (handler != null) {
+ ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
+ List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
+ resourceManager = new DefaultResourceManager(resolvers);
+ ResourceInjector injector = new ResourceInjector(resourceManager);
+ injector.inject(handler);
+ injector.construct(handler);
+ }
+ }
+
+ private InputStream getInputStream()
+ {
+ return this.getInputStream(this.handlerFile, this.clazz);
+ }
+
+ public List<Handler> createHandlerChain(PortInfo portInfo, QName portQName, QName serviceQName, String bindingID) {
+ List<Handler> chain = new ArrayList<Handler>();
+ InputStream is = getInputStream();
+ try {
+
+ if (is == null) {
+ throw new WebServiceException("Handler config file not found: " + handlerFile);
+ }
+
+ Document doc = XMLUtils.parse(is);
+ Element el = doc.getDocumentElement();
+ if (!"http://java.sun.com/xml/ns/javaee".equals(el.getNamespaceURI())
+ || !"handler-chains".equals(el.getLocalName())) {
+
+ String xml = XMLUtils.toString(el);
+ throw new WebServiceException("{http://java.sun.com/xml/ns/javaee}handler-chains element expected");
+ }
+ chain = new ArrayList<Handler>();
+ Node node = el.getFirstChild();
+ while (node != null) {
+ if (node instanceof Element) {
+ el = (Element)node;
+ if (!el.getNamespaceURI().equals("http://java.sun.com/xml/ns/javaee")
+ || !el.getLocalName().equals("handler-chain")) {
+
+ String xml = XMLUtils.toString(el);
+ throw new WebServiceException("{http://java.sun.com/xml/ns/javaee}handler-chain element expected");
+ }
+ processHandlerChainElement(el, chain, portQName, serviceQName, bindingID);
+ }
+ node = node.getNextSibling();
+ }
+ } catch (WebServiceException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new WebServiceException("No handler chain found", e);
+ }
+ finally
+ {
+ if (is != null)
+ {
+ try { is.close(); } catch (IOException ioe) {};
+ }
+ }
+ assert chain != null;
+ return sortHandlers(chain);
+ }
+
+ private void processHandlerChainElement(Element el, List<Handler> chain,
+ QName portQName, QName serviceQName, String bindingID) {
+ Node node = el.getFirstChild();
+ while (node != null) {
+ Node cur = node;
+ node = node.getNextSibling();
+ if (cur instanceof Element) {
+ el = (Element)cur;
+ if (!el.getNamespaceURI().equals("http://java.sun.com/xml/ns/javaee")) {
+ String xml = XMLUtils.toString(el);
+ throw new WebServiceException("Invalid element in handler: " + xml);
+ }
+ String name = el.getLocalName();
+ if ("port-name-pattern".equals(name)) {
+ if (!patternMatches(el, portQName)) {
+ return;
+ }
+ } else if ("service-name-pattern".equals(name)) {
+ if (!patternMatches(el, serviceQName)) {
+ return;
+ }
+ } else if ("protocol-bindings".equals(name)) {
+ if (!protocolMatches(el, bindingID)) {
+ return;
+ }
+ } else if ("handler".equals(name)) {
+ processHandlerElement(el, chain);
+ }
+ }
+ }
+ }
+ private boolean protocolMatches(Element el, String id) {
+ if (id == null) {
+ return true;
+ }
+ String name = el.getTextContent().trim();
+ if ("##SOAP11_HTTP".equals(name)) {
+ return "http://schemas.xmlsoap.org/wsdl/soap/http".contains(id)
+ || "http://schemas.xmlsoap.org/soap/".contains(id);
+ } else if ("##SOAP11_HTTP_MTOM".equals(name)) {
+ return "http://schemas.xmlsoap.org/wsdl/soap/http?mtom=true".contains(id)
+ || "http://schemas.xmlsoap.org/soap/?mtom=true".contains(id);
+ } else if ("##SOAP12_HTTP".equals(name)) {
+ return "http://www.w3.org/2003/05/soap/bindings/HTTP/".contains(id)
+ || "http://schemas.xmlsoap.org/wsdl/soap12/".contains(id);
+ } else if ("##SOAP12_HTTP_MTOM".equals(name)) {
+ return "http://www.w3.org/2003/05/soap/bindings/HTTP/?mtom=true".contains(id)
+ || "http://schemas.xmlsoap.org/wsdl/soap12/?mtom=true".contains(id);
+ } else if ("##XML_HTTP".equals(name)) {
+ name = "http://www.w3.org/2004/08/wsdl/http";
+ }
+ return name.contains(id);
+ }
+ private boolean patternMatches(Element el, QName comp) {
+ if (comp == null) {
+ return true;
+ }
+ String namePattern = el.getTextContent().trim();
+ if ("*".equals(namePattern)) {
+ return true;
+ }
+ if (!namePattern.contains(":")) {
+ throw new WebServiceException("Not a qname pattern: " + namePattern);
+ }
+ String localPart = namePattern.substring(namePattern.indexOf(':') + 1,
+ namePattern.length());
+ String pfx = namePattern.substring(0, namePattern.indexOf(':'));
+ String ns = el.lookupNamespaceURI(pfx);
+ if (ns == null) {
+ ns = pfx;
+ }
+ if (!ns.equals(comp.getNamespaceURI())) {
+ return false;
+ }
+ if (localPart.contains("*")) {
+ //wildcard pattern matching
+ return Pattern.matches(localPart, comp.getLocalPart());
+ } else if (!localPart.equals(comp.getLocalPart())) {
+ return false;
+ }
+ return true;
+ }
+
+ public List<Handler> sortHandlers(List<Handler> handlers) {
+
+ List<LogicalHandler> logicalHandlers = new ArrayList<LogicalHandler>();
+ List<Handler> protocolHandlers = new ArrayList<Handler>();
+
+ for (Handler handler : handlers) {
+ if (handler instanceof LogicalHandler) {
+ logicalHandlers.add((LogicalHandler)handler);
+ } else {
+ protocolHandlers.add(handler);
+ }
+ }
+
+ List<Handler> sortedHandlers = new ArrayList<Handler>();
+ sortedHandlers.addAll(logicalHandlers);
+ sortedHandlers.addAll(protocolHandlers);
+ return sortedHandlers;
+ }
+
+ private InputStream getInputStream(String filename, Class<?> wsClass)
+ {
+ URL fileURL = null;
+ log.debug("processHandlerChain [" + filename + "] on: " + wsClass.getName());
+
+ // Try the filename as URL
+ try
+ {
+ fileURL = new URL(filename);
+ }
+ catch (MalformedURLException ex)
+ {
+ // ignore
+ }
+
+ // Try the filename as File
+ if (fileURL == null)
+ {
+ try
+ {
+ File file = new File(filename);
+ if (file.exists())
+ fileURL = file.toURI().toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore
+ }
+ }
+
+ // Try the filename as Resource
+ if (fileURL == null)
+ {
+ log.debug(wsClass.getProtectionDomain().getCodeSource());
+ log.debug(wsClass.getClassLoader());
+ fileURL = wsClass.getClassLoader().getResource(filename);
+ }
+
+ // Try the filename relative to class
+ if (fileURL == null)
+ {
+ String filepath = filename;
+ String packagePath = wsClass.getPackage().getName().replace('.', '/');
+ String resourcePath = packagePath + "/" + filepath;
+ while (filepath.startsWith("../"))
+ {
+ packagePath = packagePath.substring(0, packagePath.lastIndexOf("/"));
+ filepath = filepath.substring(3);
+ resourcePath = packagePath + "/" + filepath;
+ }
+ fileURL = wsClass.getClassLoader().getResource(resourcePath);
+ }
+
+ if (fileURL == null)
+ throw new WebServiceException("Cannot resolve handler file '" + filename + "' on " + wsClass.getName());
+
+ try
+ {
+ return fileURL.openStream();
+ }
+ catch (IOException ioe)
+ {
+ throw new WebServiceException(ioe);
+ }
+ }
+
+ private void processHandlerElement(Element el, List<Handler> chain) {
+ try {
+ JAXBContext ctx = getContextForPortComponentHandlerType();
+ PortComponentHandlerType pt = ctx.createUnmarshaller()
+ .unmarshal(el, PortComponentHandlerType.class).getValue();
+ chain.addAll(buildHandlerChain(pt, classLoader));
+ } catch (JAXBException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static synchronized JAXBContext getContextForPortComponentHandlerType()
+ throws JAXBException {
+ if (context == null) {
+ context = JAXBContext.newInstance(PortComponentHandlerType.class);
+ }
+ return context;
+ }
+
+}
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java 2010-10-15 12:47:32 UTC (rev 13138)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java 2010-10-15 13:04:27 UTC (rev 13139)
@@ -55,7 +55,6 @@
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.stack.cxf.client.HandlerResolverImpl;
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringBusFactory;
/**
@@ -116,7 +115,7 @@
final Service serviceInstance = this.instantiateService(serviceRef, serviceClass);
if (serviceRef.getHandlerChain() != null)
{
- serviceInstance.setHandlerResolver(new HandlerResolverImpl(bus, serviceRef.getHandlerChain(),
+ serviceInstance.setHandlerResolver(new CXFHandlerResolverImpl(bus, serviceRef.getHandlerChain(),
serviceInstance.getClass()));
}
// construct port
@@ -172,7 +171,7 @@
//Add extension to configure stub properties using the UnifiedServiceRefMetaData
Configurer configurer = bus.getExtension(Configurer.class);
- bus.setExtension(new ServiceRefStubPropertyConfigurer(serviceRefMD, configurer), Configurer.class);
+ bus.setExtension(new CXFServiceRefStubPropertyConfigurer(serviceRefMD, configurer), Configurer.class);
return bus;
}
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderFactoryImpl.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderFactoryImpl.java 2010-10-15 12:47:32 UTC (rev 13138)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderFactoryImpl.java 2010-10-15 13:04:27 UTC (rev 13139)
@@ -26,7 +26,7 @@
import org.jboss.wsf.spi.serviceref.ServiceRefHandler.Type;
/**
- * Binds a JAXWS Service object in the client's ENC
+ * Binds either JAXRPC or JAXWS Service object in the client's ENC.
*
* @author Thomas.Diesler(a)jboss.com
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
Added: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefStubPropertyConfigurer.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefStubPropertyConfigurer.java (rev 0)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefStubPropertyConfigurer.java 2010-10-15 13:04:27 UTC (rev 13139)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.client.serviceref;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.soap.MTOMFeature;
+
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedStubPropertyMetaData;
+
+/**
+ * A CXF configurer that sets the serviceref data in the JaxWsProxyFactoryBean
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 21-Jul-2009
+ */
+final class CXFServiceRefStubPropertyConfigurer implements Configurer
+{
+ private UnifiedServiceRefMetaData serviceRefMD;
+ private Configurer delegate;
+
+ public CXFServiceRefStubPropertyConfigurer(UnifiedServiceRefMetaData serviceRefMD, Configurer delegate)
+ {
+ this.serviceRefMD = serviceRefMD;
+ this.delegate = delegate;
+ }
+
+ public void configureBean(Object beanInstance)
+ {
+ if (delegate != null)
+ {
+ delegate.configureBean(beanInstance);
+ }
+ }
+
+ public void configureBean(String name, Object beanInstance)
+ {
+ if (name != null && beanInstance instanceof JaxWsProxyFactoryBean)
+ {
+ QName portQName = null;
+ try
+ {
+ String portName = name.substring(0, name.indexOf(".jaxws-client.proxyFactory"));
+ portQName = QName.valueOf(portName);
+ }
+ catch (Exception e)
+ {
+ Logger.getLogger(this.getClass()).warn("Unable to retrieve port QName from '" + name + "', trying matching port using endpoint interface name only.");
+ }
+ configureJaxWsProxyFactoryBean(portQName, (JaxWsProxyFactoryBean)beanInstance);
+ }
+ if (delegate != null)
+ {
+ delegate.configureBean(name, beanInstance);
+ }
+ }
+
+ private synchronized void configureJaxWsProxyFactoryBean(QName portQName, JaxWsProxyFactoryBean proxyFactory)
+ {
+ Class<?> clazz = proxyFactory.getServiceClass();
+ UnifiedPortComponentRefMetaData upcmd = serviceRefMD.getPortComponentRef(clazz != null ? clazz.getName() : null, portQName);
+ if (upcmd != null)
+ {
+ setProperties(proxyFactory, upcmd);
+ setMTOM((JaxWsServiceFactoryBean)proxyFactory.getServiceFactory(), upcmd);
+ }
+ }
+
+ private void setMTOM(JaxWsServiceFactoryBean serviceFactoryBean, UnifiedPortComponentRefMetaData upcmd)
+ {
+ if (upcmd.isMtomEnabled())
+ {
+ List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
+ List<WebServiceFeature> prevFeatures = serviceFactoryBean.getWsFeatures();
+ if (prevFeatures != null)
+ {
+ features.addAll(prevFeatures);
+ }
+ features.add(new MTOMFeature(true));
+ serviceFactoryBean.setWsFeatures(features);
+ }
+ }
+
+ private void setProperties(JaxWsProxyFactoryBean proxyFactory, UnifiedPortComponentRefMetaData upcmd)
+ {
+ Map<String, Object> properties = proxyFactory.getProperties();
+ if (properties == null)
+ {
+ properties = new HashMap<String, Object>();
+ proxyFactory.setProperties(properties);
+ }
+ for (UnifiedStubPropertyMetaData prop : upcmd.getStubProperties())
+ {
+ properties.put(prop.getPropName(), prop.getPropValue());
+ }
+ }
+}
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceReferenceableJAXWS.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceReferenceableJAXWS.java 2010-10-15 12:47:32 UTC (rev 13138)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceReferenceableJAXWS.java 2010-10-15 13:04:27 UTC (rev 13139)
@@ -30,7 +30,7 @@
* @author Thomas.Diesler(a)jboss.org
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
-public class CXFServiceReferenceableJAXWS extends AbstractServiceReferenceableJAXWS<CXFServiceObjectFactoryJAXWS>
+final class CXFServiceReferenceableJAXWS extends AbstractServiceReferenceableJAXWS<CXFServiceObjectFactoryJAXWS>
{
public CXFServiceReferenceableJAXWS(final String serviceImplClass, final String targetClassName,
final UnifiedServiceRefMetaData serviceRefUMDM)
Deleted: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceRefStubPropertyConfigurer.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceRefStubPropertyConfigurer.java 2010-10-15 12:47:32 UTC (rev 13138)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceRefStubPropertyConfigurer.java 2010-10-15 13:04:27 UTC (rev 13139)
@@ -1,127 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.wsf.stack.cxf.client.serviceref;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.WebServiceFeature;
-import javax.xml.ws.soap.MTOMFeature;
-
-import org.apache.cxf.configuration.Configurer;
-import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
-import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedStubPropertyMetaData;
-
-/**
- * A CXF configurer that sets the serviceref data in the JaxWsProxyFactoryBean
- *
- * @author alessio.soldano(a)jboss.com
- * @since 21-Jul-2009
- */
-public class ServiceRefStubPropertyConfigurer implements Configurer
-{
- private UnifiedServiceRefMetaData serviceRefMD;
- private Configurer delegate;
-
- public ServiceRefStubPropertyConfigurer(UnifiedServiceRefMetaData serviceRefMD, Configurer delegate)
- {
- this.serviceRefMD = serviceRefMD;
- this.delegate = delegate;
- }
-
- public void configureBean(Object beanInstance)
- {
- if (delegate != null)
- {
- delegate.configureBean(beanInstance);
- }
- }
-
- public void configureBean(String name, Object beanInstance)
- {
- if (name != null && beanInstance instanceof JaxWsProxyFactoryBean)
- {
- QName portQName = null;
- try
- {
- String portName = name.substring(0, name.indexOf(".jaxws-client.proxyFactory"));
- portQName = QName.valueOf(portName);
- }
- catch (Exception e)
- {
- Logger.getLogger(this.getClass()).warn("Unable to retrieve port QName from '" + name + "', trying matching port using endpoint interface name only.");
- }
- configureJaxWsProxyFactoryBean(portQName, (JaxWsProxyFactoryBean)beanInstance);
- }
- if (delegate != null)
- {
- delegate.configureBean(name, beanInstance);
- }
- }
-
- private synchronized void configureJaxWsProxyFactoryBean(QName portQName, JaxWsProxyFactoryBean proxyFactory)
- {
- Class<?> clazz = proxyFactory.getServiceClass();
- UnifiedPortComponentRefMetaData upcmd = serviceRefMD.getPortComponentRef(clazz != null ? clazz.getName() : null, portQName);
- if (upcmd != null)
- {
- setProperties(proxyFactory, upcmd);
- setMTOM((JaxWsServiceFactoryBean)proxyFactory.getServiceFactory(), upcmd);
- }
- }
-
- private void setMTOM(JaxWsServiceFactoryBean serviceFactoryBean, UnifiedPortComponentRefMetaData upcmd)
- {
- if (upcmd.getEnableMTOM())
- {
- List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
- List<WebServiceFeature> prevFeatures = serviceFactoryBean.getWsFeatures();
- if (prevFeatures != null)
- {
- features.addAll(prevFeatures);
- }
- features.add(new MTOMFeature(true));
- serviceFactoryBean.setWsFeatures(features);
- }
- }
-
- private void setProperties(JaxWsProxyFactoryBean proxyFactory, UnifiedPortComponentRefMetaData upcmd)
- {
- Map<String, Object> properties = proxyFactory.getProperties();
- if (properties == null)
- {
- properties = new HashMap<String, Object>();
- proxyFactory.setProperties(properties);
- }
- for (UnifiedStubPropertyMetaData prop : upcmd.getStubProperties())
- {
- properties.put(prop.getPropName(), prop.getPropValue());
- }
- }
-}
14 years, 2 months