Author: keith
Date: Mon Apr 21 23:37:45 2008
New Revision: 15914

Log:

Some code clenup and adding documentation


Modified:
   
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java

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
   Mon Apr 21 23:37:45 2008
@@ -123,10 +123,13 @@
     private AxisBinding soap12Binding;
     private AxisBinding httpBinding;
 
+    // This is the map that keeps the httpLocation to axisoperation mapping to 
be used by the
+    // httpLocationBasedDispatcher
     Map httpLocationTable;
 
     /**
      * Initialize the deployer.
+     * @param configCtx our ConfigurationContext
      *
      * @see 
org.apache.axis2.deployment.Deployer#init(org.apache.axis2.context.ConfigurationContext)
      */
@@ -144,6 +147,9 @@
                     new Parameter(MashupConstants.QUARTZ_FUNCTION_SCHEDULER, 
scheduler);
             this.axisConfig.addParameter(functionScheduler);
 
+            // We initialize the registry in here cause this is the first 
point that the
+            // Mashup Server gets control before JavaScript Services are 
deployed.
+            // We prepare the registry for mashups to be added into it.
             initRegistry();
         } catch (MashupFault mashupFault) {
             throw new RuntimeException(mashupFault);
@@ -155,10 +161,18 @@
         }
     }
 
-    // Will process the file and add that to axisConfig
+    /**
+     * Process a file and add it to the configuration
+     * @param deploymentFileData the DeploymentFileData object to deploy
+     * @throws DeploymentException if there is a problem
+     */
     public void deploy(DeploymentFileData deploymentFileData) throws 
DeploymentException {
         StringWriter errorWriter = new StringWriter();
+
+        // We need to track weather the service was deployed succesfully or 
not in order to update
+        // the registry accordingly
         String serviceStatus = "";
+        String name = deploymentFileData.getName();
         try {
             
deploymentFileData.setClassLoader(axisConfig.getServiceClassLoader());
             AxisServiceGroup serviceGroup = new AxisServiceGroup(axisConfig);
@@ -169,18 +183,24 @@
                 DeploymentEngine.addServiceGroup(serviceGroup, serviceList, 
deploymentFileData
                         .getFile().toURL(), deploymentFileData, axisConfig);
 
-                log.info(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_WS, 
deploymentFileData
-                        .getName()));
+
+                log.info(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_WS, 
name));
             }
