Author: keith
Date: Thu Apr 24 05:18:11 2008
New Revision: 16107
Log:
Getting rid of inline strings and introducing constants as per the code review
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JavaScriptOperationsAnnotationParser.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
Thu Apr 24 05:18:11 2008
@@ -183,6 +183,36 @@
// function foo () {}
public static String OPERATION_NAME_ANNOTATION = "operationName";
+ // The value that is used by the javascript visible annotation.
+ // e.g foo.visible = false
+ // function foo () {}
+ public static String VISIBLE_ANNOTATION = "visible";
+
+ // The value that is used by the javascript safe annotation.
+ // e.g foo.safe = true";
+ // function foo () {}
+ public static String SAFE_ANNOTATION = "safe";
+
+ // The value that is used by the javascript inputTypes annotation.
+ // e.g foo.inputTypes = "string";
+ // function foo (a) {}
+ public static String INPUT_TYPES_ANNOTATION = "inputTypes";
+
+ // The value that is used by the javascript outputType annotation.
+ // e.g foo.outputType = "string";
+ // function foo () {}
+ public static String OUTPUT_TYPE_ANNOTATION = "outputType";
+
+ // The value that is used by the javascript httpMethod annotation.
+ // e.g foo.httpMethod = "GET";
+ // function foo () {}
+ public static String HTTP_METHOD_ANNOTATION = "httpMethod";
+
+ // The value that is used by the javascript httpLocation annotation.
+ // e.g foo.httpLocation = "foo/{a}";
+ // function foo (a) {}
+ public static String HTTP_LOCATION_ANNOTATION = "httpLocation";
+
// The value that is used by the javascript deployer as the prefix for the
default target
// namespaces. The target namespace will be of the form
// "http://services.mashup.wso2.org/" + serviceName and the
schemaTargetNamespace will be of the
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
Thu Apr 24 05:18:11 2008
@@ -25,6 +25,7 @@
import org.mozilla.javascript.Undefined;
import org.mozilla.javascript.UniqueTag;
import org.wso2.javascript.xmlimpl.XML;
+import org.wso2.mashup.MashupConstants;
import org.wso2.mashup.utils.MashupUtils;
/**
@@ -95,11 +96,12 @@
throws DeploymentException {
// Check weather the user marked this operation as visible or not
- Object visibleObject = function.get("visible", function);
+ Object visibleObject =
function.get(MashupConstants.VISIBLE_ANNOTATION, function);
visible = MashupUtils.isJSObjectTrue(visible, visibleObject);
// Check weather the user provided a operationName
- Object operationNameObject = function.get("operationName", function);
+ Object operationNameObject =
function.get(MashupConstants.OPERATION_NAME_ANNOTATION,
+ function);
if (operationNameObject instanceof String) {
String operationNameString = ((String) operationNameObject).trim();
if (operationNameString.indexOf(' ') > -1) {
@@ -112,13 +114,13 @@
}
// Check weather the user provided inputTypes
- inputTypesNameObject = function.get("inputTypes", function);
+ inputTypesNameObject =
function.get(MashupConstants.INPUT_TYPES_ANNOTATION, function);
// Check weather the user provided a outputType
- outputTypeNameObject = function.get("outputType", function);
+ outputTypeNameObject =
function.get(MashupConstants.OUTPUT_TYPE_ANNOTATION, function);
// Check weather the user marked this operation as been safe
- Object safeObject = function.get("safe", function);
+ Object safeObject = function.get(MashupConstants.SAFE_ANNOTATION,
function);
if (safeObject == null || safeObject instanceof Undefined ||
safeObject instanceof UniqueTag) {
safe = null;
@@ -129,7 +131,8 @@
// 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);
+ Object documentationObject =
function.get(MashupConstants.DOCUMENTATION_ANNOTATION,
+ function);
if (documentationObject instanceof String) {
this.documentation = omFactory.createOMText((String)
documentationObject);
} else if (documentationObject instanceof XML) {
@@ -138,7 +141,7 @@
}
// Check weather the user provided a httpMethod
- Object httpMethodObject = function.get("httpMethod", function);
+ Object httpMethodObject =
function.get(MashupConstants.HTTP_METHOD_ANNOTATION, function);
if (httpMethodObject instanceof String) {
String httpMethodString = ((String) httpMethodObject).trim();
if (!(HTTPConstants.HEADER_GET.equalsIgnoreCase(httpMethodString)
||
@@ -154,7 +157,8 @@
}
// Check weather the user provided a httpLocation
- Object httpLocationObject = function.get("httpLocation", function);
+ Object httpLocationObject =
function.get(MashupConstants.HTTP_LOCATION_ANNOTATION,
+ function);
if (httpLocationObject instanceof String) {
httpLocation = ((String) httpLocationObject).trim();
}
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev