cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r652100 - in /cxf/trunk: api/src/main/java/org/apache/cxf/service/model/ rt/core/src/main/java/org/apache/cxf/service/ rt/javascript/src/main/java/org/apache/cxf/javascript/ rt/javascript/src/main/java/org/apache/cxf/javascript/service/ rt/...
Date Tue, 29 Apr 2008 20:50:48 GMT
Author: bimargulies
Date: Tue Apr 29 13:50:47 2008
New Revision: 652100

URL: http://svn.apache.org/viewvc?rev=652100&view=rev
Log:
Fix cxf-1555 and cxf-1554.

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceModelVisitor.java
    cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java
    cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
    cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
    cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
    cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java
    cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitBareTests.js
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java
    cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java?rev=652100&r1=652099&r2=652100&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java Tue Apr 29
13:50:47 2008
@@ -24,6 +24,9 @@
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.apache.cxf.wsdl.EndpointReferenceUtils;
 
+/**
+ * The EndpointInfo contains the information for a web service 'port' inside of a service.
+ */
 public class EndpointInfo extends AbstractDescriptionElement implements NamedItem {
     String transportId;
     ServiceInfo service;

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceModelVisitor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceModelVisitor.java?rev=652100&r1=652099&r2=652100&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceModelVisitor.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceModelVisitor.java Tue Apr
29 13:50:47 2008
@@ -18,6 +18,8 @@
  */
 package org.apache.cxf.service;
 
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.FaultInfo;
 import org.apache.cxf.service.model.InterfaceInfo;
 import org.apache.cxf.service.model.MessageInfo;
@@ -47,7 +49,9 @@
  * 3.9) end the unwrapped operation.
  * 4) end the operation.
  * 5) end the interface.
- * 6) end the service info.
+ * 6) For each endpoint (= port) begin and end the EndpointInfo
+ * 7) For each binding (= BindingInfo) begin and end the BindingInfo.
+ * 8) end the service info.
  * </pre>
  * Unwrapped operations <i>share messages</i> with their corresponding wrapped
messages,
  * so beware of processing the same messages twice as if unique.
@@ -73,6 +77,14 @@
         }
         
         end(serviceInfo.getInterface());
+        for (EndpointInfo endpointInfo : serviceInfo.getEndpoints()) {
+            begin(endpointInfo);
+            end(endpointInfo);
+        }
+        for (BindingInfo bindingInfo : serviceInfo.getBindings()) {
+            begin(bindingInfo);
+            end(bindingInfo);
+        }
         end(serviceInfo);
     }
 
@@ -148,4 +160,12 @@
     }
     public void end(FaultInfo fault) {
     }
+    public void begin(EndpointInfo endpointInfo) {
+    }
+    public void end(EndpointInfo endpointInfo) {
+    }
+    private void begin(BindingInfo bindingInfo) {
+    }
+    private void end(BindingInfo bindingInfo) {
+    }
 }

Modified: cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java?rev=652100&r1=652099&r2=652100&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java
(original)
+++ cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java
Tue Apr 29 13:50:47 2008
@@ -137,6 +137,7 @@
                 }
 
                 ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo,
+                                                                                       endpoint.getAddress(),
                                                                                        prefixManager,
                                                                                        nameManager);
                 serviceBuilder.walk();

Modified: cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java?rev=652100&r1=652099&r2=652100&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
(original)
+++ cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
Tue Apr 29 13:50:47 2008
@@ -46,6 +46,7 @@
 import org.apache.cxf.javascript.XmlSchemaUtils;
 import org.apache.cxf.service.ServiceModelVisitor;
 import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.FaultInfo;
 import org.apache.cxf.service.model.InterfaceInfo;
 import org.apache.cxf.service.model.MessageInfo;
@@ -66,6 +67,9 @@
 import org.apache.ws.commons.schema.XmlSchemaSimpleType;
 import org.apache.ws.commons.schema.XmlSchemaType;
 
