Author: keith
Date: Sat Feb 9 21:12:52 2008
New Revision: 13503
Log:
Adding in lifecycle support via init and destroy
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JavaScriptServiceAnnotationParser.java
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
Sat Feb 9 21:12:52 2008
@@ -21,6 +21,7 @@
public static String MASHUP_SERVER_UUID = "ServerUUID";
public static String MASHUP_JS_SERVICE = "MashupJSService";
+ public static String MASHUP_DESTROY_FUNCTION = "MashupDestroyFunction";
public static String CONTENT_TYPE_QUERY_PARAM = "content-type";
public static String REGISTRY_CONFIG = "RegistryConfig";
public static String USERMANAGER_CONFIG = "UsermanagerConfig";
Modified:
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
==============================================================================
---
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
(original)
+++
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
Sat Feb 9 21:12:52 2008
@@ -132,6 +132,7 @@
if (serviceList != null) {
DeploymentEngine.addServiceGroup(serviceGroup, serviceList,
deploymentFileData
.getFile().toURL(), deploymentFileData, axisConfig);
+
log.info(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_WS,
deploymentFileData
.getName()));
}
@@ -233,6 +234,12 @@
RegistryConstants.REGISTRY);
registry.delete((String) myRegistryPath.getValue());
}
+
+ JavaScriptEngine engine = new JavaScriptEngine(shortFileName);
+ Function destroy = (Function)
service.getParameterValue(MashupConstants.MASHUP_DESTROY_FUNCTION);
+ if (destroy != null) {
+ destroy.call(engine.getCx(), engine, engine, new
Object[0]);
+ }
}
// There exist only one servicegroup for the JavaScript services
deployed from this deployer
@@ -326,7 +333,10 @@
JavaScriptServiceAnnotationParser serviceAnnotationParser =
new JavaScriptServiceAnnotationParser(
engine, shortFileName);
-
+
+ Function init = serviceAnnotationParser.getInit();
+ Function destroy = serviceAnnotationParser.getDestroy();
+
axisService.setParent(axisServiceGroup);
axisService.setClassLoader(currentFile.getClassLoader());
String name = serviceAnnotationParser.getServiceName();
@@ -432,6 +442,12 @@
ArrayList serviceList = new ArrayList();
serviceList.add(axisService);
+ if (init != null) {
+ init.call(engine.getCx(), engine, engine, new Object[0]);
+ }
+ if (destroy != null) {
+
axisService.addParameter(MashupConstants.MASHUP_DESTROY_FUNCTION, destroy);
+ }
return serviceList;
} catch (FileNotFoundException e) {
throw new DeploymentException("JS Service File Not Found", e);
Modified:
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JavaScriptServiceAnnotationParser.java
==============================================================================
---
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JavaScriptServiceAnnotationParser.java
(original)
+++
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JavaScriptServiceAnnotationParser.java
Sat Feb 9 21:12:52 2008
@@ -20,9 +20,9 @@
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNode;
import org.apache.axis2.deployment.DeploymentException;
+import org.mozilla.javascript.Function;
import org.mozilla.javascript.Scriptable;
import org.wso2.javascript.xmlimpl.XML;
-import org.wso2.mashup.utils.MashupUtils;
/**
* This extracts & processes the service level annotations when deploying the
@@ -55,6 +55,10 @@
private OMNode serviceDocumentation;
+ private Function init = null;
+
+ private Function destroy = null;
+
private OMFactory omFactory = OMAbstractFactory.getOMFactory();
public JavaScriptServiceAnnotationParser(Scriptable service, String
serviceName)
@@ -98,6 +102,16 @@
XML xml = (XML) serviceDocumentationObject;
this.serviceDocumentation = xml.getAxiomFromXML();
}
+
+ Object initObject = service.get("init", service);
+ if (initObject instanceof Function) {
+ this.init = (Function) initObject;
+ }
+
+ Object destroyObject = service.get("destroy", service);
+ if (destroyObject instanceof Function) {
+ this.destroy = (Function) destroyObject;
+ }
}
public String getSchemaTargetNamespace() {
@@ -119,4 +133,12 @@
public OMNode getServiceDocumentation() {
return serviceDocumentation;
}
+
+ public Function getInit() {
+ return init;
+ }
+
+ public Function getDestroy() {
+ return destroy;
+ }
}
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev