[mashup-dev] svn commit r4679 -
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/file
svn at wso2.org
svn at wso2.org
Mon Jul 2 23:46:01 PDT 2007
Author: thilina
Date: Mon Jul 2 23:45:14 2007
New Revision: 4679
Modified:
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/file/JavaScriptFileObject.java
Log:
fixing mashup-209
Modified: trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/file/JavaScriptFileObject.java
==============================================================================
--- trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/file/JavaScriptFileObject.java (original)
+++ trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/file/JavaScriptFileObject.java Mon Jul 2 23:45:14 2007
@@ -18,7 +18,6 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
@@ -30,7 +29,7 @@
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.OMText;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.Parameter;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
@@ -40,6 +39,16 @@
import org.wso2.javascript.rhino.JavaScriptEngineConstants;
import org.wso2.mashup.MashupFault;
+/**
+ * <p>
+ * This is a JavaScript Rhino host object to provide the ability for the users
+ * to manipulate with Files inside the WSO2 Mashup environment.
+ * </p>
+ * <p>
+ * For more information refer to <a
+ * href="http://www.wso2.org/wiki/display/mashup/File+Host+Object">JavaScript
+ * File Host Object</a>.
+ */
public class JavaScriptFileObject extends ScriptableObject {
File file;
@@ -55,14 +64,17 @@
boolean inNewExpr) throws IOException {
JavaScriptFileObject result = new JavaScriptFileObject();
- Object object = cx.getThreadLocal(JavaScriptEngineConstants.AXIS2_MESSAGECONTEXT);
- MessageContext messageContext;
- if (object instanceof MessageContext) {
- messageContext = (MessageContext) object;
+ // Falling back to use AxisService as MessageContext is not available in deployment time.
+ // This is a fix for MASHUP-209
+ Object object = cx.getThreadLocal(JavaScriptEngineConstants.AXIS2_SERVICE);
+ AxisService axisService;
+ if (object instanceof AxisService) {
+ axisService = (AxisService) object;
} else {
throw new MashupFault("Error obtaining the MessageContext.");
}
- Parameter parameter = messageContext
+
+ Parameter parameter = axisService
.getParameter(JavaScriptEngineConstants.RESOURCES_FOLDER);
Object resourceFileObject = parameter.getValue();
File resourceFolder;
@@ -80,6 +92,7 @@
"Given path is not a File. This object does not support directories.");
}
} else if (args[0] instanceof XML) {
+ //TODO: Initial code bits to handle MTOM using the file object. Yet to be completed.
XML xml = (XML) args[0];
OMNode node = xml.getAxiomFromXML();
if (node instanceof OMText) {
More information about the Mashup-dev
mailing list