-            MashupUtils.notifyMonitor("Deployment Success", 
deploymentFileData.getName() +
+
+            // Send a notification to the system monitor indication that the 
service was succesfully
+            // deployed
+            MashupUtils.notifyMonitor("Deployment Success", name +
                     " deployed successfully", 3);
         } catch (DeploymentException deploymentException) {
-            log.error(Messages.getMessage(DeploymentErrorMsgs.INVALID_SERVICE, 
deploymentFileData
-                    .getName(), deploymentException.getMessage()), 
deploymentException);
+            log.error(Messages.getMessage(DeploymentErrorMsgs.INVALID_SERVICE, 
name,
+                                          deploymentException.getMessage()), 
deploymentException);
             PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
             deploymentException.printStackTrace(error_ptintWriter);
             serviceStatus = "Error:\n" + errorWriter.toString();
-            MashupUtils.notifyMonitor("Deployment Error", 
deploymentFileData.getName() +
+
+            // Send a notification to the system monitor indication that the 
service was not
+            // deployed succesfully
+            MashupUtils.notifyMonitor("Deployment Error", name +
                     " deployment failed", 1);
             throw deploymentException;
         } catch (Throwable t) {
@@ -197,16 +217,21 @@
             PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
             t.printStackTrace(error_ptintWriter);
             serviceStatus = "Error:\n" + errorWriter.toString();
+            // Send a notification to the system monitor indication that the 
service was not
+            // deployed succesfully
             MashupUtils.notifyMonitor("Error", deploymentFileData.getName() +
                     " deployment unsuccessful", 0);
             throw new DeploymentException(t);
         } finally {
+
+            // Now if the service was not deployed succesfully we need to 
update the registry saying
+            // that this service was faulty
             if (serviceStatus.startsWith("Error:")) {
                 
axisConfig.getFaultyServices().put(deploymentFileData.getFile().getAbsolutePath(),
                                                    serviceStatus);
                 MashupUtils.populateRegistry(configCtx, deploymentFileData,
                                  "This Service is Faulty. Reason : " + 
serviceStatus,
-                                 
DescriptionBuilder.getShortFileName(deploymentFileData.getName()),
+                                 DescriptionBuilder.getShortFileName(name),
                                  true, MashupConstants.MASHUP_MEDIA_TYPE, 
JavaScriptEngineConstants.SERVICE_JS);
 
             }
@@ -218,15 +243,27 @@
      * using this deployer. This gets called even when hotUpdating a service as
      * Axis2 updeploy and redeploys the service when performing an hotUpdate.
      *
-     * @throws DeploymentException
+     * @param fileName name of item to remove
+     * @throws DeploymentException if there is a problem
      * @see org.apache.axis2.deployment.Deployer#unDeploy(java.lang.String)
      */
     public void unDeploy(String fileName) throws DeploymentException {
         try {
             File file = new File(fileName);
             String shortFileName = file.getName();
+
+            // As the Mashup Server deployment model is that mashups lie in a 
folder under each
+            // users username we can safly infer the author of a mashups from 
the name of the parent
+            // folder
             String username = file.getParentFile().getName();
 
+            // Axis2 has a flat space for services. But in the Mashup Server 
we need to support
+            // services on a per user basis, hence two users can have a 
service with the same name.
+            // To tackle this issue the mashup server sets the service name 
inside axis as
+            // authorName-serviceName. This fact is hidden from users by using 
a customDispatcher
+            // (MashupDispatcher), custom transportListeners
+            // (org.wso2.mashup.transport.http.HttpTransportListener and
+            // org.wso2.mashup.transport.http.HttpsTransportListener)
             String serviceGroupName = username + 
MashupConstants.SEPARATOR_CHAR +
                     shortFileName.substring(0, shortFileName.indexOf("."));
             AxisServiceGroup group =
@@ -271,6 +308,10 @@
                     registry.delete((String) myRegistryPath.getValue());
                 }
 
+                // If a mashup had specified a function to be called on 
undeployment
+                // (Service LifeCycle support) we need to call it on service 
undeployment.
+                // The deployer adds a parameter to the axisService specifying 
which function to
+                // call on undeployment if such a function was specofied.
                 JavaScriptEngine engine = new JavaScriptEngine(shortFileName);
                 Function destroy = (Function) service
                         
.getParameterValue(MashupConstants.MASHUP_DESTROY_FUNCTION);
@@ -291,20 +332,28 @@
         }
     }
 
+    /**
+     * Set the directory
+     * @param directory directory name
+     */
     public void setDirectory(String directory) {
     }
 
+    /**
+     * Set the extension to look for
+     * @param extension the file extension associated with this Deployer
+     */
     public void setExtension(String extension) {
     }
 
     /**
      * Creates and populates an AxisService
      *
-     * @param currentFile      - A Handle to the js file
-     * @param axisServiceGroup - The AxisServiceGroup That the created service 
should be added to
-     * @param configCtx        - The Axis2 Configuration Context
-     * @return - An arrylist of AxisServices
-     * @throws DeploymentException - Thrown in case an Deployment Exception 
occurs
+     * @param currentFile A Handle to the js file
+     * @param axisServiceGroup The AxisServiceGroup That the created service 
should be added to
+     * @param configCtx The Axis2 Configuration Context
+     * @return An arrylist of AxisServices
+     * @throws DeploymentException  Thrown in case an Deployment Exception 
occurs
      */
     private ArrayList processService(DeploymentFileData currentFile,
                                      AxisServiceGroup axisServiceGroup,
@@ -316,6 +365,7 @@
             AxisService axisService = new AxisService();
 
             // org.wso2.javascript.rhino.JavaScriptReceiver needs this to load 
the javascript file
+            // in order to execute the relavant JavaScript function
             File file = currentFile.getFile();
             Parameter serviceJSParameter = new 
Parameter(JavaScriptEngineConstants.SERVICE_JS,
                                                          file);
@@ -338,8 +388,11 @@
             resourcesDir.mkdir();
 
             // creating _private folder in the resources folder to keep 
private stuff
+            // This folder can be used to keep information that the user does 
not want to share when
+            // a mashup is shared
             File privatedir = new File(resourcesDir, 
MashupConstants.MASHUP_PRIVATE_FOLDER_NAME);
             privatedir.mkdir();
+
             // Add a reference to the resources folder, as this is quite 
usefull in the runtime
             Parameter resourceFolderParameter = new Parameter(
                     JavaScriptEngineConstants.RESOURCES_FOLDER, resourcesDir);
@@ -353,20 +406,28 @@
             JavaScriptEngine engine = new JavaScriptEngine(shortFileName);
             /*
              * We inject the AxisService & ConfigContext as a workaround for 
not
-             * having the MessageContext injected in the deployment time. Some 
host objects need data from them at the
-             * initialize time.
+             * having the MessageContext injected in the deployment time. Some 
host objects need
+             * data from them at the initialize time.
              */
             
engine.getCx().putThreadLocal(JavaScriptEngineConstants.AXIS2_SERVICE, 
axisService);
             
engine.getCx().putThreadLocal(JavaScriptEngineConstants.AXIS2_CONFIGURATION_CONTEXT,
                                           configCtx);
+
+            // Load the JavaScriptHostObjects that are spefified using the 
parameter
+            // <parameter name="javascript.hostobjects"> in the axis2.xml
             JavaScriptEngineUtils.loadHostObjects(engine, 
configCtx.getAxisConfiguration());
+
+            // Load the Global JavaScriptHostObjects that are spefified using 
the parameter
+            // <parameter name="javascript.global.propertyobjects"> in the 
axis2.xml
             JavaScriptEngineUtils.loadGlobalPropertyObjects(engine, configCtx
                     .getAxisConfiguration());
+
             FileInputStream fileInputStream;
             fileInputStream = new FileInputStream(file);
             // load the service java script file 
             engine.evaluate(new BufferedReader(new 
InputStreamReader(fileInputStream)));
 
+            // Use the JavaScriptServiceAnnotationParser to extract 
serviceLevel annotations
             JavaScriptServiceAnnotationParser serviceAnnotationParser =
                     new JavaScriptServiceAnnotationParser(
                             engine, shortFileName);
@@ -374,22 +435,33 @@
             axisService.setParent(axisServiceGroup);
             axisService.setClassLoader(currentFile.getClassLoader());
             String name = serviceAnnotationParser.getServiceName();
+
+            // Checks the validity of the serviceName. If the serviceName in 
invalid an exception is
+            // thrown
             MashupUtils.validateName(name, "ServiceName");
 
             UserRealm realm = (UserRealm) 
configCtx.getAxisConfiguration().getParameterValue(
                     RegistryConstants.REGISTRY_REALM);
-            // Infer the username (The owner of this service)
+
+            // Infer the username (The author of this service)
             String username = MashupUtils.inferUserName(file, realm, name);
 
             //create a service group per service.
-            // ServiceGroup name and axisservice name will be of the form 
username-serviceName
-            // Use the js filename as the service group name.
+            // Axis2 has a flat space for services. But in the Mashup Server 
we need to support
+            // services on a per user basis, hence two users can have a 
service with the same name.
+            // To tackle this issue the mashup server sets the service name 
inside axis as
+            // authorName-serviceName. This fact is hidden from users by using 
a customDispatcher
+            // (MashupDispatcher), custom transportListeners
+            // (org.wso2.mashup.transport.http.HttpTransportListener and
+            // org.wso2.mashup.transport.http.HttpsTransportListener)
             String fileName = currentFile.getName();
             axisServiceGroup.setServiceGroupName(username + 
MashupConstants.SEPARATOR_CHAR +
                     fileName.substring(0, fileName.indexOf(".")));
             axisService.setName(username + MashupConstants.SEPARATOR_CHAR + 
name);
+
             String targetNamespace = 
serviceAnnotationParser.getTargetNamespace();
             axisService.setTargetNamespace(targetNamespace);
+
             axisService.setScope(serviceAnnotationParser.getServiceScope());
             
axisService.setDocumentation(serviceAnnotationParser.getServiceDocumentation());
 
@@ -397,9 +469,16 @@
             SchemaGenerator schemaGenerator = new 
SchemaGenerator(schemaTargetNamespace);
             axisService.setNamespaceMap(schemaGenerator.getNamespaceMap());
 
+            // The interfaceName is used by 
org.apache.axis2.description.AxisService2WSDL20 to
+            // set the interface during ?wsdl2
             String interfaceName = name + WSDL2Constants.INTERFACE_PREFIX;
             axisService.addParameter(WSDL2Constants.INTERFACE_LOCAL_NAME, 
interfaceName);
 
+            // We create the AxisBinding Hierarchy in here. In the Mashup 
Server we take complete
+            // control of the Axis2 binding hierarchy cause we need to speficy 
some HTTPBinding
+            // properties such as httpMethod and httpLocation
+
+            // Create a default SOAP 1.1 Binding
             soap11Binding = new AxisBinding();
             soap11Binding.setName(new QName(name + 
Java2WSDLConstants.BINDING_NAME_SUFFIX));
             soap11Binding.setType(WSDL2Constants.URI_WSDL2_SOAP);
@@ -409,6 +488,7 @@
                                       
SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
             soap11Binding.setProperty(WSDL2Constants.INTERFACE_LOCAL_NAME, 
interfaceName);
 
+            // Create a default SOAP 1.2 Binding
             soap12Binding = new AxisBinding();
             soap12Binding.setName(new QName(name + 
Java2WSDLConstants.SOAP12BINDING_NAME_SUFFIX));
             soap12Binding.setType(WSDL2Constants.URI_WSDL2_SOAP);
@@ -418,58 +498,75 @@
                                       
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
             soap12Binding.setProperty(WSDL2Constants.INTERFACE_LOCAL_NAME, 
interfaceName);
 
+            // Create a default HTTP Binding
             httpBinding = new AxisBinding();
             httpBinding.setName(new QName(name + 
Java2WSDLConstants.HTTP_BINDING));
             httpBinding.setType(WSDL2Constants.URI_WSDL2_HTTP);
             httpBinding.setProperty(WSDL2Constants.INTERFACE_LOCAL_NAME, 
interfaceName);
 
+            // Set a comparator so tha httpLocations are stored in decending 
order. We want the
+            // HTTPLocationBasedDiapatcher to make the best match hence we 
need them in decending
+            // order
             httpLocationTable = new TreeMap(new Comparator() {
                 public int compare(Object o1, Object o2) {
                     return (-1 * ((Comparable) o1).compareTo(o2));
                 }
             });
+
+            // Add this map to all bindings
             httpBinding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, 
httpLocationTable);
             soap11Binding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, 
httpLocationTable);
             soap12Binding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, 
