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 de...@apache.org on 2006/08/29 10:23:08 UTC
svn commit: r438004 - in /webservices/axis2/trunk/java/modules/kernel: conf/
src/org/apache/axis2/ src/org/apache/axis2/deployment/
src/org/apache/axis2/engine/
Author: deepal
Date: Tue Aug 29 01:23:07 2006
New Revision: 438004
URL: http://svn.apache.org/viewvc?rev=438004&view=rev
Log:
fixing AXIS2-940
- need to add following parameter into services.xml
<parameter name="load-on-startup" locked="false">true</parameter>
- and then need to add the following method into service impl class
public void startUp(ConfigurationContext configCytx) {
}
Modified:
webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DependencyManager.java
Modified: webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml?rev=438004&r1=438003&r2=438004&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml Tue Aug 29 01:23:07 2006
@@ -167,11 +167,11 @@
<phase name="Transport">
<handler name="RequestURIBasedDispatcher"
class="org.apache.axis2.engine.RequestURIBasedDispatcher">
- <order phase="Dispatch"/>
+ <order phase="Transport"/>
</handler>
<handler name="SOAPActionBasedDispatcher"
class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
- <order phase="Dispatch"/>
+ <order phase="Transport"/>
</handler>
</phase>
<phase name="Security"/>
@@ -188,7 +188,7 @@
</handler>
<handler name="InstanceDispatcher"
class="org.apache.axis2.engine.InstanceDispatcher">
- <order phase="PostDispatch"/>
+ <order phase="Dispatch"/>
</handler>
</phase>
<!-- System pre defined phases -->
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=438004&r1=438003&r2=438004&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 Tue Aug 29 01:23:07 2006
@@ -136,9 +136,13 @@
*/
public static final String SINGLE_SERVICE = "singleservice";
- /** @deprecated Please use org.apache.axis2.transport.http.HTTPConstants.MC_HTTP_SERVLETCONTEXT */
+ /**
+ * @deprecated Please use org.apache.axis2.transport.http.HTTPConstants.MC_HTTP_SERVLETCONTEXT
+ */
public static final String SERVLET_CONTEXT = "transport.http.servletContext";
- /** @deprecated Please use org.apache.axis2.transport.http.HTTPConstants.MC_HTTP_SERVLETREQUEST */
+ /**
+ * @deprecated Please use org.apache.axis2.transport.http.HTTPConstants.MC_HTTP_SERVLETREQUEST
+ */
public static final String HTTP_SERVLET_REQUEST = "transport.http.servletRequest";
public static final String SERVICE_MAP = "servicemap";
@@ -192,10 +196,14 @@
public static final String FAULT_INFORMATION_FOR_HEADERS = "FaultHeaders";
- /** @deprecated Please use org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING */
+ /**
+ * @deprecated Please use org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING
+ */
public static final String COOKIE_STRING = "Cookie";
public static final String SESSION_COOKIE = "axis_session";
+ public static final String LOAD_ON_STARTUP = "load-on-startup";
+
/**
* Addressing Constants
*/
@@ -221,11 +229,11 @@
public static final String CONFIG_CONTEXT_TIMOUT_INTERVAL = "ConfigContextTimeoutInterval";
public static final String TRANSPORT_IN_URL = "TransportInURL";
-
+
public static final String URL_PARAMETER_LIST = "URLParameterList";
-
+
public static final String SEND_STACKTRACE_DETAILS_WITH_FAULTS = "sendStacktraceDetailsWithFaults";
-
+
public static final String DRILL_DOWN_TO_ROOT_CAUSE_FOR_FAULT_REASON = "drillDownToRootCauseForFaultReason";
public static final String ENABLE_REST_IN_AXIS2_MAIN_SERVLET = "enableRESTInAxis2MainServlet";
@@ -237,7 +245,9 @@
// this will contain the keys of all the properties that will be in the message context
public static final String TRANSPORT_URL = "TransportURL";
- /** @deprecated please use org.apache.axis2.addressing.AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES */
+ /**
+ * @deprecated please use org.apache.axis2.addressing.AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES
+ */
public static final String DISABLE_ADDRESSING_FOR_OUT_MESSAGES = "disableAddressingForOutMessages";
// if this property is set to Boolean.TRUE then the SOAPAction header, if present,
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java?rev=438004&r1=438003&r2=438004&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java Tue Aug 29 01:23:07 2006
@@ -29,14 +29,9 @@
import org.apache.axis2.deployment.scheduler.SchedulerTask;
import org.apache.axis2.deployment.util.PhasesInfo;
import org.apache.axis2.deployment.util.Utils;
-import org.apache.axis2.description.AxisModule;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.AxisServiceGroup;
-import org.apache.axis2.description.Flow;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
+import org.apache.axis2.description.*;
import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.DependencyManager;
import org.apache.axis2.engine.MessageReceiver;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.wsdl.WSDLConstants;
@@ -45,15 +40,7 @@
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.StringWriter;
+import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -88,9 +75,9 @@
* method
*/
protected AxisConfiguration axisConfig;
-
+
protected ConfigurationContext configContext;
-
+
private RepositoryListener repoListener;
public void loadServices() {
@@ -372,7 +359,6 @@
Iterator services = serviceList.iterator();
while (services.hasNext()) {
- ArrayList contolops = new ArrayList();
AxisService axisService = (AxisService) services.next();
String scope = axisService.getScope();
if (Constants.SCOPE_TRANSPORT_SESSION.equals(scope)) {
@@ -421,13 +407,36 @@
}
}
}
- contolops.clear();
}
axisConfig.addServiceGroup(serviceGroup);
+ startUpService(serviceGroup);
if (currentArchiveFile != null) {
addAsWebResources(currentArchiveFile.getFile(),
serviceGroup.getServiceGroupName(), serviceGroup);
}
+ }
+
+ /**
+ * When user adds the “load-on-startup” parameter into services.xml ,
+ * Axis2 will call following method using java reflection.
+ * If user has DB initialization , Thread creation then he can do that at this point.
+ * Public void startUp(ConfigurationContext) {}
+ *
+ * @param serviceGroup
+ */
+ private void startUpService(AxisServiceGroup serviceGroup) {
+ Iterator services = serviceGroup.getServices();
+ while (services.hasNext()) {
+ AxisService axisService = (AxisService) services.next();
+ Parameter load_on_startup = axisService.getParameter(Constants.LOAD_ON_STARTUP);
+ if (load_on_startup != null) {
+ String value = (String) load_on_startup.getValue();
+ if ("true".equals(value.trim())) {
+ DependencyManager.startService(axisService, configContext);
+ }
+ }
+ }
+
}
private void addAsWebResources(File in, String serviceFileName, AxisServiceGroup serviceGroup) {
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml?rev=438004&r1=438003&r2=438004&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml Tue Aug 29 01:23:07 2006
@@ -173,7 +173,7 @@
</handler>
<handler name="InstanceDispatcher"
class="org.apache.axis2.engine.InstanceDispatcher">
- <order phase="PostDispatch"/>
+ <order phase="Dispatch"/>
</handler>
</phase>
<!-- user can add his own phases to this area -->
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DependencyManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DependencyManager.java?rev=438004&r1=438003&r2=438004&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DependencyManager.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DependencyManager.java Tue Aug 29 01:23:07 2006
@@ -18,6 +18,7 @@
package org.apache.axis2.engine;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.OperationContext;
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.context.ServiceGroupContext;
@@ -38,6 +39,7 @@
public class DependencyManager {
public final static String MESSAGE_CONTEXT_INJECTION_METHOD = "setOperationContext";
public final static String SERVICE_INIT_METHOD = "init";
+ public final static String SERVICE_START_METHOD = "startUp";
public final static String SERVICE_DESTROY_METHOD = "destroy";
public static void configureBusinessLogicProvider(Object obj,
@@ -139,8 +141,34 @@
throw new AxisFault(Messages.getMessage("paramIsNotSpecified", "SERVICE_OBJECT_SUPPLIER"));
}
}
+ }
+ /**
+ * To startup service when user puts load-on-startup parameter
+ */
+ public static void startService(AxisService axisService,
+ ConfigurationContext configCtx) {
+ ClassLoader classLoader = axisService.getClassLoader();
+ Parameter implInfoParam = axisService.getParameter(AbstractMessageReceiver.SERVICE_CLASS);
+ if (implInfoParam != null) {
+ try {
+ Class implClass = Class.forName(((String) implInfoParam.getValue()).trim(), true,
+ classLoader);
+ Object serviceImpl = implClass.newInstance();
+ Method[] methods = serviceImpl.getClass().getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ if (SERVICE_START_METHOD.equals(methods[i].getName())
+ && (methods[i].getParameterTypes().length == 1)
+ && (methods[i].getParameterTypes()[0] == ConfigurationContext.class)) {
+ methods[i].invoke(serviceImpl, new Object[]{configCtx});
+ break;
+ }
+ }
+ } catch (Exception e) {
+ new AxisFault(e);
+ }
+ }
}
public static void destroyServiceObject(ServiceContext serviceContext) throws AxisFault {
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org