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 gd...@apache.org on 2008/12/15 15:46:19 UTC
svn commit: r726705 - in
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2:
engine/ListenerManager.java transaction/TransactionConfiguration.java
Author: gdaniels
Date: Mon Dec 15 06:46:19 2008
New Revision: 726705
URL: http://svn.apache.org/viewvc?rev=726705&view=rev
Log:
* Shutdown services before modules, the reverse of startup. Also make sure we only install the LM shutdown hook once.
* Code cleanup
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/ListenerManager.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/TransactionConfiguration.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/ListenerManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/ListenerManager.java?rev=726705&r1=726704&r2=726705&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/ListenerManager.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/ListenerManager.java Mon Dec 15 06:46:19 2008
@@ -42,6 +42,7 @@
private static final Log log = LogFactory.getLog(ListenerManager.class);
public static ConfigurationContext defaultConfigurationContext;
+ protected ListenerManagerShutdownThread shutdownHookThread;
public static ListenerManager getDefaultListenerManager() {
if (defaultConfigurationContext == null) return null;
@@ -49,8 +50,11 @@
}
private ConfigurationContext configctx;
- private HashMap<String, TransportListener> startedTransports = new HashMap<String, TransportListener>();
- private boolean stopped;
+ private HashMap<String, TransportListener> startedTransports =
+ new HashMap<String, TransportListener>();
+
+ // We're stopped at first.
+ private boolean stopped = true;
public void init(ConfigurationContext configCtx) {
configCtx.setTransportManager(this);
@@ -79,7 +83,7 @@
if (service.isEnableAllTransports()) {
Iterator<TransportListener> itr_st = startedTransports.values().iterator();
while (itr_st.hasNext()) {
- TransportListener transportListener = (TransportListener)itr_st.next();
+ TransportListener transportListener = itr_st.next();
EndpointReference[] epRsForService =
transportListener.getEPRsForService(serviceName, null);
if (epRsForService != null) {
@@ -91,9 +95,8 @@
return null;
} else {
- List exposeTransport = service.getExposedTransports();
- TransportListener listener = (TransportListener)
- startedTransports.get(exposeTransport.get(0));
+ List<String> exposeTransport = service.getExposedTransports();
+ TransportListener listener = startedTransports.get(exposeTransport.get(0));
EndpointReference[] eprsForService;
eprsForService = listener.getEPRsForService(serviceName, null);
@@ -112,6 +115,8 @@
/** To start all the transports */
public synchronized void start() {
+ if (!stopped) return;
+
for (Object o : configctx.getAxisConfiguration().getTransportsIn().values()) {
try {
TransportInDescription transportIn = (TransportInDescription)o;
@@ -125,7 +130,9 @@
log.info(e.getMessage(), e);
}
}
- Runtime.getRuntime().addShutdownHook(new ListenerManagerShutdownThread(this));
+
+ shutdownHookThread = new ListenerManagerShutdownThread(this);
+ Runtime.getRuntime().addShutdownHook(shutdownHookThread);
}
public synchronized void startSystem(ConfigurationContext configurationContext) {
@@ -139,17 +146,22 @@
return;
}
+ // Remove the shutdown hook
+ Runtime.getRuntime().removeShutdownHook(shutdownHookThread);
+ shutdownHookThread = null;
+
for (Object o : startedTransports.values()) {
TransportListener transportListener = (TransportListener)o;
transportListener.stop();
}
// Stop the transport senders
- HashMap<String, TransportOutDescription> outTransports = configctx.getAxisConfiguration().getTransportsOut();
+ HashMap<String, TransportOutDescription> outTransports =
+ configctx.getAxisConfiguration().getTransportsOut();
if (outTransports.size() > 0) {
Iterator<TransportOutDescription> trsItr = outTransports.values().iterator();
while (trsItr.hasNext()) {
- TransportOutDescription outDescription = (TransportOutDescription)trsItr.next();
+ TransportOutDescription outDescription = trsItr.next();
TransportSender sender = outDescription.getSender();
if (sender != null) {
sender.stop();
@@ -157,12 +169,21 @@
}
}
+ // Shut down the services
+ for (Object o : configctx.getAxisConfiguration().getServices().values()) {
+ AxisService axisService = (AxisService)o;
+ ServiceLifeCycle serviceLifeCycle = axisService.getServiceLifeCycle();
+ if (serviceLifeCycle != null) {
+ serviceLifeCycle.shutDown(configctx, axisService);
+ }
+ }
+
// Shut down the modules
HashMap<String, AxisModule> modules = configctx.getAxisConfiguration().getModules();
if (modules != null) {
Iterator<AxisModule> moduleitr = modules.values().iterator();
while (moduleitr.hasNext()) {
- AxisModule axisModule = (AxisModule)moduleitr.next();
+ AxisModule axisModule = moduleitr.next();
Module module = axisModule.getModule();
if (module != null) {
module.shutdown(configctx);
@@ -171,14 +192,6 @@
}
configctx.cleanupContexts();
- // Shut down the services
- for (Object o : configctx.getAxisConfiguration().getServices().values()) {
- AxisService axisService = (AxisService)o;
- ServiceLifeCycle serviceLifeCycle = axisService.getServiceLifeCycle();
- if (serviceLifeCycle != null) {
- serviceLifeCycle.shutDown(configctx, axisService);
- }
- }
stopped = true;
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/TransactionConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/TransactionConfiguration.java?rev=726705&r1=726704&r2=726705&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/TransactionConfiguration.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/TransactionConfiguration.java Mon Dec 15 06:46:19 2008
@@ -20,21 +20,16 @@
package org.apache.axis2.transaction;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.deployment.AxisConfigBuilder;
import org.apache.axis2.deployment.DeploymentException;
-import org.apache.axis2.description.ParameterInclude;
import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterIncludeImpl;
+import org.apache.axis2.description.ParameterInclude;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.axiom.om.OMElement;
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-import javax.naming.InitialContext;
import javax.naming.Context;
+import javax.naming.InitialContext;
import javax.naming.NamingException;
-import javax.xml.namespace.QName;
+import javax.transaction.TransactionManager;
import java.util.Hashtable;
import java.util.Iterator;