httpLocationTable);
 
+            // We need to get all transports from the axis2 engine and create 
endpoints for each of
+            // those in here.
             HashMap transportsIn = axisConfig.getTransportsIn();
             Iterator iterator = transportsIn.values().iterator();
             while (iterator.hasNext()) {
+                // Used to indicate whather a HTTPEndpoint is needed. Http 
endpoint is needed only
+                // for http and https transports
                 boolean needHttp = false;
+
+                // The prefix is used to genarate endpoint names
                 String prefix = "";
                 TransportInDescription transportIn = (TransportInDescription) 
iterator.next();
-                if (transportIn.getName().equals("http")) {
+                String transportInName = transportIn.getName();
+                if (transportInName.equals("http")) {
                     needHttp = true;
-                } else if (transportIn.getName().equals("https")) {
+                } else if (transportInName.equals("https")) {
                     needHttp = true;
                     prefix = WSDL2Constants.DEFAULT_HTTPS_PREFIX;
-                } else if (transportIn.getName().equals("jms")) {
+                } else if (transportInName.equals("jms")) {
                     prefix = "JMS";
-                } else if (transportIn.getName().equals("tcp")) {
+                } else if (transportInName.equals("tcp")) {
                     prefix = "TCP";
-                } else if (transportIn.getName().equals("SMTP")) {
+                } else if (transportInName.equals("SMTP")) {
                     prefix = "smtp";
-                } else if (transportIn.getName().equals("XMPP")) {
+                } else if (transportInName.equals("XMPP")) {
                     prefix = "XMPP";
                 }
+
+                // Creates a default SOAP 1.1 endpoint
                 AxisEndpoint soap11Endpoint = new AxisEndpoint();
                 String soap11EndpointName =
                         prefix + WSDL2Constants.DEFAULT_SOAP11_ENDPOINT_NAME;
                 soap11Endpoint.setName(soap11EndpointName);
                 soap11Endpoint.setBinding(soap11Binding);
                 soap11Endpoint.setParent(axisService);
-                
soap11Endpoint.setTransportInDescription(transportIn.getName());
+                soap11Endpoint.setTransportInDescription(transportInName);
                 axisService.addEndpoint(soap11EndpointName, soap11Endpoint);
 
+                // Creates a default SOAP 1.2 endpoint
                 AxisEndpoint soap12Endpoint = new AxisEndpoint();
                 String soap12EndpointName =
                         prefix + WSDL2Constants.DEFAULT_SOAP12_ENDPOINT_NAME;
                 soap12Endpoint.setName(soap12EndpointName);
                 soap12Endpoint.setBinding(soap12Binding);
                 soap12Endpoint.setParent(axisService);
-                
soap12Endpoint.setTransportInDescription(transportIn.getName());
+                soap12Endpoint.setTransportInDescription(transportInName);
                 axisService.addEndpoint(soap12EndpointName, soap12Endpoint);
 
+                // Creates a HTTP endpoint if its http or https transport is 
used
                 if (needHttp) {
                     AxisEndpoint httpEndpoint = new AxisEndpoint();
                     String httpEndpointName =
@@ -477,7 +574,7 @@
                     httpEndpoint.setName(httpEndpointName);
                     httpEndpoint.setBinding(httpBinding);
                     httpEndpoint.setParent(axisService);
-                    
httpEndpoint.setTransportInDescription(transportIn.getName());
+                    httpEndpoint.setTransportInDescription(transportInName);
                     axisService.addEndpoint(httpEndpointName, httpEndpoint);
                 }
             }
@@ -602,21 +699,31 @@
             return;
         }
         Scriptable parent = function.getParentScope();
