tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lrese...@apache.org
Subject svn commit: r1309527 - in /tuscany/sca-java-2.x/trunk/modules/node-manager/src: main/java/org/apache/tuscany/sca/node/manager/ main/java/org/apache/tuscany/sca/node/manager/impl/ test/java/services/ test/java/services/impl/ test/resources/
Date Wed, 04 Apr 2012 18:42:37 GMT
Author: lresende
Date: Wed Apr  4 18:42:37 2012
New Revision: 1309527

URL: http://svn.apache.org/viewvc?rev=1309527&view=rev
Log:
Enhancing domain asset manager to support resources that is not directly exposed with rest
binding

Added:
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResource.java
      - copied, changed from r1308444, tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyServiceImpl.java
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyService.java
      - copied, changed from r1308444, tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyServiceImpl.java
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyLongRunningResourceImpl.java
      - copied, changed from r1308444, tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResourceImpl.java
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyOtherResourceImpl.java
      - copied, changed from r1308444, tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResourceImpl.java
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyResourceImpl.java
  (contents, props changed)
      - copied, changed from r1308444, tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResourceImpl.java
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyServiceImpl.java
  (contents, props changed)
      - copied, changed from r1308444, tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyServiceImpl.java
Removed:
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResourceImpl.java
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyServiceImpl.java
Modified:
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainAssetManagerResource.java
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainAssetManagerResourceImpl.java
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/node-asset-manager-test.composite

Modified: tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainAssetManagerResource.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainAssetManagerResource.java?rev=1309527&r1=1309526&r2=1309527&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainAssetManagerResource.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainAssetManagerResource.java
Wed Apr  4 18:42:37 2012
@@ -29,6 +29,7 @@ import javax.ws.rs.PathParam;
 import org.oasisopen.sca.annotation.Remotable;
 
 @Remotable
