Author: mmerz
Date: Tue Mar 1 11:28:08 2005
New Revision: 155818
URL: http://svn.apache.org/viewcvs?view=rev&rev=155818
Log:
Fix to remove HandlerHander and install the jaxrpc handlers in Axis properly.
Contributor: Daryoush Mehrtash
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedWebServiceDeploymentHandler.java
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedWebServiceDeploymentHandler.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedWebServiceDeploymentHandler.java?view=diff&r1=155817&r2=155818
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedWebServiceDeploymentHandler.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedWebServiceDeploymentHandler.java
Tue Mar 1 11:28:08 2005
@@ -21,11 +21,16 @@
import java.io.File;
import java.io.FilenameFilter;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import javax.xml.namespace.QName;
+import javax.xml.rpc.handler.HandlerInfo;
+
import org.apache.axis.AxisFault;
import org.apache.axis.Constants;
import org.apache.axis.MessageContext;
@@ -34,40 +39,44 @@
import org.apache.axis.constants.Use;
import org.apache.axis.description.ServiceDesc;
import org.apache.axis.handlers.BasicHandler;
+import org.apache.axis.handlers.HandlerInfoChainFactory;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.providers.java.RPCProvider;
+import org.apache.axis.utils.ClassUtils;
import org.apache.commons.logging.Log;
+import org.apache.beehive.wsm.jsr181.model.BeehiveWsSOAPMessageHandlerInfo;
import org.apache.beehive.wsm.jsr181.model.BeehiveWsTypeMetadata;
import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181ObjectModelStore;
+import org.w3c.dom.Element;
+
/**
* ****************************************************************************
* A few annotation specific things added and lots of code copied from the
* JWSHandler class by
- *
- * @author Jonathan Colwell ([EMAIL PROTECTED])
- * but most of the original code was written by:
+ *
+ * @author Jonathan Colwell ([EMAIL PROTECTED]) but most of the original code
was
+ * written by:
* @author Glen Daniels ([EMAIL PROTECTED])
* @author Doug Davis ([EMAIL PROTECTED])
- * @author Sam Ruby ([EMAIL PROTECTED])
- * todo: fix directory structure/classloaders for output files
+ * @author Sam Ruby ([EMAIL PROTECTED]) todo: fix directory
+ * structure/classloaders for output files
*/
public class AnnotatedWebServiceDeploymentHandler extends BasicHandler {
-
- protected static Log log =
-
LogFactory.getLog(AnnotatedWebServiceDeploymentHandler.class.getName());
- protected Map<String, SOAPService> soapServices =
- new HashMap<String, SOAPService>();
+ protected static Log log = LogFactory
+ .getLog(AnnotatedWebServiceDeploymentHandler.class.getName());
+
+ protected Map<String, SOAPService> soapServices = new HashMap<String,
SOAPService>();
/**
* @param mc
* @throws AxisFault
*/
public void invoke(MessageContext mc) throws AxisFault {
-
+
try {
SOAPService ss = getSOAPService(getWebServiceClass(mc));
if (null != ss) {
@@ -78,16 +87,13 @@
* types were still being sent even with literal Use. Forcing
it
* to not send the types unless encoded.
*/
- mc.setProperty(
- Call.SEND_TYPE_ATTR,
- new Boolean(Use.ENCODED.equals(ss.getUse()))
- );
-
+ mc.setProperty(Call.SEND_TYPE_ATTR, new Boolean(Use.ENCODED
+ .equals(ss.getUse())));
+
// blow away the real path to bypass the regular JWSHandler
mc.removeProperty(Constants.MC_REALPATH);
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw AxisFault.makeFault(e);
}
}
@@ -110,7 +116,8 @@
if (null != clazz) {
ss = soapServices.get(clazz.getName());
if (null == ss) {
- ss = createSOAPService(Jsr181ObjectModelStore.load(clazz),
clazz);
+ ss = createSOAPService(Jsr181ObjectModelStore.load(clazz),
+ clazz);
}
}
return ss;
@@ -122,16 +129,26 @@
* @return
* @throws Exception
*/
- protected SOAPService createSOAPService(BeehiveWsTypeMetadata wsm, Class
cls) throws Exception {
+ protected SOAPService createSOAPService(BeehiveWsTypeMetadata wsm, Class
cls)
+ throws Exception {
SOAPService ss = null;
if (null != wsm) {
- HandlerHandler hh = new HandlerHandler(wsm);
- hh.init();
- // NOTE [EMAIL PROTECTED] 2004-Nov-01 --
- // not calling ss.init() since ControlProvider won't do anything
- // with it and I don't want the HandlerHandler initialized twice.
- ss = new SOAPService(hh, new ControlProvider(), hh);
+ // HandlerHandler hh = new HandlerHandler(wsm);
+ // hh.init();
+ // // NOTE [EMAIL PROTECTED] 2004-Nov-01 --
+ // // not calling ss.init() since ControlProvider won't do anything
+ // // with it and I don't want the HandlerHandler initialized
twice.
+ // ss = new SOAPService(hh, new ControlProvider(), hh);
+
+ // create soap service without any handlers.
+ ss = new SOAPService(null, new ControlProvider(), null);
+
+ // Add jaxrpc handlers if there are any.
+ HandlerInfoChainFactory jaxrpcChain;
+ if (null != (jaxrpcChain = getJaxRPCHandlerChainFactory(wsm))) {
+ ss.setOption(Constants.ATTR_HANDLERINFOCHAIN, jaxrpcChain);
+ }
ss.setName(wsm.getWsName());
ss.setOption(RPCProvider.OPTION_CLASSNAME, cls.getName());
@@ -142,7 +159,8 @@
scope = "Request";
}
ss.setOption(RPCProvider.OPTION_SCOPE, scope);
- ServiceDesc sd = AxisHook.createServiceDesc(wsm,
cls.getClassLoader());
+ ServiceDesc sd = AxisHook.createServiceDesc(wsm, cls
+ .getClassLoader());
ss.setServiceDescription(sd);
List allowedMethodNames = sd.getAllowedMethods();
Iterator allowIt = allowedMethodNames.iterator();
@@ -158,8 +176,10 @@
ss.setOption(RPCProvider.OPTION_ALLOWEDMETHODS, sb.toString());
ss.setOption(RPCProvider.OPTION_WSDL_PORTTYPE, wsm.getWsName());
ss.setOption(RPCProvider.OPTION_WSDL_SERVICEPORT, wsm.getWsName());
- ss.setOption(RPCProvider.OPTION_WSDL_SERVICEELEMENT,
wsm.getWsServiceName());
- ss.setOption(RPCProvider.OPTION_WSDL_TARGETNAMESPACE,
wsm.getWsTargetNamespace());
+ ss.setOption(RPCProvider.OPTION_WSDL_SERVICEELEMENT, wsm
+ .getWsServiceName());
+ ss.setOption(RPCProvider.OPTION_WSDL_TARGETNAMESPACE, wsm
+ .getWsTargetNamespace());
ss.setStyle(sd.getStyle());
ss.setUse(sd.getUse());
soapServices.put(cls.getName(), ss);
@@ -167,32 +187,58 @@
return ss;
}
+ protected HandlerInfoChainFactory getJaxRPCHandlerChainFactory(
+ BeehiveWsTypeMetadata wsm) throws ClassNotFoundException {
+ HandlerInfoChainFactory res = null;
+ List< ? extends BeehiveWsSOAPMessageHandlerInfo> handlers = wsm
+ .getSoapHandlers();
+ if (handlers.size() > 0) { // there are handlers to install
+ ArrayList<HandlerInfo> infoList = new ArrayList<HandlerInfo>();
+ HashSet<String> roles = new HashSet<String>();
+
+ for (BeehiveWsSOAPMessageHandlerInfo handler : handlers) {
+ Class handlerClass =
ClassUtils.forName(handler.getClassName());
+ QName[] handlerHeaders = handler.getHeaders().toArray(
+ new QName[0]);
+ infoList.add(new HandlerInfo(handlerClass, (Map) handler
+ .getParameterMap(), handlerHeaders));
+ roles.addAll(handler.getRoles());
+ }
+ res = new HandlerInfoChainFactory(infoList);
+ String[] roleArray = roles.toArray(new String[0]);
+ res.setRoles(roleArray);
+ }
+ return res;
+ }
+
/**
* @param mc
* @return
* @throws Exception
*/
- protected Class getWebServiceClass(MessageContext mc)
- throws Exception
- {
+ protected Class getWebServiceClass(MessageContext mc) throws Exception {
// check message context
if (null == mc) {
throw new IllegalArgumentException("message context not set");
}
-
+
// retrieve & check relative path
String relativePath = mc.getStrProp(Constants.MC_RELATIVE_PATH);
if (null == relativePath) {
- throw new Exception("relative path not set properly in message
context");
+ throw new Exception(
+ "relative path not set properly in message context");
}
-
+
// turn relative path into fq class name
final String JWS_EXTENSION = ".jws";
+
/*
if ((! relativePath.startsWith("/")) || (!
relativePath.endsWith(JWS_EXTENSION))) {
throw new Exception ("invalid relative path: " + relativePath);
}
- String className = relativePath.substring(1, relativePath.length() -
JWS_EXTENSION.length()).replaceAll("/", ".");
+ String className = relativePath.substring(1,
+ relativePath.length() - JWS_EXTENSION.length()).replaceAll("/",
+ ".");
*/
if (! relativePath.startsWith("/")) {
@@ -216,7 +262,7 @@
log.debug("failed to load web service class: " + className);
}
}
-
+
return clazz;
}
}