+
+        // In the case of this.init = function bar(){}; we dont need to 
process an operation for
+        // init hence we return here
         if (!method.equals(funcName) &&
                 parent.get(method, parent).equals(parent.get(funcName, 
parent))) {
             return;
         }
+
+        // In the case of this.init = function bar(){}; we want bar to appear 
in the WSDL
         String oriMethodName = method;
         if (funcName != null && !method.equals(funcName)) {
             method = funcName;
         }
 
+        // Extract all operation level annotations using the 
JavaScriptOperationsAnnotationParser
         JavaScriptOperationsAnnotationParser annotationParser =
                 new JavaScriptOperationsAnnotationParser(function, method);
+
         String schemaTargetNamespace = 
schemaGenerator.getSchemaTargetNamespace();
         if (annotationParser.isVisible()) {
 
             String name = annotationParser.getOperationName();
+
+            // Checks the validity of the OperationName. If the OperationName 
in invalid an
+            // exception is thrown
             MashupUtils.validateName(name, "OperationName");
 
             AxisOperation operation = axisService.getOperation(new 
QName(name));
@@ -625,6 +732,11 @@
                         "function with the name (or a function containing the 
operationNmae " +
                         "annotation as) " + name + " already exists. ");
             }
+
+            // In here we inject a special function into the JavaScript 
service that helps us
+            // convert a function to a string and get the full string 
corresponding to that function.
+            // We need that to get the order of the parameter names in that 
function. Rhino does not
+            // preserve the order of parameters as they are held in a map
             String sourceStr = "function convertToString(){ " + "var code = " 
