polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject zest-qi4j git commit: Formatting.
Date Sun, 12 Jul 2015 07:17:09 GMT
Repository: zest-qi4j
Updated Branches:
  refs/heads/develop 55f632eb4 -> d641afdb9


Formatting.


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/d641afdb
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/d641afdb
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/d641afdb

Branch: refs/heads/develop
Commit: d641afdb98c9412083db06479c5072f38b00080a
Parents: 55f632e
Author: Niclas Hedhman <niclas@hedhman.org>
Authored: Sun Jul 12 10:16:59 2015 +0300
Committer: Niclas Hedhman <niclas@hedhman.org>
Committed: Sun Jul 12 10:16:59 2015 +0300

----------------------------------------------------------------------
 .../library/jmx/ApplicationManagerService.java  | 75 ++++++++++++--------
 1 file changed, 44 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/d641afdb/libraries/jmx/src/main/java/org/qi4j/library/jmx/ApplicationManagerService.java
----------------------------------------------------------------------
diff --git a/libraries/jmx/src/main/java/org/qi4j/library/jmx/ApplicationManagerService.java
b/libraries/jmx/src/main/java/org/qi4j/library/jmx/ApplicationManagerService.java
index 1eda279..1c31255 100644
--- a/libraries/jmx/src/main/java/org/qi4j/library/jmx/ApplicationManagerService.java
+++ b/libraries/jmx/src/main/java/org/qi4j/library/jmx/ApplicationManagerService.java
@@ -33,15 +33,15 @@ import org.qi4j.api.service.ImportedServiceDescriptor;
 import org.qi4j.api.service.ServiceComposite;
 import org.qi4j.api.service.ServiceDescriptor;
 import org.qi4j.api.service.ServiceReference;
-import org.qi4j.api.service.qualifier.ServiceQualifier;
 import org.qi4j.api.structure.Application;
 import org.qi4j.api.structure.Layer;
 import org.qi4j.api.structure.LayerDescriptor;
 import org.qi4j.api.structure.Module;
 import org.qi4j.api.structure.ModuleDescriptor;
 import org.qi4j.functional.HierarchicalVisitorAdapter;
-import org.qi4j.functional.Iterables;
 
