diff options
author | fmoga <fmoga@13f79535-47bb-0310-9956-ffa450edef68> | 2011-07-26 21:10:39 +0000 |
---|---|---|
committer | fmoga <fmoga@13f79535-47bb-0310-9956-ffa450edef68> | 2011-07-26 21:10:39 +0000 |
commit | 24eb985532c90f1fa09a6c4672ced19e63627fc9 (patch) | |
tree | 08976324ed6b64d827bd3283dca0c77859ebbbb6 /sca-java-2.x/trunk/modules/binding-websocket/src/main/resources | |
parent | 74d9cac502ce78872317dcebe18deec3f8b37fdd (diff) |
Move the websocket binding to trunk.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1151250 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-websocket/src/main/resources')
6 files changed, 167 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.websocket.WebsocketBindingFactory b/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.websocket.WebsocketBindingFactory new file mode 100644 index 0000000000..4ec8ba4eb2 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.websocket.WebsocketBindingFactory @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for model factory
+org.apache.tuscany.sca.binding.websocket.WebsocketBindingFactory
+
diff --git a/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..fd2e21a468 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.websocket,model=org.apache.tuscany.sca.binding.websocket.WebsocketBinding,factory=org.apache.tuscany.sca.binding.websocket.WebsocketBindingFactory
+
diff --git a/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema new file mode 100644 index 0000000000..d4a7646f48 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+binding-websocket.xsd
+
diff --git a/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..e97707636d --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.websocket.runtime.WebsocketBindingProviderFactory;model=org.apache.tuscany.sca.binding.websocket.WebsocketBinding
+
diff --git a/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/binding-websocket.xsd b/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/binding-websocket.xsd new file mode 100644 index 0000000000..8ed0011361 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/binding-websocket.xsd @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" />
+
+ <element name="binding.websocket" type="t:WebsocketBinding" substitutionGroup="sca:binding"/>
+
+ <complexType name="WebsocketBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <attribute name="port" type="string" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/js/TuscanyWebsocketToolkit.js b/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/js/TuscanyWebsocketToolkit.js new file mode 100644 index 0000000000..ede28579d3 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-websocket/src/main/resources/js/TuscanyWebsocketToolkit.js @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +var channels = []; + +function buildRequest(operation, message) { + return JSON.stringify({ + operation: operation, + payload: JSON.stringify(message) + }); +} + +function sendMessage(port, operation, message) { + if (!channels[port]) { + ws = new WebSocket("ws://" + window.location.hostname + ":" + port); + channels[port] = ws; + ws.onopen = function() { + $(document).trigger('' + port); + } + ws.onmessage = function (message) { + var response = eval('(' + message.data + ')'); + eval('Tuscany.WebsocketComponentContext.' + response.operation + '.responseHandler(' + response.payload + ')'); + } + } + + var jsonReq = buildRequest(operation, message); + + if (ws.readyState == WebSocket.CONNECTING) { + $(document).bind('' + port, jsonReq, function(event) { + ws.send(event.data); + }); + } else if (ws.readyState == WebSocket.OPEN) { + ws.send(jsonReq); + } +}
\ No newline at end of file |