+@Path("")
 public interface DomainAssetManagerResource {
 
     @GET

Modified: tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java?rev=1309527&r1=1309526&r2=1309527&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java
Wed Apr  4 18:42:37 2012
@@ -27,6 +27,7 @@ import javax.ws.rs.PathParam;
 import org.oasisopen.sca.annotation.Remotable;
 
 @Remotable
+@Path("")
 public interface DomainCompositeResource {
 
     @GET

Modified: tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainAssetManagerResourceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainAssetManagerResourceImpl.java?rev=1309527&r1=1309526&r2=1309527&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainAssetManagerResourceImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainAssetManagerResourceImpl.java
Wed Apr  4 18:42:37 2012
@@ -109,7 +109,24 @@ public class DomainAssetManagerResourceI
             for(Service service : component.getServices()) {
                 Interface interfaceContract = service.getInterfaceContract().getInterface();
                 if(ManageableResource.class.getName().equals(interfaceContract.toString()))
{
+                    
+                    //the simple case, the resource is directly exposed with rest binding
                     Binding binding = service.getBinding(RESTBinding.class);
+                    if(binding == null) {
+                        //the resource is available via some other interface
+                        //(e.g. service implements resource, manageableResource interfaces)
+                        for(Service s : component.getServices()) {
+                            binding = s.getBinding(RESTBinding.class);
+                            if(binding != null) {
+                                break;
+                            }
+                        }
+                    }
+                    
+                    if(binding == null) {
+                        //WARNING that the manageableResource is not exposed via rest binding
+                    }
+                    
                     if(binding != null) {
                         
                         Status status = new Status();
@@ -167,7 +184,8 @@ public class DomainAssetManagerResourceI
                     status.setUri(service.getBindings().get(0).getURI());
                     
                     try {
-                        ManageableService serviceInstance = node.getService(ManageableService.class,
component.getName());
+                        String serviceName = component.getName() + "/" + service.getName();
+                        ManageableService serviceInstance = node.getService(ManageableService.class,
serviceName);
                         Timer t = new Timer();
                         serviceInstance.isAlive();
                         status.setExecution(t.elapsed(TimeUnit.MILLISECONDS));

Copied: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResource.java
(from r1308444, tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyServiceImpl.java)
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResource.java?p2=tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResource.java&p1=tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyServiceImpl.java&r1=1308444&r2=1309527&rev=1309527&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyServiceImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResource.java
Wed Apr  4 18:42:37 2012
@@ -19,14 +19,13 @@
 
 package services;
 
-import org.apache.tuscany.sca.node.manager.ManageableService;
+import javax.ws.rs.GET;
+import javax.ws.rs.core.Response;
 
-public class MyServiceImpl implements ManageableService {
-
- 
-    @Override
-    public void isAlive() {
-        System.out.println(">>> isAlive");
-    }
+import org.oasisopen.sca.annotation.Remotable;
 
+@Remotable
+public interface MyResource {
+    @GET
+    Response getSomething();
 }

Copied: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyService.java
(from r1308444, tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyServiceImpl.java)
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyService.java?p2=tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyService.java&p1=tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyServiceImpl.java&r1=1308444&r2=1309527&rev=1309527&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyServiceImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyService.java
Wed Apr  4 18:42:37 2012
@@ -19,14 +19,10 @@
 
 package services;
 
-import org.apache.tuscany.sca.node.manager.ManageableService;
-
-public class MyServiceImpl implements ManageableService {
-
- 
-    @Override
-    public void isAlive() {
-        System.out.println(">>> isAlive");
-    }
+import org.oasisopen.sca.annotation.Remotable;
 
+@Remotable
+public interface MyService {
+    
+    void doSomething();
 }

Copied: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyLongRunningResourceImpl.java
(from r1308444, tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResourceImpl.java)
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyLongRunningResourceImpl.java?p2=tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyLongRunningResourceImpl.java&p1=tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResourceImpl.java&r1=1308444&r2=1309527&rev=1309527&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResourceImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyLongRunningResourceImpl.java
Wed Apr  4 18:42:37 2012
@@ -17,18 +17,32 @@
  * under the License.    
  */
 
-package services;
+package services.impl;
 
 import javax.ws.rs.core.Response;
 
 import org.apache.tuscany.sca.node.manager.ManageableResource;
+import services.MyResource;
 
-public class MyResourceImpl implements ManageableResource {
+public class MyLongRunningResourceImpl implements MyResource, ManageableResource {
 
     @Override
     public Response ping() {
-        System.out.println(">>> ping");
+        System.out.println(">>> long running ping");
+        try {
+            Thread.sleep(1000);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
         return Response.ok("pong").build();
     }
+    
+
+    @Override
+    public Response getSomething() {
+        System.out.println(">>> getSomething");
+        return Response.ok("something").build();
+    }
+
 
 }

Copied: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyOtherResourceImpl.java
(from r1308444, tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResourceImpl.java)
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyOtherResourceImpl.java?p2=tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyOtherResourceImpl.java&p1=tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResourceImpl.java&r1=1308444&r2=1309527&rev=1309527&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResourceImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyOtherResourceImpl.java
Wed Apr  4 18:42:37 2012
@@ -17,18 +17,17 @@
  * under the License.    
  */
 
-package services;
+package services.impl;
 
 import javax.ws.rs.core.Response;
 
 import org.apache.tuscany.sca.node.manager.ManageableResource;
 
-public class MyResourceImpl implements ManageableResource {
+public class MyOtherResourceImpl implements ManageableResource {
 
     @Override
     public Response ping() {
         System.out.println(">>> ping");
         return Response.ok("pong").build();
     }
-
 }

Copied: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyResourceImpl.java
(from r1308444, tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResourceImpl.java)
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyResourceImpl.java?p2=tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyResourceImpl.java&p1=tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResourceImpl.java&r1=1308444&r2=1309527&rev=1309527&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyResourceImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyResourceImpl.java
Wed Apr  4 18:42:37 2012
@@ -17,18 +17,26 @@
  * under the License.    
  */
 
-package services;
+package services.impl;
 
 import javax.ws.rs.core.Response;
 
 import org.apache.tuscany.sca.node.manager.ManageableResource;
 
-public class MyResourceImpl implements ManageableResource {
+import services.MyResource;
+
+public class MyResourceImpl implements MyResource, ManageableResource {
 
     @Override
     public Response ping() {
         System.out.println(">>> ping");
         return Response.ok("pong").build();
     }
+    
+    @Override
+    public Response getSomething() {
+        System.out.println(">>> getSomething");
+        return Response.ok("something").build();
+    }
 
 }

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyResourceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyResourceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyServiceImpl.java
(from r1308444, tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyServiceImpl.java)
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyServiceImpl.java?p2=tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyServiceImpl.java&p1=tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyServiceImpl.java&r1=1308444&r2=1309527&rev=1309527&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/MyServiceImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyServiceImpl.java
Wed Apr  4 18:42:37 2012
@@ -17,11 +17,13 @@
  * under the License.    
  */
 
-package services;
+package services.impl;
 
 import org.apache.tuscany.sca.node.manager.ManageableService;
 
-public class MyServiceImpl implements ManageableService {
+import services.MyService;
+
+public class MyServiceImpl implements MyService, ManageableService {
 
  
     @Override
@@ -29,4 +31,8 @@ public class MyServiceImpl implements Ma
         System.out.println(">>> isAlive");
     }
 
+    @Override
+    public void doSomething() {
+        System.out.println(">>> doSomething");
+    }
 }

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/services/impl/MyServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/node-asset-manager-test.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/node-asset-manager-test.composite?rev=1309527&r1=1309526&r2=1309527&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/node-asset-manager-test.composite
(original)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/node-asset-manager-test.composite
Wed Apr  4 18:42:37 2012
@@ -33,21 +33,29 @@
 	</component>
 	
 	<component name="Resource">
-		<implementation.java class="services.MyResourceImpl"/>
-		<service name="ManageableResource">
+		<implementation.java class="services.impl.MyResourceImpl"/>
+		<service name="MyResource">
 			<tuscany:binding.rest uri="/services/resource" />
    		</service>
 	</component>
 
 	<component name="LongRunningResource">
-		<implementation.java class="services.MyLongRunningResourceImpl"/>
+		<implementation.java class="services.impl.MyLongRunningResourceImpl"/>
+		<service name="MyResource">
+			<tuscany:binding.rest uri="/services/long/resource" />
+   		</service>
+	</component>
+
+	<component name="OtherResource">
+		<implementation.java class="services.impl.MyOtherResourceImpl"/>
 		<service name="ManageableResource">
-			<tuscany:binding.rest uri="/services/another/resource" />
+			<tuscany:binding.rest uri="/services/other/resource" />
    		</service>
 	</component>
+
 	
 	<component name="Service">
-		<implementation.java class="services.MyServiceImpl"/>
+		<implementation.java class="services.impl.MyServiceImpl"/>
 		<service name="ManageableService">
 			<binding.sca />
    		</service>



Mime
View raw message