You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by he...@apache.org on 2004/12/16 11:57:52 UTC
svn commit: r122543 - in webservices/axis/trunk/java/dev/scratch/prototype2/src: java/org/apache/axis/client java/org/apache/axis/context java/org/apache/axis/description java/org/apache/axis/encoding java/org/apache/axis/engine java/org/apache/axis/impl/description java/org/apache/axis/impl/engine java/org/apache/axis/phaseresolver test/org/apache/axis/engine
Author: hemapani
Date: Thu Dec 16 02:57:50 2004
New Revision: 122543
URL: http://svn.apache.org/viewcvs?view=rev&rev=122543
Log:
fix the execution of handlers as discussed in the chat
Added:
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisTransport.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/PhasesInclude.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/Dispatcher.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/description/PhasesIncludeImpl.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/Echo.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/MessageWithServerTest.java
Removed:
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ServiceLocator.java
Modified:
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/client/Call.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/context/MessageContext.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisGlobal.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisService.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/encoding/SimpleTypeEncodingUtils.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/AxisEngine.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistry.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ExecutionChain.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ReceiverLocator.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/description/SimpleAxisServiceImpl.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/engine/EngineRegistryImpl.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EngineUtils.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/HandlerFaliureTest.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/SimpleAxisServerTest.java
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/client/Call.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/client/Call.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/client/Call.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/client/Call.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/client/Call.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/client/Call.java Thu Dec 16 02:57:50 2004
@@ -170,7 +170,6 @@
MessageContext msgContext;
try {
msgContext = new MessageContext(engine.getRegistry());
- msgContext.setServerSide(true);
//TODO Thanks to the URL we need nothng here .. may be need parsing code
// int level = 0;
// while(level != 2){
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/context/MessageContext.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/context/MessageContext.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/context/MessageContext.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/context/MessageContext.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/context/MessageContext.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/context/MessageContext.java Thu Dec 16 02:57:50 2004
@@ -16,17 +16,19 @@
package org.apache.axis.context;
+import java.util.HashMap;
+
import org.apache.axis.description.AxisOperation;
import org.apache.axis.description.AxisService;
+import org.apache.axis.description.AxisTransport;
import org.apache.axis.engine.AxisFault;
import org.apache.axis.engine.Constants;
import org.apache.axis.engine.EndpointReferance;
import org.apache.axis.engine.EngineRegistry;
+import org.apache.axis.engine.ExecutionChain;
import org.apache.axis.impl.context.SimpleSessionContext;
import org.apache.axis.om.SOAPEnvelope;
-import java.util.HashMap;
-
/**
* The palce where all the service specific states are kept.
* All the Global states kept in the <code>EngineRegistry</code> and all the
@@ -50,6 +52,9 @@
private EndpointReferance relatesTo;
private EndpointReferance replyTo;
private EndpointReferance faultTo;
+
+ private ExecutionChain chain;
+ private AxisTransport transport;
//there is a no use cas found to set those proprties
//so declare them final
@@ -70,6 +75,7 @@
this.globalContext = new GlobalContext(er);
this.sessionContext = new SimpleSessionContext();
properties = new HashMap();
+ chain = new ExecutionChain();
}
@@ -320,6 +326,36 @@
*/
public void setMessageStyle(int i) {
messageStyle = i;
+ }
+
+
+ /**
+ * @param chain
+ */
+ public ExecutionChain getExecutionChain() {
+ return this.chain;
+ }
+
+ /**
+ * @param chain
+ */
+ public void setExecutionChain(ExecutionChain chain) {
+ this.chain = chain;
+ }
+
+
+ /**
+ * @return
+ */
+ public AxisTransport getTransport() {
+ return transport;
+ }
+
+ /**
+ * @param transport
+ */
+ public void setTransport(AxisTransport transport) {
+ this.transport = transport;
}
}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisGlobal.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisGlobal.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisGlobal.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisGlobal.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisGlobal.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisGlobal.java Thu Dec 16 02:57:50 2004
@@ -15,16 +15,22 @@
*/
package org.apache.axis.description;
+import java.util.ArrayList;
+
+import org.apache.axis.engine.AxisFault;
import org.apache.axis.impl.description.ParameterIncludeImpl;
+import org.apache.axis.impl.description.PhasesIncludeImpl;
/**
* @author Srinath Perera(hemapani@opensource.lk)
*/
-public class AxisGlobal implements ParameterInclude {
+public class AxisGlobal implements ParameterInclude,PhasesInclude {
protected ParameterInclude paramInclude;
+ protected PhasesInclude phasesInclude;
public AxisGlobal(){
paramInclude = new ParameterIncludeImpl();
+ phasesInclude = new PhasesIncludeImpl();
}
public Parameter getParameter(String name) {
@@ -33,6 +39,24 @@
public void addParameter(Parameter param) {
paramInclude.addParameter(param);
+ }
+
+ /**
+ * @param flow
+ * @return
+ * @throws AxisFault
+ */
+ public ArrayList getPhases(int flow) throws AxisFault {
+ return phasesInclude.getPhases(flow);
+ }
+
+ /**
+ * @param phases
+ * @param flow
+ * @throws AxisFault
+ */
+ public void setPhases(ArrayList phases, int flow) throws AxisFault {
+ phasesInclude.setPhases(phases, flow);
}
}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisService.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisService.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisService.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisService.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisService.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisService.java Thu Dec 16 02:57:50 2004
@@ -20,7 +20,6 @@
import javax.swing.text.Style;
import javax.xml.namespace.QName;
-import org.apache.axis.engine.ExecutionChain;
import org.apache.axis.engine.Provider;
import org.apache.wsdl.WSDLService;
@@ -28,21 +27,10 @@
* @author chathura@opensource.lk
*
*/
-public interface AxisService extends WSDLService,ParameterInclude,FlowInclude {
+public interface AxisService extends WSDLService,ParameterInclude,FlowInclude,PhasesInclude {
//modules
public void addModule(QName moduleref);
public Collection getModules();
-
-
- public void setExecutableInChain(ExecutionChain executableInChain);
- public ExecutionChain getExecutableInChain();
-
- public void setExecutableOutChain(ExecutionChain executableOutChain);
- public ExecutionChain getExecutableOutChain();
-
- public void setExecutableFaultChain(ExecutionChain executableFaultChain);
- public ExecutionChain getExecutableFaultChain();
-
public AxisOperation getOperation(QName operationName);
public void addOperation(AxisOperation operationName);
Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisTransport.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisTransport.java?view=auto&rev=122543
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisTransport.java Thu Dec 16 02:57:50 2004
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed 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.axis.description;
+
+import java.util.ArrayList;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.impl.description.ParameterIncludeImpl;
+import org.apache.axis.impl.description.PhasesIncludeImpl;
+
+/**
+ * @author Srinath Perera(hemapani@opensource.lk)
+ */
+public class AxisTransport implements ParameterInclude,PhasesInclude {
+ protected ParameterInclude paramInclude;
+ protected PhasesInclude phasesInclude;
+ protected QName name;
+
+ public AxisTransport(){
+ paramInclude = new ParameterIncludeImpl();
+ phasesInclude = new PhasesIncludeImpl();
+ }
+
+ public Parameter getParameter(String name) {
+ return paramInclude.getParameter(name);
+ }
+
+ public void addParameter(Parameter param) {
+ paramInclude.addParameter(param);
+ }
+
+ /**
+ * @param flow
+ * @return
+ * @throws AxisFault
+ */
+ public ArrayList getPhases(int flow) throws AxisFault {
+ return phasesInclude.getPhases(flow);
+ }
+
+ /**
+ * @param phases
+ * @param flow
+ * @throws AxisFault
+ */
+ public void setPhases(ArrayList phases, int flow) throws AxisFault {
+ phasesInclude.setPhases(phases, flow);
+ }
+
+ /**
+ * @return
+ */
+ public QName getName() {
+ return name;
+ }
+
+ /**
+ * @param name
+ */
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+}
Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/PhasesInclude.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/PhasesInclude.java?view=auto&rev=122543
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/PhasesInclude.java Thu Dec 16 02:57:50 2004
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed 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.axis.description;
+
+import java.util.ArrayList;
+
+import org.apache.axis.engine.AxisFault;
+
+
+public interface PhasesInclude {
+ /**
+ * When the Phases are resolved they are added to the EngineRegistry as phases at deploy time.
+ * At the runtime they are used to create the ExecutionChain at the runtime whic resides in the
+ * MessageContext.
+ * @param flow
+ * @return
+ */
+
+ public ArrayList getPhases(int flow)throws AxisFault;
+ public void setPhases(ArrayList phases,int flow)throws AxisFault;
+}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/encoding/SimpleTypeEncodingUtils.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/encoding/SimpleTypeEncodingUtils.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/encoding/SimpleTypeEncodingUtils.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/encoding/SimpleTypeEncodingUtils.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/encoding/SimpleTypeEncodingUtils.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/encoding/SimpleTypeEncodingUtils.java Thu Dec 16 02:57:50 2004
@@ -15,9 +15,11 @@
*/
package org.apache.axis.encoding;
+import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
import org.apache.axis.engine.AxisFault;
@@ -53,6 +55,16 @@
throw new AxisFault("Number format exception value is null");
}
return Integer.parseInt(val);
-
}
+ public static void serialize(XMLStreamWriter out,QName elementName,String value)throws AxisFault{
+ try {
+ out.writeStartElement(elementName.getNamespaceURI(),elementName.getLocalPart());
+ out.writeCharacters(value);
+ out.writeEndElement();
+ } catch (XMLStreamException e) {
+ throw AxisFault.makeFault(e);
+ }
+
+ }
+
}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/AxisEngine.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/AxisEngine.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/AxisEngine.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/AxisEngine.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/AxisEngine.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/AxisEngine.java Thu Dec 16 02:57:50 2004
@@ -17,7 +17,9 @@
package org.apache.axis.engine;
import org.apache.axis.context.MessageContext;
+import org.apache.axis.description.AxisGlobal;
import org.apache.axis.description.AxisService;
+import org.apache.axis.description.AxisTransport;
import org.apache.axis.impl.handlers.OpNameFinder;
import org.apache.axis.om.OMFactory;
import org.apache.axis.om.SOAPEnvelope;
@@ -39,69 +41,106 @@
this.registry = registry;
}
- public void send(MessageContext mc) throws AxisFault {
- AxisService service = mc.getService();
- try {
- //what are we suppose to do in the client side
- //how the client side handlers are deployed ??? this is a hack and no client side handlers
- if (mc.isServerSide() || service != null) {
- ExecutionChain exeChain = service.getExecutableOutChain();
- exeChain.invoke(mc);
- }
- sendTheMessage(mc);
- } catch (AxisFault e) {
- handleFault(mc, e, service);
- }
+ public void send(MessageContext context) throws AxisFault {
+ executeOutFlow(context,EngineRegistry.OUTFLOW);
log.info("end the send()");
}
- public void receive(MessageContext mc) throws AxisFault {
- AxisService service = null;
+ public void receive(MessageContext context) throws AxisFault {
try {
- if (mc.isServerSide()) {
- service = ServiceLocator.locateService(mc);
- mc.setService(service);
+ context.setExecutionChain(new ExecutionChain());
+ ExecutionChain chain = context.getExecutionChain();
+
+ // Receiving is always a matter of running the transport handlers first
+ AxisTransport transport = context.getTransport();
+ if (transport != null) {
+ chain.addPhases(transport.getPhases(EngineRegistry.INFLOW));
}
-
- if (service != null) {
- ExecutionChain exeChain = service.getExecutableInChain();
- exeChain.invoke(mc);
- }
- if (mc.isServerSide()) {
- OpNameFinder finder = new OpNameFinder();
- finder.invoke(mc);
- Receiver receiver = ReceiverLocator.locateReceiver(mc);
- receiver.invoke(mc);
+ //Add the phases that are are at Global scope
+ AxisGlobal global = context.getGlobalContext().getRegistry().getGlobal();
+ chain.addPhases(global.getPhases(EngineRegistry.INFLOW));
+
+ //create a Dispatch Phase and add it to the Execution Chain
+ Dispatcher dispatcher = new Dispatcher();
+ Phase dispatchPhase = new Phase("DispatchPhase");
+ dispatchPhase.addHandler(dispatcher);
+ chain.addPhase(dispatchPhase);
+
+ //Start rolling the Service Handlers will,be added by the Dispatcher
+ chain.invoke(context);
+ //TODO should we done inside the Dispatcher !!
+ if(context.isServerSide()){
+ OpNameFinder opNameFinder = new OpNameFinder();
+ opNameFinder.invoke(context);
+ Receiver reciver = ReceiverLocator.locateReceiver(context);
+ reciver.invoke(context);
}
} catch (AxisFault e) {
- handleFault(mc, e, service);
+ handleFault(context, e);
}
- log.info("end the receive()");
}
private void sendTheMessage(MessageContext msgCtx) throws AxisFault {
- TransportSender ts = TransportSenderLocator.locateTransPortSender(msgCtx);
+ TransportSender ts =
+ TransportSenderLocator.locateTransPortSender(msgCtx);
ts.invoke(msgCtx);
}
- private void handleFault(MessageContext mc,Exception e,AxisService service) throws AxisFault{
- if(mc.isProcessingFault()){
+ private void handleFault(
+ MessageContext context,
+ AxisFault e)
+ throws AxisFault {
+ boolean serverSide = context.isServerSide();
+ if(serverSide && !context.isProcessingFault()){
+ AxisService service = context.getService();
+ context.setProcessingFault(true);
+ SOAPEnvelope envelope =
+ OMFactory.newInstance().getDefaultEnvelope();
+ //TODO do we need to set old Headers back?
+ envelope.getBody().addFault(e);
+ context.setEnvelope(envelope);
+ sendTheMessage(context);
+
+ executeOutFlow(context,EngineRegistry.FAULTFLOW);
+ }else if (!serverSide){
+ throw e;
+ }else{
//TODO log and exit
log.error("Error in fault flow", e);
- } else {
- log.debug("receive failed", e);
- mc.setProcessingFault(true);
+ }
+ }
+
+
+ private void executeOutFlow(MessageContext context,int flow) throws AxisFault{
+ try {
+ AxisService service = context.getService();
if (service != null) {
- ExecutionChain faultExeChain = service.getExecutableFaultChain();
- faultExeChain.invoke(mc);
+ context.setExecutionChain(new ExecutionChain());
+ ExecutionChain chain = context.getExecutionChain();
+ //what are we suppose to do in the client side
+ //how the client side handlers are deployed ??? this is a hack and no client side handlers
+ chain.addPhases(service.getPhases(flow));
+
+ //Add the phases that are are at Global scope
+ AxisGlobal global = context.getGlobalContext().getRegistry().getGlobal();
+ chain.addPhases(global.getPhases(flow));
+
+ // Receiving is always a matter of running the transport handlers first
+ AxisTransport transport = context.getTransport();
+ if (transport != null) {
+ chain.addPhases(transport.getPhases(flow));
+ }
+ chain.invoke(context);
+ }else{
+ if(context.isServerSide() && !context.isInfaultFlow()){
+ throw new AxisFault("in Server Side there must be service object");
+ }
+
}
- SOAPEnvelope envelope = OMFactory.newInstance().getDefaultEnvelope();
- //TODO do we need to set old Headers back?
- envelope.getBody().addFault(e);
- mc.setEnvelope(envelope);
- sendTheMessage(mc);
+ sendTheMessage(context);
+ } catch (AxisFault error) {
+ handleFault(context, error);
}
}
-
/**
* @return Returns the registry.
*/
Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/Dispatcher.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/Dispatcher.java?view=auto&rev=122543
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/Dispatcher.java Thu Dec 16 02:57:50 2004
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.axis.engine;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.description.AxisService;
+import org.apache.axis.impl.handlers.AbstractHandler;
+
+public class Dispatcher extends AbstractHandler implements Handler {
+ public void invoke(MessageContext msgctx) throws AxisFault{
+ if(msgctx.isServerSide()){
+ String uri = null;
+ String filePart = (String) msgctx.getProperty(MessageContext.REQUEST_URL);
+ String soapAction = (String) msgctx.getProperty(MessageContext.SOAP_ACTION);
+
+ if (filePart.startsWith("axis/services/")) {
+ String servicePart = filePart.substring(14);
+ int separator = servicePart.indexOf('/');
+ if (separator > -1) {
+ uri = servicePart.substring(0, separator);
+ } else {
+ uri = servicePart;
+ }
+ }
+
+ QName serviceName = null;
+ if (uri != null) {
+ int index = uri.indexOf('?');
+ if (index > -1) {
+ //TODO get the opeartion name from URI as well
+ serviceName = new QName(uri);
+ } else {
+ serviceName = new QName(uri);
+ }
+ } else {
+ if (soapAction != null) {
+ serviceName = new QName(soapAction);
+ }
+ }
+ if (serviceName != null) {
+ AxisService service = msgctx.getGlobalContext().getRegistry().getService(serviceName);
+ if (service != null) {
+ msgctx.setService(service);
+ //let add the Handlers
+ ExecutionChain chain = msgctx.getExecutionChain();
+ chain.addPhases(service.getPhases(EngineRegistry.INFLOW));
+ } else {
+ throw new AxisFault("Service Not found");
+ }
+ }else{
+ throw new AxisFault("Both the URI and SOAP_ACTION Is Null");
+ }
+ }else{
+ //TODO client side service Dispatch ,, What this really mean?
+ }
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistry.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistry.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistry.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistry.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistry.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistry.java Thu Dec 16 02:57:50 2004
@@ -22,6 +22,7 @@
import org.apache.axis.description.AxisGlobal;
import org.apache.axis.description.AxisModule;
import org.apache.axis.description.AxisService;
+import org.apache.axis.description.AxisTransport;
/**
* The palce where all the Globel states of Axis is kept.
@@ -31,6 +32,11 @@
*/
public interface EngineRegistry {
+ public static final int INFLOW = 10003;
+ public static final int OUTFLOW = 10004;
+ public static final int FAULTFLOW = 10005;
+
+
public AxisGlobal getGlobal()throws AxisFault;
public AxisService getService(QName name)throws AxisFault;
@@ -39,4 +45,7 @@
public AxisModule getModule(QName name)throws AxisFault;
public void addMdoule(AxisModule module)throws AxisFault;
+
+ public AxisTransport getTransport(QName name) throws AxisFault;
+ public void addTransport(AxisTransport transport) throws AxisFault;
}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ExecutionChain.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ExecutionChain.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ExecutionChain.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ExecutionChain.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ExecutionChain.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ExecutionChain.java Thu Dec 16 02:57:50 2004
@@ -36,6 +36,15 @@
phases.put(phase.getPhaseName(), phase);
executionList.add(phase);
}
+
+
+ public void addPhases(ArrayList phases){
+ if (phases != null && !phases.isEmpty()) {
+ for (int i = 0; i < phases.size(); i++) {
+ addPhase((Phase) phases.get(i));
+ }
+ }
+ }
public void addHandlerDirectly(Handler directHandler, int index) {
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ReceiverLocator.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ReceiverLocator.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ReceiverLocator.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ReceiverLocator.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ReceiverLocator.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ReceiverLocator.java Thu Dec 16 02:57:50 2004
@@ -21,7 +21,7 @@
public class ReceiverLocator {
public static Receiver locateReceiver(MessageContext msgCtx) throws AxisFault {
-
+ //TODO
//File wsdlFile = msgCtx.getService().getParameter("wsdlFile");
//parse the WSDL find the patterns
//create a receiver
Deleted: /webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ServiceLocator.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/ServiceLocator.java?view=auto&rev=122542
==============================================================================
Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/description/PhasesIncludeImpl.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/description/PhasesIncludeImpl.java?view=auto&rev=122543
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/description/PhasesIncludeImpl.java Thu Dec 16 02:57:50 2004
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed 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.axis.impl.description;
+
+import java.util.ArrayList;
+
+import org.apache.axis.description.PhasesInclude;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.engine.EngineRegistry;
+
+/**
+ * Util class to implements the Phases include with delegation
+ */
+public class PhasesIncludeImpl implements PhasesInclude{
+ private ArrayList inflow;
+ private ArrayList outflow;
+ private ArrayList faultflow;
+
+ public ArrayList getPhases(int flow) throws AxisFault {
+ if(flow == EngineRegistry.INFLOW){
+ return inflow;
+ }else if(flow == EngineRegistry.OUTFLOW){
+ return outflow;
+ }else if(flow == EngineRegistry.FAULTFLOW){
+ return faultflow;
+ }else{
+ throw new AxisFault("Unknown type flow ");
+ }
+
+ }
+
+ public void setPhases(ArrayList phases, int flow) throws AxisFault {
+ if(flow == EngineRegistry.INFLOW){
+ inflow = phases;
+ }else if(flow == EngineRegistry.OUTFLOW){
+ outflow= phases;
+ }else if(flow == EngineRegistry.FAULTFLOW){
+ faultflow = phases;
+ }else{
+ throw new AxisFault("Unknown type flow ");
+ }
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/description/SimpleAxisServiceImpl.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/description/SimpleAxisServiceImpl.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/description/SimpleAxisServiceImpl.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/description/SimpleAxisServiceImpl.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/description/SimpleAxisServiceImpl.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/description/SimpleAxisServiceImpl.java Thu Dec 16 02:57:50 2004
@@ -15,6 +15,7 @@
*/
package org.apache.axis.impl.description;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Vector;
@@ -28,6 +29,8 @@
import org.apache.axis.description.FlowInclude;
import org.apache.axis.description.Parameter;
import org.apache.axis.description.ParameterInclude;
+import org.apache.axis.description.PhasesInclude;
+import org.apache.axis.engine.AxisFault;
import org.apache.axis.engine.ExecutionChain;
import org.apache.axis.engine.Provider;
import org.apache.wsdl.WSDLEndpoint;
@@ -39,6 +42,7 @@
* @author Srinath Perera(hemapani@opensource.lk)
*/
public class SimpleAxisServiceImpl implements AxisService {
+ protected PhasesInclude phaseInclude;
protected WSDLService wsdlService;
protected FlowInclude flowInclude;
protected String contextPath;
@@ -63,6 +67,7 @@
wsdlService.setName(name);
flowInclude = new FlowIncludeImpl();
parameters = new ParameterIncludeImpl();
+ phaseInclude = new PhasesIncludeImpl();
}
/**
@@ -244,27 +249,6 @@
}
/**
- * @param chain
- */
- public void setExecutableFaultChain(ExecutionChain chain) {
- executableFaultChain = chain;
- }
-
- /**
- * @param chain
- */
- public void setExecutableInChain(ExecutionChain chain) {
- executableInChain = chain;
- }
-
- /**
- * @param chain
- */
- public void setExecutableOutChain(ExecutionChain chain) {
- executableOutChain = chain;
- }
-
- /**
* @param style
*/
public void setStyle(Style style) {
@@ -333,6 +317,24 @@
public void setComponentProperty(Object key, Object obj) {
wsdlService.setComponentProperty(key,obj);
+ }
+
+ /**
+ * @param flow
+ * @return
+ * @throws AxisFault
+ */
+ public ArrayList getPhases(int flow) throws AxisFault {
+ return phaseInclude.getPhases(flow);
+ }
+
+ /**
+ * @param phases
+ * @param flow
+ * @throws AxisFault
+ */
+ public void setPhases(ArrayList phases, int flow) throws AxisFault {
+ phaseInclude.setPhases(phases, flow);
}
}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/engine/EngineRegistryImpl.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/engine/EngineRegistryImpl.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/engine/EngineRegistryImpl.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/engine/EngineRegistryImpl.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/engine/EngineRegistryImpl.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/engine/EngineRegistryImpl.java Thu Dec 16 02:57:50 2004
@@ -22,12 +22,14 @@
import org.apache.axis.description.AxisGlobal;
import org.apache.axis.description.AxisModule;
import org.apache.axis.description.AxisService;
+import org.apache.axis.description.AxisTransport;
import org.apache.axis.engine.AxisFault;
import org.apache.axis.engine.EngineRegistry;
public class EngineRegistryImpl implements EngineRegistry{
private HashMap modules = new HashMap();
private HashMap services = new HashMap();
+ private HashMap transports = new HashMap();
private AxisGlobal global;
public EngineRegistryImpl(AxisGlobal global){
@@ -57,5 +59,12 @@
public synchronized void removeService(QName name) throws AxisFault {
services.remove(name);
}
-
+
+ public AxisTransport getTransport(QName name) throws AxisFault {
+ return (AxisTransport)transports.get(name);
+ }
+
+ public synchronized void addTransport(AxisTransport transport) throws AxisFault {
+ transports.put(transport.getName(),transport);
+ }
}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java Thu Dec 16 02:57:50 2004
@@ -4,12 +4,14 @@
import org.apache.axis.deployment.metadata.ServerMetaData;
import org.apache.axis.description.AxisService;
import org.apache.axis.description.HandlerMetaData;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.engine.EngineRegistry;
import org.apache.axis.engine.ExecutionChain;
import org.apache.axis.engine.Phase;
-import org.apache.axis.phaseresolver.PhaseException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.ArrayList;
import java.util.Vector;
/**
@@ -120,54 +122,58 @@
* @throws org.apache.axis.phaseresolver.PhaseException
*/
public void getOrderdHandlers(int chainType) throws PhaseException {
- OrderdPhases();
- Vector tempHander = new Vector();
- HandlerMetaData[] handlers;
-
- switch (chainType) {
- case 1 : {
- ExecutionChain inChain = new ExecutionChain();// service.getExecutableInChain();
- for (int i = 0; i < phaseholder.size(); i++) {
- PhaseMetaData phase = (PhaseMetaData) phaseholder.elementAt(i);
- Phase axisPhase = new Phase(phase.getName());
- handlers = phase.getOrderedHandlers();
- for (int j = 0; j < handlers.length; j++) {
- axisPhase.addHandler(handlers[j].getHandler());
+ try {
+ OrderdPhases();
+ Vector tempHander = new Vector();
+ HandlerMetaData[] handlers;
+
+ switch (chainType) {
+ case 1 : {
+ ArrayList inChain = new ArrayList();// service.getExecutableInChain();
+ for (int i = 0; i < phaseholder.size(); i++) {
+ PhaseMetaData phase = (PhaseMetaData) phaseholder.elementAt(i);
+ Phase axisPhase = new Phase(phase.getName());
+ handlers = phase.getOrderedHandlers();
+ for (int j = 0; j < handlers.length; j++) {
+ axisPhase.addHandler(handlers[j].getHandler());
+ }
+ inChain.add(axisPhase);
}
- inChain.addPhase(axisPhase);
+ service.setPhases(inChain,EngineRegistry.INFLOW);
+ break;
}
- service.setExecutableInChain(inChain);
- break;
- }
- case 2 : {
- ExecutionChain outChain =new ExecutionChain();// service.getExecutableOutChain();
- for (int i = 0; i < phaseholder.size(); i++) {
- PhaseMetaData phase = (PhaseMetaData) phaseholder.elementAt(i);
- Phase axisPhase = new Phase(phase.getName());
- handlers = phase.getOrderedHandlers();
- for (int j = 0; j < handlers.length; j++) {
- axisPhase.addHandler(handlers[j].getHandler());
+ case 2 : {
+ ArrayList outChain =new ArrayList();// service.getExecutableOutChain();
+ for (int i = 0; i < phaseholder.size(); i++) {
+ PhaseMetaData phase = (PhaseMetaData) phaseholder.elementAt(i);
+ Phase axisPhase = new Phase(phase.getName());
+ handlers = phase.getOrderedHandlers();
+ for (int j = 0; j < handlers.length; j++) {
+ axisPhase.addHandler(handlers[j].getHandler());
+ }
+ outChain.add(axisPhase);
}
- outChain.addPhase(axisPhase);
+ service.setPhases(outChain,EngineRegistry.OUTFLOW);
+ break;
}
- service.setExecutableOutChain(outChain);
- break;
- }
- case 3 : {
- ExecutionChain faultChain = new ExecutionChain();//service.getExecutableFaultChain();
- for (int i = 0; i < phaseholder.size(); i++) {
- PhaseMetaData phase = (PhaseMetaData) phaseholder.elementAt(i);
- Phase axisPhase = new Phase(phase.getName());
- handlers = phase.getOrderedHandlers();
- for (int j = 0; j < handlers.length; j++) {
- axisPhase.addHandler(handlers[j].getHandler());
+ case 3 : {
+ ArrayList faultChain = new ArrayList();//service.getExecutableFaultChain();
+ for (int i = 0; i < phaseholder.size(); i++) {
+ PhaseMetaData phase = (PhaseMetaData) phaseholder.elementAt(i);
+ Phase axisPhase = new Phase(phase.getName());
+ handlers = phase.getOrderedHandlers();
+ for (int j = 0; j < handlers.length; j++) {
+ axisPhase.addHandler(handlers[j].getHandler());
+ }
+ faultChain.add(axisPhase);
}
- faultChain.addPhase(axisPhase);
+ service.setPhases(faultChain,EngineRegistry.FAULTFLOW);
+ break;
}
- service.setExecutableFaultChain(faultChain);
- break;
}
- }
+ } catch (AxisFault e) {
+ throw new PhaseException(e);
+ }
}
}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java Thu Dec 16 02:57:50 2004
@@ -19,8 +19,6 @@
import java.net.URL;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
import org.apache.axis.AbstractTestCase;
import org.apache.axis.client.Call;
@@ -33,7 +31,6 @@
import org.apache.axis.impl.description.SimpleAxisServiceImpl;
import org.apache.axis.impl.providers.RawXMLProvider;
import org.apache.axis.impl.transport.http.SimpleHTTPReceiver;
-import org.apache.axis.impl.llom.serialize.SimpleOMSerializer;
import org.apache.axis.om.OMElement;
import org.apache.axis.om.OMFactory;
import org.apache.axis.om.OMNamespace;
@@ -63,7 +60,7 @@
engineRegistry = EngineUtils.createMockRegistry(serviceName,operationName,transportName);
AxisService service = new SimpleAxisServiceImpl(serviceName);
service.setClassLoader(Thread.currentThread().getContextClassLoader());
- Parameter classParam = new ParameterImpl("className",EchoXML.class.getName());
+ Parameter classParam = new ParameterImpl("className",Echo.class.getName());
service.addParameter(classParam);
service.setProvider(new RawXMLProvider());
AxisOperation operation = new SimpleAxisOperationImpl(operationName);
Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/Echo.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/Echo.java?view=auto&rev=122543
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/Echo.java Thu Dec 16 02:57:50 2004
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed 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.axis.engine;
+
+import org.apache.axis.om.OMElement;
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+
+public class Echo{
+ public Echo(){}
+
+ public OMElement echoOMElement(OMElement omEle){
+ omEle.setLocalName(omEle.getLocalName()+"Response");
+ return omEle;
+ }
+
+ public String echoString(String in){
+ return in;
+ }
+
+ public int echoInt(int in){
+ return in;
+ }
+}
\ No newline at end of file
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java Thu Dec 16 02:57:50 2004
@@ -19,9 +19,6 @@
import java.net.URL;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.stream.XMLOutputFactory;
import org.apache.axis.AbstractTestCase;
import org.apache.axis.client.Call;
@@ -35,7 +32,6 @@
import org.apache.axis.impl.description.SimpleAxisServiceImpl;
import org.apache.axis.impl.providers.RawXMLProvider;
import org.apache.axis.impl.transport.http.SimpleHTTPReceiver;
-import org.apache.axis.impl.llom.serialize.SimpleOMSerializer;
import org.apache.axis.om.OMElement;
import org.apache.axis.om.OMFactory;
import org.apache.axis.om.OMNamespace;
@@ -66,7 +62,7 @@
AxisService service = new SimpleAxisServiceImpl(serviceName);
service.setClassLoader(Thread.currentThread().getContextClassLoader());
- Parameter classParam = new ParameterImpl("className",EchoXML.class.getName());
+ Parameter classParam = new ParameterImpl("className",Echo.class.getName());
service.addParameter(classParam);
service.setProvider(new RawXMLProvider());
AxisOperation operation = new SimpleAxisOperationImpl(operationName);
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java Thu Dec 16 02:57:50 2004
@@ -16,72 +16,130 @@
package org.apache.axis.engine;
//todo
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.net.Socket;
+import java.net.URL;
import javax.xml.namespace.QName;
import org.apache.axis.AbstractTestCase;
+import org.apache.axis.client.Call;
+import org.apache.axis.client.CallBack;
import org.apache.axis.context.MessageContext;
+import org.apache.axis.description.AxisGlobal;
+import org.apache.axis.description.AxisOperation;
+import org.apache.axis.description.AxisService;
+import org.apache.axis.description.Parameter;
+import org.apache.axis.impl.description.ParameterImpl;
+import org.apache.axis.impl.description.SimpleAxisOperationImpl;
+import org.apache.axis.impl.description.SimpleAxisServiceImpl;
+import org.apache.axis.impl.providers.SimpleJavaProvider;
import org.apache.axis.impl.transport.http.SimpleHTTPReceiver;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMNamespace;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class EchoTest extends AbstractTestCase{
private Log log = LogFactory.getLog(getClass());
- private QName serviceName = new QName("","EchoService");
- private QName operationName = new QName("http://ws.apache.org/axis2","echoVoid");
- private QName transportName = new QName("","NullTransport");
+ private QName serviceName = new QName("","EchoXMLService");
+ private QName operationName1 = new QName("http://localhost/my","echoInt");
+ private QName operationName2 = new QName("http://localhost/my","echoString");
+ private QName transportName = new QName("http://localhost/my","NullTransport");
private EngineRegistry engineRegistry;
private MessageContext mc;
private Thread thisThread = null;
private SimpleHTTPReceiver sas;
+
+ public EchoTest(){
+ super(EchoTest.class.getName());
+ }
public EchoTest(String testName) {
super(testName);
}
protected void setUp() throws Exception {
- engineRegistry = EngineUtils.createMockRegistry(serviceName,operationName,transportName);
+ AxisGlobal global = new AxisGlobal();
+ engineRegistry = new org.apache.axis.impl.engine.EngineRegistryImpl(global);
+
+ AxisService service = new SimpleAxisServiceImpl(serviceName);
+ service.setClassLoader(Thread.currentThread().getContextClassLoader());
+ Parameter classParam = new ParameterImpl("className",Echo.class.getName());
+ service.addParameter(classParam);
+ service.setProvider(new SimpleJavaProvider());
+
+ AxisOperation operation1 = new SimpleAxisOperationImpl(operationName1);
+ service.addOperation(operation1);
+
+ AxisOperation operation2 = new SimpleAxisOperationImpl(operationName2);
+ service.addOperation(operation2);
+
+ EngineUtils.createExecutionChains(service);
+ engineRegistry.addService(service);
+
sas = EngineUtils.startServer(engineRegistry);
}
protected void tearDown() throws Exception {
- sas.stop();
- Thread.sleep(1000);
+ sas.stop();
+ Thread.sleep(1000);
}
- public void testEchoStringServer() throws Exception{
- File file = getTestResourceFile("soap/soapmessage.txt");
- FileInputStream in = new FileInputStream(file);
-
- Socket socket = new Socket("127.0.0.1",EngineUtils.TESTING_PORT);
- OutputStream out = socket.getOutputStream();
- byte[] buf = new byte[1024];
- int index = -1;
- while((index = in.read(buf)) > 0){
- out.write(buf,0,index);
- }
-
-
- InputStream respose = socket.getInputStream();
- Reader rReader = new InputStreamReader(respose);
- char[] charBuf = new char[1024];
- while((index = rReader.read(charBuf)) > 0){
- log.info(new String(charBuf));
- }
-
- in.close();
- out.close();
-
- rReader.close();
- socket.close();
+ public void testInt() throws Exception{
+// try{
+// OMFactory fac = OMFactory.newInstance();
+//
+// OMNamespace omNs = fac.createOMNamespace("http://localhost/my","my");
+// OMElement method = fac.createOMElement("echoOMElement",omNs) ;
+// OMElement value = fac.createOMElement("myValue",omNs) ;
+// value.setValue("Isaac Assimov, the foundation Sega");
+// method.addChild(value);
+//
+// Call call = new Call();
+// URL url = new URL("http","127.0.0.1",EngineUtils.TESTING_PORT,"/axis/services/EchoXMLService");
+// OMElement omele = call.syncCall(method,url);
+// assertNotNull(omele);
+// }catch(Exception e){
+// e.printStackTrace();
+// tearDown();
+// throw e;
+// }
}
+ public void testString() throws Exception{
+// try{
+// OMFactory fac = OMFactory.newInstance();
+//
+// OMNamespace omNs = fac.createOMNamespace("http://localhost/my","my");
+// OMElement method = fac.createOMElement("echoOMElement",omNs) ;
+// OMElement value = fac.createOMElement("myValue",omNs) ;
+// value.setValue("Isaac Assimov, the foundation Sega");
+// method.addChild(value);
+//
+// Call call = new Call();
+// URL url = new URL("http","127.0.0.1",EngineUtils.TESTING_PORT,"/axis/services/EchoXMLService");
+//
+// CallBack callback = new CallBack() {
+// public void doWork(OMElement ele) {
+// System.out.print("got the result = " + ele +" :)");
+//
+// }
+// public void reportError(Exception e) {
+// log.info("reporting error from callback !");
+// e.printStackTrace();
+// }
+// };
+//
+// call.asyncCall(method,url,callback);
+// log.info("send the reqest");
+//
+// Thread.sleep(1000);
+// }catch(Exception e){
+// e.printStackTrace();
+// tearDown();
+// throw e;
+// }
+ }
+
}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EngineUtils.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EngineUtils.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EngineUtils.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EngineUtils.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EngineUtils.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EngineUtils.java Thu Dec 16 02:57:50 2004
@@ -17,6 +17,7 @@
import java.io.IOException;
import java.net.ServerSocket;
+import java.util.ArrayList;
import javax.xml.namespace.QName;
@@ -40,11 +41,11 @@
public static final String FAILURE_MESSAGE = "Intentional Faliure";
private static int index = 0;
- public static void addHandlers(Flow flow,ExecutionChain exeChain,String phaseName) throws AxisFault{
+ public static void addHandlers(Flow flow,Phase phase) throws AxisFault{
if(flow != null){
int handlerCount = flow.getHandlerCount();
for(int i = 0;i<handlerCount;i++){
- exeChain.addHandler(phaseName,flow.getHandler(i).getHandler());
+ phase.addHandler(flow.getHandler(i).getHandler());
}
}
}
@@ -69,22 +70,9 @@
}
public static void createExecutionChains(AxisService service) throws AxisFault{
- ExecutionChain inchain = new ExecutionChain();
- inchain.addPhase(new Phase(Constants.PHASE_SERVICE));
- EngineUtils.addHandlers(service.getInFlow(),inchain,Constants.PHASE_SERVICE);
- service.setExecutableInChain(inchain);
-
- ExecutionChain outchain = new ExecutionChain();
- outchain.addPhase(new Phase(Constants.PHASE_SERVICE));
- EngineUtils.addHandlers(service.getOutFlow(),outchain,Constants.PHASE_SERVICE);
- service.setExecutableOutChain(outchain);
-
- ExecutionChain faultchain = new ExecutionChain();
-
- faultchain.addPhase(new Phase(Constants.PHASE_SERVICE));
-
- EngineUtils.addHandlers(service.getFaultFlow(),faultchain,Constants.PHASE_SERVICE);
- service.setExecutableFaultChain(faultchain);
+ addPhasesToServiceFromFlow(service,Constants.PHASE_SERVICE,service.getInFlow(),EngineRegistry.INFLOW);
+ addPhasesToServiceFromFlow(service,Constants.PHASE_SERVICE,service.getOutFlow(),EngineRegistry.OUTFLOW);
+ addPhasesToServiceFromFlow(service,Constants.PHASE_SERVICE,service.getFaultFlow(),EngineRegistry.FAULTFLOW);
}
public static EngineRegistry createMockRegistry(QName serviceName,QName operationName,QName transportName) throws AxisFault{
EngineRegistry engineRegistry = null;
@@ -110,33 +98,22 @@
service.addModule(m1.getName());
AxisOperation operation = new SimpleAxisOperationImpl(operationName);
-
service.addOperation(operation);
+
engineRegistry.addService(service);
//create Execution Chains
- ExecutionChain inchain = new ExecutionChain();
- inchain.addPhase(new Phase(Constants.PHASE_TRANSPORT));
- inchain.addPhase(new Phase(Constants.PHASE_GLOBAL));
- inchain.addPhase(new Phase(Constants.PHASE_SERVICE));
- EngineUtils.addHandlers(service.getInFlow(),inchain,Constants.PHASE_SERVICE);
- service.setExecutableInChain(inchain);
-
- ExecutionChain outchain = new ExecutionChain();
- outchain.addPhase(new Phase(Constants.PHASE_SERVICE));
- outchain.addPhase(new Phase(Constants.PHASE_GLOBAL));
- outchain.addPhase(new Phase(Constants.PHASE_TRANSPORT));
- EngineUtils.addHandlers(service.getOutFlow(),outchain,Constants.PHASE_SERVICE);
- service.setExecutableOutChain(outchain);
-
- ExecutionChain faultchain = new ExecutionChain();
-
- faultchain.addPhase(new Phase(Constants.PHASE_SERVICE));
- faultchain.addPhase(new Phase(Constants.PHASE_GLOBAL));
- faultchain.addPhase(new Phase(Constants.PHASE_TRANSPORT));
-
- EngineUtils.addHandlers(service.getFaultFlow(),faultchain,Constants.PHASE_SERVICE);
- service.setExecutableFaultChain(faultchain);
+ addPhasesToServiceFromFlow(service,Constants.PHASE_SERVICE,service.getInFlow(),EngineRegistry.INFLOW);
+ addPhasesToServiceFromFlow(service,Constants.PHASE_SERVICE,service.getOutFlow(),EngineRegistry.OUTFLOW);
+ addPhasesToServiceFromFlow(service,Constants.PHASE_SERVICE,service.getFaultFlow(),EngineRegistry.FAULTFLOW);
return engineRegistry;
+ }
+
+ public static void addPhasesToServiceFromFlow(AxisService service, String phaseName, Flow flow,int flowtype) throws AxisFault{
+ ArrayList faultchain = new ArrayList();
+ Phase p = new Phase(Constants.PHASE_SERVICE);
+ faultchain.add(p);
+ EngineUtils.addHandlers(flow,p);
+ service.setPhases(faultchain,flowtype);
}
}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/HandlerFaliureTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/HandlerFaliureTest.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/HandlerFaliureTest.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/HandlerFaliureTest.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/HandlerFaliureTest.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/HandlerFaliureTest.java Thu Dec 16 02:57:50 2004
@@ -80,7 +80,7 @@
service.setInFlow(flow);
service.setClassLoader(Thread.currentThread().getContextClassLoader());
- Parameter classParam = new ParameterImpl("className",EchoXML.class.getName());
+ Parameter classParam = new ParameterImpl("className",Echo.class.getName());
service.addParameter(classParam);
service.setProvider(new RawXMLProvider());
AxisOperation operation = new SimpleAxisOperationImpl(operationName);
@@ -116,29 +116,14 @@
service.setInFlow(flow);
service.setClassLoader(Thread.currentThread().getContextClassLoader());
- Parameter classParam = new ParameterImpl("className",EchoXML.class.getName());
+ Parameter classParam = new ParameterImpl("className",Echo.class.getName());
service.addParameter(classParam);
service.setProvider(new RawXMLProvider());
AxisOperation operation = new SimpleAxisOperationImpl(operationName);
service.addOperation(operation);
-
- ExecutionChain inchain = new ExecutionChain();
- inchain.addPhase(new Phase(Constants.PHASE_SERVICE));
- EngineUtils.addHandlers(service.getInFlow(),inchain,Constants.PHASE_SERVICE);
- service.setExecutableInChain(inchain);
-
- ExecutionChain outchain = new ExecutionChain();
- outchain.addPhase(new Phase(Constants.PHASE_SERVICE));
- EngineUtils.addHandlers(service.getOutFlow(),outchain,Constants.PHASE_SERVICE);
- service.setExecutableOutChain(outchain);
-
- ExecutionChain faultchain = new ExecutionChain();
-
- faultchain.addPhase(new Phase(Constants.PHASE_SERVICE));
-
- EngineUtils.addHandlers(service.getFaultFlow(),faultchain,Constants.PHASE_SERVICE);
- service.setExecutableFaultChain(outchain);
+
+ EngineUtils.createExecutionChains(service);
engineRegistry.addService(service);
sas = EngineUtils.startServer(engineRegistry);
callTheService();
Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/MessageWithServerTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/MessageWithServerTest.java?view=auto&rev=122543
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/MessageWithServerTest.java Thu Dec 16 02:57:50 2004
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed 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.axis.engine;
+
+//todo
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.net.Socket;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis.AbstractTestCase;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.impl.transport.http.SimpleHTTPReceiver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class MessageWithServerTest extends AbstractTestCase{
+ private Log log = LogFactory.getLog(getClass());
+ private QName serviceName = new QName("","EchoService");
+ private QName operationName = new QName("http://ws.apache.org/axis2","echoVoid");
+ private QName transportName = new QName("","NullTransport");
+
+ private EngineRegistry engineRegistry;
+ private MessageContext mc;
+ private Thread thisThread = null;
+ private SimpleHTTPReceiver sas;
+
+ public MessageWithServerTest(String testName) {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ engineRegistry = EngineUtils.createMockRegistry(serviceName,operationName,transportName);
+ sas = EngineUtils.startServer(engineRegistry);
+ }
+
+ protected void tearDown() throws Exception {
+ sas.stop();
+ Thread.sleep(1000);
+ }
+
+
+ public void testEchoStringServer() throws Exception{
+ File file = getTestResourceFile("soap/soapmessage.txt");
+ FileInputStream in = new FileInputStream(file);
+
+ Socket socket = new Socket("127.0.0.1",EngineUtils.TESTING_PORT);
+ OutputStream out = socket.getOutputStream();
+ byte[] buf = new byte[1024];
+ int index = -1;
+ while((index = in.read(buf)) > 0){
+ out.write(buf,0,index);
+ }
+
+
+ InputStream respose = socket.getInputStream();
+ Reader rReader = new InputStreamReader(respose);
+ char[] charBuf = new char[1024];
+ while((index = rReader.read(charBuf)) > 0){
+ log.info(new String(charBuf));
+ }
+
+ in.close();
+ out.close();
+
+ rReader.close();
+ socket.close();
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/SimpleAxisServerTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/SimpleAxisServerTest.java?view=diff&rev=122543&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/SimpleAxisServerTest.java&r1=122542&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/SimpleAxisServerTest.java&r2=122543
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/SimpleAxisServerTest.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/SimpleAxisServerTest.java Thu Dec 16 02:57:50 2004
@@ -56,30 +56,14 @@
engineRegistry = EngineUtils.createMockRegistry(serviceName,operationName,transportName);
AxisService service = new SimpleAxisServiceImpl(serviceName);
service.setClassLoader(Thread.currentThread().getContextClassLoader());
- Parameter classParam = new ParameterImpl("className",EchoXML.class.getName());
+ Parameter classParam = new ParameterImpl("className",Echo.class.getName());
service.addParameter(classParam);
service.setProvider(new RawXMLProvider());
AxisOperation operation = new SimpleAxisOperationImpl(operationName);
service.addOperation(operation);
- ExecutionChain inchain = new ExecutionChain();
- inchain.addPhase(new Phase(Constants.PHASE_SERVICE));
- EngineUtils.addHandlers(service.getInFlow(),inchain,Constants.PHASE_SERVICE);
- service.setExecutableInChain(inchain);
-
- ExecutionChain outchain = new ExecutionChain();
- outchain.addPhase(new Phase(Constants.PHASE_SERVICE));
- EngineUtils.addHandlers(service.getOutFlow(),outchain,Constants.PHASE_SERVICE);
- service.setExecutableOutChain(outchain);
-
- ExecutionChain faultchain = new ExecutionChain();
-
- faultchain.addPhase(new Phase(Constants.PHASE_SERVICE));
-
- EngineUtils.addHandlers(service.getFaultFlow(),faultchain,Constants.PHASE_SERVICE);
- service.setExecutableFaultChain(outchain);
-
+ EngineUtils.createExecutionChains(service);
engineRegistry.addService(service);
engine = new AxisEngine(engineRegistry);