Author: heiko.braun(a)jboss.com
Date: 2007-07-12 10:02:02 -0400 (Thu, 12 Jul 2007)
New Revision: 3856
Removed:
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceRefHandlerImpl.java
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceRefObjectFactory.java
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceRefHandlerJAXRPC.java
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceRefHandlerJAXWS.java
Modified:
branches/hbraun/trunk/integration/native/src/main/resources/jbossws-native42.sar/jbossws.beans/META-INF/jboss-beans.xml
Log:
Cleanup legacy code
Modified:
branches/hbraun/trunk/integration/native/src/main/resources/jbossws-native42.sar/jbossws.beans/META-INF/jboss-beans.xml
===================================================================
---
branches/hbraun/trunk/integration/native/src/main/resources/jbossws-native42.sar/jbossws.beans/META-INF/jboss-beans.xml 2007-07-12
13:59:37 UTC (rev 3855)
+++
branches/hbraun/trunk/integration/native/src/main/resources/jbossws-native42.sar/jbossws.beans/META-INF/jboss-beans.xml 2007-07-12
14:02:02 UTC (rev 3856)
@@ -38,7 +38,10 @@
-->
<!-- Bind Service objects in client environment context -->
- <bean name="WSServiceRefHandler"
class="org.jboss.wsf.spi.deployment.serviceref.ServiceRefHandlerImpl"/>
+ <bean name="WSServiceRefHandler"
class="org.jboss.wsf.spi.deployment.serviceref.ServiceRefHandlerImpl">
+ <property name="jaxrpcBinder"><inject
bean="WSServiceRefBinderJAXRPC"/></property>
+ <property name="jaxwsBinder"><inject
bean="WSServiceRefBinderJAXWS"/></property>
+ </bean>
<!-- Note, JBoss_4_2_0_GA uses this hardcoded bean name -->
<bean name="ServiceRefHandler"
class="org.jboss.wsf.spi.deployment.serviceref.ServiceRefHandlerImpl">
Deleted:
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceRefHandlerImpl.java
===================================================================
---
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceRefHandlerImpl.java 2007-07-12
13:59:37 UTC (rev 3855)
+++
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceRefHandlerImpl.java 2007-07-12
14:02:02 UTC (rev 3856)
@@ -1,166 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.ws.core.client;
-
-// $Id$
-
-import java.lang.reflect.AnnotatedElement;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.io.File;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.jboss.logging.Logger;
-import org.jboss.ws.core.jaxrpc.client.ServiceRefHandlerJAXRPC;
-import org.jboss.ws.core.jaxws.client.ServiceRefHandlerJAXWS;
-import org.jboss.ws.integration.*;
-import org.jboss.ws.metadata.umdm.EndpointMetaData.Type;
-import org.jboss.ws.WSException;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.xb.binding.UnmarshallingContext;
-import org.xml.sax.Attributes;
-
-/**
- * Bind service refs in the client's ENC for every service-ref element in the
- * deployment descriptor.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 04-Nov-2006
- */
-public class ServiceRefHandlerImpl implements ServiceRefHandler
-{
- // logging support
- private static Logger log = Logger.getLogger(ServiceRefHandlerImpl.class);
-
- private ServiceRefObjectFactory objectFactory = new ServiceRefObjectFactory();
-
- public ServiceRefMetaData newServiceRefMetaData()
- {
- return new UnifiedServiceRefMetaData();
- }
-
- public void bindServiceRef(Context encCtx, String encName, UnifiedVirtualFile vfsRoot,
ClassLoader loader, ServiceRefMetaData sref) throws NamingException
- {
- if (sref.isProcessed())
- {
- log.debug("Attempt to rebind the service-ref: " +
sref.getServiceRefName());
- return;
- }
-
- // In case of an .war deployment the associated root file doesn't point to
- // the expanded war file structure and thus breaks service-ref usage for servlet
clients.
- // This needs to be fixed in org.jboss.web.AbstractWebDeployer (JBOSS_AS/server
module)
- if(vfsRoot instanceof URLLoaderAdapter)
- {
- URLLoaderAdapter ula = (URLLoaderAdapter)vfsRoot;
- URL rootURL = ula.toURL();
- if("file".equals( rootURL.getProtocol()) &&
rootURL.getFile().endsWith(".war") )
- {
- String fileName = rootURL.getFile();
-
- if( ! new File(fileName).exists() ) // might be an exploded directory
- {
- // There is a filename convention for exploded directories
- fileName = fileName.substring(0, fileName.indexOf(".war")) +
"-exp.war";
-
- File expandedDirectory = new File(fileName);
- if(! expandedDirectory.exists())
- throw new WSException("Failed to bind service-ref, the deployment
root expandedDirectory doesn't exist: " + fileName);
-
- // update the rootFile
- try
- {
- vfsRoot = new URLLoaderAdapter(expandedDirectory.toURL());
- }
- catch (MalformedURLException e){}
- }
-
- }
- }
-
- UnifiedServiceRefMetaData serviceRef = (UnifiedServiceRefMetaData)sref;
- serviceRef.setVfsRoot(vfsRoot);
- try
- {
- if (getServiceRefType(serviceRef, loader) == Type.JAXRPC)
- {
- ServiceRefHandlerJAXRPC handler = new ServiceRefHandlerJAXRPC();
- handler.setupServiceRef(encCtx, encName, serviceRef);
- }
- else
- {
- AnnotatedElement anElement = (AnnotatedElement)sref.getAnnotatedElement();
- ServiceRefHandlerJAXWS handler = new ServiceRefHandlerJAXWS();
- handler.setupServiceRef(encCtx, encName, anElement, serviceRef);
- }
- }
- finally
- {
- sref.setProcessed(true);
- }
- }
-
- public Object newChild(ServiceRefElement ref, UnmarshallingContext navigator, String
namespaceURI, String localName, Attributes attrs)
- {
- return objectFactory.newChild(ref, navigator, namespaceURI, localName, attrs);
- }
-
- public void setValue(ServiceRefElement ref, UnmarshallingContext navigator, String
namespaceURI, String localName, String value)
- {
- objectFactory.setValue(ref, navigator, namespaceURI, localName, value);
- }
-
- private Type getServiceRefType(UnifiedServiceRefMetaData serviceRef, ClassLoader
loader) throws NamingException
- {
- // The service-ref-type is JAXWS specific
- String serviceRefType = serviceRef.getServiceRefType();
- if (serviceRefType != null || serviceRef.getAnnotatedElement() != null)
- return Type.JAXWS;
-
- // The mapping-file is JAXRPC specific
- if (serviceRef.getMappingFile() != null)
- return Type.JAXRPC;
-
- String siName = serviceRef.getServiceInterface();
- if (siName == null)
- throw new IllegalStateException("<service-interface> cannot be
null");
-
- if (siName.equals("javax.xml.rpc.Service"))
- return Type.JAXRPC;
-
- try
- {
- Class siClass = loader.loadClass(siName);
- if (javax.xml.ws.Service.class.isAssignableFrom(siClass))
- return Type.JAXWS;
- else if (javax.xml.rpc.Service.class.isAssignableFrom(siClass))
- return Type.JAXRPC;
- else throw new IllegalStateException("Illegal service interface: " +
siName);
- }
- catch (ClassNotFoundException e)
- {
- throw new IllegalStateException("Cannot load <service-interface>:
" + siName);
- }
- }
-}
Deleted:
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceRefObjectFactory.java
===================================================================
---
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceRefObjectFactory.java 2007-07-12
13:59:37 UTC (rev 3855)
+++
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceRefObjectFactory.java 2007-07-12
14:02:02 UTC (rev 3856)
@@ -1,305 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.ws.core.client;
-
-// $Id$
-
-import javax.xml.namespace.QName;
-
-import org.jboss.ws.integration.ServiceRefElement;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedCallPropertyMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainsMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedInitParamMetaData;
-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;
-import org.jboss.xb.binding.UnmarshallingContext;
-import org.xml.sax.Attributes;
-
-/**
- * A object model factory for <service-ref>
- *
- * @author Thomas.Diesler(a)jboss.com
- */
-public class ServiceRefObjectFactory
-{
- public Object newChild(ServiceRefElement ref, UnmarshallingContext navigator, String
namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
- if (ref instanceof UnifiedHandlerChainsMetaData)
- child = newChild((UnifiedHandlerChainsMetaData)ref, navigator, namespaceURI,
localName, attrs);
- else if (ref instanceof UnifiedHandlerMetaData)
- child = newChild((UnifiedHandlerMetaData)ref, navigator, namespaceURI,
localName, attrs);
- else if (ref instanceof UnifiedPortComponentRefMetaData)
- child = newChild((UnifiedPortComponentRefMetaData)ref, navigator, namespaceURI,
localName, attrs);
- else if (ref instanceof UnifiedServiceRefMetaData)
- child = newChild((UnifiedServiceRefMetaData)ref, navigator, namespaceURI,
localName, attrs);
- return child;
- }
-
- public void setValue(ServiceRefElement ref, UnmarshallingContext navigator, String
namespaceURI, String localName, String value)
- {
- if (ref instanceof UnifiedCallPropertyMetaData)
- setValue((UnifiedCallPropertyMetaData)ref, navigator, namespaceURI, localName,
value);
- else if (ref instanceof UnifiedHandlerChainMetaData)
- setValue((UnifiedHandlerChainMetaData)ref, navigator, namespaceURI, localName,
value);
- else if (ref instanceof UnifiedHandlerMetaData)
- setValue((UnifiedHandlerMetaData)ref, navigator, namespaceURI, localName,
value);
- else if (ref instanceof UnifiedInitParamMetaData)
- setValue((UnifiedInitParamMetaData)ref, navigator, namespaceURI, localName,
value);
- else if (ref instanceof UnifiedPortComponentRefMetaData)
- setValue((UnifiedPortComponentRefMetaData)ref, navigator, namespaceURI,
localName, value);
- else if (ref instanceof UnifiedServiceRefMetaData)
- setValue((UnifiedServiceRefMetaData)ref, navigator, namespaceURI, localName,
value);
- else if (ref instanceof UnifiedCallPropertyMetaData)
- setValue((UnifiedCallPropertyMetaData)ref, navigator, namespaceURI, localName,
value);
- else if (ref instanceof UnifiedStubPropertyMetaData)
- setValue((UnifiedStubPropertyMetaData)ref, navigator, namespaceURI, localName,
value);
- }
-
- private void setValue(UnifiedServiceRefMetaData ref, UnmarshallingContext navigator,
String namespaceURI, String localName, String value)
- {
- /* Standard properties */
- if (localName.equals("service-ref-name"))
- {
- ref.setServiceRefName(value);
- }
- else if (localName.equals("service-interface"))
- {
- ref.setServiceInterface(value);
- }
- else if (localName.equals("service-ref-type"))
- {
- ref.setServiceRefType(value);
- }
- else if (localName.equals("wsdl-file"))
- {
- ref.setWsdlFile(value);
- }
- else if (localName.equals("jaxrpc-mapping-file"))
- {
- ref.setMappingFile(value);
- }
- else if (localName.equals("service-qname"))
- {
- ref.setServiceQName(getQNameValue(navigator, value));
- }
-
- /* JBoss properties */
- else if (localName.equals("service-impl-class"))
- {
- ref.setServiceImplClass(value);
- }
- else if (localName.equals("config-name"))
- {
- ref.setConfigName(value);
- }
- else if (localName.equals("config-file"))
- {
- ref.setConfigFile(value);
- }
- else if (localName.equals("wsdl-override"))
- {
- ref.setWsdlOverride(value);
- }
- else if (localName.equals("handler-chain"))
- {
- ref.setHandlerChain(value);
- }
- }
-
- private Object newChild(UnifiedServiceRefMetaData ref, UnmarshallingContext navigator,
String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
- if (localName.equals("port-component-ref"))
- {
- child = new UnifiedPortComponentRefMetaData(ref);
- ref.addPortComponentRef((UnifiedPortComponentRefMetaData)child);
- }
- else if (localName.equals("handler"))
- {
- child = new UnifiedHandlerMetaData();
- ref.addHandler((UnifiedHandlerMetaData)child);
- }
- else if (localName.equals("handler-chains"))
- {
- child = new UnifiedHandlerChainsMetaData();
- ref.setHandlerChains((UnifiedHandlerChainsMetaData)child);
- }
- else if (localName.equals("call-property"))
- {
- child = new UnifiedCallPropertyMetaData();
- ref.addCallProperty((UnifiedCallPropertyMetaData)child);
- }
- return child;
- }
-
- private Object newChild(UnifiedHandlerChainsMetaData ref, UnmarshallingContext
navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
- if (localName.equals("handler-chain"))
- {
- child = new UnifiedHandlerChainMetaData();
- ref.addHandlerChain((UnifiedHandlerChainMetaData)child);
- }
- return child;
- }
-
- private void setValue(UnifiedPortComponentRefMetaData pcref, UnmarshallingContext
navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("service-endpoint-interface"))
- {
- pcref.setServiceEndpointInterface(value);
- }
- else if (localName.equals("enable-mtom"))
- {
- pcref.setEnableMTOM(Boolean.valueOf(value));
- }
- else if (localName.equals("port-component-link"))
- {
- pcref.setPortComponentLink(value);
- }
- else if (localName.equals("port-qname"))
- {
- pcref.setPortQName(getQNameValue(navigator, value));
- }
- else if (localName.equals("config-name"))
- {
- pcref.setConfigName(value);
- }
- else if (localName.equals("config-file"))
- {
- pcref.setConfigFile(value);
- }
- }
-
- private Object newChild(UnifiedPortComponentRefMetaData ref, UnmarshallingContext
navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
- if (localName.equals("call-property"))
- {
- child = new UnifiedCallPropertyMetaData();
- ref.addCallProperty((UnifiedCallPropertyMetaData)child);
- }
- if (localName.equals("stub-property"))
- {
- child = new UnifiedStubPropertyMetaData();
- ref.addStubProperty((UnifiedStubPropertyMetaData)child);
- }
- return child;
- }
-
- private void setValue(UnifiedHandlerChainMetaData ref, UnmarshallingContext navigator,
String namespaceURI, String localName, String value)
- {
- if (localName.equals("service-name-pattern"))
- {
- ref.setServiceNamePattern(getQNameValue(navigator, value));
- }
- else if (localName.equals("port-name-pattern"))
- {
- ref.setPortNamePattern(getQNameValue(navigator, value));
- }
- else if (localName.equals("protocol-binding"))
- {
- ref.setProtocolBindings(value);
- }
- }
-
- private void setValue(UnifiedHandlerMetaData ref, UnmarshallingContext navigator,
String namespaceURI, String localName, String value)
- {
- if (localName.equals("handler-name"))
- {
- ref.setHandlerName(value);
- }
- else if (localName.equals("handler-class"))
- {
- ref.setHandlerClass(value);
- }
- else if (localName.equals("soap-header"))
- {
- ref.addSoapHeader(getQNameValue(navigator, value));
- }
- else if (localName.equals("soap-role"))
- {
- ref.addSoapRole(value);
- }
- else if (localName.equals("port-name"))
- {
- ref.addPortName(value);
- }
- }
-
- private Object newChild(UnifiedHandlerMetaData ref, UnmarshallingContext navigator,
String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
- if (localName.equals("init-param"))
- {
- child = new UnifiedInitParamMetaData();
- ref.addInitParam((UnifiedInitParamMetaData)child);
- }
- return child;
- }
-
- private void setValue(UnifiedInitParamMetaData ref, UnmarshallingContext navigator,
String namespaceURI, String localName, String value)
- {
- if (localName.equals("param-name"))
- {
- ref.setParamName(value);
- }
- else if (localName.equals("param-value"))
- {
- ref.setParamValue(value);
- }
- }
-
- private void setValue(UnifiedCallPropertyMetaData ref, UnmarshallingContext navigator,
String namespaceURI, String localName, String value)
- {
- if (localName.equals("prop-name"))
- {
- ref.setPropName(value);
- }
- else if (localName.equals("prop-value"))
- {
- ref.setPropValue(value);
- }
- }
-
- private void setValue(UnifiedStubPropertyMetaData ref, UnmarshallingContext navigator,
String namespaceURI, String localName, String value)
- {
- if (localName.equals("prop-name"))
- {
- ref.setPropName(value);
- }
- else if (localName.equals("prop-value"))
- {
- ref.setPropValue(value);
- }
- }
-
- private QName getQNameValue(UnmarshallingContext navigator, String value)
- {
- QName qname = (value.startsWith("{") ? QName.valueOf(value) :
navigator.resolveQName(value));
- return qname;
- }
-}
Deleted:
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceRefHandlerJAXRPC.java
===================================================================
---
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceRefHandlerJAXRPC.java 2007-07-12
13:59:37 UTC (rev 3855)
+++
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceRefHandlerJAXRPC.java 2007-07-12
14:02:02 UTC (rev 3856)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.ws.core.jaxrpc.client;
-
-// $Id$
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.jboss.logging.Logger;
-import org.jboss.util.naming.Util;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-/**
- * Binds a JAXRPC Service object in the client's ENC for every service-ref element in
the
- * deployment descriptor.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 04-Nov-2006
- */
-public class ServiceRefHandlerJAXRPC
-{
- // logging support
- private static Logger log = Logger.getLogger(ServiceRefHandlerJAXRPC.class);
-
- /**
- * Binds a Service into the callers ENC for every service-ref element
- */
- public void setupServiceRef(Context encCtx, String encName, UnifiedServiceRefMetaData
serviceRef) throws NamingException
- {
- String externalName = encCtx.getNameInNamespace() + "/" + encName;
- log.info("setupServiceRef [jndi=" + externalName + "]");
-
- // Do not use rebind, the binding should be unique
- ServiceReferenceable ref = new ServiceReferenceable(serviceRef);
- Util.bind(encCtx, encName, ref);
- }
-}
Deleted:
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceRefHandlerJAXWS.java
===================================================================
---
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceRefHandlerJAXWS.java 2007-07-12
13:59:37 UTC (rev 3855)
+++
branches/hbraun/trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceRefHandlerJAXWS.java 2007-07-12
14:02:02 UTC (rev 3856)
@@ -1,182 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.ws.core.jaxws.client;
-
-// $Id$
-
-import org.jboss.logging.Logger;
-import org.jboss.util.naming.Util;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-import javax.jws.HandlerChain;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.xml.ws.Service;
-import javax.xml.ws.WebServiceRef;
-import javax.xml.ws.WebServiceRefs;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Binds a JAXWS Service object in the client's ENC
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 17-Jan-2007
- */
-public class ServiceRefHandlerJAXWS
-{
- // logging support
- private static Logger log = Logger.getLogger(ServiceRefHandlerJAXWS.class);
-
- public void setupServiceRef(Context encCtx, String encName, AnnotatedElement
anElement, UnifiedServiceRefMetaData serviceRef) throws NamingException
- {
- WebServiceRef wsref = null;
-
- // Build the list of @WebServiceRef relevant annotations
- List<WebServiceRef> wsrefList = new ArrayList<WebServiceRef>();
- if (anElement != null)
- {
- for (Annotation an : anElement.getAnnotations())
- {
- if (an instanceof WebServiceRef)
- wsrefList.add((WebServiceRef)an);
-
- if (an instanceof WebServiceRefs)
- {
- WebServiceRefs wsrefs = (WebServiceRefs)an;
- for (WebServiceRef aux : wsrefs.value())
- wsrefList.add(aux);
- }
- }
- }
-
- // Use the single @WebServiceRef
- if (wsrefList.size() == 1)
- {
- wsref = wsrefList.get(0);
- }
- else
- {
- for (WebServiceRef aux : wsrefList)
- {
- if (encName.endsWith("/" + aux.name()))
- {
- wsref = aux;
- break;
- }
- }
- }
-
- 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 externalName = encCtx.getNameInNamespace() + "/" + encName;
- log.debug("setupServiceRef [jndi=" + externalName + ",target="
+ targetClassName + "]");
-
- String serviceImplClass = null;
-
- // #1 Use the explicit @WebServiceRef.value
- if (wsref != null && wsref.value() != Object.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());
-
- // Set the handlerChain from @HandlerChain on the annotated element
- String handlerChain = serviceRef.getHandlerChain();
- if (anElement != null)
- {
- HandlerChain anHandlerChain = anElement.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 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;
-
- handlerChain = declaringClass.getPackage().getName().replace('.',
'/') + "/" + handlerChain;
- }
-
- serviceRef.setHandlerChain(handlerChain);
- }
-
- // Do not use rebind, the binding should be unique
- // [JBWS-1499] - Revisit WebServiceRefHandler JNDI rebind
- Util.bind(encCtx, encName, new ServiceReferenceable(serviceImplClass,
targetClassName, serviceRef));
-
- }
-}