+import static org.qi4j.api.service.qualifier.ServiceQualifier.withId;
+import static org.qi4j.functional.Iterables.filter;
 import static org.qi4j.functional.Iterables.first;
 
 /**
@@ -69,32 +69,31 @@ public interface ApplicationManagerService
 {
 
     void exportApplicationStructure()
-            throws Exception;
+        throws Exception;
 
     void unexportApplicationStructure()
-            throws Exception;
+        throws Exception;
 
-    static class Activator
-            extends ActivatorAdapter<ServiceReference<ApplicationManagerService>>
+    class Activator
+        extends ActivatorAdapter<ServiceReference<ApplicationManagerService>>
     {
 
         @Override
         public void afterActivation( ServiceReference<ApplicationManagerService> activated
)
-                throws Exception
+            throws Exception
         {
             activated.get().exportApplicationStructure();
         }
 
         @Override
         public void beforePassivation( ServiceReference<ApplicationManagerService>
passivating )
-                throws Exception
+            throws Exception
         {
             passivating.get().unexportApplicationStructure();
         }
-
     }
 
-    static abstract class Mixin
+    abstract class Mixin
         implements ApplicationManagerService
     {
         @Service
@@ -103,7 +102,7 @@ public interface ApplicationManagerService
         @Structure
         public Application application;
 
-        private List<ObjectName> mbeans = new ArrayList<ObjectName>();
+        private List<ObjectName> mbeans = new ArrayList<>();
 
         @Override
         public void exportApplicationStructure()
@@ -113,7 +112,7 @@ public interface ApplicationManagerService
             {
                 Layer layer;
                 Module module;
-                Stack<ObjectName> names = new Stack<ObjectName>();
+                Stack<ObjectName> names = new Stack<>();
 
                 @Override
                 public boolean visitEnter( Object visited )
@@ -132,10 +131,8 @@ public interface ApplicationManagerService
                         RequiredModelMBean mbean = new ModelMBeanBuilder( objectName, layerDescriptor.name(),
LayerBean.class
                             .getName() ).
                             attribute( "uses", "Layer usages", String.class.getName(), "Other
layers that this layer uses", "getUses", null )
-                            .
-                                operation( "restart", "Restart layer", String.class.getName(),
MBeanOperationInfo.ACTION_INFO )
-                            .
-                                newModelMBean();
+                            .operation( "restart", "Restart layer", String.class.getName(),
MBeanOperationInfo.ACTION_INFO )
+                            .newModelMBean();
 
                         mbean.setManagedResource( layerBean, "ObjectReference" );
                         server.registerMBean( mbean, objectName );
@@ -164,7 +161,7 @@ public interface ApplicationManagerService
                         ServiceDescriptor serviceDescriptor = (ServiceDescriptor) visited;
                         ObjectName objectName = new ObjectName( names.peek()
                                                                     .toString() + ",class=Service,service="
+ serviceDescriptor
-                            .identity() );
+                                                                    .identity() );
                         RequiredModelMBean mbean = new ModelMBeanBuilder( objectName, serviceDescriptor.identity(),
ServiceBean.class
                             .getName() ).
                             attribute( "Id", "Service id", String.class.getName(), "Id of
service", "getId", null ).
@@ -190,7 +187,7 @@ public interface ApplicationManagerService
                         ImportedServiceDescriptor importedServiceDescriptor = (ImportedServiceDescriptor)
visited;
                         ObjectName objectName = new ObjectName( names.peek()
                                                                     .toString() + ",class=Imported
service,importedservice=" + importedServiceDescriptor
-                            .identity() );
+                                                                    .identity() );
                         RequiredModelMBean mbean = new ModelMBeanBuilder( objectName, importedServiceDescriptor.identity(),
ImportedServiceBean.class
                             .getName() ).
                             attribute( "Id", "Service id", String.class.getName(), "Id of
service", "getId", null ).
@@ -234,7 +231,7 @@ public interface ApplicationManagerService
         }
     }
 
-    public static class LayerBean
+    class LayerBean
     {
         private final Layer layer;
         private final LayerDescriptor layerDescriptor;
@@ -273,7 +270,7 @@ public interface ApplicationManagerService
         }
     }
 
-    public static class ServiceBean
+    class ServiceBean
     {
         private final ServiceDescriptor serviceDescriptor;
         private final Module module;
@@ -296,27 +293,38 @@ public interface ApplicationManagerService
 
         public String getType()
         {
-            return first( serviceDescriptor.types() ).getName();
+            Class<?> first = first( serviceDescriptor.types() );
+            if( first == null )
+            {
+                return null;
+            }
+            return first.getName();
         }
 
         public boolean isActive()
         {
-            return Iterables.first( Iterables.filter( ServiceQualifier.withId( serviceDescriptor.identity()
), module.findServices( first( serviceDescriptor
-                                                                                        
                                                      .types() ) ) ) )
-                .isActive();
+            Class<?> mainType = first( serviceDescriptor.types() );
+            ServiceReference<?> first = first( filter( withId( serviceDescriptor.identity()
),
+                                                       module.findServices( mainType ) )
+            );
+            return first != null && first.isActive();
         }
 
         public boolean isAvailable()
         {
-            return Iterables.first( Iterables.filter( ServiceQualifier.withId( serviceDescriptor.identity()
), module.findServices( first( serviceDescriptor
-                                                                                        
                                                      .types() ) ) ) )
-                .isAvailable();
+            Class<?> mainType = first( serviceDescriptor.types() );
+            ServiceReference<?> first = first( filter( withId( serviceDescriptor.identity()
),
+                                                       module.findServices( mainType ) )
+            );
+            return first != null && first.isAvailable();
         }
 
         public String restart()
         {
-            Iterable services = module.findServices( first( serviceDescriptor.types() ) );
-            ServiceReference serviceRef = ( ServiceReference ) Iterables.first( Iterables.filter(
ServiceQualifier.withId( serviceDescriptor.identity() ), services ) );
+            Iterable<?> services = module.findServices( first( serviceDescriptor.types()
) );
+            ServiceReference<?> serviceRef = (ServiceReference) first( filter( withId(
serviceDescriptor.identity() ),
+                                                                               services )
+            );
             if( serviceRef != null )
             {
                 try
@@ -337,7 +345,7 @@ public interface ApplicationManagerService
         }
     }
 
-    public static class ImportedServiceBean
+    class ImportedServiceBean
     {
         private final ImportedServiceDescriptor serviceDescriptor;
 
@@ -358,7 +366,12 @@ public interface ApplicationManagerService
 
         public String getType()
         {
-            return first( serviceDescriptor.types() ).getName();
+            Class<?> mainType = first( serviceDescriptor.types() );
+            if( mainType == null )
+            {
+                return null;
+            }
+            return mainType.getName();
         }
     }
 }


Mime
View raw message