+ oriMethodName
                             + ".toString();" + "return code;}";
                     engine.getCx().evaluateString(engine, sourceStr, "", 0, 
null);
@@ -635,18 +747,27 @@
                 throw new DeploymentException("Method " + "convertToString"
                         + " is undefined or not a function");
             }
+
             Object functionArgs[] = { };
             Function f = (Function) fObj;
+
+            // Execute our convertToString function and get the function a 
string
             Object args = f.call(engine.getCx(), engine, engine, functionArgs);
             String[] params = null;
             if (args instanceof String) {
                 String functionString = (String) args;
                 int paramStartIndex = functionString.indexOf('(');
                 int paramEndIndex = functionString.indexOf(')');
+
+                // Get the parameters of the function as a string. Parameters 
are always enclosed
+                // using braces
                 String paramString = functionString.substring(paramStartIndex 
+ 1, paramEndIndex);
+
+                // Get the paramer names by splitting them using ","
                 params = paramString.split(",");
             }
 
+            // We always assume that our operations are inout operations
             AxisOperation axisOp = new InOutAxisOperation(new QName(name));
 
             Boolean safe = annotationParser.isSafe();
@@ -656,12 +777,18 @@
             }
 
             String httpLocation = annotationParser.getHttpLocation();
+
+            // If the user did not specify a httpLocation default it to 
serviceName/operationName
+            // cause this is the default that axis2 uses
             if (httpLocation == null) {
                 httpLocation = serviceName + "/" + name;
             }
 
             String httpMethod = annotationParser.getHttpMethod();
             if (httpMethod == null) {
+
+                // If no httpMethod is specified we look for the safely 
annotation. If an operation
+                // is marked as safe then the httpMethod defults to GET else 
its POST
                 if (safe != null && safe.booleanValue()) {
                     httpMethod = HTTPConstants.HEADER_GET;
                 } else {
@@ -669,18 +796,21 @@
                 }
             }
 
