polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [27/50] polygene-java git commit: :libraries:fileconfig refine
Date Mon, 15 May 2017 11:03:32 GMT
:libraries:fileconfig refine


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/9e6e2932
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/9e6e2932
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/9e6e2932

Branch: refs/heads/develop
Commit: 9e6e2932c51260b05aea5fe33af355c397bb5814
Parents: 69d8229
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Mon May 15 10:56:25 2017 +0200
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Mon May 15 10:56:25 2017 +0200

----------------------------------------------------------------------
 .../fileconfig/FileConfigurationDataWiper.java  | 27 ++++++++++----------
 .../fileconfig/FileConfigurationService.java    | 11 ++++----
 2 files changed, 18 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9e6e2932/libraries/fileconfig/src/main/java/org/apache/polygene/library/fileconfig/FileConfigurationDataWiper.java
----------------------------------------------------------------------
diff --git a/libraries/fileconfig/src/main/java/org/apache/polygene/library/fileconfig/FileConfigurationDataWiper.java
b/libraries/fileconfig/src/main/java/org/apache/polygene/library/fileconfig/FileConfigurationDataWiper.java
index f73ee08..2a0799a 100644
--- a/libraries/fileconfig/src/main/java/org/apache/polygene/library/fileconfig/FileConfigurationDataWiper.java
+++ b/libraries/fileconfig/src/main/java/org/apache/polygene/library/fileconfig/FileConfigurationDataWiper.java
@@ -23,26 +23,23 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 import org.apache.polygene.api.activation.ActivationEvent;
-import org.apache.polygene.api.activation.ActivationEventListener;
 import org.apache.polygene.api.structure.Application;
 
 public final class FileConfigurationDataWiper
 {
-
     public static void registerApplicationPassivationDataWiper( FileConfiguration fileConfig,
Application application )
     {
-        final List<File> dataDirectories = new ArrayList<File>();
+        final List<File> dataDirectories = new ArrayList<>();
         dataDirectories.add( fileConfig.configurationDirectory() );
         dataDirectories.add( fileConfig.cacheDirectory() );
         dataDirectories.add( fileConfig.dataDirectory() );
         dataDirectories.add( fileConfig.logDirectory() );
         dataDirectories.add( fileConfig.temporaryDirectory() );
-        application.registerActivationEventListener( new ActivationEventListener()
-        {
-            @Override
-            public void onEvent( ActivationEvent event )
+        application.registerActivationEventListener(
+            event ->
             {
-                if( event.type() == ActivationEvent.EventType.PASSIVATED && Application.class.isAssignableFrom(
event.source().getClass() ) )
+                if( event.type() == ActivationEvent.EventType.PASSIVATED
+                    && Application.class.isAssignableFrom( event.source().getClass()
) )
                 {
                     for( File dataDir : dataDirectories )
                     {
@@ -52,8 +49,7 @@ public final class FileConfigurationDataWiper
                         }
                     }
                 }
-            }
-        } );
+            } );
     }
 
     private static boolean delete( File file )
@@ -68,11 +64,15 @@ public final class FileConfigurationDataWiper
         }
         else
         {
-            for( File childFile : file.listFiles() )
+            File[] files = file.listFiles();
+            if( files != null )
             {
-                if( !delete( childFile ) )
+                for( File childFile : files )
                 {
-                    return false;
+                    if( !delete( childFile ) )
+                    {
+                        return false;
+                    }
                 }
             }
             return file.delete();
@@ -82,5 +82,4 @@ public final class FileConfigurationDataWiper
     private FileConfigurationDataWiper()
     {
     }
-
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9e6e2932/libraries/fileconfig/src/main/java/org/apache/polygene/library/fileconfig/FileConfigurationService.java
----------------------------------------------------------------------
diff --git a/libraries/fileconfig/src/main/java/org/apache/polygene/library/fileconfig/FileConfigurationService.java
b/libraries/fileconfig/src/main/java/org/apache/polygene/library/fileconfig/FileConfigurationService.java
index d4b4a3d..f2d35e6 100644
--- a/libraries/fileconfig/src/main/java/org/apache/polygene/library/fileconfig/FileConfigurationService.java
+++ b/libraries/fileconfig/src/main/java/org/apache/polygene/library/fileconfig/FileConfigurationService.java
@@ -33,7 +33,6 @@ import org.apache.polygene.api.injection.scope.This;
 import org.apache.polygene.api.injection.scope.Uses;
 import org.apache.polygene.api.mixin.Mixins;
 import org.apache.polygene.api.property.Property;
-import org.apache.polygene.api.service.ServiceComposite;
 import org.apache.polygene.api.service.ServiceDescriptor;
 import org.apache.polygene.api.service.ServiceReference;
 import org.apache.polygene.api.structure.Application;
@@ -43,12 +42,12 @@ import org.slf4j.LoggerFactory;
 @Mixins( FileConfigurationService.Mixin.class )
 @Activators( FileConfigurationService.Activator.class )
 public interface FileConfigurationService
-        extends FileConfiguration, ServiceComposite
+        extends FileConfiguration
 {
 
     void resolveFileConfiguration();
 
-    public static class Activator
+    class Activator
             extends ActivatorAdapter<ServiceReference<FileConfigurationService>>
     {
 
@@ -146,7 +145,7 @@ public interface FileConfigurationService
             }
 
             // Arguments available to use in directory specifications
-            Map<String, String> arguments = new HashMap<String, String>();
+            Map<String, String> arguments = new HashMap<>();
             arguments.put( "application", application );
             arguments.put( "user", user );
             arguments.put( "os", os.name() );
@@ -232,9 +231,9 @@ public interface FileConfigurationService
         {
             String osName = System.getProperty( "os.name" ).toLowerCase();
             OS os;
-            if ( osName.indexOf( "win" ) != -1 ) {
+            if ( osName.contains( "win" ) ) {
                 os = OS.windows;
-            } else if ( osName.indexOf( "mac" ) != -1 ) {
+            } else if ( osName.contains( "mac" ) ) {
                 os = OS.mac;
             } else {
                 os = OS.unix;


Mime
View raw message