Author: thomas.diesler(a)jboss.com
Date: 2007-06-27 07:32:01 -0400 (Wed, 27 Jun 2007)
New Revision: 3744
Modified:
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedInitParamMetaData.java
branches/jbossws-2.0/jbossws-core/src/main/java/javax/xml/rpc/handler/HandlerInfo.java
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceObjectFactory.java
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/HandlerRegistryImpl.java
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaData.java
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaDataJAXRPC.java
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaDataJAXWS.java
branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/samples/handler/ClientSideHandler.java
branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/samples/handler/ServerSideHandler.java
Log:
Fix jaxrpc handler init-param processing
Modified:
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedInitParamMetaData.java
===================================================================
---
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedInitParamMetaData.java 2007-06-27
10:01:06 UTC (rev 3743)
+++
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedInitParamMetaData.java 2007-06-27
11:32:01 UTC (rev 3744)
@@ -36,6 +36,16 @@
// The required <param-value> element
private String paramValue;
+ public UnifiedInitParamMetaData(String paramName, String paramValue)
+ {
+ this.paramName = paramName;
+ this.paramValue = paramValue;
+ }
+
+ public UnifiedInitParamMetaData()
+ {
+ }
+
public String getParamName()
{
return paramName;
Modified:
branches/jbossws-2.0/jbossws-core/src/main/java/javax/xml/rpc/handler/HandlerInfo.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/main/java/javax/xml/rpc/handler/HandlerInfo.java 2007-06-27
10:01:06 UTC (rev 3743)
+++
branches/jbossws-2.0/jbossws-core/src/main/java/javax/xml/rpc/handler/HandlerInfo.java 2007-06-27
11:32:01 UTC (rev 3744)
@@ -59,7 +59,7 @@
public HandlerInfo(Class handlerClass, Map config, QName[] headers)
{
this.handlerClass = handlerClass;
- this.configMap = config;
+ this.configMap.putAll(config);
this.headers = headers;
}
Modified:
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceObjectFactory.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceObjectFactory.java 2007-06-27
10:01:06 UTC (rev 3743)
+++
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceObjectFactory.java 2007-06-27
11:32:01 UTC (rev 3744)
@@ -58,61 +58,63 @@
*/
protected void narrowPortSelection(UnifiedServiceRefMetaData serviceRef,
ServiceMetaData serviceMetaData)
{
- Map<String, UnifiedPortComponentRefMetaData> pcrefs = new HashMap<String,
UnifiedPortComponentRefMetaData>();
- for (UnifiedPortComponentRefMetaData pcref : serviceRef.getPortComponentRefs())
+ if (serviceMetaData.getEndpoints().size() > 1)
{
- String seiName = pcref.getServiceEndpointInterface();
+ 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("Within a <service-ref> it's not allowed
to use a SEI across different <port-component-ref>'s: " + seiName);
-
- pcrefs.put(seiName, pcref);
- }
+ // 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("Within a <service-ref> it's not
allowed to use a SEI across different <port-component-ref>'s: " +
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>();
+ // 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);
+ 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())
+ // Constraint#3: Port selection only applies when both SEI and QName are
given
+ if (pcref.getServiceEndpointInterface() != null &&
pcref.getPortQName() != null)
{
- if
(pcref.getServiceEndpointInterface().equals(epMetaData.getServiceEndpointInterfaceName()))
+ List<QName> pcRef2EndpointMapping = new ArrayList<QName>();
+ for (EndpointMetaData epMetaData : serviceMetaData.getEndpoints())
{
- pcRef2EndpointMapping.add(epMetaData.getPortName());
+ 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);
- }
+ 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("Failed to narrow available endpoints by
<port-component-ref> declaration");
+ // Constraint: Dont exclude all of them ;)
+ if (pcRef2EndpointMapping.size() > 0 &&
(pcRef2EndpointMapping.size() == narrowedEndpoints.size()))
+ throw new WSException("Failed to narrow available endpoints by
<port-component-ref> declaration");
- for (QName q : narrowedEndpoints)
+ for (QName q : narrowedEndpoints)
+ {
+ EndpointMetaData removed = serviceMetaData.removeEndpoint(q);
+ log.debug("Narrowed endpoint " + q + "(" + removed
+ ")");
+ }
+ }
+ else
{
- EndpointMetaData removed = serviceMetaData.removeEndpoint(q);
- log.debug("Narrowed endpoint " + q + "(" + removed +
")");
+ // TODO: In case there is more then one EMPD this should cause an
exception
+ log.warn("Unable to narrow port selection for " + pcref);
}
}
- else
- {
- // TODO: In case there is more then one EMPD this should cause an exception
- log.warn("Unable to narrow port selection for " + pcref);
- }
-
}
}
}
Modified:
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/HandlerRegistryImpl.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/HandlerRegistryImpl.java 2007-06-27
10:01:06 UTC (rev 3743)
+++
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/HandlerRegistryImpl.java 2007-06-27
11:32:01 UTC (rev 3744)
@@ -27,6 +27,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -41,6 +42,7 @@
import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.ws.metadata.umdm.HandlerMetaDataJAXRPC;
import org.jboss.ws.metadata.umdm.ServiceMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedInitParamMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
/**
@@ -115,13 +117,26 @@
handler.setEndpointMetaData(epMetaData);
handler.setHandlerClassName(info.getHandlerClass().getName());
handler.setSoapRoles(roles);
-
+
+ // copy headers
Set<QName> headers = new HashSet<QName>();
for (QName header : info.getHeaders())
headers.add(header);
-
handler.setSoapHeaders(headers);
+ // copy init params
+ List<UnifiedInitParamMetaData> initParams = new
ArrayList<UnifiedInitParamMetaData>();
+ Iterator<Map.Entry> entries =
info.getHandlerConfig().entrySet().iterator();
+ while (entries.hasNext())
+ {
+ Map.Entry entry = entries.next();
+ String key = (String)entry.getKey();
+ Object value = entry.getValue();
+ if (value instanceof String)
+ initParams.add(new UnifiedInitParamMetaData(key, (String)value));
+ }
+ handler.setInitParams(initParams);
+
epMetaData.addHandler(handler);
log.debug("Add handler to: " + portName + handler);
}
Modified:
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java 2007-06-27
10:01:06 UTC (rev 3743)
+++
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java 2007-06-27
11:32:01 UTC (rev 3744)
@@ -519,12 +519,12 @@
log.debug("Adding client side handler to endpoint '" + portName
+ "': " + info);
handlerInfos.add(info);
-
- // register the handlers with the client engine
- if (handlerInfos.size() > 0)
- registerHandlerChain(portName, handlerInfos, handlerRoles);
}
+ // register the handlers with the client engine
+ if (handlerInfos.size() > 0)
+ registerHandlerChain(portName, handlerInfos, handlerRoles);
+
epMetaData.setHandlersInitialized(true);
}
}
Modified:
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaData.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaData.java 2007-06-27
10:01:06 UTC (rev 3743)
+++
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaData.java 2007-06-27
11:32:01 UTC (rev 3744)
@@ -140,7 +140,7 @@
return soapHeaders;
}
- public void seiInitParams(List<UnifiedInitParamMetaData> initParams)
+ public void setInitParams(List<UnifiedInitParamMetaData> initParams)
{
this.initParams = initParams;
}
Modified:
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaDataJAXRPC.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaDataJAXRPC.java 2007-06-27
10:01:06 UTC (rev 3743)
+++
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaDataJAXRPC.java 2007-06-27
11:32:01 UTC (rev 3744)
@@ -49,7 +49,7 @@
HandlerMetaDataJAXRPC hmd = new HandlerMetaDataJAXRPC(type);
hmd.setHandlerName(uhmd.getHandlerName());
hmd.setHandlerClassName(uhmd.getHandlerClass());
- hmd.seiInitParams(uhmd.getInitParams());
+ hmd.setInitParams(uhmd.getInitParams());
hmd.setSoapHeaders(uhmd.getSoapHeaders());
hmd.setSoapRoles(uhmd.getSoapRoles());
hmd.setPortNames(uhmd.getPortNames());
Modified:
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaDataJAXWS.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaDataJAXWS.java 2007-06-27
10:01:06 UTC (rev 3743)
+++
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaDataJAXWS.java 2007-06-27
11:32:01 UTC (rev 3744)
@@ -51,7 +51,7 @@
HandlerMetaDataJAXWS hmd = new HandlerMetaDataJAXWS(type);
hmd.setHandlerName(uhmd.getHandlerName());
hmd.setHandlerClassName(uhmd.getHandlerClass());
- hmd.seiInitParams(uhmd.getInitParams());
+ hmd.setInitParams(uhmd.getInitParams());
UnifiedHandlerChainMetaData handlerChain = uhmd.getHandlerChain();
if (handlerChain != null)
{
Modified:
branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/samples/handler/ClientSideHandler.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/samples/handler/ClientSideHandler.java 2007-06-27
10:01:06 UTC (rev 3743)
+++
branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/samples/handler/ClientSideHandler.java 2007-06-27
11:32:01 UTC (rev 3744)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.ws.jaxrpc.samples.handler;
+import java.util.Map;
+
import javax.xml.namespace.QName;
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.handler.GenericHandler;
@@ -53,6 +55,12 @@
{
log.info("init: " + info);
headers = info.getHeaders();
+
+ Map configMap = info.getHandlerConfig();
+ String value1 = (String)configMap.get("ClientParam1");
+ String value2 = (String)configMap.get("ClientParam2");
+ if (!"value1".equals(value1) || !"value2".equals(value2))
+ throw new IllegalStateException("Invalid handler config: " +
configMap);
}
public boolean handleRequest(MessageContext msgContext)
Modified:
branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/samples/handler/ServerSideHandler.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/samples/handler/ServerSideHandler.java 2007-06-27
10:01:06 UTC (rev 3743)
+++
branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/samples/handler/ServerSideHandler.java 2007-06-27
11:32:01 UTC (rev 3744)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.ws.jaxrpc.samples.handler;
+import java.util.Map;
+
import javax.xml.namespace.QName;
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.handler.GenericHandler;
@@ -57,6 +59,11 @@
{
log.info("init: " + info);
headers = info.getHeaders();
+ Map configMap = info.getHandlerConfig();
+ String value1 = (String)configMap.get("ServerParam1");
+ String value2 = (String)configMap.get("ServerParam2");
+ if (!"value1".equals(value1) || !"value2".equals(value2))
+ throw new IllegalStateException("Invalid handler config: " +
configMap);
}
public boolean handleRequest(MessageContext msgContext)