+            // Create a default SOAP 1.1 Binding operation
             AxisBindingOperation soap11BindingOperation = new 
AxisBindingOperation();
             soap11BindingOperation.setAxisOperation(axisOp);
             soap11BindingOperation.setName(axisOp.getName());
             soap11BindingOperation.setParent(soap11Binding);
             
soap11BindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, 
httpLocation);
 
+            // Create a default SOAP 1.2 Binding operation
             AxisBindingOperation soap12BindingOperation = new 
AxisBindingOperation();
             soap12BindingOperation.setAxisOperation(axisOp);
             soap12BindingOperation.setName(axisOp.getName());
             soap12BindingOperation.setParent(soap12Binding);
             
soap12BindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, 
httpLocation);
 
+            // Create a default HTTP Binding operation
             AxisBindingOperation httpBindingOperation = new 
AxisBindingOperation();
             httpBindingOperation.setAxisOperation(axisOp);
             httpBindingOperation.setName(axisOp.getName());
@@ -688,6 +818,8 @@
             
httpBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, 
httpLocation);
             httpBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_METHOD, 
httpMethod);
 
+            // We need to extract a constant value from the httpLocation so 
that the
+            // httpLocationBasedDispatcher can use that value to dispatch to 
the correct operation
             String httpLocationString =
                     RESTUtil.getConstantFromHTTPLocation(httpLocation, 
httpMethod);
             httpLocationTable.put(httpLocationString, axisOp);
@@ -699,6 +831,9 @@
             if (!targetNamespace.endsWith("/")) {
                 targetNamespace = targetNamespace + "/";
             }
+
+            // Calculate the values for input and output actions according to
+            // http://www.w3.org/TR/ws-addr-wsdl/#defactionwsdl20
             String inputAction =
                     targetNamespace + WSDL2Constants.DEFAULT_INTERFACE_NAME + 
"/" + name +
                             Java2WSDLConstants.REQUEST;
@@ -709,16 +844,23 @@
             
soap11BindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_ACTION, 
inputAction);
             
soap12BindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_ACTION, 
inputAction);
             axisOp.setOutputAction(outAction);
-            //set the org.wso2.javascript.rhino.JavaScriptReceiver as the MR 
for this operation
+
+            //set the org.wso2.javascript.rhino.JavaScriptReceiver as the 
MessageReceiver for this
+            // operation
             axisOp.setMessageReceiver(new JavaScriptReceiver());
             axisOp.setStyle(WSDLConstants.STYLE_DOC);
             axisOp.setDocumentation(annotationParser.getDocumentation());
 
+            // This is needed in case the user used the "operationName" 
annoatation. for e.g if the
+            // following was used
+            // foo.operationName="bar";
+            // function foo () {};
+            // The WSDL will show bar but ehen a request come in we should be 
executing foo instead.
             Parameter jsFunctionNameParamter = new Parameter(
                     JavaScriptEngineConstants.JS_FUNCTION_NAME, oriMethodName);
             axisOp.addParameter(jsFunctionNameParamter);
 
-
+            // Create the in and out axis messages for this operation
             AxisMessage inMessage = 
axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
             Object inputTypes = annotationParser.getInputTypesNameObject();
             if (inMessage != null) {
@@ -729,6 +871,9 @@
                 
soap11BindingOperation.addChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE, 
inBindingMessage);
                 
soap12BindingOperation.addChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE, 
inBindingMessage);
                 
httpBindingOperation.addChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE, 
inBindingMessage);
+
+                // Genarate the input element for the input message using the 
"inputTypes'
+                // annotation specified by the user
                 XmlSchemaElement element =
                         schemaGenerator.createInputElement(inMessage, 
inputTypes, name,
                                                            params, method);
@@ -736,6 +881,7 @@
                     inMessage.setElementQName(new QName(schemaTargetNamespace, 
element.getName()));
                 }
             }
+
             AxisMessage outMessage = 
axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
             Object outputType = annotationParser.getOutputTypeNameObject();
 
@@ -749,6 +895,9 @@
                 
soap11BindingOperation.addChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE, 
outBindingMessage);
                 
soap12BindingOperation.addChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE, 
outBindingMessage);
                 
httpBindingOperation.addChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE, 
outBindingMessage);
+
+                // Genarate the output element for the input message using the 
"outputType'
+                // annotation specified by the user
                 XmlSchemaElement element =
                         schemaGenerator.createOutputElement(outMessage, 
outputType, name,
                                                             params, method);

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

Reply via email to