axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject svn commit: r762836 - /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/ListenerManager.java
Date Wed, 08 Apr 2009 04:11:21 GMT
Author: gdaniels
Date: Tue Apr  7 16:28:15 2009
New Revision: 762836

URL: http://svn.apache.org/viewvc?rev=762836&view=rev
Log:
Merge over ListenerManager changes from 1.5 branch.

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/ListenerManager.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=762836&r1=762835&r2=762836&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
Tue Apr  7 16:28:15 2009
@@ -56,9 +56,27 @@
     // We're stopped at first.
     private boolean stopped = true;
 
+    // need to preserve the default behavior of requiring a shutdown hook
+    private boolean shutdownHookRequired = true;
+
     public void init(ConfigurationContext configCtx) {
+        if (this.configctx != null) return;
+
         configCtx.setTransportManager(this);
         this.configctx = configCtx;
+
+        // initialize all the transport listeners
+        for (Object o : configctx.getAxisConfiguration().getTransportsIn().values()) {
+            try {
+                TransportInDescription transportIn = (TransportInDescription)o;
+                TransportListener listener = transportIn.getReceiver();
+                if (listener != null && startedTransports.get(transportIn.getName())
== null) {
+                    listener.init(configctx, transportIn);
+                }
+            } catch (Exception e) {
+                log.info(e.getMessage(), e);
+            }
+        }
     }
 
     public ConfigurationContext getConfigctx() {
@@ -117,12 +135,16 @@
     public synchronized void start() {
         if (!stopped) return;
 
+        if (configctx == null) {
+            log.error("Can't start uninitialized ListenerManager!");
+            return;
+        }
+
         for (Object o : configctx.getAxisConfiguration().getTransportsIn().values()) {
             try {
                 TransportInDescription transportIn = (TransportInDescription)o;
                 TransportListener listener = transportIn.getReceiver();
                 if (listener != null && startedTransports.get(transportIn.getName())
== null) {
-                    listener.init(configctx, transportIn);
                     listener.start();
                     startedTransports.put(transportIn.getName(), listener);
                 }
@@ -131,7 +153,7 @@
             }
         }
 
-        if (shutdownHookThread == null) {
+        if (shutdownHookThread == null && isShutdownHookRequired()) {
             shutdownHookThread = new ListenerManagerShutdownThread(this);
             Runtime.getRuntime().addShutdownHook(shutdownHookThread);
         }
@@ -214,7 +236,7 @@
             if (!started) {
                 transportListener.init(configctx, trsIn);
                 transportListener.start();
-                if (shutdownHookThread == null) {
+                if (shutdownHookThread == null && isShutdownHookRequired()) {
                     shutdownHookThread = new ListenerManagerShutdownThread(this);
                     Runtime.getRuntime().addShutdownHook(shutdownHookThread);
                 }
@@ -244,6 +266,14 @@
         defaultConfigurationContext = null;
     }
 
+    public boolean isShutdownHookRequired() {
+        return shutdownHookRequired;
+    }
+
+    public void setShutdownHookRequired(boolean shutdownHookRequired) {
+        this.shutdownHookRequired = shutdownHookRequired;
+    }
+
     static class ListenerManagerShutdownThread extends Thread {
         ListenerManager listenerManager;
 



Mime
View raw message