+/**
+ * Class to construct the JavaScript corresponding to a service.
+ */
 public class ServiceJavascriptBuilder extends ServiceModelVisitor {
     private static final Logger LOG = LogUtils.getL7dLogger(ServiceJavascriptBuilder.class);
 
@@ -79,6 +83,8 @@
     private Set<MessageInfo> inputMessagesWithNameConflicts;
     private Set<MessageInfo> outputMessagesWithNameConflicts;
     private SchemaCollection xmlSchemaCollection;
+    // When generating from a tool or ?js, we know the endpoint addr and can build it into
the javascript.
+    private String endpointAddress;
     
     private boolean isWrapped;
     // facts about the wrapper when there is one.
@@ -110,9 +116,19 @@
     private boolean nonVoidOutput;
     private boolean isRPC;
 
-    public ServiceJavascriptBuilder(ServiceInfo serviceInfo, NamespacePrefixAccumulator prefixAccumulator,
+    /**
+     * Construct builder object.
+     * @param serviceInfo CXF service model description of the service.
+     * @param endpointAddress http:// URL for the service, or null if not known.
+     * @param prefixAccumulator object that keeps track of prefixes through an entire WSDL.
+     * @param nameManager object that generates names for JavaScript objects.
+     */
+    public ServiceJavascriptBuilder(ServiceInfo serviceInfo,
+                                    String endpointAddress,
+                                    NamespacePrefixAccumulator prefixAccumulator,
                                     NameManager nameManager) {
         super(serviceInfo);
+        this.endpointAddress = endpointAddress;
         code = new StringBuilder();
         utils = new JavascriptUtils(code);
         this.nameManager = nameManager;
@@ -144,7 +160,11 @@
         utils.appendLine("this.jsutils = new CxfApacheOrgUtil();");
         utils.appendLine("this.jsutils.interfaceObject = this;");
         utils.appendLine("this.synchronous = false;");
-        utils.appendLine("this.url = null;");
+        if (endpointAddress != null) {
+            utils.appendLine("this.url = '" + endpointAddress + "';");
+        } else {
+            utils.appendLine("this.url = null;");
+        }
         utils.appendLine("this.client = null;");
         utils.appendLine("this.response = null;");
         // the callback functions for a pending operation are stored in these.
@@ -927,5 +947,16 @@
         nameMap.put(msg.getName().getLocalPart(), msg);
     }
 
+    @Override
+    public void begin(EndpointInfo endpointInfo) {
+        String address = endpointInfo.getAddress();
+        String portClassName = currentInterfaceClassName + "_" 
+            + nameManager.getJavascriptName(endpointInfo.getName());
+        code.append("function " + portClassName + " () {\n");
+        code.append("  this.url = '" + address + "';\n");
+        code.append("}\n");
+        code.append(portClassName + ".prototype = new " + currentInterfaceClassName + ";\n");
+    }
+
 
 }

Modified: cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js?rev=652100&r1=652099&r2=652100&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js (original)
+++ cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js Tue
Apr 29 13:50:47 2008
@@ -18,8 +18,7 @@
 // This code is structured on to require a 'new' of an object of type
 // CxfApacheOrgUtil.
 // Alternative, it could be made 'static', but this allowed us to use this same
-// object
-// to carry some state.
+// object to carry some state.
 var org_apache_cxf_XSI_namespace_uri = "http://www.w3.org/2001/XMLSchema-instance";
 var org_apache_cxf_XSD_namespace_uri = "http://www.w3.org/2001/XMLSchema";
 
@@ -27,8 +26,7 @@
 }
 
 function CxfApacheOrgUtil() {
-	this.ELEMENT_NODE = 1;
-
+	// Set up tracing if there is a trace object.
 	if ("function" == typeof(org_apache_cxf_trace)) {
 		this.trace = org_apache_cxf_trace.trace;
 	} else {
@@ -36,6 +34,9 @@
 	}
 }
 
