Author: keith
Date: Tue Apr 29 08:09:01 2008
New Revision: 16343

Log:

Moving a couple of functions to utils so that these function can be used bu the 
MashupServerInitializer when invoking the init function


Modified:
   trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
   
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/system/FunctionSchedulingJob.java

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java   
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java   
Tue Apr 29 08:09:01 2008
@@ -81,6 +81,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
+import java.io.Reader;
+import java.io.InputStreamReader;
 import java.math.BigInteger;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -952,4 +954,69 @@
                 .isEnableAllTransports() || 
configContext.getAxisConfiguration()
                 .getService(serviceName).isExposedTransport(transportName);
     }
+
+    /**
+     * Locates the service Javascript file associated with ServiceJS parameter 
and returns
+     * a Reader for it.
+     *
+     * @param axisService The relavant AxisService
+     * @return an input stream to the javascript source file
+     * @throws org.apache.axis2.AxisFault if the parameter ServiceJS is not 
specified or if the service
+     *                                    implementation is not available
+     */
+    public static Reader readJS(AxisService axisService) throws AxisFault {
+        InputStream jsFileStream;
+
+        Parameter implInfoParam = 
axisService.getParameter(JavaScriptEngineConstants.SERVICE_JS);
+        if (implInfoParam == null) {
+            throw new AxisFault("Parameter 'ServiceJS' not specified");
+        }
+        if (implInfoParam.getValue() instanceof File) {
+            try {
+                jsFileStream = new FileInputStream((File) 
(implInfoParam.getValue()));
+            } catch (FileNotFoundException e) {
+                throw new AxisFault("Unable to load the javaScript, File not 
Found", e);
+            }
+        } else {
+            jsFileStream = axisService.getClassLoader().getResourceAsStream(
+                    implInfoParam.getValue().toString());
+        }
+        if (jsFileStream == null) {
+            throw new AxisFault("Unable to load the javaScript");
+        }
+        return new BufferedReader(new InputStreamReader(jsFileStream));
+    }
+
+    /**
+     * Provides support for importing JavaScript files specified in the
+     * Services.xml or the Axis2.xml using the "loadJSScripts" parameter.
+     *
+     * @param axisService - The irelavant AxisService
+     * @return String
+     */
+    public static String getImportScriptsList(AxisService axisService) {
+        String scripts = null;
+
+        // Get necessary JavaScripts to be loaded from services.xml
+        Parameter param = axisService.getParameter(
+                JavaScriptEngineConstants.LOAD_JSSCRIPTS);
+        if (param != null) {
+            scripts = (String) param.getValue();
+        }
+
+        // Get necessary JavaScripts to be loaded from axis2.xml
+        param = axisService.getAxisConfiguration().getParameter(
+                JavaScriptEngineConstants.LOAD_JSSCRIPTS);
+        if (param != null) {
+            if (scripts == null) {
+                scripts = (String) param.getValue();
+            } else {
+                // Avoids loading the same set of script files twice
+                if (!scripts.equals(param.getValue())) {
+                    scripts += "," + param.getValue();
+                }
+            }
+        }
+        return scripts;
+    }
 }
\ No newline at end of file

Modified: 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/system/FunctionSchedulingJob.java
==============================================================================
--- 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/system/FunctionSchedulingJob.java
     (original)
+++ 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/system/FunctionSchedulingJob.java
     Tue Apr 29 08:09:01 2008
@@ -15,11 +15,10 @@
  */
 package org.wso2.mashup.hostobjects.system;
 
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.Function;
 import org.quartz.Job;
@@ -28,14 +27,9 @@
 import org.wso2.javascript.rhino.JavaScriptEngine;
 import org.wso2.javascript.rhino.JavaScriptEngineConstants;
 import org.wso2.javascript.rhino.JavaScriptEngineUtils;
+import org.wso2.mashup.utils.MashupUtils;
 import org.wso2.wsas.ServerManager;
 
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.Reader;
 import java.net.URL;
 
@@ -94,12 +88,12 @@
                 JavaScriptEngine.axis2RepositoryLocation = repoURL.getPath();
             }
 
-            Reader reader = readJS(axisServce);
+            Reader reader = MashupUtils.readJS(axisServce);
 
             Object[] args;
 
             //support for importing javaScript files using services.xml or the 
axis2.xml
-            String scripts = getImportScriptsList(axisServce);
+            String scripts = MashupUtils.getImportScriptsList(axisServce);
 
             //Loading imported JavaScript files if there are any
             if (scripts != null) {
@@ -135,69 +129,4 @@
 
     }
 
-    /**
-     * Locates the service Javascript file associated with ServiceJS parameter 
and returns
-     * a Reader for it.
-     *
-     * @param axisService The relavant AxisService
-     * @return an input stream to the javascript source file
-     * @throws org.apache.axis2.AxisFault if the parameter ServiceJS is not 
specified or if the service
-     *                                    implementation is not available
-     */
-    private Reader readJS(AxisService axisService) throws AxisFault {
-        InputStream jsFileStream;
-
-        Parameter implInfoParam = 
axisService.getParameter(JavaScriptEngineConstants.SERVICE_JS);
-        if (implInfoParam == null) {
-            throw new AxisFault("Parameter 'ServiceJS' not specified");
-        }
-        if (implInfoParam.getValue() instanceof File) {
-            try {
-                jsFileStream = new FileInputStream((File) 
(implInfoParam.getValue()));
-            } catch (FileNotFoundException e) {
-                throw new AxisFault("Unable to load the javaScript, File not 
Found", e);
-            }
-        } else {
-            jsFileStream = axisService.getClassLoader().getResourceAsStream(
-                    implInfoParam.getValue().toString());
-        }
-        if (jsFileStream == null) {
-            throw new AxisFault("Unable to load the javaScript");
-        }
-        return new BufferedReader(new InputStreamReader(jsFileStream));
-    }
-
-    /**
-     * Provides support for importing JavaScript files specified in the
-     * Services.xml or the Axis2.xml using the "loadJSScripts" parameter.
-     *
-     * @param axisService - The irelavant AxisService
-     * @return String
-     */
-    private String getImportScriptsList(AxisService axisService) {
-        String scripts = null;
-
-        // Get necessary JavaScripts to be loaded from services.xml
-        Parameter param = axisService.getParameter(
-                JavaScriptEngineConstants.LOAD_JSSCRIPTS);
-        if (param != null) {
-            scripts = (String) param.getValue();
-        }
-
-        // Get necessary JavaScripts to be loaded from axis2.xml
-        param = axisService.getAxisConfiguration().getParameter(
-                JavaScriptEngineConstants.LOAD_JSSCRIPTS);
-        if (param != null) {
-            if (scripts == null) {
-                scripts = (String) param.getValue();
-            } else {
-                // Avoids loading the same set of script files twice
-                if (!scripts.equals(param.getValue())) {
-                    scripts += "," + param.getValue();
-                }
-            }
-        }
-        return scripts;
-    }
-
 }

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to