JBossWS SVN: r13158 - stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-10-20 06:20:01 -0400 (Wed, 20 Oct 2010)
New Revision: 13158
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java
Log:
Minor cosmetic change
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java 2010-10-20 07:51:43 UTC (rev 13157)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java 2010-10-20 10:20:01 UTC (rev 13158)
@@ -106,7 +106,6 @@
{
WSAddressingFeature addressingFeature = new WSAddressingFeature();
addressingFeature.setAddressingRequired(dde.isAddressingRequired());
- //endpoint.get
endpoint.getFeatures().add(addressingFeature);
}
endpoint.publish();
@@ -115,7 +114,6 @@
{
SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
binding.setMTOMEnabled(true);
-
}
}
configured = true;
14 years, 2 months
JBossWS SVN: r13157 - stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2010-10-20 03:51:43 -0400 (Wed, 20 Oct 2010)
New Revision: 13157
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDBeans.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java
Log:
[JBWS-3140][JBWS-3141]:Generate addressing feature element in jbossws-cxf.xml for spring endpoint
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDBeans.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDBeans.java 2010-10-20 07:14:01 UTC (rev 13156)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDBeans.java 2010-10-20 07:51:43 UTC (rev 13157)
@@ -112,6 +112,7 @@
"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " +
"xmlns:beans='http://www.springframework.org/schema/beans' " +
"xmlns:jaxws='http://cxf.apache.org/jaxws' " +
+ "xmlns:wsa='http://cxf.apache.org/ws/addressing' " +
"xmlns:jms='http://cxf.apache.org/transports/jms' " +
"xmlns:soap='http://cxf.apache.org/bindings/soap' " +
"xsi:schemaLocation='http://www.springframework.org/schema/beans " +
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java 2010-10-20 07:14:01 UTC (rev 13156)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java 2010-10-20 07:51:43 UTC (rev 13157)
@@ -231,6 +231,12 @@
}
writer.write(">");
+ if (this.addressingEnabled) {
+ writer.write("<jaxws:features>");
+ writer.write("<wsa:addressing addressingRequired='" + this.addressingRequired + "'/>");
+ writer.write("</jaxws:features>");
+ }
+
if (this.mtomEnabled)
{
writer.write("<jaxws:binding>");
14 years, 2 months
JBossWS SVN: r13156 - stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2010-10-20 03:14:01 -0400 (Wed, 20 Oct 2010)
New Revision: 13156
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefStubPropertyConfigurer.java
Log:
[JBWS-3140][JBWS-3141]:minor change to refactor
Modified: 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 2010-10-20 07:05:26 UTC (rev 13155)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefStubPropertyConfigurer.java 2010-10-20 07:14:01 UTC (rev 13156)
@@ -93,11 +93,11 @@
if (upcmd != null)
{
setProperties(proxyFactory, upcmd);
- setMTOM((JaxWsServiceFactoryBean)proxyFactory.getServiceFactory(), upcmd);
+ setWSFeature((JaxWsServiceFactoryBean)proxyFactory.getServiceFactory(), upcmd);
}
}
- private void setMTOM(JaxWsServiceFactoryBean serviceFactoryBean, UnifiedPortComponentRefMetaData upcmd)
+ private void setWSFeature(JaxWsServiceFactoryBean serviceFactoryBean, UnifiedPortComponentRefMetaData upcmd)
{
List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
List<WebServiceFeature> prevFeatures = serviceFactoryBean.getWsFeatures();
14 years, 2 months
JBossWS SVN: r13155 - in stack/cxf/trunk/modules: server/src/main/java/org/jboss/wsf/stack/cxf/configuration and 2 other directories.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2010-10-20 03:05:26 -0400 (Wed, 20 Oct 2010)
New Revision: 13155
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefStubPropertyConfigurer.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java
Log:
[JBWS-3140][JBWS-3141]:Create Non-spring endpoint and stub with parsed addressing, respectBinding and mtom-threshold element
Modified: 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 2010-10-19 12:46:34 UTC (rev 13154)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefStubPropertyConfigurer.java 2010-10-20 07:05:26 UTC (rev 13155)
@@ -28,6 +28,7 @@
import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.soap.AddressingFeature;
import javax.xml.ws.soap.MTOMFeature;
import org.apache.cxf.configuration.Configurer;
@@ -98,17 +99,32 @@
private void setMTOM(JaxWsServiceFactoryBean serviceFactoryBean, UnifiedPortComponentRefMetaData upcmd)
{
+ List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
+ List<WebServiceFeature> prevFeatures = serviceFactoryBean.getWsFeatures();
+ if (prevFeatures != null)
+ {
+ features.addAll(prevFeatures);
+ }
+
if (upcmd.isMtomEnabled())
{
- List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
- List<WebServiceFeature> prevFeatures = serviceFactoryBean.getWsFeatures();
- if (prevFeatures != null)
+ if (upcmd.getMtomThreshold() > 0)
{
- features.addAll(prevFeatures);
+ features.add(new MTOMFeature(true, upcmd.getMtomThreshold()));
+ }
+ else
+ {
+ features.add(new MTOMFeature(true));
}
- features.add(new MTOMFeature(true));
- serviceFactoryBean.setWsFeatures(features);
}
+
+ if (upcmd.isAddressingEnabled())
+ {
+ features.add(new AddressingFeature(true, upcmd.isAddressingRequired()));
+ }
+
+ serviceFactoryBean.setWsFeatures(features);
+
}
private void setProperties(JaxWsProxyFactoryBean proxyFactory, UnifiedPortComponentRefMetaData upcmd)
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java 2010-10-19 12:46:34 UTC (rev 13154)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java 2010-10-20 07:05:26 UTC (rev 13155)
@@ -35,6 +35,7 @@
import org.apache.cxf.transport.ConduitInitiator;
import org.apache.cxf.transport.DestinationFactory;
import org.apache.cxf.transport.servlet.ServletTransportFactory;
+import org.apache.cxf.ws.addressing.WSAddressingFeature;
import org.apache.cxf.ws.rm.RMManager;
import org.jboss.wsf.spi.binding.BindingCustomization;
import org.jboss.wsf.spi.deployment.Endpoint;
@@ -101,12 +102,20 @@
endpoint.setServiceName(dde.getServiceName());
endpoint.setWsdlLocation(dde.getWsdlLocation());
setHandlers(endpoint, dde.getHandlers());
+ if (dde.isAddressingEnabled())
+ {
+ WSAddressingFeature addressingFeature = new WSAddressingFeature();
+ addressingFeature.setAddressingRequired(dde.isAddressingRequired());
+ //endpoint.get
+ endpoint.getFeatures().add(addressingFeature);
+ }
endpoint.publish();
endpoints.add(endpoint);
if (dde.isMtomEnabled())
{
SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
binding.setMTOMEnabled(true);
+
}
}
configured = true;
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java 2010-10-19 12:46:34 UTC (rev 13154)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java 2010-10-20 07:05:26 UTC (rev 13155)
@@ -168,12 +168,27 @@
}
// MTOM settings
- if (portComp.isEnableMtom())
+ if (portComp.isMtomEnabled())
{
log.debug("Enabling MTOM");
endpoint.setMtomEnabled(true);
+ endpoint.setMtomThreshold(portComp.getMtomThreshold());
}
+ //Addressing
+ if (portComp.isAddressingEnabled())
+ {
+ log.debug("Enabling Addressing");
+ endpoint.setAddressingEnabled(true);
+ endpoint.setAddressingRequired(portComp.isAddressingRequired());
+ endpoint.setAddressingResponses(portComp.getAddressingResponses());
+ }
+ //RespectBinding
+ if (portComp.isRespectBindingEnabled())
+ {
+ log.debug("RepectBinging...");
+ endpoint.setRespectBindingEnabled(true);
+ }
//wsdlLocation override
String wsdlFile = portComp.getWebserviceDescription().getWsdlFile();
if (wsdlFile != null)
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java 2010-10-19 12:46:34 UTC (rev 13154)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java 2010-10-20 07:05:26 UTC (rev 13155)
@@ -46,6 +46,17 @@
private String invoker;
private boolean mtomEnabled;
+
+ private int mtomThreshold;
+
+ private boolean addressingEnabled;
+
+ private boolean addressingRequired;
+
+ private String addressingResponses;
+
+ private boolean respectBindingEnabled;
+
private String wsdlLocation;
private QName portName;
private QName serviceName;
@@ -157,6 +168,50 @@
this.mtomEnabled = 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 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)
+ {
+ this.addressingResponses = responsesTypes;
+ }
+
+ public String getAddressingResponses() {
+ return this.addressingResponses;
+ }
+
+
public void writeTo(Writer writer) throws IOException
{
writer.write("<jaxws:endpoint id='" + this.id + "'");
14 years, 2 months
JBossWS SVN: r13154 - 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-19 08:46:34 -0400 (Tue, 19 Oct 2010)
New Revision: 13154
Added:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/ServiceRefSerializer.java
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceObjectFactoryJAXWS.java
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinder.java
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXRPC.java
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceReferenceableJAXWS.java
Log:
final refactoring
Modified: common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceObjectFactoryJAXWS.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceObjectFactoryJAXWS.java 2010-10-19 09:27:10 UTC (rev 13153)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceObjectFactoryJAXWS.java 2010-10-19 12:46:34 UTC (rev 13154)
@@ -21,9 +21,6 @@
*/
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;
@@ -35,8 +32,6 @@
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;
@@ -54,7 +49,6 @@
* 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
@@ -80,14 +74,15 @@
* @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
+ public final 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);
+ final byte[] binaryData = (byte[]) ref.get(ServiceRefSerializer.SERVICE_REF_META_DATA).getContent();
+ final UnifiedServiceRefMetaData serviceRef = ServiceRefSerializer.unmarshall(binaryData);
// class names
final String serviceImplClass = this.getServiceClassName(ref, serviceRef);
final String targetClassName = this.getTargetClassName(ref, serviceRef, serviceImplClass);
@@ -127,10 +122,28 @@
return null;
}
+ /**
+ * Lifecycle template method called before javax.xml.ws.Service object instantiation.
+ *
+ * @param serviceRefUMDM service reference meta data
+ */
protected abstract void init(final UnifiedServiceRefMetaData serviceRefUMDM);
+ /**
+ * Lifecycle template method called after javax.xml.ws.Service object was created
+ * and before port is instantiated. It allows stack to configure service before
+ * creating ports.
+ *
+ * @param serviceRefUMDM service reference meta data
+ * @param service service instance
+ */
protected abstract void configure(final UnifiedServiceRefMetaData serviceRefUMDM, final Service service);
+ /**
+ * Lifecycle template method called after javax.xml.ws.Service object and after port instantiation.
+ *
+ * @param serviceRefUMDM
+ */
protected abstract void destroy(final UnifiedServiceRefMetaData serviceRefUMDM);
private Class<?> getClass(final String className) throws ClassNotFoundException
@@ -147,7 +160,7 @@
{
String serviceClassName = serviceRefMD.getServiceImplClass();
if (serviceClassName == null)
- serviceClassName = (String) ref.get(AbstractServiceReferenceableJAXWS.SERVICE_IMPL_CLASS).getContent();
+ serviceClassName = (String) ref.get(ServiceRefSerializer.SERVICE_IMPL_CLASS).getContent();
return serviceClassName;
}
@@ -157,7 +170,7 @@
{
String targetClassName = serviceRefMD.getServiceRefType();
if (targetClassName == null)
- targetClassName = (String) ref.get(AbstractServiceReferenceableJAXWS.TARGET_CLASS_NAME).getContent();
+ targetClassName = (String) ref.get(ServiceRefSerializer.TARGET_CLASS_NAME).getContent();
if (Service.class.getName().equals(targetClassName))
targetClassName = serviceImplClass;
@@ -406,24 +419,4 @@
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;
- }
}
Modified: common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinder.java 2010-10-19 09:27:10 UTC (rev 13153)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinder.java 2010-10-19 12:46:34 UTC (rev 13154)
@@ -58,7 +58,7 @@
{
final String jndiFullName = encCtx.getNameInNamespace() + "/" + encName;
- log.info("binding service reference to [jndi=" + jndiFullName + "]");
+ 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-19 09:27:10 UTC (rev 13153)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXRPC.java 2010-10-19 12:46:34 UTC (rev 13154)
@@ -39,7 +39,7 @@
/**
* Template method for creating stack specific JAXRPC referenceables.
- *
+ *
* @param serviceRef service reference UMDM
* @return stack specific JAXRPC JNDI referenceable
*/
Modified: common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceReferenceableJAXWS.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceReferenceableJAXWS.java 2010-10-19 09:27:10 UTC (rev 13153)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceReferenceableJAXWS.java 2010-10-19 12:46:34 UTC (rev 13154)
@@ -21,10 +21,6 @@
*/
package org.jboss.wsf.common.serviceref;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-
import javax.naming.BinaryRefAddr;
import javax.naming.NamingException;
import javax.naming.Reference;
@@ -36,23 +32,16 @@
/**
* A JNDI reference to a javax.xml.ws.Service metadata.
- *
+ *
* It holds all the information necessary to reconstruct the javax.xml.ws.Service
* instances when client does a JNDI lookup.
*
* @param <T> JNDI object factory type
- *
- * @author Thomas.Diesler(a)jboss.org
+ *
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
public abstract class AbstractServiceReferenceableJAXWS<T extends ObjectFactory> implements Referenceable
{
- public static final String SERVICE_REF_META_DATA = "SERVICE_REF_META_DATA";
-
- public static final String SERVICE_IMPL_CLASS = "SERVICE_CLASS_NAME";
-
- public static final String TARGET_CLASS_NAME = "TARGET_CLASS_NAME";
-
private final String serviceImplClass;
private final String targetClassName;
@@ -67,39 +56,27 @@
this.serviceRef = serviceRef;
}
- public Reference getReference() throws NamingException
+ public final Reference getReference() throws NamingException
{
final Reference myRef = new Reference(getClass().getName(), this.getObjectFactory().getName(), null);
- myRef.add(new StringRefAddr(SERVICE_IMPL_CLASS, this.serviceImplClass));
- myRef.add(new StringRefAddr(TARGET_CLASS_NAME, this.targetClassName));
- myRef.add(new BinaryRefAddr(SERVICE_REF_META_DATA, this.marshall(this.serviceRef)));
+ myRef.add(new StringRefAddr(ServiceRefSerializer.SERVICE_IMPL_CLASS, this.serviceImplClass));
+ myRef.add(new StringRefAddr(ServiceRefSerializer.TARGET_CLASS_NAME, this.targetClassName));
+ myRef.add(new BinaryRefAddr(ServiceRefSerializer.SERVICE_REF_META_DATA, ServiceRefSerializer
+ .marshall(this.serviceRef)));
return myRef;
}
+ /**
+ * Template method for providing stack specific JNDI object factory.
+ *
+ * @return JNDI object factory
+ */
protected abstract Class<T> getObjectFactory();
- private byte[] marshall(final Object obj) throws NamingException
+ public final String toString()
{
- final ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
-
- try
- {
- final ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(obj);
- oos.close();
- }
- catch (final IOException e)
- {
- throw new NamingException("Cannot marshall object, cause: " + e.toString());
- }
-
- return baos.toByteArray();
- }
-
- public String toString()
- {
final StringBuilder sb = new StringBuilder();
sb.append("\n").append(getClass().getName());
Added: common/trunk/src/main/java/org/jboss/wsf/common/serviceref/ServiceRefSerializer.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/serviceref/ServiceRefSerializer.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/ServiceRefSerializer.java 2010-10-19 12:46:34 UTC (rev 13154)
@@ -0,0 +1,92 @@
+/*
+ * 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.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import javax.naming.NamingException;
+
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+/**
+ * Provides utility methods and constants for web service reference de/serialization.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+final class ServiceRefSerializer
+{
+ public static final String SERVICE_REF_META_DATA = "SERVICE_REF_META_DATA";
+
+ public static final String SERVICE_IMPL_CLASS = "SERVICE_CLASS_NAME";
+
+ public static final String TARGET_CLASS_NAME = "TARGET_CLASS_NAME";
+
+ private ServiceRefSerializer()
+ {
+ // forbidden constructor
+ }
+
+ public static byte[] marshall(final UnifiedServiceRefMetaData obj) throws NamingException
+ {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
+
+ try
+ {
+ final ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(obj);
+ oos.close();
+ }
+ catch (final IOException e)
+ {
+ throw new NamingException("Cannot marshall service ref meta data, cause: " + e.toString());
+ }
+
+ return baos.toByteArray();
+ }
+
+ public static UnifiedServiceRefMetaData unmarshall(final byte[] data) throws NamingException
+ {
+ final UnifiedServiceRefMetaData sref;
+
+ try
+ {
+ final ByteArrayInputStream bais = new ByteArrayInputStream(data);
+ final ObjectInputStream ois = new ObjectInputStream(bais);
+ sref = (UnifiedServiceRefMetaData) ois.readObject();
+ ois.close();
+ }
+ catch (final IOException e)
+ {
+ throw new NamingException("Cannot unmarshall service ref meta data, cause: " + e.toString());
+ }
+ catch (final ClassNotFoundException e)
+ {
+ throw new NamingException("Cannot unmarshall service ref meta data, cause: " + e.toString());
+ }
+
+ return sref;
+ }
+}
14 years, 2 months
JBossWS SVN: r13153 - 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-19 05:27:10 -0400 (Tue, 19 Oct 2010)
New Revision: 13153
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceObjectFactoryJAXWS.java
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java
Log:
refactoring
Modified: common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceObjectFactoryJAXWS.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceObjectFactoryJAXWS.java 2010-10-19 07:27:57 UTC (rev 13152)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceObjectFactoryJAXWS.java 2010-10-19 09:27:10 UTC (rev 13153)
@@ -95,7 +95,7 @@
final Class<?> serviceClass = this.getClass(serviceImplClass);
final Class<?> targetClass = this.getClass(targetClassName);
final Service serviceInstance;
-
+
this.init(serviceRef);
try
{
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-19 07:27:57 UTC (rev 13152)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java 2010-10-19 09:27:10 UTC (rev 13153)
@@ -68,16 +68,98 @@
return this.createJAXWSReferenceable(serviceImplClassName, targetClassName, serviceRef);
}
- private void processWsdlOverride(final 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 serviceRefMD);
+
+ private void processAddressingAnnotation(final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ final Addressing addressingAnnotation = this.getAnnotation(serviceRefMD, Addressing.class);
+
+ if (addressingAnnotation != null)
+ {
+ serviceRefMD.setAddressingEnabled(addressingAnnotation.enabled());
+ serviceRefMD.setAddressingRequired(addressingAnnotation.required());
+ serviceRefMD.setAddressingResponses(addressingAnnotation.responses().toString());
+ }
+ }
+
+ private void processMTOMAnnotation(final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ final MTOM mtomAnnotation = this.getAnnotation(serviceRefMD, MTOM.class);
+
+ if (mtomAnnotation != null)
+ {
+ serviceRefMD.setMtomEnabled(mtomAnnotation.enabled());
+ serviceRefMD.setMtomThreshold(mtomAnnotation.threshold());
+ }
+ }
+
+ private void processRespectBindingAnnotation(final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ final RespectBinding respectBindingAnnotation = this.getAnnotation(serviceRefMD, RespectBinding.class);
+
+ if (respectBindingAnnotation != null)
+ {
+ serviceRefMD.setRespectBindingEnabled(respectBindingAnnotation.enabled());
+ }
+ }
+
+ private void processHandlerChainAnnotation(final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ final HandlerChain handlerChainAnnotation = this.getAnnotation(serviceRefMD, HandlerChain.class);
+
+ if (handlerChainAnnotation != null)
+ {
+ // Set the handlerChain from @HandlerChain on the annotated element
+ String handlerChain = serviceRefMD.getHandlerChain();
+ if (handlerChain == null && handlerChainAnnotation.file().length() > 0)
+ handlerChain = handlerChainAnnotation.file();
+
+ // Resolve path to handler chain
+ if (handlerChain != null)
+ {
+ try
+ {
+ new URL(handlerChain);
+ }
+ catch (MalformedURLException ignored)
+ {
+ final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRefMD.getAnnotatedElement();
+ final Class<?> declaringClass = getDeclaringClass(annotatedElement);
+
+ handlerChain = declaringClass.getPackage().getName().replace('.', '/') + "/" + handlerChain;
+ }
+
+ serviceRefMD.setHandlerChain(handlerChain);
+ }
+ }
+ }
+
+ private <T extends Annotation> T getAnnotation(final UnifiedServiceRefMetaData serviceRefMD, Class<T> annotationClass)
+ {
+ final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRefMD.getAnnotatedElement();
+
+ return annotatedElement != null ? (T) annotatedElement.getAnnotation(annotationClass) : null;
+ }
+
+ private void processWsdlOverride(final UnifiedServiceRefMetaData serviceRefMD,
final WebServiceRef serviceRefAnnotation, final ClassLoader loader, final String serviceImplClassName)
{
// Set the wsdlLocation if there is no override already
- if (serviceRef.getWsdlOverride() == null && serviceRefAnnotation != null
+ if (serviceRefMD.getWsdlOverride() == null && serviceRefAnnotation != null
&& serviceRefAnnotation.wsdlLocation().length() > 0)
- serviceRef.setWsdlOverride(serviceRefAnnotation.wsdlLocation());
+ serviceRefMD.setWsdlOverride(serviceRefAnnotation.wsdlLocation());
// Extract service QName for target service
- if (null == serviceRef.getServiceQName())
+ if (null == serviceRefMD.getServiceQName())
{
try
{
@@ -85,11 +167,11 @@
if (serviceClass.getAnnotation(WebServiceClient.class) != null)
{
WebServiceClient clientDecl = (WebServiceClient) serviceClass.getAnnotation(WebServiceClient.class);
- serviceRef.setServiceQName(new QName(clientDecl.targetNamespace(), clientDecl.name()));
+ serviceRefMD.setServiceQName(new QName(clientDecl.targetNamespace(), clientDecl.name()));
//use the @WebServiceClien(wsdlLocation=...) if the service ref wsdl location returned at this time would be null
- if (clientDecl.wsdlLocation().length() > 0 && serviceRef.getWsdlLocation() == null)
+ if (clientDecl.wsdlLocation().length() > 0 && serviceRefMD.getWsdlLocation() == null)
{
- serviceRef.setWsdlOverride(clientDecl.wsdlLocation());
+ serviceRefMD.setWsdlOverride(clientDecl.wsdlLocation());
}
}
}
@@ -100,36 +182,6 @@
}
}
- private void processHandlerChainAnnotation(final UnifiedServiceRefMetaData serviceRef)
- {
- // Set the handlerChain from @HandlerChain on the annotated element
- String handlerChain = serviceRef.getHandlerChain();
- AnnotatedElement annotatedElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
- if (annotatedElement != null)
- {
- HandlerChain anHandlerChain = annotatedElement.getAnnotation(HandlerChain.class);
- if (handlerChain == null && anHandlerChain != null && anHandlerChain.file().length() > 0)
- handlerChain = anHandlerChain.file();
- }
-
- // Resolve path to handler chain
- if (handlerChain != null)
- {
- try
- {
- new URL(handlerChain);
- }
- catch (MalformedURLException ignored)
- {
- final Class<?> declaringClass = getDeclaringClass(annotatedElement);
-
- handlerChain = declaringClass.getPackage().getName().replace('.', '/') + "/" + handlerChain;
- }
-
- serviceRef.setHandlerChain(handlerChain);
- }
- }
-
private Class<?> getDeclaringClass(final AnnotatedElement annotatedElement)
{
Class<?> declaringClass = null;
@@ -143,9 +195,9 @@
return declaringClass;
}
- private Class<?> getTargetClass(final UnifiedServiceRefMetaData serviceRef, WebServiceRef serviceRefAnnotation)
+ private Class<?> getTargetClass(final UnifiedServiceRefMetaData serviceRefMD, WebServiceRef serviceRefAnnotation)
{
- final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
+ final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRefMD.getAnnotatedElement();
Class<?> targetClass = null;
@@ -166,136 +218,54 @@
return targetClass;
}
- /**
- * 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);
-
- private void processAddressingAnnotation(final UnifiedServiceRefMetaData serviceRef)
+ private WebServiceRef getWebServiceRefAnnotation(final UnifiedServiceRefMetaData serviceRefMD)
{
- final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
+ final WebServiceRef webServiceRefAnnotation = this.getAnnotation(serviceRefMD, WebServiceRef.class);
+ final WebServiceRefs webServiceRefsAnnotation = this.getAnnotation(serviceRefMD, WebServiceRefs.class);
- if (annotatedElement == null)
+ if (webServiceRefAnnotation == null && webServiceRefsAnnotation == null)
{
- return;
- }
-
- for (final Annotation annotation : annotatedElement.getAnnotations())
- {
- if (annotation instanceof Addressing)
- {
- final Addressing addressingAnnotation = (Addressing) annotation;
-
- serviceRef.setAddressingEnabled(addressingAnnotation.enabled());
- serviceRef.setAddressingRequired(addressingAnnotation.required());
- serviceRef.setAddressingResponses(addressingAnnotation.responses().toString());
-
- return;
- }
- }
- }
-
- private void processMTOMAnnotation(final UnifiedServiceRefMetaData serviceRef)
- {
- final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
-
- if (annotatedElement == null)
- {
- return;
- }
-
- for (final Annotation annotation : annotatedElement.getAnnotations())
- {
- if (annotation instanceof MTOM)
- {
- final MTOM mtomAnnotation = (MTOM) annotation;
-
- serviceRef.setMtomEnabled(mtomAnnotation.enabled());
- serviceRef.setMtomThreshold(mtomAnnotation.threshold());
-
- return;
- }
- }
- }
-
- private void processRespectBindingAnnotation(final UnifiedServiceRefMetaData serviceRef)
- {
- final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
-
- if (annotatedElement == null)
- {
- return;
- }
-
- for (final Annotation annotation : annotatedElement.getAnnotations())
- {
- if (annotation instanceof RespectBinding)
- {
- final RespectBinding respectBindingAnnotation = (RespectBinding) annotation;
-
- serviceRef.setRespectBindingEnabled(respectBindingAnnotation.enabled());
-
- return;
- }
- }
- }
-
- private WebServiceRef getWebServiceRefAnnotation(final UnifiedServiceRefMetaData serviceRef)
- {
- final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
-
- if (annotatedElement == null)
- {
return null;
}
// Build the list of @WebServiceRef relevant annotations
final List<WebServiceRef> wsrefList = new ArrayList<WebServiceRef>();
- for (final Annotation an : annotatedElement.getAnnotations())
+ if (webServiceRefAnnotation != null)
{
- if (an instanceof WebServiceRef)
- {
- wsrefList.add((WebServiceRef) an);
- continue;
- }
+ wsrefList.add(webServiceRefAnnotation);
+ }
- if (an instanceof WebServiceRefs)
+ if (webServiceRefsAnnotation != null)
+ {
+ for (final WebServiceRef webServiceRefAnn : webServiceRefsAnnotation.value())
{
- WebServiceRefs wsrefs = (WebServiceRefs) an;
- for (WebServiceRef aux : wsrefs.value())
- wsrefList.add(aux);
+ wsrefList.add(webServiceRefAnn);
}
}
// Return effective @WebServiceRef annotation
- WebServiceRef wsref = null;
+ WebServiceRef returnValue = null;
if (wsrefList.size() == 1)
{
- wsref = wsrefList.get(0);
+ returnValue = wsrefList.get(0);
}
else
{
- for (WebServiceRef aux : wsrefList)
+ for (WebServiceRef webServiceRefAnn : wsrefList)
{
- if (serviceRef.getServiceRefName().endsWith(aux.name()))
+ if (serviceRefMD.getServiceRefName().endsWith(webServiceRefAnn.name()))
{
- wsref = aux;
+ returnValue = webServiceRefAnn;
break;
}
}
}
- return wsref;
+ return returnValue;
}
- private String getServiceImplClassName(final UnifiedServiceRefMetaData serviceRef,
+ private String getServiceImplClassName(final UnifiedServiceRefMetaData serviceRefMD,
final WebServiceRef serviceRefAnnotation, final Class<?> targetClass)
{
String serviceImplClass = null;
@@ -309,8 +279,8 @@
serviceImplClass = targetClass.getName();
// #3 Use <service-interface>
- if (serviceImplClass == null && serviceRef.getServiceInterface() != null)
- serviceImplClass = serviceRef.getServiceInterface();
+ if (serviceImplClass == null && serviceRefMD.getServiceInterface() != null)
+ serviceImplClass = serviceRefMD.getServiceInterface();
// #4 Use javax.xml.ws.Service
if (serviceImplClass == null)
14 years, 2 months
JBossWS SVN: r13152 - 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-19 03:27:57 -0400 (Tue, 19 Oct 2010)
New Revision: 13152
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java
Log:
refactoring
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-19 05:05:14 UTC (rev 13151)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java 2010-10-19 07:27:57 UTC (rev 13152)
@@ -53,26 +53,58 @@
{
public final Referenceable createReferenceable(final UnifiedServiceRefMetaData serviceRef, final ClassLoader loader)
{
- final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
- WebServiceRef serviceRefAnnotation = null;
- if (annotatedElement != null)
- {
- this.processAddressingAnnotation(serviceRef, annotatedElement);
- this.processMTOMAnnotation(serviceRef, annotatedElement);
- this.processRespectBindingAnnotation(serviceRef, annotatedElement);
- serviceRefAnnotation = this.getWebServiceRefAnnotation(serviceRef, annotatedElement);
- }
+ this.processAddressingAnnotation(serviceRef);
+ this.processMTOMAnnotation(serviceRef);
+ this.processRespectBindingAnnotation(serviceRef);
+ this.processHandlerChainAnnotation(serviceRef);
- final Class<?> targetClass = getTargetClass(annotatedElement, serviceRefAnnotation);
+ final WebServiceRef serviceRefAnnotation = this.getWebServiceRefAnnotation(serviceRef);
+ final Class<?> targetClass = getTargetClass(serviceRef, serviceRefAnnotation);
final String targetClassName = (targetClass != null ? targetClass.getName() : null);
final String serviceImplClassName = getServiceImplClassName(serviceRef, serviceRefAnnotation, targetClass);
+ this.processWsdlOverride(serviceRef, serviceRefAnnotation, loader, serviceImplClassName);
+
+ return this.createJAXWSReferenceable(serviceImplClassName, targetClassName, serviceRef);
+ }
+
+ private void processWsdlOverride(final UnifiedServiceRefMetaData serviceRef,
+ final WebServiceRef serviceRefAnnotation, final ClassLoader loader, final String serviceImplClassName)
+ {
// Set the wsdlLocation if there is no override already
- if (serviceRef.getWsdlOverride() == null && serviceRefAnnotation != null && serviceRefAnnotation.wsdlLocation().length() > 0)
+ if (serviceRef.getWsdlOverride() == null && serviceRefAnnotation != null
+ && serviceRefAnnotation.wsdlLocation().length() > 0)
serviceRef.setWsdlOverride(serviceRefAnnotation.wsdlLocation());
+ // Extract service QName for target service
+ if (null == serviceRef.getServiceQName())
+ {
+ try
+ {
+ Class<?> serviceClass = loader.loadClass(serviceImplClassName);
+ if (serviceClass.getAnnotation(WebServiceClient.class) != null)
+ {
+ WebServiceClient clientDecl = (WebServiceClient) serviceClass.getAnnotation(WebServiceClient.class);
+ serviceRef.setServiceQName(new QName(clientDecl.targetNamespace(), clientDecl.name()));
+ //use the @WebServiceClien(wsdlLocation=...) if the service ref wsdl location returned at this time would be null
+ if (clientDecl.wsdlLocation().length() > 0 && serviceRef.getWsdlLocation() == null)
+ {
+ serviceRef.setWsdlOverride(clientDecl.wsdlLocation());
+ }
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ WSFException.rethrow("Cannot extract service QName for target service", e);
+ }
+ }
+ }
+
+ private void processHandlerChainAnnotation(final UnifiedServiceRefMetaData serviceRef)
+ {
// Set the handlerChain from @HandlerChain on the annotated element
String handlerChain = serviceRef.getHandlerChain();
+ AnnotatedElement annotatedElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
if (annotatedElement != null)
{
HandlerChain anHandlerChain = annotatedElement.getAnnotation(HandlerChain.class);
@@ -87,50 +119,34 @@
{
new URL(handlerChain);
}
- catch (MalformedURLException ex)
+ catch (MalformedURLException ignored)
{
- Class<?> declaringClass = null;
- if (annotatedElement instanceof Field)
- declaringClass = ((Field) annotatedElement).getDeclaringClass();
- else if (annotatedElement instanceof Method)
- declaringClass = ((Method) annotatedElement).getDeclaringClass();
- else if (annotatedElement instanceof Class)
- declaringClass = (Class<?>) annotatedElement;
+ final Class<?> declaringClass = getDeclaringClass(annotatedElement);
handlerChain = declaringClass.getPackage().getName().replace('.', '/') + "/" + handlerChain;
}
serviceRef.setHandlerChain(handlerChain);
}
+ }
- // Extract service QName for target service
- if (null == serviceRef.getServiceQName())
- {
- try
- {
- Class<?> serviceClass = loader.loadClass(serviceImplClassName);
- if (serviceClass.getAnnotation(WebServiceClient.class) != null)
- {
- WebServiceClient clientDecl = (WebServiceClient) serviceClass.getAnnotation(WebServiceClient.class);
- serviceRef.setServiceQName(new QName(clientDecl.targetNamespace(), clientDecl.name()));
- //use the @WebServiceClien(wsdlLocation=...) if the service ref wsdl location returned at this time would be null
- if (clientDecl.wsdlLocation().length() > 0 && serviceRef.getWsdlLocation() == null)
- {
- serviceRef.setWsdlOverride(clientDecl.wsdlLocation());
- }
- }
- }
- catch (ClassNotFoundException e)
- {
- WSFException.rethrow("Cannot extract service QName for target service", e);
- }
- }
+ private Class<?> getDeclaringClass(final AnnotatedElement annotatedElement)
+ {
+ Class<?> declaringClass = null;
+ if (annotatedElement instanceof Field)
+ declaringClass = ((Field) annotatedElement).getDeclaringClass();
+ else if (annotatedElement instanceof Method)
+ declaringClass = ((Method) annotatedElement).getDeclaringClass();
+ else if (annotatedElement instanceof Class)
+ declaringClass = (Class<?>) annotatedElement;
- return this.createJAXWSReferenceable(serviceImplClassName, targetClassName, serviceRef);
+ return declaringClass;
}
- private Class<?> getTargetClass(final AnnotatedElement annotatedElement, WebServiceRef serviceRefAnnotation)
+ private Class<?> getTargetClass(final UnifiedServiceRefMetaData serviceRef, WebServiceRef serviceRefAnnotation)
{
+ final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
+
Class<?> targetClass = null;
if (annotatedElement instanceof Field)
@@ -161,8 +177,15 @@
protected abstract Referenceable createJAXWSReferenceable(final String serviceImplClass,
final String targetClassName, final UnifiedServiceRefMetaData serviceRef);
- private void processAddressingAnnotation(final UnifiedServiceRefMetaData serviceRef, final AnnotatedElement annotatedElement)
+ private void processAddressingAnnotation(final UnifiedServiceRefMetaData serviceRef)
{
+ final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
+
+ if (annotatedElement == null)
+ {
+ return;
+ }
+
for (final Annotation annotation : annotatedElement.getAnnotations())
{
if (annotation instanceof Addressing)
@@ -178,8 +201,15 @@
}
}
- private void processMTOMAnnotation(final UnifiedServiceRefMetaData serviceRef, final AnnotatedElement annotatedElement)
+ private void processMTOMAnnotation(final UnifiedServiceRefMetaData serviceRef)
{
+ final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
+
+ if (annotatedElement == null)
+ {
+ return;
+ }
+
for (final Annotation annotation : annotatedElement.getAnnotations())
{
if (annotation instanceof MTOM)
@@ -194,8 +224,15 @@
}
}
- private void processRespectBindingAnnotation(final UnifiedServiceRefMetaData serviceRef, final AnnotatedElement annotatedElement)
+ private void processRespectBindingAnnotation(final UnifiedServiceRefMetaData serviceRef)
{
+ final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
+
+ if (annotatedElement == null)
+ {
+ return;
+ }
+
for (final Annotation annotation : annotatedElement.getAnnotations())
{
if (annotation instanceof RespectBinding)
@@ -209,8 +246,15 @@
}
}
- private WebServiceRef getWebServiceRefAnnotation(final UnifiedServiceRefMetaData serviceRef, final AnnotatedElement annotatedElement)
+ private WebServiceRef getWebServiceRefAnnotation(final UnifiedServiceRefMetaData serviceRef)
{
+ final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
+
+ if (annotatedElement == null)
+ {
+ return null;
+ }
+
// Build the list of @WebServiceRef relevant annotations
final List<WebServiceRef> wsrefList = new ArrayList<WebServiceRef>();
@@ -251,7 +295,8 @@
return wsref;
}
- private String getServiceImplClassName(final UnifiedServiceRefMetaData serviceRef, final WebServiceRef serviceRefAnnotation, final Class<?> targetClass)
+ private String getServiceImplClassName(final UnifiedServiceRefMetaData serviceRef,
+ final WebServiceRef serviceRefAnnotation, final Class<?> targetClass)
{
String serviceImplClass = null;
14 years, 2 months
JBossWS SVN: r13151 - 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-19 01:05:14 -0400 (Tue, 19 Oct 2010)
New Revision: 13151
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java
Log:
refactoring
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:45:25 UTC (rev 13150)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java 2010-10-19 05:05:14 UTC (rev 13151)
@@ -43,7 +43,6 @@
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 factory to the client's ENC.
@@ -54,124 +53,29 @@
{
public final Referenceable createReferenceable(final UnifiedServiceRefMetaData serviceRef, final ClassLoader loader)
{
- WebServiceRef wsref = null;
-
- if (null == loader)
- throw new IllegalArgumentException("There needs to be a classloader available");
-
- // Build the list of @WebServiceRef relevant annotations
- List<WebServiceRef> wsrefList = new ArrayList<WebServiceRef>();
- Addressing addressingAnnotation = null;
- MTOM mtomAnnotation = null;
- RespectBinding respectBindingAnnotation = null;
-
- AnnotatedElement anElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
- if (anElement != null)
+ final AnnotatedElement annotatedElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
+ WebServiceRef serviceRefAnnotation = null;
+ if (annotatedElement != null)
{
- for (Annotation an : anElement.getAnnotations())
- {
- if (an instanceof Addressing)
- {
- addressingAnnotation = (Addressing) an;
- continue;
- }
-
- if (an instanceof MTOM)
- {
- mtomAnnotation = (MTOM) an;
- continue;
- }
-
- if (an instanceof RespectBinding)
- {
- respectBindingAnnotation = (RespectBinding) an;
- continue;
- }
-
- if (an instanceof WebServiceRef)
- {
- wsrefList.add((WebServiceRef) an);
- continue;
- }
-
- if (an instanceof WebServiceRefs)
- {
- WebServiceRefs wsrefs = (WebServiceRefs) an;
- for (WebServiceRef aux : wsrefs.value())
- wsrefList.add(aux);
- }
- }
+ this.processAddressingAnnotation(serviceRef, annotatedElement);
+ this.processMTOMAnnotation(serviceRef, annotatedElement);
+ this.processRespectBindingAnnotation(serviceRef, annotatedElement);
+ serviceRefAnnotation = this.getWebServiceRefAnnotation(serviceRef, annotatedElement);
}
- // Use the single @WebServiceRef
- if (wsrefList.size() == 1)
- {
- wsref = wsrefList.get(0);
- }
- else
- {
- for (WebServiceRef aux : wsrefList)
- {
- if (serviceRef.getServiceRefName().endsWith("/" + aux.name()))
- {
- wsref = aux;
- break;
- }
- }
- }
+ final Class<?> targetClass = getTargetClass(annotatedElement, serviceRefAnnotation);
+ final String targetClassName = (targetClass != null ? targetClass.getName() : null);
+ final String serviceImplClassName = getServiceImplClassName(serviceRef, serviceRefAnnotation, targetClass);
- Class<?> targetClass = null;
- if (anElement instanceof Field)
- {
- targetClass = ((Field) anElement).getType();
- }
- else if (anElement instanceof Method)
- {
- targetClass = ((Method) anElement).getParameterTypes()[0];
- }
- else
- {
- if (wsref != null && (wsref.type() != Object.class))
- targetClass = wsref.type();
- }
-
- String targetClassName = (targetClass != null ? targetClass.getName() : null);
-
- String serviceImplClass = null;
-
- // #1 Use the explicit @WebServiceRef.value
- if (wsref != null && wsref.value() != Service.class)
- serviceImplClass = wsref.value().getName();
-
- // #2 Use the target ref type
- if (serviceImplClass == null && targetClass != null && Service.class.isAssignableFrom(targetClass))
- serviceImplClass = targetClass.getName();
-
- // #3 Use <service-interface>
- if (serviceImplClass == null && serviceRef.getServiceInterface() != null)
- serviceImplClass = serviceRef.getServiceInterface();
-
- // #4 Use javax.xml.ws.Service
- if (serviceImplClass == null)
- serviceImplClass = Service.class.getName();
-
- // #1 Use the explicit @WebServiceRef.type
- if (wsref != null && wsref.type() != Object.class)
- targetClassName = wsref.type().getName();
-
- // #2 Use the target ref type
- if (targetClassName == null && targetClass != null && Service.class.isAssignableFrom(targetClass) == false)
- targetClassName = targetClass.getName();
-
// Set the wsdlLocation if there is no override already
- if (serviceRef.getWsdlOverride() == null && wsref != null && wsref.wsdlLocation().length() > 0)
- serviceRef.setWsdlOverride(wsref.wsdlLocation());
+ if (serviceRef.getWsdlOverride() == null && serviceRefAnnotation != null && serviceRefAnnotation.wsdlLocation().length() > 0)
+ serviceRef.setWsdlOverride(serviceRefAnnotation.wsdlLocation());
// Set the handlerChain from @HandlerChain on the annotated element
String handlerChain = serviceRef.getHandlerChain();
- if (anElement != null)
+ if (annotatedElement != null)
{
- HandlerChain anHandlerChain = anElement.getAnnotation(HandlerChain.class);
+ HandlerChain anHandlerChain = annotatedElement.getAnnotation(HandlerChain.class);
if (handlerChain == null && anHandlerChain != null && anHandlerChain.file().length() > 0)
handlerChain = anHandlerChain.file();
}
@@ -186,12 +90,12 @@
catch (MalformedURLException ex)
{
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;
+ if (annotatedElement instanceof Field)
+ declaringClass = ((Field) annotatedElement).getDeclaringClass();
+ else if (annotatedElement instanceof Method)
+ declaringClass = ((Method) annotatedElement).getDeclaringClass();
+ else if (annotatedElement instanceof Class)
+ declaringClass = (Class<?>) annotatedElement;
handlerChain = declaringClass.getPackage().getName().replace('.', '/') + "/" + handlerChain;
}
@@ -204,7 +108,7 @@
{
try
{
- Class<?> serviceClass = loader.loadClass(serviceImplClass);
+ Class<?> serviceClass = loader.loadClass(serviceImplClassName);
if (serviceClass.getAnnotation(WebServiceClient.class) != null)
{
WebServiceClient clientDecl = (WebServiceClient) serviceClass.getAnnotation(WebServiceClient.class);
@@ -222,30 +126,33 @@
}
}
- if (addressingAnnotation != null)
+ return this.createJAXWSReferenceable(serviceImplClassName, targetClassName, serviceRef);
+ }
+
+ private Class<?> getTargetClass(final AnnotatedElement annotatedElement, WebServiceRef serviceRefAnnotation)
+ {
+ Class<?> targetClass = null;
+
+ if (annotatedElement instanceof Field)
{
- serviceRef.setAddressingEnabled(addressingAnnotation.enabled());
- serviceRef.setAddressingRequired(addressingAnnotation.required());
- serviceRef.setAddressingResponses(addressingAnnotation.responses().toString());
+ targetClass = ((Field) annotatedElement).getType();
}
-
- if (mtomAnnotation != null)
+ else if (annotatedElement instanceof Method)
{
- serviceRef.setMtomEnabled(mtomAnnotation.enabled());
- serviceRef.setMtomThreshold(mtomAnnotation.threshold());
+ targetClass = ((Method) annotatedElement).getParameterTypes()[0];
}
-
- if (respectBindingAnnotation != null)
+ else
{
- serviceRef.setRespectBindingEnabled(respectBindingAnnotation.enabled());
+ if (serviceRefAnnotation != null && (serviceRefAnnotation.type() != Object.class))
+ targetClass = serviceRefAnnotation.type();
}
- return this.createJAXWSReferenceable(serviceImplClass, targetClassName, serviceRef);
+ return targetClass;
}
/**
* Template method for creating stack specific JAXWS referenceables.
- *
+ *
* @param serviceImplClass service implementation class name
* @param targetClassName target class name
* @param serviceRef service reference UMDM
@@ -253,4 +160,117 @@
*/
protected abstract Referenceable createJAXWSReferenceable(final String serviceImplClass,
final String targetClassName, final UnifiedServiceRefMetaData serviceRef);
+
+ private void processAddressingAnnotation(final UnifiedServiceRefMetaData serviceRef, final AnnotatedElement annotatedElement)
+ {
+ for (final Annotation annotation : annotatedElement.getAnnotations())
+ {
+ if (annotation instanceof Addressing)
+ {
+ final Addressing addressingAnnotation = (Addressing) annotation;
+
+ serviceRef.setAddressingEnabled(addressingAnnotation.enabled());
+ serviceRef.setAddressingRequired(addressingAnnotation.required());
+ serviceRef.setAddressingResponses(addressingAnnotation.responses().toString());
+
+ return;
+ }
+ }
+ }
+
+ private void processMTOMAnnotation(final UnifiedServiceRefMetaData serviceRef, final AnnotatedElement annotatedElement)
+ {
+ for (final Annotation annotation : annotatedElement.getAnnotations())
+ {
+ if (annotation instanceof MTOM)
+ {
+ final MTOM mtomAnnotation = (MTOM) annotation;
+
+ serviceRef.setMtomEnabled(mtomAnnotation.enabled());
+ serviceRef.setMtomThreshold(mtomAnnotation.threshold());
+
+ return;
+ }
+ }
+ }
+
+ private void processRespectBindingAnnotation(final UnifiedServiceRefMetaData serviceRef, final AnnotatedElement annotatedElement)
+ {
+ for (final Annotation annotation : annotatedElement.getAnnotations())
+ {
+ if (annotation instanceof RespectBinding)
+ {
+ final RespectBinding respectBindingAnnotation = (RespectBinding) annotation;
+
+ serviceRef.setRespectBindingEnabled(respectBindingAnnotation.enabled());
+
+ return;
+ }
+ }
+ }
+
+ private WebServiceRef getWebServiceRefAnnotation(final UnifiedServiceRefMetaData serviceRef, final AnnotatedElement annotatedElement)
+ {
+ // Build the list of @WebServiceRef relevant annotations
+ final List<WebServiceRef> wsrefList = new ArrayList<WebServiceRef>();
+
+ for (final Annotation an : annotatedElement.getAnnotations())
+ {
+ if (an instanceof WebServiceRef)
+ {
+ wsrefList.add((WebServiceRef) an);
+ continue;
+ }
+
+ if (an instanceof WebServiceRefs)
+ {
+ WebServiceRefs wsrefs = (WebServiceRefs) an;
+ for (WebServiceRef aux : wsrefs.value())
+ wsrefList.add(aux);
+ }
+ }
+
+ // Return effective @WebServiceRef annotation
+ WebServiceRef wsref = null;
+ if (wsrefList.size() == 1)
+ {
+ wsref = wsrefList.get(0);
+ }
+ else
+ {
+ for (WebServiceRef aux : wsrefList)
+ {
+ if (serviceRef.getServiceRefName().endsWith(aux.name()))
+ {
+ wsref = aux;
+ break;
+ }
+ }
+ }
+
+ return wsref;
+ }
+
+ private String getServiceImplClassName(final UnifiedServiceRefMetaData serviceRef, final WebServiceRef serviceRefAnnotation, final Class<?> targetClass)
+ {
+ String serviceImplClass = null;
+
+ // #1 Use the explicit @WebServiceRef.value
+ if (serviceRefAnnotation != null && serviceRefAnnotation.value() != Service.class)
+ serviceImplClass = serviceRefAnnotation.value().getName();
+
+ // #2 Use the target ref type
+ if (serviceImplClass == null && targetClass != null && Service.class.isAssignableFrom(targetClass))
+ serviceImplClass = targetClass.getName();
+
+ // #3 Use <service-interface>
+ if (serviceImplClass == null && serviceRef.getServiceInterface() != null)
+ serviceImplClass = serviceRef.getServiceInterface();
+
+ // #4 Use javax.xml.ws.Service
+ if (serviceImplClass == null)
+ serviceImplClass = Service.class.getName();
+
+ return serviceImplClass;
+ }
}
14 years, 2 months
JBossWS SVN: r13150 - 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-18 08:45:25 -0400 (Mon, 18 Oct 2010)
New Revision: 13150
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXRPC.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXWS.java
Log:
refactoring - adding new SPI methods
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXRPC.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXRPC.java 2010-10-18 12:44:45 UTC (rev 13149)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXRPC.java 2010-10-18 12:45:25 UTC (rev 13150)
@@ -29,13 +29,12 @@
/**
* Binds a JAXRPC Service object to the client's ENC.
*
- * @author Thomas.Diesler(a)jboss.org
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
final class CXFServiceRefBinderJAXRPC extends AbstractServiceRefBinderJAXRPC
{
@Override
- protected Referenceable createReferenceable(final UnifiedServiceRefMetaData serviceRefUMDM)
+ protected Referenceable createJAXRPCReferenceable(final UnifiedServiceRefMetaData serviceRefUMDM)
{
throw new IllegalArgumentException("CXF does not support JAX-RPC");
}
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXWS.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXWS.java 2010-10-18 12:44:45 UTC (rev 13149)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXWS.java 2010-10-18 12:45:25 UTC (rev 13150)
@@ -29,13 +29,12 @@
/**
* Binds a JAXWS Service object to the client's ENC.
*
- * @author Thomas.Diesler(a)jboss.org
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
final class CXFServiceRefBinderJAXWS extends AbstractServiceRefBinderJAXWS
{
@Override
- protected Referenceable createReferenceable(final String serviceImplClass, final String targetClassName,
+ protected Referenceable createJAXWSReferenceable(final String serviceImplClass, final String targetClassName,
final UnifiedServiceRefMetaData serviceRefUMDM)
{
return new CXFServiceReferenceableJAXWS(serviceImplClass, targetClassName, serviceRefUMDM);
14 years, 2 months
JBossWS SVN: r13149 - in stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core: jaxws/client and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-18 08:44:45 -0400 (Mon, 18 Oct 2010)
New Revision: 13149
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java
Log:
refactoring - adding new SPI methods
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java 2010-10-18 12:41:36 UTC (rev 13148)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java 2010-10-18 12:44:45 UTC (rev 13149)
@@ -29,13 +29,12 @@
/**
* Binds a JAXRPC Service object to the client's ENC.
*
- * @author Thomas.Diesler(a)jboss.org
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
public final class NativeServiceRefBinderJAXRPC extends AbstractServiceRefBinderJAXRPC
{
@Override
- protected Referenceable createReferenceable(final UnifiedServiceRefMetaData serviceRefUMDM)
+ protected Referenceable createJAXRPCReferenceable(final UnifiedServiceRefMetaData serviceRefUMDM)
{
return new ServiceReferenceable(serviceRefUMDM);
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java 2010-10-18 12:41:36 UTC (rev 13148)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java 2010-10-18 12:44:45 UTC (rev 13149)
@@ -29,13 +29,12 @@
/**
* Binds a JAXWS Service object to the client's ENC.
*
- * @author Thomas.Diesler(a)jboss.org
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
public final class NativeServiceRefBinderJAXWS extends AbstractServiceRefBinderJAXWS
{
@Override
- protected Referenceable createReferenceable(final String serviceImplClass, final String targetClassName,
+ protected Referenceable createJAXWSReferenceable(final String serviceImplClass, final String targetClassName,
final UnifiedServiceRefMetaData serviceRefUMDM)
{
return new NativeServiceReferenceableJAXWS(serviceImplClass, targetClassName, serviceRefUMDM);
14 years, 2 months