+// define a constant for the DOM node type for an element.
+CxfApacheOrgUtil.prototype.ELEMENT_NODE = 1;
+
 // compensate for Microsoft's weakness here.
 function org_apache_cxf_getNodeLocalName(node) {
 	if ("localName" in node) {
@@ -64,6 +65,7 @@
 	return namespaceURI;
 }
 
+// Search through the attributes of one node to find a namespace prefix definition.
 function org_apache_cxf_findNamespace(elementNode, namespacePrefix) {
 	var attributes = elementNode.attributes;
 	if ((attributes != null) && (attributes.length > 0)) {
@@ -85,6 +87,7 @@
 	}
 }
 
+// Get namespace for a node.
 function org_apache_cxf_get_node_namespaceURI(elementNode) {
 	var prefix = org_apache_cxf_getPrefix(elementNode.nodeName);
 	return org_apache_cxf_getNamespaceURI(elementNode, prefix);
@@ -92,6 +95,9 @@
 
 CxfApacheOrgUtil.prototype.getElementNamespaceURI = org_apache_cxf_get_node_namespaceURI;
 
+// Supprt functions for xsd:any start here.
+
+// Object that can test an element against an 'any' specification.
 function org_apache_cxf_any_ns_matcher(style, tns, nslist, nextLocalPart) {
 	this.style = style;
 	this.tns = tns;
@@ -178,6 +184,7 @@
 
 CxfApacheOrgUtil.prototype.escapeXmlEntities = org_apache_cxf_escapeXmlEntities;
 
+// Is an element xsi:nil? Note, in IE this requires the use of the prefix 'xsi', literally.
 function org_apache_cxf_isElementNil(node) {
 	if (node == null)
 		throw "null node passed to isElementNil";
@@ -239,7 +246,7 @@
 CxfApacheOrgUtil.prototype.isNodeNamedNS = org_apache_cxf_isNodeNamedNS;
 
 // Firefox splits large text regions into multiple Text objects (4096 chars in
-// each).
+// each). Glue it back together.
 function org_apache_cxf_getNodeText(node) {
 	var r = "";
 	for (var x = 0;x < node.childNodes.length; x++) {
@@ -460,12 +467,9 @@
 	return plaintext;
 }
 
-// var placeholder = '<xop:Include
-// xmlns:xop="http://www.w3.org/2004/08/xop/include" '
-// + 'href="cid:' + uuid + '" />';
-// var mtomObject = 'Content-Type: text/plain; charset="utf-8";\r\nContent-ID:
-// <'
-// + uuid + '>\r\n\r\n' + value + '\r\n';
+// MTOM deserialization.
+// This assumes that the only content type it will be asked to deal with is text/plain;charset=utf-8.
+// This only handles cid: xop URNs.
 
 var org_apache_cxf_XOP_NS = 'http://www.w3.org/2004/08/xop/include';
 
@@ -505,10 +509,10 @@
 }
 
 CxfApacheOrgUtil.prototype.deserializeBase64orMom = org_apache_cxf_deserialize_MTOM_or_base64;
+
 /*
  * Client object sends requests and calls back with responses.
  */
-
 function CxfApacheOrgClient(utils) {
 	utils.trace("Client constructor");
 	this.utils = utils;
@@ -656,7 +660,8 @@
 		this.req.setRequestHeader("Content-Type", ctHeader);
 
 	} else {
-		this.req.setRequestHeader("Content-Type", "application/xml");
+	// for now, assume SOAP 1.1. 1.2 calls for application/xml. 
+		this.req.setRequestHeader("Content-Type", "text/xml");
 	}
 
 	if (headers) { // must be array indexed by header field.
@@ -943,7 +948,7 @@
 	}
 }
 
-// return the an object if we can deserialize an object, otherwise return the
+// Return an object if we can deserialize an object, otherwise return the
 // element itself.
 function org_apache_cxf_deserialize_anyType(cxfjsutils, element) {
 	var type = org_apache_cxf_get_xsi_type(element);

Modified: cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java?rev=652100&r1=652099&r2=652100&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
(original)
+++ cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
Tue Apr 29 13:50:47 2008
@@ -238,6 +238,35 @@
             }
         });
     }
