Author: keith
Date: Tue Apr 22 19:20:14 2008
New Revision: 15986
Log:
Adding some javadoc
Modified:
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JavaScriptOperationsAnnotationParser.java
Modified:
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JavaScriptOperationsAnnotationParser.java
==============================================================================
---
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JavaScriptOperationsAnnotationParser.java
(original)
+++
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JavaScriptOperationsAnnotationParser.java
Tue Apr 22 19:20:14 2008
@@ -37,18 +37,19 @@
* //operation level annotations
* reverse.visible = true;
* reverse.safe = true;
- * reverse.operationName = "swap";
+ * reverse.operationName = "swap";
* reverse.inputTypes = {
- * "first" : "string",
- * "second" : "string"
+ * "first" : "string";,
+ * "second" : "string"
* }
- * reverse.outputType = "anyType";
- * reverse.documentation =Simple string or html markup (xml node, xml
nodelist);
- * <p/>
+ * reverse.outputType = "any";
+ * reverse.documentation = "Simple string or html markup (xml node, xml
nodelist)";
+ * reverse.httpMethod = "GET";
+ * reverse.httpLocation = "reverse/{first}/{second}";
+ *
* function reverse(first, last) {
- * return (<result>{last + first}</result>);
+ * return (last + " " + first);
* }
- * </pre>
* <p/>
* For more details visit <a
*
href="http://www.wso2.org/wiki/display/mashup/Javascript+Web+Service+Annotations">JavaScript
@@ -56,30 +57,47 @@
*/
public class JavaScriptOperationsAnnotationParser {
+ // Holds the value for visible annotation
private boolean visible = true;
+ // Holds the value for safe annotation
private Boolean safe;
+ // Holds the value for operationName annotation
private String operationName = null;
+ // Holds the value for inputTypes annotation
private Object inputTypesNameObject = null;
+ // Holds the value for outputType annotation
private Object outputTypeNameObject = null;
+ // Holds the value for documentation annotation
private OMNode documentation;
- private OMFactory omFactory = OMAbstractFactory.getOMFactory();
-
+ // Holds the value for httpMethod annotation
private String httpMethod = null;
+ // Holds the value for httpLocation annotation
private String httpLocation = null;
+ private OMFactory omFactory = OMAbstractFactory.getOMFactory();
+
+ /**
+ * Given a JavaScript function object and functionName extract all the
defined annotations and
+ * populates its private variables
+ * @param function The JavaScript function object
+ * @param functionName The JavaScript function name
+ * @throws DeploymentException Thrown in case any annotations are not in
the expected form
+ */
public JavaScriptOperationsAnnotationParser(Function function, String
functionName)
throws DeploymentException {
+ // Check weather the user marked this operation as visible or not
Object visibleObject = function.get("visible", function);
visible = MashupUtils.isJSObjectTrue(visible, visibleObject);
+ // Check weather the user provided a operationName
Object operationNameObject = function.get("operationName", function);
if (operationNameObject instanceof String) {
String operationNameString = ((String) operationNameObject).trim();
@@ -92,10 +110,13 @@
operationName = functionName;
}
+ // Check weather the user provided inputTypes
inputTypesNameObject = function.get("inputTypes", function);
+ // Check weather the user provided a outputType
outputTypeNameObject = function.get("outputType", function);
+ // Check weather the user marked this operation as been safe
Object safeObject = function.get("safe", function);
if (safeObject == null || safeObject instanceof Undefined ||
safeObject instanceof UniqueTag) {
@@ -103,6 +124,10 @@
} else {
safe = Boolean.valueOf(MashupUtils.isJSObjectTrue(true,
safeObject));
}
+
+ // Check weather the user provided some operation level documentation.
If the documentation
+ // is a String we wrap it as a OMText. Else if its an E4X XML object
we get the axiom from
+ // it and set that as the documentation.
Object documentationObject = function.get("documentation", function);
if (documentationObject instanceof String) {
this.documentation = omFactory.createOMText((String)
documentationObject);
@@ -111,6 +136,7 @@
this.documentation = xml.getAxiomFromXML();
}
+ // Check weather the user provided a httpMethod
Object httpMethodObject = function.get("httpMethod", function);
if (httpMethodObject instanceof String) {
String httpMethodString = ((String) httpMethodObject).trim();
@@ -122,41 +148,74 @@
httpMethod = httpMethodString;
}
+ // Check weather the user provided a httpLocation
Object httpLocationObject = function.get("httpLocation", function);
if (httpLocationObject instanceof String) {
httpLocation = ((String) httpLocationObject).trim();
}
}
+ /**
+ * Getter for operationName
+ * @return String representing the operationName
+ */
public String getOperationName() {
return operationName;
}
+ /**
+ * Getter for visible
+ * @return boolean representing visibility of the function
+ */
public boolean isVisible() {
return visible;
}
+ /**
+ * Getter for outputType
+ * @return Object A Javascript object that conatins the outputType
annotation value
+ */
public Object getOutputTypeNameObject() {
return outputTypeNameObject;
}
+ /**
+ * Getter for inputTypes
+ * @return Object A Javascript object that conatins the inputTypes
annotation value
+ */
public Object getInputTypesNameObject() {
return inputTypesNameObject;
}
+ /**
+ * Getter for safe
+ * @return Boolean representing the safety of the function
+ */
public Boolean isSafe() {
return safe;
}
+ /**
+ * Getter for documentation
+ * @return OMNode representing the documentation of the operation
+ */
public OMNode getDocumentation() {
return documentation;
}
+ /**
+ * Getter for httpMethod
+ * @return String representing the httpMethod
+ */
public String getHttpMethod() {
return httpMethod;
}
+ /**
+ * Getter for httpLocation
+ * @return String representing the httpLocation
+ */
public String getHttpLocation() {
return httpLocation;
}
-}
+}
\ No newline at end of file
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev