Author: richard.opalka(a)jboss.com
Date: 2011-07-26 06:22:18 -0400 (Tue, 26 Jul 2011)
New Revision: 14743
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/Message.properties
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/NativeServiceObjectFactoryJAXRPC.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/NativeServiceRefBinderJAXRPC.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/NativeServiceReferenceableJAXRPC.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/SecurityActions.java
Removed:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ServiceObjectFactory.java
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/NativeServiceReferenceableJAXRPC.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceObjectFactoryJAXRPC.java
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/Message.properties
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NativeServiceRefBinderFactoryImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/Message.properties
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java
Log:
refactoring Native JAXRPC service ref to separate package
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/Message.properties
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/Message.properties 2011-07-26
08:04:46 UTC (rev 14742)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/Message.properties 2011-07-26
10:22:18 UTC (rev 14743)
@@ -1,6 +1,3 @@
-NOT_ALLOWED_TO_USE=Within a <service-ref> it's not allowed to use a SEI across
different <port-component-ref>'s: {0}
-FAILED_TO_NARROW_ENDPOINTS=Failed to narrow available endpoints by
<port-component-ref> declaration
-UNABLE_TO_NARROW_PORT_SELECTION=Unable to narrow port selection for {0}
GIVEN_ENDPOINT_CANNOT_BE_NULL=Given endpoint cannot be null
CONNECTION_IS_ALREADY_CLOSED=Connection is already closed
GIVEN_ENDPOINT_CANNOT_BE_NULL=Given endpoint cannot be null
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NativeServiceRefBinderFactoryImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NativeServiceRefBinderFactoryImpl.java 2011-07-26
08:04:46 UTC (rev 14742)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NativeServiceRefBinderFactoryImpl.java 2011-07-26
10:22:18 UTC (rev 14743)
@@ -21,7 +21,7 @@
*/
package org.jboss.ws.core.client;
-import org.jboss.ws.core.jaxrpc.client.NativeServiceRefBinderJAXRPC;
+import org.jboss.ws.core.jaxrpc.client.serviceref.NativeServiceRefBinderJAXRPC;
import org.jboss.ws.core.jaxws.client.NativeServiceRefBinderJAXWS;
import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
import org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory;
Deleted:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ServiceObjectFactory.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ServiceObjectFactory.java 2011-07-26
08:04:46 UTC (rev 14742)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ServiceObjectFactory.java 2011-07-26
10:22:18 UTC (rev 14743)
@@ -1,121 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.ws.core.client;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import javax.naming.spi.ObjectFactory;
-import javax.xml.namespace.QName;
-
-import org.jboss.logging.Logger;
-import org.jboss.ws.WSException;
-import org.jboss.ws.api.util.BundleUtils;
-import org.jboss.ws.metadata.umdm.EndpointMetaData;
-import org.jboss.ws.metadata.umdm.ServiceMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-/**
- * This ServiceObjectFactory reconstructs a service for a given WSDL when the webservice
client does a JNDI lookup
- * <p/>
- * It uses the information provided by the service-ref element in application-client.xml
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 15-April-2004
- */
-public abstract class ServiceObjectFactory implements ObjectFactory
-{
- private static final ResourceBundle bundle =
BundleUtils.getBundle(ServiceObjectFactory.class);
- // provide logging
- private static final Logger log = Logger.getLogger(ServiceObjectFactory.class);
-
- /**
- * Narrow available endpoints by <port-component-ref> declarations.
- * Service.getPort(SEI) must be able to retrieve a distinct port definition.
- */
- protected void narrowPortSelection(UnifiedServiceRefMetaData serviceRef,
ServiceMetaData serviceMetaData)
- {
- if (serviceMetaData.getEndpoints().size() > 1)
- {
- Map<String, UnifiedPortComponentRefMetaData> pcrefs = new
HashMap<String, UnifiedPortComponentRefMetaData>();
- for (UnifiedPortComponentRefMetaData pcref : serviceRef.getPortComponentRefs())
- {
- String seiName = pcref.getServiceEndpointInterface();
-
- // Constraint#1: within a service-ref it's not allowed to use a SEI
across different pcref's
- if (pcrefs.get(seiName) != null)
- throw new WSException(BundleUtils.getMessage(bundle,
"NOT_ALLOWED_TO_USE", seiName));
-
- pcrefs.put(seiName, pcref);
- }
-
- // Constraint#2: A pcref may only match one EndpointMetaData
- for (String sei : pcrefs.keySet())
- {
- // Narrow available endpoints by port-component-ref declaration
- List<QName> narrowedEndpoints = new ArrayList<QName>();
-
- UnifiedPortComponentRefMetaData pcref = pcrefs.get(sei);
-
- // Constraint#3: Port selection only applies when both SEI and QName are
given
- if (pcref.getServiceEndpointInterface() != null &&
pcref.getPortQName() != null)
- {
- List<QName> pcRef2EndpointMapping = new ArrayList<QName>();
- for (EndpointMetaData epMetaData : serviceMetaData.getEndpoints())
- {
- if
(pcref.getServiceEndpointInterface().equals(epMetaData.getServiceEndpointInterfaceName()))
- {
- pcRef2EndpointMapping.add(epMetaData.getPortName());
- }
- }
-
- for (QName q : pcRef2EndpointMapping)
- {
- EndpointMetaData mappedEndpoint = serviceMetaData.getEndpoint(q);
- if (!pcref.getPortQName().equals(mappedEndpoint.getPortName()))
- narrowedEndpoints.add(q);
- }
-
- // Constraint: Dont exclude all of them ;)
- if (pcRef2EndpointMapping.size() > 0 &&
(pcRef2EndpointMapping.size() == narrowedEndpoints.size()))
- throw new WSException(BundleUtils.getMessage(bundle,
"FAILED_TO_NARROW_ENDPOINTS"));
-
- for (QName q : narrowedEndpoints)
- {
- EndpointMetaData removed = serviceMetaData.removeEndpoint(q);
- if (log.isDebugEnabled())
- log.debug("Narrowed endpoint " + q + "(" +
removed + ")");
- }
- }
- else
- {
- // TODO: In case there is more then one EMPD this should cause an
exception
- log.warn(BundleUtils.getMessage(bundle,
"UNABLE_TO_NARROW_PORT_SELECTION", pcref));
- }
- }
- }
- }
-}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/Message.properties
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/Message.properties 2011-07-26
08:04:46 UTC (rev 14742)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/Message.properties 2011-07-26
10:22:18 UTC (rev 14743)
@@ -8,18 +8,15 @@
CALL_INVOCATION_FAILED_CAUSE=Call invocation failed with code [{0}] because of: {1}
ALREADY_REGISTERED=Different java type already registered: {0}
-CANNOT_OBTAIN_PATH=Cannot obtain path to PortComponentLinkServlet: {0}
-CANNOT_MARSHALL_SERVICE_REF_META_DATA=Cannot marshall service ref meta data, cause: {0}
-CANNOT_MARSHALL_SECURITY_CONFIG=Cannot marshall security config, cause: {0}
CANNOT_OBTAIN_ENDPOINT_META_DATA=Cannot obtain endpoint meta data for: {0}
CANNOT_FIND_ENDPOINT=Cannot find endpoint for name: {0}
SHOULD_NOT_USE_METHOD=Components should not use the {0} method.
SEI_CLASS_CANNOT_BE_NULL=SEI class cannot be null
-NOT_IMPLEMENT_REMOTE=SEI does not implement java.rmi.Remote: {0}
SERVICE_META_DATA_NOT_AVAILABLE=Service meta data not available
CANNOT_FIND_ENDPOINT_META_DATA=Cannot find endpoint meta data for: {0}
+NOT_IMPLEMENT_REMOTE=SEI does not implement java.rmi.Remote: {0}
CANNOT_CREATE_PROXY=Cannot create proxy
SEI_CLASS_CANNOT_BE_NULL=SEI class cannot be null
SERVICE_META_DATA_NOT_AVAILABLE=Service meta data not available
@@ -30,11 +27,3 @@
RETURN_VALUE_NOT_SUPPORTED=Return value not supported by: {0}
UNSUPPORTED_PROPERTY=Unsupported property: {0}
LEGACY_PROPERY=Legacy propery {0} mapped to {1}
-CANNOT_UNMARSHALL_SERVICE_REF_META_DATA=Cannot unmarshall service ref meta data
-CANNOT_UNMARSHALL_SECURITY_CONFIG=Cannot unmarshall security config, cause: {0}
-CANNOT_RESOLVE_PORT_COMPONENT_LINK=Cannot resolve port-component-link: {0}
-CANNOT_SET_ENDPOINT_ADDRESS=Cannot set endpoint address for port-component-link,
unsuported number of endpoints
-NOT_IMPLEMENT_SERVICE=The service interface does not implement javax.xml.rpc.Service:
{0}
-THE_SEI_DOES_NOT_IMPLEMENT_JAVA.RMI.REMOTE=The SEI does not implement java.rmi.Remote:
{0}
-CANNOT_CREATE_SERVICE=Cannot create service
-CANNOT_UNMARSHAL_JAXRPC_MAPPING_FILE=Cannot unmarshal jaxrpc-mapping-file: {0}
Deleted:
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 2011-07-26
08:04:46 UTC (rev 14742)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java 2011-07-26
10:22:18 UTC (rev 14743)
@@ -1,41 +0,0 @@
-/*
- * 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.ws.core.jaxrpc.client;
-
-import javax.naming.Referenceable;
-
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
-
-/**
- * Binds a JAXRPC Service object to the client's ENC.
- *
- * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
- */
-public final class NativeServiceRefBinderJAXRPC implements ServiceRefBinder
-{
- @Override
- public Referenceable createReferenceable(final UnifiedServiceRefMetaData
serviceRefMD)
- {
- return new NativeServiceReferenceableJAXRPC(serviceRefMD);
- }
-}
Deleted:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceReferenceableJAXRPC.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceReferenceableJAXRPC.java 2011-07-26
08:04:46 UTC (rev 14742)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceReferenceableJAXRPC.java 2011-07-26
10:22:18 UTC (rev 14743)
@@ -1,185 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.ws.core.jaxrpc.client;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.net.URL;
-import java.util.ResourceBundle;
-
-import javax.naming.BinaryRefAddr;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-import javax.naming.StringRefAddr;
-
-import org.jboss.ws.api.util.BundleUtils;
-import org.jboss.ws.metadata.wsse.WSSecurityConfigFactory;
-import org.jboss.ws.metadata.wsse.WSSecurityConfiguration;
-import org.jboss.ws.metadata.wsse.WSSecurityOMFactory;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.management.ServerConfig;
-import org.jboss.wsf.spi.management.ServerConfigFactory;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-/**
- * A JNDI reference to a javax.xml.rpc.Service
- * <p/>
- * It holds the information to reconstrut the javax.xml.rpc.Service
- * when the client does a JNDI lookup.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 15-April-2004
- */
-public class NativeServiceReferenceableJAXRPC implements Referenceable
-{
- private static final ResourceBundle bundle =
BundleUtils.getBundle(NativeServiceReferenceableJAXRPC.class);
- public static final String SERVICE_REF_META_DATA = "SERVICE_REF_META_DATA";
- public static final String SECURITY_CONFIG = "SECURITY_CONFIG";
- public static final String PORT_COMPONENT_LINK = "PORT_COMPONENT_LINK";
- public static final String PORT_COMPONENT_LINK_SERVLET =
"PORT_COMPONENT_LINK_SERVLET";
-
- private UnifiedServiceRefMetaData refMetaData;
- private UnifiedVirtualFile vfsRoot;
-
- /**
- * A service referenceable for a WSDL document that is part of the deployment
- */
- public NativeServiceReferenceableJAXRPC(UnifiedServiceRefMetaData refMetaData)
- {
- this.refMetaData = refMetaData;
- this.vfsRoot = refMetaData.getVfsRoot();
- }
-
- /**
- * Retrieves the Reference of this object.
- *
- * @return The non-null Reference of this object.
- * @throws javax.naming.NamingException If a naming exception was encountered while
retrieving the reference.
- */
- public Reference getReference() throws NamingException
- {
- Reference myRef = new Reference(NativeServiceReferenceableJAXRPC.class.getName(),
ServiceObjectFactoryJAXRPC.class.getName(), null);
-
- // Add a reference to the ServiceRefMetaData and WSDLDefinitions
- myRef.add(new BinaryRefAddr(SERVICE_REF_META_DATA, marshallServiceRef()));
-
- // FIXME: JBWS-1431 Merge ws-security config with jaxrpc/jaxws config
- if (getSecurityConfig() != null)
- myRef.add(new BinaryRefAddr(SECURITY_CONFIG, marshallSecurityConfig()));
-
- // Add references to port component links
- for (UnifiedPortComponentRefMetaData pcr : refMetaData.getPortComponentRefs())
- {
- String pcLink = pcr.getPortComponentLink();
- if (pcLink != null)
- {
- myRef.add(new StringRefAddr(PORT_COMPONENT_LINK, pcLink));
- try
- {
- SPIProvider spiProvider =
SPIProviderResolver.getInstance().getProvider();
- ServerConfig config =
spiProvider.getSPI(ServerConfigFactory.class).getServerConfig();
-
- String host = config.getWebServiceHost();
- int port = config.getWebServicePort();
-
- String servletURL = "http://" + host + ":" + port +
"/jbossws/pclink";
- myRef.add(new StringRefAddr(PORT_COMPONENT_LINK_SERVLET, servletURL));
- }
- catch (Exception ex)
- {
- throw new NamingException(BundleUtils.getMessage(bundle,
"CANNOT_OBTAIN_PATH", ex));
- }
- }
- }
-
- return myRef;
- }
-
- /** Marshall the ServiceRefMetaData to an byte array
- */
- private byte[] marshallServiceRef() throws NamingException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
- try
- {
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(refMetaData);
- oos.close();
- }
- catch (IOException e)
- {
- throw new NamingException(BundleUtils.getMessage(bundle,
"CANNOT_MARSHALL_SERVICE_REF_META_DATA", e.toString()));
- }
- return baos.toByteArray();
- }
-
- /** Marshall the WSSecurityConfiguration to an byte array
- */
- private byte[] marshallSecurityConfig() throws NamingException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
- try
- {
- WSSecurityConfiguration securityConfig =
WSSecurityConfigFactory.newInstance().createConfiguration(
- refMetaData.getVfsRoot(), WSSecurityOMFactory.CLIENT_RESOURCE_NAME
- );
-
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(securityConfig);
- oos.close();
- }
- catch (IOException e)
- {
- throw new NamingException(BundleUtils.getMessage(bundle,
"CANNOT_MARSHALL_SECURITY_CONFIG", e.toString()));
- }
- return baos.toByteArray();
- }
-
- private URL getSecurityConfig()
- {
- URL securityConfigURL = null;
- try
- {
- UnifiedVirtualFile vfConfig = vfsRoot.findChild("WEB-INF/" +
WSSecurityOMFactory.CLIENT_RESOURCE_NAME);
- securityConfigURL = vfConfig.toURL();
- }
- catch (IOException ex)
- {
- // ignore
- }
- try
- {
- UnifiedVirtualFile vfConfig = vfsRoot.findChild("META-INF/" +
WSSecurityOMFactory.CLIENT_RESOURCE_NAME);
- securityConfigURL = vfConfig.toURL();
- }
- catch (IOException ex)
- {
- // ignore
- }
- return securityConfigURL;
- }
-}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java 2011-07-26
08:04:46 UTC (rev 14742)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java 2011-07-26
10:22:18 UTC (rev 14743)
@@ -92,7 +92,7 @@
/**
* Construct a Service without WSDL meta data
*/
- ServiceImpl(QName serviceName)
+ public ServiceImpl(QName serviceName)
{
UnifiedMetaData wsMetaData = new UnifiedMetaData(new ResourceLoaderAdapter());
serviceMetaData = new ServiceMetaData(wsMetaData, serviceName);
@@ -102,7 +102,7 @@
/**
* Construct a Service that has access to some WSDL meta data
*/
- ServiceImpl(QName serviceName, URL wsdlURL, URL mappingURL, URL securityURL)
+ public ServiceImpl(QName serviceName, URL wsdlURL, URL mappingURL, URL securityURL)
{
this.wsdlLocation = wsdlURL;
JAXRPCClientMetaDataBuilder builder = new JAXRPCClientMetaDataBuilder();
@@ -116,7 +116,7 @@
/**
* Construct a Service that has access to some WSDL meta data
*/
- ServiceImpl(QName serviceName, URL wsdlURL, JavaWsdlMapping mappingURL,
WSSecurityConfiguration securityConfig, UnifiedServiceRefMetaData usrMetaData)
+ public ServiceImpl(QName serviceName, URL wsdlURL, JavaWsdlMapping mappingURL,
WSSecurityConfiguration securityConfig, UnifiedServiceRefMetaData usrMetaData)
{
this.wsdlLocation = wsdlURL;
this.usrMetaData = usrMetaData;
@@ -494,7 +494,7 @@
handlerRegistry.registerClientHandlerChain(portName, infos, roles);
}
- void setupHandlerChain(EndpointMetaData epMetaData)
+ public void setupHandlerChain(EndpointMetaData epMetaData)
{
if (epMetaData.isHandlersInitialized() == false)
{
Deleted:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceObjectFactoryJAXRPC.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceObjectFactoryJAXRPC.java 2011-07-26
08:04:46 UTC (rev 14742)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceObjectFactoryJAXRPC.java 2011-07-26
10:22:18 UTC (rev 14743)
@@ -1,295 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.ws.core.jaxrpc.client;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.ObjectInputStream;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.rmi.Remote;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Properties;
-import java.util.ResourceBundle;
-
-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.rpc.JAXRPCException;
-import javax.xml.rpc.Service;
-
-import org.jboss.logging.Logger;
-import org.jboss.ws.WSException;
-import org.jboss.ws.api.util.BundleUtils;
-import org.jboss.ws.common.Constants;
-import org.jboss.ws.core.client.ServiceObjectFactory;
-import org.jboss.ws.core.server.PortComponentResolver;
-import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMapping;
-import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMappingFactory;
-import org.jboss.ws.metadata.umdm.EndpointMetaData;
-import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
-import org.jboss.ws.metadata.umdm.ServiceMetaData;
-import org.jboss.ws.metadata.wsse.WSSecurityConfiguration;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.management.EndpointRegistry;
-import org.jboss.wsf.spi.management.EndpointRegistryFactory;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedCallPropertyMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-/**
- * This ServiceObjectFactory reconstructs a javax.xml.rpc.Service
- * for a given WSDL when the webservice client does a JNDI lookup
- * <p/>
- * It uses the information provided by the service-ref element in application-client.xml
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 15-April-2004
- */
-public class ServiceObjectFactoryJAXRPC extends ServiceObjectFactory
-{
- private static final ResourceBundle bundle =
BundleUtils.getBundle(ServiceObjectFactoryJAXRPC.class);
- // provide logging
- private static final Logger log = Logger.getLogger(ServiceObjectFactoryJAXRPC.class);
-
- /**
- * 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
- */
- public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable
environment) throws Exception
- {
- try
- {
- Reference ref = (Reference)obj;
-
- // Unmarshall the ServiceRefMetaData
- UnifiedServiceRefMetaData serviceRef = null;
- RefAddr metaRefAddr =
ref.get(NativeServiceReferenceableJAXRPC.SERVICE_REF_META_DATA);
- ByteArrayInputStream bais = new
ByteArrayInputStream((byte[])metaRefAddr.getContent());
- try
- {
- ObjectInputStream ois = new ObjectInputStream(bais);
- serviceRef = (UnifiedServiceRefMetaData)ois.readObject();
- ois.close();
- }
- catch (IOException ex)
- {
- NamingException ne = new NamingException(BundleUtils.getMessage(bundle,
"CANNOT_UNMARSHALL_SERVICE_REF_META_DATA"));
- ne.setRootCause(ex);
- throw ne;
- }
-
- // Unmarshall the WSSecurityConfiguration
- WSSecurityConfiguration securityConfig = null;
- RefAddr wsseRefAddr =
ref.get(NativeServiceReferenceableJAXRPC.SECURITY_CONFIG);
- if (wsseRefAddr != null)
- {
- bais = new ByteArrayInputStream((byte[])wsseRefAddr.getContent());
- try
- {
- ObjectInputStream ois = new ObjectInputStream(bais);
- securityConfig = (WSSecurityConfiguration)ois.readObject();
- ois.close();
- }
- catch (IOException e)
- {
- throw new NamingException(BundleUtils.getMessage(bundle,
"CANNOT_UNMARSHALL_SECURITY_CONFIG", e.toString()));
- }
- }
-
- ServiceImpl jaxrpcService = null;
- URL wsdlLocation = serviceRef.getWsdlLocation();
- if (wsdlLocation != null)
- {
- if (log.isDebugEnabled())
- log.debug("Create jaxrpc service from wsdl");
-
- // Create the actual service object
- QName serviceName = serviceRef.getServiceQName();
- JavaWsdlMapping javaWsdlMapping = getJavaWsdlMapping(serviceRef);
- jaxrpcService = new ServiceImpl(serviceName, wsdlLocation, javaWsdlMapping,
securityConfig, serviceRef);
- }
- else
- {
- if (log.isDebugEnabled())
- log.debug("Create jaxrpc service with no wsdl");
- jaxrpcService = new ServiceImpl(new QName(Constants.NS_JBOSSWS_URI,
"AnonymousService"));
- }
-
- ServiceMetaData serviceMetaData = jaxrpcService.getServiceMetaData();
-
- // Set any service level properties
- if (serviceRef.getCallProperties().size() > 0)
- {
- Properties callProps = new Properties();
- serviceMetaData.setProperties(callProps);
- for (UnifiedCallPropertyMetaData prop : serviceRef.getCallProperties())
- callProps.setProperty(prop.getPropName(), prop.getPropValue());
- }
-
- // The web service client using a port-component-link, the contet is the URL to
- // the PortComponentLinkServlet that will return the actual endpoint address
- RefAddr pcLinkRef =
ref.get(NativeServiceReferenceableJAXRPC.PORT_COMPONENT_LINK);
- if (pcLinkRef != null)
- {
- String pcLink = (String)pcLinkRef.getContent();
- log.debug("Resolving port-component-link: " + pcLink);
-
- // First try to obtain the endpoint address loacally
- String endpointAddress = null;
- try
- {
- SPIProvider spiProvider =
SPIProviderResolver.getInstance().getProvider();
- EndpointRegistry epRegistry =
spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
- Endpoint endpoint = epRegistry.resolve( new PortComponentResolver(pcLink)
);
- if (endpoint == null)
- throw new WSException(BundleUtils.getMessage(bundle,
"CANNOT_RESOLVE_PORT_COMPONENT_LINK", pcLink));
-
- ServerEndpointMetaData sepMetaData =
endpoint.getAttachment(ServerEndpointMetaData.class);
- endpointAddress = sepMetaData.getEndpointAddress();
- }
- catch (Throwable ex)
- {
- // ignore, we are probably a remote client
- }
-
- // We may be remote in the esoteric case where an appclient uses the
port-comonent-link feature
- if (endpointAddress == null)
- {
- String servletPath =
(String)ref.get(NativeServiceReferenceableJAXRPC.PORT_COMPONENT_LINK_SERVLET).getContent();
- servletPath += "?pcLink=" + URLEncoder.encode(pcLink,
"UTF-8");
- InputStream is = new URL(servletPath).openStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(is));
- endpointAddress = br.readLine();
- br.close();
- is.close();
- }
-
- if (log.isDebugEnabled())
- log.debug("Resolved to: " + endpointAddress);
- if (serviceMetaData.getEndpoints().size() == 1)
- {
- EndpointMetaData epMetaData = serviceMetaData.getEndpoints().get(0);
- epMetaData.setEndpointAddress(endpointAddress);
- }
- else
- {
- log.warn(BundleUtils.getMessage(bundle,
"CANNOT_SET_ENDPOINT_ADDRESS"));
- }
- }
-
- narrowPortSelection(serviceRef, serviceMetaData);
-
- /********************************************************
- * Setup the Proxy that implements the service-interface
- ********************************************************/
-
- // load the service interface class
- ClassLoader contextCL = SecurityActions.getContextClassLoader();
- Class<?> siClass = SecurityActions.loadClass(contextCL,
serviceRef.getServiceInterface());
- if (Service.class.isAssignableFrom(siClass) == false)
- throw new JAXRPCException(BundleUtils.getMessage(bundle,
"NOT_IMPLEMENT_SERVICE", siClass.getName()));
-
- // load all service endpoint interface classes
- for (UnifiedPortComponentRefMetaData pcr : serviceRef.getPortComponentRefs())
- {
- String seiName = pcr.getServiceEndpointInterface();
- if (seiName != null)
- {
- Class seiClass = contextCL.loadClass(seiName);
- if (Remote.class.isAssignableFrom(seiClass) == false)
- throw new IllegalArgumentException(BundleUtils.getMessage(bundle,
"NOT_IMPLEMENT_REMOTE", seiClass.getName()));
- }
- }
-
- // Setup the handler chain
- setupHandlerChain(jaxrpcService);
-
- InvocationHandler handler = new ServiceProxy(jaxrpcService, siClass);
- return Proxy.newProxyInstance(contextCL, new Class[] { siClass, ServiceExt.class
}, handler);
- }
- catch (Exception ex)
- {
- log.error(BundleUtils.getMessage(bundle, "CANNOT_CREATE_SERVICE"),
ex);
- throw ex;
- }
- }
-
- /**
- * Setup the handler chain(s) for this service
- */
- private void setupHandlerChain(ServiceImpl jaxrpcService) throws Exception
- {
- List<EndpointMetaData> endpoints =
jaxrpcService.getServiceMetaData().getEndpoints();
- for (EndpointMetaData epMetaData : endpoints)
- {
- jaxrpcService.setupHandlerChain(epMetaData);
- }
- }
-
- private JavaWsdlMapping getJavaWsdlMapping(UnifiedServiceRefMetaData serviceRef)
- {
- JavaWsdlMapping javaWsdlMapping = null;
- if (serviceRef.getMappingFile() != null)
- {
- String mappingFile = serviceRef.getMappingFile();
- try
- {
- JavaWsdlMappingFactory mappingFactory =
JavaWsdlMappingFactory.newInstance();
- URL mappingURL = serviceRef.getVfsRoot().findChild(mappingFile).toURL();
- javaWsdlMapping = mappingFactory.parse(mappingURL);
- }
- catch (Exception e)
- {
- throw new WSException(BundleUtils.getMessage(bundle,
"CANNOT_UNMARSHAL_JAXRPC_MAPPING_FILE", mappingFile), e);
- }
- }
- return javaWsdlMapping;
- }
-}
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/Message.properties
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/Message.properties
(rev 0)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/Message.properties 2011-07-26
10:22:18 UTC (rev 14743)
@@ -0,0 +1,17 @@
+# NativeServiceReferenceableJAXRPC.java
+CANNOT_OBTAIN_PATH=Cannot obtain path to PortComponentLinkServlet: {0}
+CANNOT_MARSHALL_SERVICE_REF_META_DATA=Cannot marshall service ref meta data, cause: {0}
+CANNOT_MARSHALL_SECURITY_CONFIG=Cannot marshall security config, cause: {0}
+
+# NativeServiceObjectFactoryJAXRPC.java
+NOT_IMPLEMENT_REMOTE=SEI does not implement java.rmi.Remote: {0}
+CANNOT_UNMARSHALL_SERVICE_REF_META_DATA=Cannot unmarshall service ref meta data
+CANNOT_UNMARSHALL_SECURITY_CONFIG=Cannot unmarshall security config, cause: {0}
+CANNOT_RESOLVE_PORT_COMPONENT_LINK=Cannot resolve port-component-link: {0}
+CANNOT_SET_ENDPOINT_ADDRESS=Cannot set endpoint address for port-component-link,
unsuported number of endpoints
+NOT_IMPLEMENT_SERVICE=The service interface does not implement javax.xml.rpc.Service:
{0}
+CANNOT_CREATE_SERVICE=Cannot create service
+NOT_ALLOWED_TO_USE=Within a <service-ref> it's not allowed to use a SEI across
different <port-component-ref>'s: {0}
+FAILED_TO_NARROW_ENDPOINTS=Failed to narrow available endpoints by
<port-component-ref> declaration
+UNABLE_TO_NARROW_PORT_SELECTION=Unable to narrow port selection for {0}
+CANNOT_UNMARSHALL_JAXRPC_MAPPING_FILE=Cannot unmarshal jaxrpc-mapping-file: {0}
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/NativeServiceObjectFactoryJAXRPC.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/NativeServiceObjectFactoryJAXRPC.java
(rev 0)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/NativeServiceObjectFactoryJAXRPC.java 2011-07-26
10:22:18 UTC (rev 14743)
@@ -0,0 +1,368 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ws.core.jaxrpc.client.serviceref;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.ObjectInputStream;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.rmi.Remote;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.ResourceBundle;
+
+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.rpc.JAXRPCException;
+import javax.xml.rpc.Service;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.WSException;
+import org.jboss.ws.api.util.BundleUtils;
+import org.jboss.ws.common.Constants;
+import org.jboss.ws.core.jaxrpc.client.ServiceExt;
+import org.jboss.ws.core.jaxrpc.client.ServiceImpl;
+import org.jboss.ws.core.jaxrpc.client.ServiceProxy;
+import org.jboss.ws.core.server.PortComponentResolver;
+import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMapping;
+import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMappingFactory;
+import org.jboss.ws.metadata.umdm.EndpointMetaData;
+import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
+import org.jboss.ws.metadata.umdm.ServiceMetaData;
+import org.jboss.ws.metadata.wsse.WSSecurityConfiguration;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.management.EndpointRegistry;
+import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedCallPropertyMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+/**
+ * This ServiceObjectFactory reconstructs a javax.xml.rpc.Service
+ * for a given WSDL when the webservice client does a JNDI lookup
+ * <p/>
+ * It uses the information provided by the service-ref element in application-client.xml
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 15-April-2004
+ */
+public final class NativeServiceObjectFactoryJAXRPC implements ObjectFactory
+{
+ private static final ResourceBundle bundle =
BundleUtils.getBundle(NativeServiceObjectFactoryJAXRPC.class);
+ // provide logging
+ private static final Logger log =
Logger.getLogger(NativeServiceObjectFactoryJAXRPC.class);
+
+ /**
+ * 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
+ */
+ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable
environment) throws Exception
+ {
+ try
+ {
+ Reference ref = (Reference)obj;
+
+ // Unmarshall the ServiceRefMetaData
+ UnifiedServiceRefMetaData serviceRef = null;
+ RefAddr metaRefAddr =
ref.get(NativeServiceReferenceableJAXRPC.SERVICE_REF_META_DATA);
+ ByteArrayInputStream bais = new
ByteArrayInputStream((byte[])metaRefAddr.getContent());
+ try
+ {
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ serviceRef = (UnifiedServiceRefMetaData)ois.readObject();
+ ois.close();
+ }
+ catch (IOException ex)
+ {
+ NamingException ne = new NamingException(BundleUtils.getMessage(bundle,
"CANNOT_UNMARSHALL_SERVICE_REF_META_DATA"));
+ ne.setRootCause(ex);
+ throw ne;
+ }
+
+ // Unmarshall the WSSecurityConfiguration
+ WSSecurityConfiguration securityConfig = null;
+ RefAddr wsseRefAddr =
ref.get(NativeServiceReferenceableJAXRPC.SECURITY_CONFIG);
+ if (wsseRefAddr != null)
+ {
+ bais = new ByteArrayInputStream((byte[])wsseRefAddr.getContent());
+ try
+ {
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ securityConfig = (WSSecurityConfiguration)ois.readObject();
+ ois.close();
+ }
+ catch (IOException e)
+ {
+ throw new NamingException(BundleUtils.getMessage(bundle,
"CANNOT_UNMARSHALL_SECURITY_CONFIG", e.toString()));
+ }
+ }
+
+ ServiceImpl jaxrpcService = null;
+ URL wsdlLocation = serviceRef.getWsdlLocation();
+ if (wsdlLocation != null)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Create jaxrpc service from wsdl");
+
+ // Create the actual service object
+ QName serviceName = serviceRef.getServiceQName();
+ JavaWsdlMapping javaWsdlMapping = getJavaWsdlMapping(serviceRef);
+ jaxrpcService = new ServiceImpl(serviceName, wsdlLocation, javaWsdlMapping,
securityConfig, serviceRef);
+ }
+ else
+ {
+ if (log.isDebugEnabled())
+ log.debug("Create jaxrpc service with no wsdl");
+ jaxrpcService = new ServiceImpl(new QName(Constants.NS_JBOSSWS_URI,
"AnonymousService"));
+ }
+
+ ServiceMetaData serviceMetaData = jaxrpcService.getServiceMetaData();
+
+ // Set any service level properties
+ if (serviceRef.getCallProperties().size() > 0)
+ {
+ Properties callProps = new Properties();
+ serviceMetaData.setProperties(callProps);
+ for (UnifiedCallPropertyMetaData prop : serviceRef.getCallProperties())
+ callProps.setProperty(prop.getPropName(), prop.getPropValue());
+ }
+
+ // The web service client using a port-component-link, the contet is the URL to
+ // the PortComponentLinkServlet that will return the actual endpoint address
+ RefAddr pcLinkRef =
ref.get(NativeServiceReferenceableJAXRPC.PORT_COMPONENT_LINK);
+ if (pcLinkRef != null)
+ {
+ String pcLink = (String)pcLinkRef.getContent();
+ log.debug("Resolving port-component-link: " + pcLink);
+
+ // First try to obtain the endpoint address loacally
+ String endpointAddress = null;
+ try
+ {
+ SPIProvider spiProvider =
SPIProviderResolver.getInstance().getProvider();
+ EndpointRegistry epRegistry =
spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
+ Endpoint endpoint = epRegistry.resolve( new PortComponentResolver(pcLink)
);
+ if (endpoint == null)
+ throw new WSException(BundleUtils.getMessage(bundle,
"CANNOT_RESOLVE_PORT_COMPONENT_LINK", pcLink));
+
+ ServerEndpointMetaData sepMetaData =
endpoint.getAttachment(ServerEndpointMetaData.class);
+ endpointAddress = sepMetaData.getEndpointAddress();
+ }
+ catch (Throwable ex)
+ {
+ // ignore, we are probably a remote client
+ }
+
+ // We may be remote in the esoteric case where an appclient uses the
port-comonent-link feature
+ if (endpointAddress == null)
+ {
+ String servletPath =
(String)ref.get(NativeServiceReferenceableJAXRPC.PORT_COMPONENT_LINK_SERVLET).getContent();
+ servletPath += "?pcLink=" + URLEncoder.encode(pcLink,
"UTF-8");
+ InputStream is = new URL(servletPath).openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ endpointAddress = br.readLine();
+ br.close();
+ is.close();
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Resolved to: " + endpointAddress);
+ if (serviceMetaData.getEndpoints().size() == 1)
+ {
+ EndpointMetaData epMetaData = serviceMetaData.getEndpoints().get(0);
+ epMetaData.setEndpointAddress(endpointAddress);
+ }
+ else
+ {
+ log.warn(BundleUtils.getMessage(bundle,
"CANNOT_SET_ENDPOINT_ADDRESS"));
+ }
+ }
+
+ narrowPortSelection(serviceRef, serviceMetaData);
+
+ /********************************************************
+ * Setup the Proxy that implements the service-interface
+ ********************************************************/
+
+ // load the service interface class
+ ClassLoader contextCL = SecurityActions.getContextClassLoader();
+ Class<?> siClass = SecurityActions.loadClass(contextCL,
serviceRef.getServiceInterface());
+ if (Service.class.isAssignableFrom(siClass) == false)
+ throw new JAXRPCException(BundleUtils.getMessage(bundle,
"NOT_IMPLEMENT_SERVICE", siClass.getName()));
+
+ // load all service endpoint interface classes
+ for (UnifiedPortComponentRefMetaData pcr : serviceRef.getPortComponentRefs())
+ {
+ String seiName = pcr.getServiceEndpointInterface();
+ if (seiName != null)
+ {
+ Class<?> seiClass = contextCL.loadClass(seiName);
+ if (Remote.class.isAssignableFrom(seiClass) == false)
+ throw new IllegalArgumentException(BundleUtils.getMessage(bundle,
"NOT_IMPLEMENT_REMOTE", seiClass.getName()));
+ }
+ }
+
+ // Setup the handler chain
+ setupHandlerChain(jaxrpcService);
+
+ InvocationHandler handler = new ServiceProxy(jaxrpcService, siClass);
+ return Proxy.newProxyInstance(contextCL, new Class[] { siClass, ServiceExt.class
}, handler);
+ }
+ catch (Exception ex)
+ {
+ log.error(BundleUtils.getMessage(bundle, "CANNOT_CREATE_SERVICE"),
ex);
+ throw ex;
+ }
+ }
+
+ /**
+ * Narrow available endpoints by <port-component-ref> declarations.
+ * Service.getPort(SEI) must be able to retrieve a distinct port definition.
+ */
+ protected void narrowPortSelection(UnifiedServiceRefMetaData serviceRef,
ServiceMetaData serviceMetaData)
+ {
+ if (serviceMetaData.getEndpoints().size() > 1)
+ {
+ Map<String, UnifiedPortComponentRefMetaData> pcrefs = new
HashMap<String, UnifiedPortComponentRefMetaData>();
+ for (UnifiedPortComponentRefMetaData pcref : serviceRef.getPortComponentRefs())
+ {
+ String seiName = pcref.getServiceEndpointInterface();
+
+ // Constraint#1: within a service-ref it's not allowed to use a SEI
across different pcref's
+ if (pcrefs.get(seiName) != null)
+ throw new WSException(BundleUtils.getMessage(bundle,
"NOT_ALLOWED_TO_USE", seiName));
+
+ pcrefs.put(seiName, pcref);
+ }
+
+ // Constraint#2: A pcref may only match one EndpointMetaData
+ for (String sei : pcrefs.keySet())
+ {
+ // Narrow available endpoints by port-component-ref declaration
+ List<QName> narrowedEndpoints = new ArrayList<QName>();
+
+ UnifiedPortComponentRefMetaData pcref = pcrefs.get(sei);
+
+ // Constraint#3: Port selection only applies when both SEI and QName are
given
+ if (pcref.getServiceEndpointInterface() != null &&
pcref.getPortQName() != null)
+ {
+ List<QName> pcRef2EndpointMapping = new ArrayList<QName>();
+ for (EndpointMetaData epMetaData : serviceMetaData.getEndpoints())
+ {
+ if
(pcref.getServiceEndpointInterface().equals(epMetaData.getServiceEndpointInterfaceName()))
+ {
+ pcRef2EndpointMapping.add(epMetaData.getPortName());
+ }
+ }
+
+ for (QName q : pcRef2EndpointMapping)
+ {
+ EndpointMetaData mappedEndpoint = serviceMetaData.getEndpoint(q);
+ if (!pcref.getPortQName().equals(mappedEndpoint.getPortName()))
+ narrowedEndpoints.add(q);
+ }
+
+ // Constraint: Dont exclude all of them ;)
+ if (pcRef2EndpointMapping.size() > 0 &&
(pcRef2EndpointMapping.size() == narrowedEndpoints.size()))
+ throw new WSException(BundleUtils.getMessage(bundle,
"FAILED_TO_NARROW_ENDPOINTS"));
+
+ for (QName q : narrowedEndpoints)
+ {
+ EndpointMetaData removed = serviceMetaData.removeEndpoint(q);
+ if (log.isDebugEnabled())
+ log.debug("Narrowed endpoint " + q + "(" +
removed + ")");
+ }
+ }
+ else
+ {
+ // TODO: In case there is more then one EMPD this should cause an
exception
+ log.warn(BundleUtils.getMessage(bundle,
"UNABLE_TO_NARROW_PORT_SELECTION", pcref));
+ }
+ }
+ }
+ }
+
+ /**
+ * Setup the handler chain(s) for this service
+ */
+ private void setupHandlerChain(ServiceImpl jaxrpcService) throws Exception
+ {
+ List<EndpointMetaData> endpoints =
jaxrpcService.getServiceMetaData().getEndpoints();
+ for (EndpointMetaData epMetaData : endpoints)
+ {
+ jaxrpcService.setupHandlerChain(epMetaData);
+ }
+ }
+
+ private JavaWsdlMapping getJavaWsdlMapping(UnifiedServiceRefMetaData serviceRef)
+ {
+ JavaWsdlMapping javaWsdlMapping = null;
+ if (serviceRef.getMappingFile() != null)
+ {
+ String mappingFile = serviceRef.getMappingFile();
+ try
+ {
+ JavaWsdlMappingFactory mappingFactory =
JavaWsdlMappingFactory.newInstance();
+ URL mappingURL = serviceRef.getVfsRoot().findChild(mappingFile).toURL();
+ javaWsdlMapping = mappingFactory.parse(mappingURL);
+ }
+ catch (Exception e)
+ {
+ throw new WSException(BundleUtils.getMessage(bundle,
"CANNOT_UNMARSHALL_JAXRPC_MAPPING_FILE", mappingFile), e);
+ }
+ }
+ return javaWsdlMapping;
+ }
+}
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/NativeServiceRefBinderJAXRPC.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/NativeServiceRefBinderJAXRPC.java
(rev 0)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/NativeServiceRefBinderJAXRPC.java 2011-07-26
10:22:18 UTC (rev 14743)
@@ -0,0 +1,41 @@
+/*
+ * 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.ws.core.jaxrpc.client.serviceref;
+
+import javax.naming.Referenceable;
+
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
+
+/**
+ * Binds a JAXRPC Service object to the client's ENC.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class NativeServiceRefBinderJAXRPC implements ServiceRefBinder
+{
+ @Override
+ public Referenceable createReferenceable(final UnifiedServiceRefMetaData
serviceRefMD)
+ {
+ return new NativeServiceReferenceableJAXRPC(serviceRefMD);
+ }
+}
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/NativeServiceReferenceableJAXRPC.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/NativeServiceReferenceableJAXRPC.java
(rev 0)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/NativeServiceReferenceableJAXRPC.java 2011-07-26
10:22:18 UTC (rev 14743)
@@ -0,0 +1,185 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ws.core.jaxrpc.client.serviceref;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.net.URL;
+import java.util.ResourceBundle;
+
+import javax.naming.BinaryRefAddr;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.StringRefAddr;
+
+import org.jboss.ws.api.util.BundleUtils;
+import org.jboss.ws.metadata.wsse.WSSecurityConfigFactory;
+import org.jboss.ws.metadata.wsse.WSSecurityConfiguration;
+import org.jboss.ws.metadata.wsse.WSSecurityOMFactory;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.management.ServerConfig;
+import org.jboss.wsf.spi.management.ServerConfigFactory;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+/**
+ * A JNDI reference to a javax.xml.rpc.Service
+ * <p/>
+ * It holds the information to reconstrut the javax.xml.rpc.Service
+ * when the client does a JNDI lookup.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 15-April-2004
+ */
+public final class NativeServiceReferenceableJAXRPC implements Referenceable
+{
+ private static final ResourceBundle bundle =
BundleUtils.getBundle(NativeServiceReferenceableJAXRPC.class);
+ public static final String SERVICE_REF_META_DATA = "SERVICE_REF_META_DATA";
+ public static final String SECURITY_CONFIG = "SECURITY_CONFIG";
+ public static final String PORT_COMPONENT_LINK = "PORT_COMPONENT_LINK";
+ public static final String PORT_COMPONENT_LINK_SERVLET =
"PORT_COMPONENT_LINK_SERVLET";
+
+ private UnifiedServiceRefMetaData refMetaData;
+ private UnifiedVirtualFile vfsRoot;
+
+ /**
+ * A service referenceable for a WSDL document that is part of the deployment
+ */
+ public NativeServiceReferenceableJAXRPC(UnifiedServiceRefMetaData refMetaData)
+ {
+ this.refMetaData = refMetaData;
+ this.vfsRoot = refMetaData.getVfsRoot();
+ }
+
+ /**
+ * Retrieves the Reference of this object.
+ *
+ * @return The non-null Reference of this object.
+ * @throws javax.naming.NamingException If a naming exception was encountered while
retrieving the reference.
+ */
+ public Reference getReference() throws NamingException
+ {
+ Reference myRef = new Reference(NativeServiceReferenceableJAXRPC.class.getName(),
NativeServiceObjectFactoryJAXRPC.class.getName(), null);
+
+ // Add a reference to the ServiceRefMetaData and WSDLDefinitions
+ myRef.add(new BinaryRefAddr(SERVICE_REF_META_DATA, marshallServiceRef()));
+
+ // FIXME: JBWS-1431 Merge ws-security config with jaxrpc/jaxws config
+ if (getSecurityConfig() != null)
+ myRef.add(new BinaryRefAddr(SECURITY_CONFIG, marshallSecurityConfig()));
+
+ // Add references to port component links
+ for (UnifiedPortComponentRefMetaData pcr : refMetaData.getPortComponentRefs())
+ {
+ String pcLink = pcr.getPortComponentLink();
+ if (pcLink != null)
+ {
+ myRef.add(new StringRefAddr(PORT_COMPONENT_LINK, pcLink));
+ try
+ {
+ SPIProvider spiProvider =
SPIProviderResolver.getInstance().getProvider();
+ ServerConfig config =
spiProvider.getSPI(ServerConfigFactory.class).getServerConfig();
+
+ String host = config.getWebServiceHost();
+ int port = config.getWebServicePort();
+
+ String servletURL = "http://" + host + ":" + port +
"/jbossws/pclink";
+ myRef.add(new StringRefAddr(PORT_COMPONENT_LINK_SERVLET, servletURL));
+ }
+ catch (Exception ex)
+ {
+ throw new NamingException(BundleUtils.getMessage(bundle,
"CANNOT_OBTAIN_PATH", ex));
+ }
+ }
+ }
+
+ return myRef;
+ }
+
+ /** Marshall the ServiceRefMetaData to an byte array
+ */
+ private byte[] marshallServiceRef() throws NamingException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
+ try
+ {
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(refMetaData);
+ oos.close();
+ }
+ catch (IOException e)
+ {
+ throw new NamingException(BundleUtils.getMessage(bundle,
"CANNOT_MARSHALL_SERVICE_REF_META_DATA", e.toString()));
+ }
+ return baos.toByteArray();
+ }
+
+ /** Marshall the WSSecurityConfiguration to an byte array
+ */
+ private byte[] marshallSecurityConfig() throws NamingException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
+ try
+ {
+ WSSecurityConfiguration securityConfig =
WSSecurityConfigFactory.newInstance().createConfiguration(
+ refMetaData.getVfsRoot(), WSSecurityOMFactory.CLIENT_RESOURCE_NAME
+ );
+
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(securityConfig);
+ oos.close();
+ }
+ catch (IOException e)
+ {
+ throw new NamingException(BundleUtils.getMessage(bundle,
"CANNOT_MARSHALL_SECURITY_CONFIG", e.toString()));
+ }
+ return baos.toByteArray();
+ }
+
+ private URL getSecurityConfig()
+ {
+ URL securityConfigURL = null;
+ try
+ {
+ UnifiedVirtualFile vfConfig = vfsRoot.findChild("WEB-INF/" +
WSSecurityOMFactory.CLIENT_RESOURCE_NAME);
+ securityConfigURL = vfConfig.toURL();
+ }
+ catch (IOException ex)
+ {
+ // ignore
+ }
+ try
+ {
+ UnifiedVirtualFile vfConfig = vfsRoot.findChild("META-INF/" +
WSSecurityOMFactory.CLIENT_RESOURCE_NAME);
+ securityConfigURL = vfConfig.toURL();
+ }
+ catch (IOException ex)
+ {
+ // ignore
+ }
+ return securityConfigURL;
+ }
+}
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/SecurityActions.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/SecurityActions.java
(rev 0)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/serviceref/SecurityActions.java 2011-07-26
10:22:18 UTC (rev 14743)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ws.core.jaxrpc.client.serviceref;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+class SecurityActions
+{
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
{
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws
PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new
PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+
+ static URL getResource(final ClassLoader cl, final String filename)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.getResource(filename);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run()
+ {
+ return cl.getResource(filename);
+ }
+ });
+ }
+ }
+}
\ No newline at end of file