+    
+    private Void portObjectCaller(Context context) {
+        LOG.info("About to call portObjectTest " + getAddress());
+        Notifier notifier = 
+            testUtilities.rhinoCallConvert("portObjectTest", Notifier.class);
+
+        boolean notified = notifier.waitForJavascript(1000 * 10);
+        assertTrue(notified);
+        Integer errorStatus = testUtilities.rhinoEvaluateConvert("globalErrorStatus", Integer.class);
+        assertNull(errorStatus);
+        String errorText = testUtilities.rhinoEvaluateConvert("globalErrorStatusText", String.class);
+        assertNull(errorText);
+
+        //This method returns a String
+        Scriptable response = (Scriptable)testUtilities.rhinoEvaluate("globalResponseObject");
+        String item = testUtilities.rhinoCallMethodConvert(String.class, response, "getStringItem");
+        assertEquals("horsefeathers", item);
+        return null;
+    }
+    
+    @Test
+    public void callPortObject() {
+        LOG.info("about to call portObject");
+        testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
+            public Void run(Context context) {
+                return portObjectCaller(context);
+            }
+        });
+    }
 
     public static Scriptable testBean1ToJS(JavascriptTestUtilities testUtilities,
                                            Context context, 

Modified: cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java?rev=652100&r1=652099&r2=652100&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java
(original)
+++ cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java
Tue Apr 29 13:50:47 2008
@@ -363,7 +363,9 @@
             readStringIntoRhino(allThatJavascript, schema.toString() + ".js");
         }
 
-        ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo,
prefixManager,
+        ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo,

+                                                                               null,
+                                                                               prefixManager,
                                                                                nameManager);
         serviceBuilder.walk();
         String serviceJavascript = serviceBuilder.getCode();

Modified: cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitBareTests.js
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitBareTests.js?rev=652100&r1=652099&r2=652100&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitBareTests.js
(original)
+++ cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitBareTests.js
Tue Apr 29 13:50:47 2008
@@ -89,7 +89,7 @@
 
 function compliantNoArgsTest(url)
 {
-	org_apache_cxf_trace.trace("Enter compliantArgsTest.");
+	org_apache_cxf_trace.trace("Enter compliantNoArgsTest.");
 	resetGlobals();
 	globalNotifier = new org_apache_cxf_notifier();
 	
@@ -103,6 +103,21 @@
 	return globalNotifier;
 }
 
+// a test of depending on the URL taken from the service model.
+function portObjectTest()
+{
+	org_apache_cxf_trace.trace("Enter portObjectTest.");
+	resetGlobals();
+	globalNotifier = new org_apache_cxf_notifier();
+	
+	var intf = 
+	   new org_apache_cxf_javascript_fortest_SimpleDocLitBare_org_apache_cxf_javascript_fortest_SimpleDocLitBareImplPort();
+    intf.compliantNoArgs(test1SuccessCallback, test1ErrorCallback); 
+    // Return the notifier as a convenience to the Java code.
+	return globalNotifier;
+}
+
+
 function actionMethodTest(url, param)
 {
 	org_apache_cxf_trace.trace("Enter actionMethodTest.");

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java?rev=652100&r1=652099&r2=652100&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java
Tue Apr 29 13:50:47 2008
@@ -128,7 +128,9 @@
                 writer.append(allThatJavascript);
             }
 
-            ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo,
prefixManager,
+            ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo,

+                                                                                   null,
+                                                                                   prefixManager,
                                                                                    nameManager);
             serviceBuilder.walk();
             String serviceJavascript = serviceBuilder.getCode();

Modified: cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java?rev=652100&r1=652099&r2=652100&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java
(original)
+++ cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java
Tue Apr 29 13:50:47 2008
@@ -73,7 +73,9 @@
                 writer.append(allThatJavascript);
             }
 
-            ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo,
prefixManager,
+            ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo,

+                                                                                   null,
+                                                                                   prefixManager,
                                                                                    nameManager);
             serviceBuilder.walk();
             String serviceJavascript = serviceBuilder.getCode();



Mime
View raw message