You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ro...@apache.org on 2008/02/22 19:10:42 UTC

svn commit: r630273 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/handler/ src/org/apache/axis2/jaxws/handler/factory/ src/org/apache/axis2/jaxws/handler/factory/impl/ src/org/apache/axis2/jaxws/handler/impl/ src/org/apac...

Author: rott
Date: Fri Feb 22 10:10:38 2008
New Revision: 630273

URL: http://svn.apache.org/viewvc?rev=630273&view=rev
Log:
new factories:  we need the ability to set pre-conditions and post-conditions for each handler.handleMessage invocation.  JSR109, for example, restricts what parts of a message can and cannot be modified by a handler.  This restriction is not enforced in pure axis2, but may be in other environments.  The most convenient means is to include a plugable "preInvoker" and "postInvoker" which users of Axis2 may leverage.

Added:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerPostInvoker.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerPreInvoker.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/HandlerPostInvokerFactory.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/HandlerPreInvokerFactory.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/impl/HandlerPostInvokerFactoryImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/impl/HandlerPreInvokerFactoryImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/impl/HandlerPostInvokerImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/impl/HandlerPreInvokerImpl.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerProtectionTests.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java?rev=630273&r1=630272&r2=630273&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java Fri Feb 22 10:10:38 2008
@@ -26,6 +26,8 @@
 import org.apache.axis2.jaxws.message.Protocol;
 import org.apache.axis2.jaxws.message.XMLFault;
 import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.handler.factory.HandlerPostInvokerFactory;
+import org.apache.axis2.jaxws.handler.factory.HandlerPreInvokerFactory;
 import org.apache.axis2.jaxws.message.util.XMLFaultUtils;
 import org.apache.axis2.jaxws.registry.FactoryRegistry;
 import org.apache.axis2.jaxws.utility.SAAJFactory;
