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 di...@apache.org on 2005/09/15 21:07:03 UTC
svn commit: r289289 [9/134] - in /webservices/axis2/trunk/java: ./ etc/
modules/addressing/ modules/addressing/src/META-INF/
modules/addressing/src/org/apache/axis2/handlers/addressing/
modules/addressing/test-resources/ modules/addressing/test/org/apa...
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/TwoWayTransportBasedSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/TwoWayTransportBasedSender.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/TwoWayTransportBasedSender.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/TwoWayTransportBasedSender.java Thu Sep 15 11:52:11 2005
@@ -1,66 +1,66 @@
-/*
- * Copyright 2004,2005 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.axis2.clientapi;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.om.impl.OMOutputImpl;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.i18n.Messages;
-import org.apache.axis2.soap.SOAPEnvelope;
-import org.apache.axis2.transport.TransportUtils;
-
-import javax.xml.stream.XMLStreamException;
-
-/**
- * This works for only a two way transport, this class send the SOAP Message and wait till the\result arrives
- */
-public class TwoWayTransportBasedSender {
- public static MessageContext send(MessageContext msgctx,
- TransportInDescription transportIn) throws AxisFault {
-
- AxisEngine engine = new AxisEngine(msgctx.getSystemContext());
- engine.send(msgctx);
-
- //create the response
- MessageContext response =
- new MessageContext(msgctx.getSystemContext(),
- msgctx.getSessionContext(),
- msgctx.getTransportIn(),
- msgctx.getTransportOut());
- response.setProperty(MessageContext.TRANSPORT_IN,
- msgctx.getProperty(MessageContext.TRANSPORT_IN));
- response.setServerSide(false);
- response.setOperationContext(msgctx.getOperationContext());
- response.setServiceContext(msgctx.getServiceContext());
- response.setServiceGroupContext(msgctx.getServiceGroupContext());
-
- //If request is REST we assume the response is REST, so set the variable
- response.setDoingREST(msgctx.isDoingREST());
-
- SOAPEnvelope resenvelope = TransportUtils.createSOAPMessage(response, msgctx.getEnvelope().getNamespace().getName());
-
- if (resenvelope != null) {
- response.setEnvelope(resenvelope);
- engine = new AxisEngine(msgctx.getSystemContext());
- engine.receive(response);
- } else {
- throw new AxisFault(Messages.getMessage("blockInvocationExpectsRes="));
- }
- return response;
- }
-}
+/*
+ * Copyright 2004,2005 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.axis2.clientapi;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.transport.TransportUtils;
+
+import javax.xml.stream.XMLStreamException;
+
+/**
+ * This works for only a two way transport, this class send the SOAP Message and wait till the\result arrives
+ */
+public class TwoWayTransportBasedSender {
+ public static MessageContext send(MessageContext msgctx,
+ TransportInDescription transportIn) throws AxisFault {
+
+ AxisEngine engine = new AxisEngine(msgctx.getSystemContext());
+ engine.send(msgctx);
+
+ //create the response
+ MessageContext response =
+ new MessageContext(msgctx.getSystemContext(),
+ msgctx.getSessionContext(),
+ msgctx.getTransportIn(),
+ msgctx.getTransportOut());
+ response.setProperty(MessageContext.TRANSPORT_IN,
+ msgctx.getProperty(MessageContext.TRANSPORT_IN));
+ response.setServerSide(false);
+ response.setOperationContext(msgctx.getOperationContext());
+ response.setServiceContext(msgctx.getServiceContext());
+ response.setServiceGroupContext(msgctx.getServiceGroupContext());
+
+ //If request is REST we assume the response is REST, so set the variable
+ response.setDoingREST(msgctx.isDoingREST());
+
+ SOAPEnvelope resenvelope = TransportUtils.createSOAPMessage(response, msgctx.getEnvelope().getNamespace().getName());
+
+ if (resenvelope != null) {
+ response.setEnvelope(resenvelope);
+ engine = new AxisEngine(msgctx.getSystemContext());
+ engine.receive(response);
+ } else {
+ throw new AxisFault(Messages.getMessage("blockInvocationExpectsRes="));
+ }
+ return response;
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/TwoWayTransportBasedSender.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/AbstractContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/AbstractContext.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/AbstractContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/AbstractContext.java Thu Sep 15 11:52:11 2005
@@ -1,128 +1,128 @@
-package org.apache.axis2.context;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.HashMap;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.engine.AxisConfiguration;
-
-/*
- * Copyright 2004,2005 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.
- *
- *
- */
-/**
- * This is the topmost level of the Context hierachy, is potentially a bag of
- * properties.
- */
-public abstract class AbstractContext implements Serializable {
-
- protected transient HashMap nonPersistentMap;
- protected final HashMap persistentMap;
- protected AbstractContext parent;
-
- public abstract void init (AxisConfiguration axisConfiguration) throws AxisFault;
-
- private void writeObject(ObjectOutputStream out) throws IOException {
- out.defaultWriteObject();
- }
-
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- nonPersistentMap = new HashMap ();
- }
-
- protected AbstractContext(AbstractContext parent) {
- this.persistentMap = new HashMap();
- this.nonPersistentMap = new HashMap();
- this.parent = parent;
- }
-
- /**
- * Store an object. depending on the persistent flag the
- * object is either saved in the persistent way or the non-persistent
- * way
- *
- * @param key
- * @param value
- * @param persistent
- */
- public void setProperty(String key, Object value, boolean persistent) {
- if (persistent) {
- persistentMap.put(key, value);
- } else {
- nonPersistentMap.put(key, value);
- }
- }
-
- /**
- * Store an object with the default persistent flag.
- * default is no persistance
- *
- * @param key
- * @param value
- */
- public void setProperty(String key, Object value) {
- this.setProperty(key, value, false);
- }
-
- /**
- * Retrieve an object. Default search is done in the non persistent
- * group
- *
- * @param key
- * @return
- */
- public Object getProperty(String key) {
- return this.getProperty(key, false);
- }
-
- /**
- * @param key
- * @param persistent
- * @return
- */
- public Object getProperty(String key, boolean persistent) {
- Object obj = null;
- if (persistent) {
- obj = persistentMap.get(key);
- }
- if (obj == null) {
- obj = nonPersistentMap.get(key);
- }
- if (obj == null && parent != null) {
- obj = parent.getProperty(key, persistent);
- }
- return obj;
- }
-
- /**
- * @param context
- */
- public void setParent(AbstractContext context) {
- parent = context;
- }
-
- /**
- * @return
- */
- public AbstractContext getParent() {
- return parent;
- }
-
-}
+package org.apache.axis2.context;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.HashMap;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.engine.AxisConfiguration;
+
+/*
+ * Copyright 2004,2005 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.
+ *
+ *
+ */
+/**
+ * This is the topmost level of the Context hierachy, is potentially a bag of
+ * properties.
+ */
+public abstract class AbstractContext implements Serializable {
+
+ protected transient HashMap nonPersistentMap;
+ protected final HashMap persistentMap;
+ protected AbstractContext parent;
+
+ public abstract void init (AxisConfiguration axisConfiguration) throws AxisFault;
+
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ out.defaultWriteObject();
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ nonPersistentMap = new HashMap ();
+ }
+
+ protected AbstractContext(AbstractContext parent) {
+ this.persistentMap = new HashMap();
+ this.nonPersistentMap = new HashMap();
+ this.parent = parent;
+ }
+
+ /**
+ * Store an object. depending on the persistent flag the
+ * object is either saved in the persistent way or the non-persistent
+ * way
+ *
+ * @param key
+ * @param value
+ * @param persistent
+ */
+ public void setProperty(String key, Object value, boolean persistent) {
+ if (persistent) {
+ persistentMap.put(key, value);
+ } else {
+ nonPersistentMap.put(key, value);
+ }
+ }
+
+ /**
+ * Store an object with the default persistent flag.
+ * default is no persistance
+ *
+ * @param key
+ * @param value
+ */
+ public void setProperty(String key, Object value) {
+ this.setProperty(key, value, false);
+ }
+
+ /**
+ * Retrieve an object. Default search is done in the non persistent
+ * group
+ *
+ * @param key
+ * @return
+ */
+ public Object getProperty(String key) {
+ return this.getProperty(key, false);
+ }
+
+ /**
+ * @param key
+ * @param persistent
+ * @return
+ */
+ public Object getProperty(String key, boolean persistent) {
+ Object obj = null;
+ if (persistent) {
+ obj = persistentMap.get(key);
+ }
+ if (obj == null) {
+ obj = nonPersistentMap.get(key);
+ }
+ if (obj == null && parent != null) {
+ obj = parent.getProperty(key, persistent);
+ }
+ return obj;
+ }
+
+ /**
+ * @param context
+ */
+ public void setParent(AbstractContext context) {
+ parent = context;
+ }
+
+ /**
+ * @return
+ */
+ public AbstractContext getParent() {
+ return parent;
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/AbstractContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java Thu Sep 15 11:52:11 2005
@@ -1,290 +1,290 @@
-package org.apache.axis2.context;
-
-/*
- * Copyright 2004,2005 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.
- *
- * Runtime state of the engine
- */
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.ServiceGroupDescription;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.storage.AxisStorage;
-import org.apache.axis2.util.UUIDGenerator;
-import org.apache.axis2.util.threadpool.ThreadPool;
-
-import javax.xml.namespace.QName;
-import java.io.File;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * This is the biggest memeber of the Axis2 information hierachy, and if this is serialized completly
- * the whole Axis2 is saved to the disc.
- */
-
-public class ConfigurationContext extends AbstractContext {
-
- private transient AxisConfiguration axisConfiguration;
- private AxisStorage storage;
-
- private Map sessionContextMap;
- private Map moduleContextMap;
-
- private transient ThreadPool threadPool;
-
- private File rootDir;
-
- /**
- * Map containing <code>MessageID</code> to
- * <code>OperationContext</code> mapping.
- */
- private final Map operationContextMap = new HashMap();
-
- private final Map serviceContextMap = new HashMap ();
-
- private final Map serviceGroupContextMap = new HashMap();
-
- public ConfigurationContext(AxisConfiguration axisConfiguration) {
- super(null);
- this.axisConfiguration = axisConfiguration;
- }
-
- /**
- * The method is used to do the intialization of the EngineContext
- *
- * @throws AxisFault
- */
-
- public void init() throws AxisFault {
-
- }
-
- public synchronized void removeService(QName name) {
- serviceContextMap.remove(name);
- }
-
-
- public void init(AxisConfiguration axisConfiguration) throws AxisFault {
- this.axisConfiguration = axisConfiguration;
-
- Iterator operationContextIt = operationContextMap.keySet().iterator();
- while (operationContextIt.hasNext()) {
- Object key = operationContextIt.next();
- OperationContext operationContext = (OperationContext) operationContextMap.get(key);
- if (operationContext!=null)
- operationContext.init(axisConfiguration);
- }
-
- Iterator serviceContextIt = serviceContextMap.keySet().iterator();
- while (serviceContextIt.hasNext()) {
- Object key = serviceContextIt.next();
- ServiceContext serviceContext = (ServiceContext) serviceContextMap.get(key);
- if (serviceContext!=null)
- serviceContext.init(axisConfiguration);
- }
-
- Iterator serviceGroupContextIt = serviceGroupContextMap.keySet().iterator();
- while (serviceGroupContextIt.hasNext()) {
- Object key = serviceGroupContextIt.next();
- ServiceGroupContext serviceGroupContext = (ServiceGroupContext) serviceGroupContextMap.get(key);
- if (serviceGroupContext!=null)
- serviceGroupContext.init(axisConfiguration);
- }
- }
-
- private void writeObject(ObjectOutputStream out) throws IOException {
- out.defaultWriteObject();
- }
-
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- threadPool = new ThreadPool ();
- }
-
- /**
- */
- public AxisConfiguration getAxisConfiguration() {
- return axisConfiguration;
- }
-
- /**
- * @param configuration
- */
- public void setAxisConfiguration(AxisConfiguration configuration) {
- axisConfiguration = configuration;
- }
-
- /**
- * Register a OperationContext agienst a given Message ID.
- *
- * @param messageID
- * @param mepContext
- */
- public synchronized void registerOperationContext(
- String messageID,
- OperationContext mepContext) {
- this.operationContextMap.put(messageID, mepContext);
- }
-
- /**
- * get a OperationContext given a Message ID
- *
- * @param messageID
- * @return OperationContext <code>OperationContext<code>
- */
- public OperationContext getOperationContext(String messageID) {
- return (OperationContext) this.operationContextMap.get(messageID);
- }
-
- public Map getOperationContextMap() {
- return this.operationContextMap;
- }
-
- /**
- * Register a ServiceContext agienst a given Message ID.
- */
- public synchronized void registerServiceContext(
- String serviceInstanceID,
- ServiceContext serviceContext) {
- this.serviceContextMap.put(serviceInstanceID, serviceContext);
- }
-
- /**
- * get the ServiceContext given a id
- *
- * @param serviceInstanceID
- */
- public ServiceContext getServiceContext(String serviceInstanceID) {
- return (ServiceContext) this.serviceContextMap.get(serviceInstanceID);
- }
-
- public AxisStorage getStorage() {
- return axisConfiguration.getAxisStorage(); //storage;
- }
-
- public void setStorage(AxisStorage storage) {
- this.storage = storage;
- }
-
-
-
- /**
- * @return the Gloal ThradPool
- */
- public ThreadPool getThreadPool() {
- if (threadPool == null) {
- threadPool = new ThreadPool();
- }
- return threadPool;
- }
-
- /**
- * This method allows users to reolve the paths relative to the
- * root diretory
- *
- * @param path
- */
- public File getRealPath(String path) {
- if (rootDir == null) {
- return new File(path);
- } else {
- return new File(rootDir, path);
- }
- }
-
- /**
- * @param file
- */
- public void setRootDir(File file) {
- rootDir = file;
- }
-
- /**
- * This method should search for a SGC in the map with given id as the key.
- * If(key != null && found)
- * check for a service context for the intended service.
- * if (!found)
- * create one and hook up to SGC
- * else
- * create new sgc with the given key or if key is null with a new key
- * create a new service context for the service
- *
- * @param messageContext
- */
- public ServiceGroupContext fillServiceContextAndServiceGroupContext(MessageContext messageContext) throws AxisFault {
- String serviceGroupContextId = messageContext.getServiceGroupContextId();
-
- ServiceGroupContext serviceGroupContext = null;
- ServiceContext serviceContext = null;
- if (!isNull(serviceGroupContextId) && serviceGroupContextMap.get(serviceGroupContextId) != null) {
- // SGC is already there
- serviceGroupContext = (ServiceGroupContext) serviceGroupContextMap.get(serviceGroupContextId);
-
- // check service context is there or not
-
- //todo Chinthka : I think we do not need to do this
- // ckecking here , inside ServiceGropContext I have done that , please take a look at taht
-
- serviceContext = serviceGroupContext.getServiceContext(messageContext.getServiceDescription().getName().
- getLocalPart());
-// if (serviceContext == null) {
-// serviceContext = new ServiceContext(messageContext.getServiceDescription(), serviceGroupContext);
-// serviceGroupContext.registerServiceContext(serviceContext);
-// }
- } else {
- // either the key is null or no SGC is found from the give key
- if (isNull(serviceGroupContextId)) {
- serviceGroupContextId = UUIDGenerator.getUUID();
- messageContext.setServiceGroupContextId(serviceGroupContextId);
- }
- if(messageContext.getServiceDescription() !=null){
- String servicName = messageContext.getServiceDescription().getName().getLocalPart();
- ServiceGroupDescription servicGroupDescription =
- this.getAxisConfiguration().getServiceGroup(servicName);
- serviceGroupContext = servicGroupDescription.getServiceGroupContext(this);
- serviceContext = serviceGroupContext.getServiceContext(
- messageContext.getServiceDescription().getName().
- getLocalPart());
- this.registerServiceGroupContext(serviceGroupContext);
- } else {
- throw new AxisFault("ServiceDescription Not found yet");
- }
- }
-
- // when you come here operation context MUST already been assigned to the message context
- messageContext.getOperationContext().setParent(serviceContext);
- messageContext.setServiceContext(serviceContext);
- messageContext.setServiceGroupContext(serviceGroupContext);
- return serviceGroupContext;
- }
-
- public void registerServiceGroupContext(ServiceGroupContext serviceGroupContext) {
- String id = serviceGroupContext.getId();
- if (serviceGroupContextMap.get(id) == null) {
- serviceGroupContextMap.put(id, serviceGroupContext);
- serviceGroupContext.setParent(this);
- }
- }
-
- private boolean isNull(String string) {
- return "".equals(string) || string == null;
- }
-
-}
+package org.apache.axis2.context;
+
+/*
+ * Copyright 2004,2005 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.
+ *
+ * Runtime state of the engine
+ */
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.ServiceGroupDescription;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.storage.AxisStorage;
+import org.apache.axis2.util.UUIDGenerator;
+import org.apache.axis2.util.threadpool.ThreadPool;
+
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * This is the biggest memeber of the Axis2 information hierachy, and if this is serialized completly
+ * the whole Axis2 is saved to the disc.
+ */
+
+public class ConfigurationContext extends AbstractContext {
+
+ private transient AxisConfiguration axisConfiguration;
+ private AxisStorage storage;
+
+ private Map sessionContextMap;
+ private Map moduleContextMap;
+
+ private transient ThreadPool threadPool;
+
+ private File rootDir;
+
+ /**
+ * Map containing <code>MessageID</code> to
+ * <code>OperationContext</code> mapping.
+ */
+ private final Map operationContextMap = new HashMap();
+
+ private final Map serviceContextMap = new HashMap ();
+
+ private final Map serviceGroupContextMap = new HashMap();
+
+ public ConfigurationContext(AxisConfiguration axisConfiguration) {
+ super(null);
+ this.axisConfiguration = axisConfiguration;
+ }
+
+ /**
+ * The method is used to do the intialization of the EngineContext
+ *
+ * @throws AxisFault
+ */
+
+ public void init() throws AxisFault {
+
+ }
+
+ public synchronized void removeService(QName name) {
+ serviceContextMap.remove(name);
+ }
+
+
+ public void init(AxisConfiguration axisConfiguration) throws AxisFault {
+ this.axisConfiguration = axisConfiguration;
+
+ Iterator operationContextIt = operationContextMap.keySet().iterator();
+ while (operationContextIt.hasNext()) {
+ Object key = operationContextIt.next();
+ OperationContext operationContext = (OperationContext) operationContextMap.get(key);
+ if (operationContext!=null)
+ operationContext.init(axisConfiguration);
+ }
+
+ Iterator serviceContextIt = serviceContextMap.keySet().iterator();
+ while (serviceContextIt.hasNext()) {
+ Object key = serviceContextIt.next();
+ ServiceContext serviceContext = (ServiceContext) serviceContextMap.get(key);
+ if (serviceContext!=null)
+ serviceContext.init(axisConfiguration);
+ }
+
+ Iterator serviceGroupContextIt = serviceGroupContextMap.keySet().iterator();
+ while (serviceGroupContextIt.hasNext()) {
+ Object key = serviceGroupContextIt.next();
+ ServiceGroupContext serviceGroupContext = (ServiceGroupContext) serviceGroupContextMap.get(key);
+ if (serviceGroupContext!=null)
+ serviceGroupContext.init(axisConfiguration);
+ }
+ }
+
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ out.defaultWriteObject();
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ threadPool = new ThreadPool ();
+ }
+
+ /**
+ */
+ public AxisConfiguration getAxisConfiguration() {
+ return axisConfiguration;
+ }
+
+ /**
+ * @param configuration
+ */
+ public void setAxisConfiguration(AxisConfiguration configuration) {
+ axisConfiguration = configuration;
+ }
+
+ /**
+ * Register a OperationContext agienst a given Message ID.
+ *
+ * @param messageID
+ * @param mepContext
+ */
+ public synchronized void registerOperationContext(
+ String messageID,
+ OperationContext mepContext) {
+ this.operationContextMap.put(messageID, mepContext);
+ }
+
+ /**
+ * get a OperationContext given a Message ID
+ *
+ * @param messageID
+ * @return OperationContext <code>OperationContext<code>
+ */
+ public OperationContext getOperationContext(String messageID) {
+ return (OperationContext) this.operationContextMap.get(messageID);
+ }
+
+ public Map getOperationContextMap() {
+ return this.operationContextMap;
+ }
+
+ /**
+ * Register a ServiceContext agienst a given Message ID.
+ */
+ public synchronized void registerServiceContext(
+ String serviceInstanceID,
+ ServiceContext serviceContext) {
+ this.serviceContextMap.put(serviceInstanceID, serviceContext);
+ }
+
+ /**
+ * get the ServiceContext given a id
+ *
+ * @param serviceInstanceID
+ */
+ public ServiceContext getServiceContext(String serviceInstanceID) {
+ return (ServiceContext) this.serviceContextMap.get(serviceInstanceID);
+ }
+
+ public AxisStorage getStorage() {
+ return axisConfiguration.getAxisStorage(); //storage;
+ }
+
+ public void setStorage(AxisStorage storage) {
+ this.storage = storage;
+ }
+
+
+
+ /**
+ * @return the Gloal ThradPool
+ */
+ public ThreadPool getThreadPool() {
+ if (threadPool == null) {
+ threadPool = new ThreadPool();
+ }
+ return threadPool;
+ }
+
+ /**
+ * This method allows users to reolve the paths relative to the
+ * root diretory
+ *
+ * @param path
+ */
+ public File getRealPath(String path) {
+ if (rootDir == null) {
+ return new File(path);
+ } else {
+ return new File(rootDir, path);
+ }
+ }
+
+ /**
+ * @param file
+ */
+ public void setRootDir(File file) {
+ rootDir = file;
+ }
+
+ /**
+ * This method should search for a SGC in the map with given id as the key.
+ * If(key != null && found)
+ * check for a service context for the intended service.
+ * if (!found)
+ * create one and hook up to SGC
+ * else
+ * create new sgc with the given key or if key is null with a new key
+ * create a new service context for the service
+ *
+ * @param messageContext
+ */
+ public ServiceGroupContext fillServiceContextAndServiceGroupContext(MessageContext messageContext) throws AxisFault {
+ String serviceGroupContextId = messageContext.getServiceGroupContextId();
+
+ ServiceGroupContext serviceGroupContext = null;
+ ServiceContext serviceContext = null;
+ if (!isNull(serviceGroupContextId) && serviceGroupContextMap.get(serviceGroupContextId) != null) {
+ // SGC is already there
+ serviceGroupContext = (ServiceGroupContext) serviceGroupContextMap.get(serviceGroupContextId);
+
+ // check service context is there or not
+
+ //todo Chinthka : I think we do not need to do this
+ // ckecking here , inside ServiceGropContext I have done that , please take a look at taht
+
+ serviceContext = serviceGroupContext.getServiceContext(messageContext.getServiceDescription().getName().
+ getLocalPart());
+// if (serviceContext == null) {
+// serviceContext = new ServiceContext(messageContext.getServiceDescription(), serviceGroupContext);
+// serviceGroupContext.registerServiceContext(serviceContext);
+// }
+ } else {
+ // either the key is null or no SGC is found from the give key
+ if (isNull(serviceGroupContextId)) {
+ serviceGroupContextId = UUIDGenerator.getUUID();
+ messageContext.setServiceGroupContextId(serviceGroupContextId);
+ }
+ if(messageContext.getServiceDescription() !=null){
+ String servicName = messageContext.getServiceDescription().getName().getLocalPart();
+ ServiceGroupDescription servicGroupDescription =
+ this.getAxisConfiguration().getServiceGroup(servicName);
+ serviceGroupContext = servicGroupDescription.getServiceGroupContext(this);
+ serviceContext = serviceGroupContext.getServiceContext(
+ messageContext.getServiceDescription().getName().
+ getLocalPart());
+ this.registerServiceGroupContext(serviceGroupContext);
+ } else {
+ throw new AxisFault("ServiceDescription Not found yet");
+ }
+ }
+
+ // when you come here operation context MUST already been assigned to the message context
+ messageContext.getOperationContext().setParent(serviceContext);
+ messageContext.setServiceContext(serviceContext);
+ messageContext.setServiceGroupContext(serviceGroupContext);
+ return serviceGroupContext;
+ }
+
+ public void registerServiceGroupContext(ServiceGroupContext serviceGroupContext) {
+ String id = serviceGroupContext.getId();
+ if (serviceGroupContextMap.get(id) == null) {
+ serviceGroupContextMap.put(id, serviceGroupContext);
+ serviceGroupContext.setParent(this);
+ }
+ }
+
+ private boolean isNull(String string) {
+ return "".equals(string) || string == null;
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java Thu Sep 15 11:52:11 2005
@@ -1,174 +1,174 @@
-package org.apache.axis2.context;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.deployment.DeploymentEngine;
-import org.apache.axis2.deployment.DeploymentException;
-import org.apache.axis2.description.ModuleDescription;
-import org.apache.axis2.description.ServiceDescription;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.engine.AxisConfigurationImpl;
-import org.apache.axis2.modules.Module;
-import org.apache.axis2.phaseresolver.PhaseException;
-import org.apache.axis2.phaseresolver.PhaseResolver;
-import org.apache.axis2.transport.TransportListener;
-import org.apache.axis2.transport.TransportSender;
-
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-
-/**
- * Created by IntelliJ IDEA.
- * Author : Deepal Jayasinghe
- * Date: Apr 19, 2005
- * Time: 10:44:38 AM
- */
-public class ConfigurationContextFactory {
-
- /**
- * Build the configuration for the Server
- * @param repositoryName
- * @return
- * @throws DeploymentException
- */
- public ConfigurationContext buildConfigurationContext(
- String repositoryName)
- throws DeploymentException {
- ConfigurationContext configurationContext = null;
- try {
- DeploymentEngine deploymentEngine =
- new DeploymentEngine(repositoryName);
- AxisConfiguration configuration = deploymentEngine.load();
- PhaseResolver phaseResolver = new PhaseResolver(configuration);
- configurationContext = new ConfigurationContext(configuration);
- phaseResolver.buildTranspotsChains();
- initModules(configurationContext);
- initTransports(configurationContext);
- } catch (AxisFault axisFault) {
- throw new DeploymentException(axisFault);
- }
- return configurationContext;
- }
-
- /**
- * Built the Configuration for the Client
- * @param axis2home the value can be null and it is resolved to the default
- * axis2.xml file
- * @return
- * @throws DeploymentException
- */
- public ConfigurationContext buildClientConfigurationContext(
- String axis2home)
- throws DeploymentException {
- ConfigurationContext engineContext = null;
- try {
- AxisConfiguration configuration =
- new DeploymentEngine().loadClient(axis2home);
- PhaseResolver phaseResolver = new PhaseResolver(configuration);
- engineContext = new ConfigurationContext(configuration);
- phaseResolver.buildTranspotsChains();
- initModules(engineContext);
- initTransports(engineContext);
- } catch (AxisFault axisFault) {
- throw new DeploymentException(axisFault);
- }
- return engineContext;
- }
-
- /**
- * Is used to initilize the modules , if the module needs to so some recovery process
- * it can do inside init and this is differnt form module.engage()
- *
- * @param context
- * @throws DeploymentException
- */
-
- private void initModules(ConfigurationContext context)
- throws DeploymentException {
- try {
- HashMap modules =
- ((AxisConfigurationImpl) context.getAxisConfiguration())
- .getModules();
- Collection col = modules.values();
- for (Iterator iterator = col.iterator(); iterator.hasNext();) {
- ModuleDescription axismodule =
- (ModuleDescription) iterator.next();
- Module module = axismodule.getModule();
- if (module != null) {
- module.init(context.getAxisConfiguration());
- }
- }
- } catch (AxisFault e) {
- throw new DeploymentException(e);
- }
- }
-
- /**
- * Here the Phases are resolved and the Order of the Handlers are established
- * @param service
- * @param configurationContextVal
- * @param modules
- * @throws PhaseException
- */
- public static void createChains(ServiceDescription service,
- AxisConfiguration configurationContextVal,
- ArrayList modules)
- throws PhaseException {
- try {
- PhaseResolver reolve =
- new PhaseResolver(configurationContextVal, service);
- reolve.buildchains();
- for (int i = 0; i < modules.size(); i++) {
- QName qName = (QName) modules.get(i);
- ModuleDescription moduledecs =
- configurationContextVal.getModule(qName);
- reolve.engageModuleToService(service, moduledecs);
- }
- } catch (PhaseException e) {
- throw e;
- } catch (AxisFault axisFault) {
- throw new PhaseException(axisFault);
- }
- }
-
- /**
- * This method initilize the transports, passing the information taken from the
- * deployment to the real instance, for and example here the <code>TransportSender</code>
- * get a referance to the <code>TransportOutDescription</code>.
- * @param configContext
- * @throws AxisFault
- */
- public void initTransports(ConfigurationContext configContext)
- throws AxisFault {
- AxisConfiguration axisConf = configContext.getAxisConfiguration();
-
- //Initzialize Transport Ins
- HashMap transportIns = axisConf.getTransportsIn();
- Iterator values = transportIns.values().iterator();
- while (values.hasNext()) {
- TransportInDescription transportIn =
- (TransportInDescription) values.next();
- TransportListener listener = transportIn.getReceiver();
- if (listener != null) {
- listener.init(configContext, transportIn);
- }
- }
- //Initzialize Transport Outs
- HashMap transportOuts = axisConf.getTransportsOut();
- values = transportOuts.values().iterator();
- while (values.hasNext()) {
- TransportOutDescription transportOut =
- (TransportOutDescription) values.next();
- TransportSender sender = transportOut.getSender();
- if (sender != null) {
- sender.init(configContext, transportOut);
- }
- }
-
- }
-
-}
+package org.apache.axis2.context;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.deployment.DeploymentEngine;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.description.ModuleDescription;
+import org.apache.axis2.description.ServiceDescription;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisConfigurationImpl;
+import org.apache.axis2.modules.Module;
+import org.apache.axis2.phaseresolver.PhaseException;
+import org.apache.axis2.phaseresolver.PhaseResolver;
+import org.apache.axis2.transport.TransportListener;
+import org.apache.axis2.transport.TransportSender;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * Created by IntelliJ IDEA.
+ * Author : Deepal Jayasinghe
+ * Date: Apr 19, 2005
+ * Time: 10:44:38 AM
+ */
+public class ConfigurationContextFactory {
+
+ /**
+ * Build the configuration for the Server
+ * @param repositoryName
+ * @return
+ * @throws DeploymentException
+ */
+ public ConfigurationContext buildConfigurationContext(
+ String repositoryName)
+ throws DeploymentException {
+ ConfigurationContext configurationContext = null;
+ try {
+ DeploymentEngine deploymentEngine =
+ new DeploymentEngine(repositoryName);
+ AxisConfiguration configuration = deploymentEngine.load();
+ PhaseResolver phaseResolver = new PhaseResolver(configuration);
+ configurationContext = new ConfigurationContext(configuration);
+ phaseResolver.buildTranspotsChains();
+ initModules(configurationContext);
+ initTransports(configurationContext);
+ } catch (AxisFault axisFault) {
+ throw new DeploymentException(axisFault);
+ }
+ return configurationContext;
+ }
+
+ /**
+ * Built the Configuration for the Client
+ * @param axis2home the value can be null and it is resolved to the default
+ * axis2.xml file
+ * @return
+ * @throws DeploymentException
+ */
+ public ConfigurationContext buildClientConfigurationContext(
+ String axis2home)
+ throws DeploymentException {
+ ConfigurationContext engineContext = null;
+ try {
+ AxisConfiguration configuration =
+ new DeploymentEngine().loadClient(axis2home);
+ PhaseResolver phaseResolver = new PhaseResolver(configuration);
+ engineContext = new ConfigurationContext(configuration);
+ phaseResolver.buildTranspotsChains();
+ initModules(engineContext);
+ initTransports(engineContext);
+ } catch (AxisFault axisFault) {
+ throw new DeploymentException(axisFault);
+ }
+ return engineContext;
+ }
+
+ /**
+ * Is used to initilize the modules , if the module needs to so some recovery process
+ * it can do inside init and this is differnt form module.engage()
+ *
+ * @param context
+ * @throws DeploymentException
+ */
+
+ private void initModules(ConfigurationContext context)
+ throws DeploymentException {
+ try {
+ HashMap modules =
+ ((AxisConfigurationImpl) context.getAxisConfiguration())
+ .getModules();
+ Collection col = modules.values();
+ for (Iterator iterator = col.iterator(); iterator.hasNext();) {
+ ModuleDescription axismodule =
+ (ModuleDescription) iterator.next();
+ Module module = axismodule.getModule();
+ if (module != null) {
+ module.init(context.getAxisConfiguration());
+ }
+ }
+ } catch (AxisFault e) {
+ throw new DeploymentException(e);
+ }
+ }
+
+ /**
+ * Here the Phases are resolved and the Order of the Handlers are established
+ * @param service
+ * @param configurationContextVal
+ * @param modules
+ * @throws PhaseException
+ */
+ public static void createChains(ServiceDescription service,
+ AxisConfiguration configurationContextVal,
+ ArrayList modules)
+ throws PhaseException {
+ try {
+ PhaseResolver reolve =
+ new PhaseResolver(configurationContextVal, service);
+ reolve.buildchains();
+ for (int i = 0; i < modules.size(); i++) {
+ QName qName = (QName) modules.get(i);
+ ModuleDescription moduledecs =
+ configurationContextVal.getModule(qName);
+ reolve.engageModuleToService(service, moduledecs);
+ }
+ } catch (PhaseException e) {
+ throw e;
+ } catch (AxisFault axisFault) {
+ throw new PhaseException(axisFault);
+ }
+ }
+
+ /**
+ * This method initilize the transports, passing the information taken from the
+ * deployment to the real instance, for and example here the <code>TransportSender</code>
+ * get a referance to the <code>TransportOutDescription</code>.
+ * @param configContext
+ * @throws AxisFault
+ */
+ public void initTransports(ConfigurationContext configContext)
+ throws AxisFault {
+ AxisConfiguration axisConf = configContext.getAxisConfiguration();
+
+ //Initzialize Transport Ins
+ HashMap transportIns = axisConf.getTransportsIn();
+ Iterator values = transportIns.values().iterator();
+ while (values.hasNext()) {
+ TransportInDescription transportIn =
+ (TransportInDescription) values.next();
+ TransportListener listener = transportIn.getReceiver();
+ if (listener != null) {
+ listener.init(configContext, transportIn);
+ }
+ }
+ //Initzialize Transport Outs
+ HashMap transportOuts = axisConf.getTransportsOut();
+ values = transportOuts.values().iterator();
+ while (values.hasNext()) {
+ TransportOutDescription transportOut =
+ (TransportOutDescription) values.next();
+ TransportSender sender = transportOut.getSender();
+ if (sender != null) {
+ sender.init(configContext, transportOut);
+ }
+ }
+
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java
------------------------------------------------------------------------------
svn:eol-style = native