You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by am...@apache.org on 2008/08/04 08:06:35 UTC

svn commit: r682265 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: Constants.java context/ConfigurationContextFactory.java deployment/DeploymentLifeCycleListener.java

Author: amilas
Date: Sun Aug  3 23:06:35 2008
New Revision: 682265

URL: http://svn.apache.org/viewvc?rev=682265&view=rev
Log:
Added a deployment life cycle listener to Axis2. (issue Axis2-3957)

Added:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentLifeCycleListener.java
Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java?rev=682265&r1=682264&r2=682265&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java Sun Aug  3 23:06:35 2008
@@ -397,5 +397,11 @@
          */
         public static final String DISABLE_RESPONSE_ACK = "DisableResponseAck";
 
+        /**
+         * This constant is used to add an deployment life cycle listner to Axis2
+         */
+
+        public static final String DEPLOYMENT_LIFE_CYCLE_LISTENER = "deploymentLifeCycleListener";
+
     }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java?rev=682265&r1=682264&r2=682265&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java Sun Aug  3 23:06:35 2008
@@ -21,11 +21,7 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
-import org.apache.axis2.deployment.AxisConfigBuilder;
-import org.apache.axis2.deployment.DeploymentConstants;
-import org.apache.axis2.deployment.DeploymentEngine;
-import org.apache.axis2.deployment.FileSystemConfigurator;
-import org.apache.axis2.deployment.URLBasedAxisConfigurator;
+import org.apache.axis2.deployment.*;
 import org.apache.axis2.deployment.util.Utils;
 import org.apache.axis2.description.AxisModule;
 import org.apache.axis2.description.AxisServiceGroup;
@@ -66,6 +62,27 @@
     public static ConfigurationContext createConfigurationContext(
             AxisConfigurator axisConfigurator) throws AxisFault {
         AxisConfiguration axisConfig = axisConfigurator.getAxisConfiguration();
+        // call to the deployment listners
+        Parameter param = axisConfig.getParameter(Constants.Configuration.DEPLOYMENT_LIFE_CYCLE_LISTENER);
+        DeploymentLifeCycleListener deploymentLifeCycleListener = null;
+        if (param != null){
+            String className = (String) param.getValue();
+            try {
+                deploymentLifeCycleListener = (DeploymentLifeCycleListener) Class.forName(className).newInstance();
+            } catch (InstantiationException e) {
+                log.error("Can not instantiate deployment Listener " + className, e);
+                throw new AxisFault("Can not instantiate deployment Listener " + className);
+            } catch (IllegalAccessException e) {
+                log.error("Illegal Access deployment Listener " + className, e);
+                throw new AxisFault("Illegal Access deployment Listener " + className);
+            } catch (ClassNotFoundException e) {
+                log.error("Class not found deployment Listener " + className, e);
+                throw new AxisFault("Class not found deployment Listener " + className);
+            }
+        }
+        if (deploymentLifeCycleListener != null){
+            deploymentLifeCycleListener.preDeploy(axisConfig);
+        }
         ConfigurationContext configContext = new ConfigurationContext(axisConfig);
 
         if (axisConfig.getClusterManager() != null) {
@@ -86,6 +103,9 @@
         initApplicationScopeServices(configContext);
 
         axisConfig.setStart(true);
+        if (deploymentLifeCycleListener != null){
+            deploymentLifeCycleListener.postDeploy(configContext);
+        }
         return configContext;
     }
 

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentLifeCycleListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentLifeCycleListener.java?rev=682265&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentLifeCycleListener.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentLifeCycleListener.java Sun Aug  3 23:06:35 2008
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.deployment;
+
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.AxisFault;
+
+/**
+ * this interface is used to inform deployment lifecycle realated events to
+ * listners
+ */
+public interface DeploymentLifeCycleListener {
+
+    /**
+     * calls before creating the configuration context to do any initializing work.
+     * @param axisConfig
+     * @throws AxisFault
+     */
+    public void preDeploy(AxisConfiguration axisConfig) throws AxisFault;
+
+    /**
+     * calls after starting the configuration context to resume any activity.
+     * @param configurationContext
+     * @throws AxisFault
+     */
+    public void postDeploy(ConfigurationContext configurationContext) throws AxisFault;
+
+}