@@ -49,6 +51,8 @@
 public class HandlerChainProcessor {
 
     private static final Log log = LogFactory.getLog(HandlerChainProcessor.class);
+    private HandlerPreInvoker handlerPreInvoker = null;
+    private HandlerPostInvoker handlerPostInvoker = null;
     
     public enum Direction {
         IN, OUT
@@ -329,7 +333,9 @@
             if (log.isDebugEnabled()) {
                 log.debug("Invoking handleMessage on: " + handler.getClass().getName()); 
             }
+            getPreInvoker().preInvoke(currentMC);
             boolean success = handler.handleMessage(currentMC);
+            getPostInvoker().postInvoke(currentMC);
             if (success) {
                 if (log.isDebugEnabled()) {
                     log.debug("handleMessage() returned true");
@@ -581,5 +587,22 @@
                 currentMC = logicalMC; //MessageContextFactory.createLogicalMessageContext(mepCtx.getMessageContext());
         }
     }
+    
+    private HandlerPreInvoker getPreInvoker() {
+    	if (handlerPreInvoker == null) {
+    		HandlerPreInvokerFactory preInvokerFactory = (HandlerPreInvokerFactory)FactoryRegistry.getFactory(HandlerPreInvokerFactory.class);
+    		handlerPreInvoker = (HandlerPreInvoker)preInvokerFactory.createHandlerPreInvoker();
+    	}
+    	return handlerPreInvoker;
+    }
+    
+    private HandlerPostInvoker getPostInvoker() {
+    	if (handlerPostInvoker == null) {
+    		HandlerPostInvokerFactory postInvokerFactory = (HandlerPostInvokerFactory)FactoryRegistry.getFactory(HandlerPostInvokerFactory.class);
+    		handlerPostInvoker = (HandlerPostInvoker)postInvokerFactory.createHandlerPostInvoker();
+    	}
+    	return handlerPostInvoker;
+    }
+    
 
 }

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerPostInvoker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerPostInvoker.java?rev=630273&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerPostInvoker.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerPostInvoker.java Fri Feb 22 10:10:38 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.handler;
+
+import javax.xml.ws.handler.MessageContext;
+
+/*
+ * HandlerPostInvoker - this is the interface returned by the
+ * HandlerPostInvokerFactory to be called just after each
+ * JAXWS handler.handleMessage invocation.
+ */
+public interface HandlerPostInvoker {
+
+	/**
+	 * postInvoke is called just prior to each JAXWS handler.handleMessage.
+	 * Implementations may need to check if we are inbound or outbound, and
+	 * client or server.  Implementations may validate the pre-conditions for handlers,
+	 * such as saving a SOAP message body, that were registered by HandlerPreInvoker.
+	 * 
+	 * @param mc
+	 */
+	public void postInvoke(MessageContext mc);
+	
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerPreInvoker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerPreInvoker.java?rev=630273&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerPreInvoker.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerPreInvoker.java Fri Feb 22 10:10:38 2008
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.handler;
+
+import javax.xml.ws.handler.MessageContext;
+
+/*
+ * HandlerPreInvoker - this is the interface returned by the
+ * HandlerPreInvokerFactory to be called just prior to each
+ * JAXWS handler.handleMessage invocation.
+ */
+public interface HandlerPreInvoker {
+
+	/**
+	 * preInvoke is called just prior to each JAXWS handler.handleMessage.
+	 * Implementations may need to check if we are inbound or outbound, and
+	 * client or server.  Implementations may set up pre-conditions for handlers,
+	 * such as saving a SOAP message body, to be checked by HandlerPostInvoker
+	 * for illegal modifications.
+	 * 
+	 * @param mc
+	 */
+	public void preInvoke(MessageContext mc);
+	
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/HandlerPostInvokerFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/HandlerPostInvokerFactory.java?rev=630273&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/HandlerPostInvokerFactory.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/HandlerPostInvokerFactory.java Fri Feb 22 10:10:38 2008
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.handler.factory;
+
+import org.apache.axis2.jaxws.handler.HandlerPostInvoker;
+
+/**
+ * HandlerPostInvokerFactory is used to create a HandlerPostInvoker
+ * implementation class that will be called just after each
+ * JAXWS handler.handleMessage invocation.
+ * @author rott
+ */
+public interface HandlerPostInvokerFactory {
+
+	public HandlerPostInvoker createHandlerPostInvoker();
+	
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/HandlerPreInvokerFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/HandlerPreInvokerFactory.java?rev=630273&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/HandlerPreInvokerFactory.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/HandlerPreInvokerFactory.java Fri Feb 22 10:10:38 2008
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.handler.factory;
+
+import org.apache.axis2.jaxws.handler.HandlerPreInvoker;
+
+/**
+ * HandlerPreInvokerFactory is used to create a HandlerPreInvoker
+ * implementation class that will be called just prior to each
+ * JAXWS handler.handleMessage invocation.
+ * @author rott
+ */
+public interface HandlerPreInvokerFactory {
+	
+	public HandlerPreInvoker createHandlerPreInvoker();
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/impl/HandlerPostInvokerFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/impl/HandlerPostInvokerFactoryImpl.java?rev=630273&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/impl/HandlerPostInvokerFactoryImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/impl/HandlerPostInvokerFactoryImpl.java Fri Feb 22 10:10:38 2008
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.handler.factory.impl;
+
+import org.apache.axis2.jaxws.handler.HandlerPostInvoker;
+import org.apache.axis2.jaxws.handler.factory.HandlerPostInvokerFactory;
+import org.apache.axis2.jaxws.handler.impl.HandlerPostInvokerImpl;
+
+/**
+ * HandlerPostInvokerFactoryImpl - the default implementation
+ * of HandlerPostInvokerFactory.  An instance of this class should
+ * be registered with the FactoryRegistry.
+ * 
+ * @author rott
+ */
+public class HandlerPostInvokerFactoryImpl implements HandlerPostInvokerFactory {
+
+	public HandlerPostInvoker createHandlerPostInvoker() {
+		return new HandlerPostInvokerImpl();
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/impl/HandlerPreInvokerFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/impl/HandlerPreInvokerFactoryImpl.java?rev=630273&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/impl/HandlerPreInvokerFactoryImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/factory/impl/HandlerPreInvokerFactoryImpl.java Fri Feb 22 10:10:38 2008
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.handler.factory.impl;
+
+import org.apache.axis2.jaxws.handler.HandlerPreInvoker;
+import org.apache.axis2.jaxws.handler.factory.HandlerPreInvokerFactory;
+import org.apache.axis2.jaxws.handler.impl.HandlerPreInvokerImpl;
+
+/**
+ * HandlerPreInvokerFactoryImpl - the default implementation
+ * of HandlerPreInvokerFactory.  An instance of this class should
+ * be registered with the FactoryRegistry.
+ * 
+ * @author rott
+ */
+public class HandlerPreInvokerFactoryImpl implements HandlerPreInvokerFactory {
+
+	public HandlerPreInvoker createHandlerPreInvoker() {
+		return new HandlerPreInvokerImpl();
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/impl/HandlerPostInvokerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/impl/HandlerPostInvokerImpl.java?rev=630273&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/impl/HandlerPostInvokerImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/impl/HandlerPostInvokerImpl.java Fri Feb 22 10:10:38 2008
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.handler.impl;
+
+import javax.xml.ws.handler.MessageContext;
+import org.apache.axis2.jaxws.handler.HandlerPostInvoker;
+
+public class HandlerPostInvokerImpl implements HandlerPostInvoker {
+
+	public void postInvoke(MessageContext mc) {
+		// this default implementation is a no-op
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/impl/HandlerPreInvokerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/impl/HandlerPreInvokerImpl.java?rev=630273&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/impl/HandlerPreInvokerImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/impl/HandlerPreInvokerImpl.java Fri Feb 22 10:10:38 2008
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.handler.impl;
+
+import javax.xml.ws.handler.MessageContext;
+import org.apache.axis2.jaxws.handler.HandlerPreInvoker;
+
+public class HandlerPreInvokerImpl implements HandlerPreInvoker {
+
+	public void preInvoke(MessageContext mc) {
+		// this default implementation is a no-op
+	}
+
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java?rev=630273&r1=630272&r2=630273&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java Fri Feb 22 10:10:38 2008
@@ -26,7 +26,11 @@
 import org.apache.axis2.jaxws.core.controller.InvocationControllerFactory;
 import org.apache.axis2.jaxws.core.controller.impl.InvocationControllerFactoryImpl;
 import org.apache.axis2.jaxws.handler.factory.HandlerInvokerFactory;
+import org.apache.axis2.jaxws.handler.factory.HandlerPostInvokerFactory;
+import org.apache.axis2.jaxws.handler.factory.HandlerPreInvokerFactory;
 import org.apache.axis2.jaxws.handler.factory.impl.HandlerInvokerFactoryImpl;
+import org.apache.axis2.jaxws.handler.factory.impl.HandlerPostInvokerFactoryImpl;
+import org.apache.axis2.jaxws.handler.factory.impl.HandlerPreInvokerFactoryImpl;
 import org.apache.axis2.jaxws.handler.lifecycle.factory.HandlerLifecycleManagerFactory;
 import org.apache.axis2.jaxws.message.databinding.impl.JAXBBlockFactoryImpl;
 import org.apache.axis2.jaxws.message.databinding.impl.OMBlockFactoryImpl;
@@ -112,6 +116,8 @@
         table.put(ExecutorFactory.class, new JAXWSExecutorFactory());
         table.put(ServiceInstanceFactory.class, new ServiceInstanceFactoryImpl());
         table.put(InvocationControllerFactory.class, new InvocationControllerFactoryImpl());
+        table.put(HandlerPreInvokerFactory.class, new HandlerPreInvokerFactoryImpl());
+        table.put(HandlerPostInvokerFactory.class, new HandlerPostInvokerFactoryImpl());
         
         // register the implementation responsible for both WebServiceContext 
         // injection and the updating of the WebServiceContext instances that

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?rev=630273&r1=630272&r2=630273&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java Fri Feb 22 10:10:38 2008
@@ -44,6 +44,7 @@
 import org.apache.axis2.jaxws.endpoint.BasicEndpointTests;
 import org.apache.axis2.jaxws.exception.ExceptionFactoryTests;
 import org.apache.axis2.jaxws.handler.HandlerChainProcessorTests;
+import org.apache.axis2.jaxws.handler.HandlerPrePostInvokerTests;
 import org.apache.axis2.jaxws.handler.context.CompositeMessageContextTests;
 import org.apache.axis2.jaxws.handler.context.LogicalMessageContextTests;
 import org.apache.axis2.jaxws.handler.context.SOAPMessageContextTests;
@@ -155,6 +156,7 @@
         // ------ Handler Tests ------
         suite.addTestSuite(LogicalMessageContextTests.class);
         suite.addTestSuite(SOAPMessageContextTests.class);
+        suite.addTestSuite(HandlerPrePostInvokerTests.class);
         suite.addTestSuite(CompositeMessageContextTests.class);
         suite.addTestSuite(HandlerChainProcessorTests.class);
         suite.addTestSuite(HandlerResolverTests.class);

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java?rev=630273&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java Fri Feb 22 10:10:38 2008
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.handler;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.handler.factory.HandlerPostInvokerFactory;
+import org.apache.axis2.jaxws.handler.factory.HandlerPreInvokerFactory;
+import org.apache.axis2.jaxws.message.Block;
+import org.apache.axis2.jaxws.message.Message;
+import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+
+/**
+ * HandlerPrePostInvokerTests verifies that the mechanisms for finding the implementation classes to 
+ * call before and after handler.handleMessage work, and that the calls are actually made.  Simple as that.
+ * 
+ * @author rott
+ *
+ */
+public class HandlerPrePostInvokerTests extends TestCase {
+
+	private MessageContext mc = null;
+	private boolean preInvokerCalled = false;
+	private boolean postInvokerCalled = false;
+	
+	private static final String soap11env = "http://schemas.xmlsoap.org/soap/envelope/";
+	
+    public static final String SOAP11_ENVELOPE = 
+        "<?xml version='1.0' encoding='utf-8'?>" + 
+        "<soapenv:Envelope xmlns:soapenv=\"" + soap11env + "\">" +
+        "<soapenv:Header />" + 
+        "<soapenv:Body>" +
+        "</soapenv:Body>" + 
+        "</soapenv:Envelope>";
+
+	@Override
+	protected void setUp() throws Exception {
+
+        // Create a SOAP 1.1 Message and MessageContext
+		// I just grabbed this code from the JAXWS MessageTests
+        MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.create(Protocol.soap11);
+        XMLStringBlockFactory f =
+                (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+        Block block = f.createFrom(SOAP11_ENVELOPE, null, null);
+        m.setBodyBlock(block);
+
+        mc = new MessageContext();
+        mc.setMessage(m);
+        mc.setMEPContext(new MEPContext(mc));
+	}
+
+	/**
+	 * make sure the defaults are as expected
+	 *
+	 */
+	public void testFactoryRegistry() {
+		HandlerPreInvokerFactory preFact = (HandlerPreInvokerFactory)FactoryRegistry.getFactory(HandlerPreInvokerFactory.class);
+		HandlerPostInvokerFactory postFact = (HandlerPostInvokerFactory)FactoryRegistry.getFactory(HandlerPostInvokerFactory.class);
+		HandlerPreInvoker preInvoker = preFact.createHandlerPreInvoker();
+		HandlerPostInvoker postInvoker = postFact.createHandlerPostInvoker();
+		assertTrue("preInvoker should be instanceof " + org.apache.axis2.jaxws.handler.impl.HandlerPreInvokerImpl.class.getCanonicalName(), preInvoker instanceof org.apache.axis2.jaxws.handler.impl.HandlerPreInvokerImpl);
+		assertTrue("postInvoker should be instanceof " + org.apache.axis2.jaxws.handler.impl.HandlerPostInvokerImpl.class.getCanonicalName(), postInvoker instanceof org.apache.axis2.jaxws.handler.impl.HandlerPostInvokerImpl);
+	}
+	
+	/**
+	 * make sure the registered factories are used, and the calls are made in the places we expect
+	 *
+	 */
+	public void testFactoryPrePost() {
+		
+		FactoryRegistry.setFactory(HandlerPreInvokerFactory.class, new HandlerPreInvokerFactoryImpl());
+		FactoryRegistry.setFactory(HandlerPostInvokerFactory.class, new HandlerPostInvokerFactoryImpl());
+		
+		ArrayList<Handler> handlers = new ArrayList<Handler>();
+		handlers.add(new SOAPHandler1());
+        HandlerChainProcessor processor =
+                new HandlerChainProcessor(handlers, Protocol.soap11);
+        boolean success = true;
+        try {
+            // server-side incoming request
+            success = processor.processChain(mc.getMEPContext(),
+                                    HandlerChainProcessor.Direction.IN,
+                                    HandlerChainProcessor.MEP.REQUEST,
+                                    true);
+        } catch (Exception e) {
+            assertNull(e);  // should not get exception
+        }
+        
+        assertTrue("processChain should have succeeded", success);
+        assertTrue("preInvoker should have been called", preInvokerCalled);
+        assertTrue("postInvoker should have been called", postInvokerCalled);
+
+	}
+	
+	/*****************************************
+	 * Classes needed for junit testcase     *
+	 *****************************************/
+	
+    private class SOAPHandler1 implements SOAPHandler<SOAPMessageContext> {
+
+        public Set getHeaders() {
+            return null;
+        }
+
+        public void close(javax.xml.ws.handler.MessageContext messagecontext) {
+        }
+
+        public boolean handleFault(SOAPMessageContext messagecontext) {
+            return true;
+        }
+
+        public boolean handleMessage(SOAPMessageContext messagecontext) {
+        	return true;
+        }
+
+    }
+    
+    private class HandlerPreInvokerFactoryImpl implements HandlerPreInvokerFactory {
+		public HandlerPreInvoker createHandlerPreInvoker() {
+			return new HandlerPreInvokerImpl();
+		}
+    }
+    
+    private class HandlerPostInvokerFactoryImpl implements HandlerPostInvokerFactory {
+    	public HandlerPostInvoker createHandlerPostInvoker() {
+    		return new HandlerPostInvokerImpl();
+    	}
+    }
+    
+    private class HandlerPreInvokerImpl implements HandlerPreInvoker {
+		public void preInvoke(javax.xml.ws.handler.MessageContext mc) {
+			preInvokerCalled = true;
+		}
+    }
+    
+    private class HandlerPostInvokerImpl implements HandlerPostInvoker {
+		public void postInvoke(javax.xml.ws.handler.MessageContext mc) {
+			postInvokerCalled = true;
+		}
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerProtectionTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerProtectionTests.java?rev=630273&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerProtectionTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerProtectionTests.java Fri Feb 22 10:10:38 2008
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.handler;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.handler.factory.HandlerPostInvokerFactory;
+import org.apache.axis2.jaxws.handler.factory.HandlerPreInvokerFactory;
+import org.apache.axis2.jaxws.message.Block;
+import org.apache.axis2.jaxws.message.Message;
+import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+
+public class HandlerProtectionTests extends TestCase {
+
+	private MessageContext mc = null;
+	
+	private static final String soap11env = "http://schemas.xmlsoap.org/soap/envelope/";
+	
+    public static final String SOAP11_ENVELOPE = 
+        "<?xml version='1.0' encoding='utf-8'?>" + 
+        "<soapenv:Envelope xmlns:soapenv=\"" + soap11env + "\">" +
+        "<soapenv:Header />" + 
+        "<soapenv:Body>" +
+        "</soapenv:Body>" + 
+        "</soapenv:Envelope>";
+
+	//@Override
+	protected void setUp() throws Exception {
+
+		try {
+			FactoryRegistry.setFactory(HandlerPreInvokerFactory.class, Class.forName("com.ibm.ws.webservices.engine.xmlsoap.saaj12.HandlerPreInvokerFactoryImpl").newInstance());
+			FactoryRegistry.setFactory(HandlerPostInvokerFactory.class, Class.forName("com.ibm.ws.webservices.engine.xmlsoap.saaj12.HandlerPostInvokerFactoryImpl").newInstance());
+			FactoryRegistry.setFactory(javax.xml.soap.SOAPFactory.class, Class.forName("com.ibm.ws.webservices.engine.xmlsoap.SOAPFactory").newInstance());
+			FactoryRegistry.setFactory(javax.xml.soap.SOAPConnectionFactory.class, Class.forName("com.ibm.ws.webservices.engine.soap.SOAPConnectionFactoryImpl").newInstance());
+			FactoryRegistry.setFactory(javax.xml.soap.SAAJMetaFactory.class, Class.forName("com.ibm.ws.webservices.engine.soap.SAAJMetaFactoryImpl").newInstance());
+			FactoryRegistry.setFactory(javax.xml.parsers.SAXParserFactory.class, Class.forName("com.ibm.xml.xlxp.api.was.WSSAXParserFactoryImpl").newInstance());
+		} catch (Throwable e) {
+			e.printStackTrace();
+		}
+        // Create a SOAP 1.1 Message and MessageContext
+		// I just grabbed this code from the JAXWS MessageTests
+        MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.create(Protocol.soap11);
+        XMLStringBlockFactory f =
+                (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+        Block block = f.createFrom(SOAP11_ENVELOPE, null, null);
+        m.setBodyBlock(block);
+
+        mc = new MessageContext();
+        mc.setMessage(m);
+        mc.setMEPContext(new MEPContext(mc));
+	}
+
+	public void _testProtectionViolation01() {
+		
+		ArrayList<Handler> handlers = new ArrayList<Handler>();
+		handlers.add(new SOAPHandler1());
+        HandlerChainProcessor processor =
+                new HandlerChainProcessor(handlers, Protocol.soap11);
+        Exception local_exception = null;
+        boolean success = true;
+        try {
+            // server-side incoming request
+            success = processor.processChain(mc.getMEPContext(),
+                                    HandlerChainProcessor.Direction.IN,
+                                    HandlerChainProcessor.MEP.REQUEST,
+                                    true);
+        } catch (Exception e) {
+            assertNull(e);  // should not get exception
+        }
+        
+        assertTrue("process chain should returned false due to illegal message modification by handler", !success);
+
+        // we want an exception due to JSR109 handler violation
+        //assertNotNull(local_exception);
+	}
+	
+    private class SOAPHandler1 implements SOAPHandler<SOAPMessageContext> {
+
+        public Set getHeaders() {
+            return null;
+        }
+
+        public void close(javax.xml.ws.handler.MessageContext messagecontext) {
+        }
+
+        public boolean handleFault(SOAPMessageContext messagecontext) {
+            return true;
+        }
+
+        public boolean handleMessage(SOAPMessageContext messagecontext) {
+        	try {
+        		// should cause a protection state violation
+        		SOAPMessage msg = messagecontext.getMessage();
+        		SOAPBody body = messagecontext.getMessage().getSOAPPart().getEnvelope().getBody();
+        		body.addNamespaceDeclaration("blarg", "blarg");
+
+        		return true;
+        	} catch (SOAPException e) {
+        		throw new RuntimeException(e);
+        	}
+        }
+
+    }
+}
+
+



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org