flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlosrov...@apache.org
Subject git commit: [flex-asjs] [refs/heads/feature/amf] - Network AMF RemoteObject and Events
Date Sat, 18 Feb 2017 16:27:11 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/feature/amf a8afc4eb3 -> e3bfc5582


Network AMF RemoteObject and Events


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/e3bfc558
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/e3bfc558
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/e3bfc558

Branch: refs/heads/feature/amf
Commit: e3bfc5582e65e66da7cd448ee5ed7ddfaf3b550b
Parents: a8afc4e
Author: Carlos Rovira <carlosrovira@apache.org>
Authored: Sat Feb 18 17:27:07 2017 +0100
Committer: Carlos Rovira <carlosrovira@apache.org>
Committed: Sat Feb 18 17:27:07 2017 +0100

----------------------------------------------------------------------
 frameworks/projects/Network/.vscode/tasks.json  |   9 ++
 frameworks/projects/Network/pom.xml             |  14 +++
 .../src/main/config/compile-as-config.xml       |   1 +
 .../Network/src/main/flex/NetworkClasses.as     |  26 ++--
 .../flex/org/apache/flex/net/RemoteObject.as    | 123 +++++++++++++++++++
 .../org/apache/flex/net/events/FaultEvent.as    |  35 ++++++
 .../org/apache/flex/net/events/ResultEvent.as   |  34 +++++
 .../src/main/resources/basic-manifest.xml       |   1 +
 8 files changed, 230 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e3bfc558/frameworks/projects/Network/.vscode/tasks.json
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/.vscode/tasks.json b/frameworks/projects/Network/.vscode/tasks.json
new file mode 100644
index 0000000..e562c32
--- /dev/null
+++ b/frameworks/projects/Network/.vscode/tasks.json
@@ -0,0 +1,9 @@
+{
+	// See https://go.microsoft.com/fwlink/?LinkId=733558
+	// for the documentation about the tasks.json format
+	"version": "0.1.0",
+	"command": "mvn",
+	"args": ["clean", "install", "-DskipTests"],
+	"isShellCommand": true,
+	"showOutput": "always"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e3bfc558/frameworks/projects/Network/pom.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/pom.xml b/frameworks/projects/Network/pom.xml
index b13cf88..87ae73f 100644
--- a/frameworks/projects/Network/pom.xml
+++ b/frameworks/projects/Network/pom.xml
@@ -69,6 +69,20 @@
       <type>swc</type>
       <classifier>typedefs</classifier>
     </dependency>
+    <dependency>
+      <groupId>org.apache.flex.flexjs.framework</groupId>
+      <artifactId>Reflection</artifactId>
+      <version>0.8.0-SNAPSHOT</version>
+      <type>swc</type>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.flex.flexjs.framework</groupId>
+      <artifactId>Reflection</artifactId>
+      <version>0.8.0-SNAPSHOT</version>
+      <type>swc</type>
+      <classifier>typedefs</classifier>
+    </dependency>
+    
   </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e3bfc558/frameworks/projects/Network/src/main/config/compile-as-config.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/src/main/config/compile-as-config.xml b/frameworks/projects/Network/src/main/config/compile-as-config.xml
index 591d4c8..0e0aa9a 100644
--- a/frameworks/projects/Network/src/main/config/compile-as-config.xml
+++ b/frameworks/projects/Network/src/main/config/compile-as-config.xml
@@ -24,6 +24,7 @@
         <external-library-path>
             <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element>
             <path-element>../../../../../libs/Core.swc</path-element>
+            <path-element>../../../../../libs/Reflection.swc</path-element>
         </external-library-path>
         
 		<mxml>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e3bfc558/frameworks/projects/Network/src/main/flex/NetworkClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/src/main/flex/NetworkClasses.as b/frameworks/projects/Network/src/main/flex/NetworkClasses.as
index a649df0..aeb8e42 100644
--- a/frameworks/projects/Network/src/main/flex/NetworkClasses.as
+++ b/frameworks/projects/Network/src/main/flex/NetworkClasses.as
@@ -18,18 +18,18 @@
 ////////////////////////////////////////////////////////////////////////////////
 package
 {   
-
-/**
- *  @private
- *  This class is used to link additional classes into rpc.swc
- *  beyond those that are found by dependecy analysis starting
- *  from the classes specified in manifest.xml.
- */
-internal class NetworkClasses
-{	
-    import org.apache.flex.net.URLBinaryLoader; URLBinaryLoader;
-	import org.apache.flex.net.HTTPConstants; HTTPConstants;
-}
-
+    /**
+    *  @private
+    *  This class is used to link additional classes into Network.swc
+    *  beyond those that are found by dependecy analysis starting
+    *  from the classes specified in manifest.xml.
+    */
+    internal class NetworkClasses
+    {	
+        import org.apache.flex.net.URLBinaryLoader; URLBinaryLoader;
+        import org.apache.flex.net.HTTPConstants; HTTPConstants;
+        import org.apache.flex.net.events.ResultEvent; ResultEvent;
+        import org.apache.flex.net.events.FaultEvent; FaultEvent;
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e3bfc558/frameworks/projects/Network/src/main/flex/org/apache/flex/net/RemoteObject.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/net/RemoteObject.as
b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/RemoteObject.as
new file mode 100755
index 0000000..b57be6f
--- /dev/null
+++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/RemoteObject.as
@@ -0,0 +1,123 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.net
+{
+	import org.apache.flex.net.events.FaultEvent;
+	import org.apache.flex.net.events.ResultEvent;
+	
+	import org.apache.flex.events.EventDispatcher;
+	import org.apache.flex.reflection.getClassByAlias;
+	import org.apache.flex.reflection.registerClassAlias;
+
+	[Event(name="result", type="org.apache.flex.net.events.ResultEvent")]
+	[Event(name="fault", type="org.apache.flex.net.events.FaultEvent")]
+	public class RemoteObject extends EventDispatcher
+	{
+		private var _endPoint:String;
+		private var _destination:String;
+		private var _source:String;
+		
+		/** 
+		 * 
+		 * <inject_html>
+		 * <script src="https://rawgit.com/emilkm/amfjs/master/amf.js"></script>
+		 * </inject_html>
+		 */ 
+		public function RemoteObject()
+		{
+		}
+		
+		public function set endPoint(value:String):void
+		{
+			_endPoint = value;	
+		}
+		public function get endPoint():String
+		{
+			return _endPoint;	
+		}
+		
+		public function set destination(value:String):void
+		{
+			_destination = value;	
+		}
+		public function get destination():String
+		{
+			return _destination;	
+		}
+		
+		public function set source(value:String):void
+		{
+			_source = value;	
+		}
+		public function get source():String
+		{
+			return _source;	
+		}
+		
+		public function send(operation:String , params:Array):void
+		{
+			COMPILE::JS
+			{				
+				var amfClient:Object = new ((window as Object).amf).Client(_destination, _endPoint);
+				var amfReq:Object = amfClient.invoke(_source, operation, params[0]);
+				amfReq.then(resultHandler , faultHandler);
+			}
+		}
+		
+		private function resultHandler(param:Object):void
+		{
+			if(param is Object && param.hasOwnProperty("_explicitType"))
+			{
+				param = typeUntypedObject(param);
+			}
+			else if (param is Array && param.length > 0)
+			{
+				for(var i:uint ; i < param.length ; i++)
+				{
+					var typedObj:Object = typeUntypedObject(param[i]);
+					param[i] = typedObj;
+				}
+			}			
+			dispatchEvent(new ResultEvent(ResultEvent.RESULT,param));
+		}
+		
+		private function faultHandler(param:Object):void
+		{
+			dispatchEvent(new FaultEvent(FaultEvent.FAULT,param));
+		}
+		
+		private function typeUntypedObject(unTypeObject:Object):Object
+		{
+			registerClassAlias(unTypeObject['_explicitType'],getClassByAlias(unTypeObject['_explicitType']));
+			
+			var classToInstantiate:Class = getClassByAlias(unTypeObject['_explicitType']); 
+			
+			var typedInstance:Object = new classToInstantiate(); 
+			
+			for (var field:String in unTypeObject) 
+			{ 
+				if (field == "_explicitType") continue; //Do nothing incase of "_explicitType"
+				
+				typedInstance[field] = unTypeObject[field]; 
+			}
+
+			return  typedInstance;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e3bfc558/frameworks/projects/Network/src/main/flex/org/apache/flex/net/events/FaultEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/net/events/FaultEvent.as
b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/events/FaultEvent.as
new file mode 100755
index 0000000..a9bfb40
--- /dev/null
+++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/events/FaultEvent.as
@@ -0,0 +1,35 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.net.events
+{
+	import org.apache.flex.events.Event;
+	
+	public class FaultEvent extends Event
+	{
+	    public static const FAULT:String = "fault";	
+		public var message:Object;
+	
+	    public function FaultEvent(type:String, message:Object = null, bubbles:Boolean = false,
cancelable:Boolean = true)
+	    {
+	        super(type, bubbles, cancelable);
+			this.message = message;
+	    }
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e3bfc558/frameworks/projects/Network/src/main/flex/org/apache/flex/net/events/ResultEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/net/events/ResultEvent.as
b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/events/ResultEvent.as
new file mode 100755
index 0000000..69c767b
--- /dev/null
+++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/events/ResultEvent.as
@@ -0,0 +1,34 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.net.events
+{
+	import org.apache.flex.events.Event;
+	
+	public class ResultEvent extends Event
+	{
+		public static const RESULT:String = "result";
+		public var data:Object;
+		public function ResultEvent(type:String, resultData:Object=null, bubbles:Boolean = false,
cancelable:Boolean = true)
+		{
+			super(type, bubbles, cancelable);
+			this.data = resultData;
+		}
+	}
+}
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e3bfc558/frameworks/projects/Network/src/main/resources/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/src/main/resources/basic-manifest.xml b/frameworks/projects/Network/src/main/resources/basic-manifest.xml
index 235b09d..acc6897 100644
--- a/frameworks/projects/Network/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Network/src/main/resources/basic-manifest.xml
@@ -21,6 +21,7 @@
 
 <componentPackage>
 
+    <component id="RemoteObject" class="org.apache.flex.net.RemoteObject"/>
     <component id="HTTPService" class="org.apache.flex.net.HTTPService"/>
     <component id="BinaryUploader" class="org.apache.flex.net.BinaryUploader"/>
 


Mime
View raw message