You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2013/12/18 13:22:43 UTC

[08/50] [abbrv] Code cleanup

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/utils/CellarUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/utils/CellarUtils.java b/core/src/main/java/org/apache/karaf/cellar/core/utils/CellarUtils.java
index a7f8158..28e57d7 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/utils/CellarUtils.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/utils/CellarUtils.java
@@ -1,3 +1,16 @@
+/*
+ * Licensed 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.karaf.cellar.core.utils;
 
 import java.util.Collection;
@@ -7,6 +20,9 @@ import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+/**
+ * Generic Cellar utils class.
+ */
 public class CellarUtils {
 
     public static enum MergeType {
@@ -18,11 +34,11 @@ public class CellarUtils {
 
     private static final Pattern mergablePattern = Pattern.compile(MERGABLE_REGEX);
 
-
     /**
-     * Returns true if String is mergable.
-     * @param s
-     * @return
+     * Check if a String is "merge-able".
+     *
+     * @param s the String to check.
+     * @return true if the String is "merge-able", false else.
      */
     public static boolean isMergable(String s) {
        Matcher matcher = mergablePattern.matcher(s);
@@ -30,10 +46,10 @@ public class CellarUtils {
     }
 
     /**
-     * Converts a comma delimited String to a Set of Strings.
+     * Convert a comma delimited String to a Set of Strings.
      *
-     * @param text
-     * @return
+     * @param text the String to "split".
+     * @return the set of Strings.
      */
     public static Set<String> createSetFromString(String text) {
         if(isMergable(text)) {
@@ -56,12 +72,13 @@ public class CellarUtils {
     }
 
     /**
-     * Creates a comma delimited list of items.
+     * Convert a set of Strings into a global String.
      *
-     * @param items
-     * @return
+     * @param items the set of String.
+     * @param mergeable true if you want to use the MERRGEABLE string format, false else.
+     * @return the global String resulting of the concatenation of the Strings in the Set.
      */
-    public static String createStringFromSet(Set<String> items, boolean mergable) {
+    public static String createStringFromSet(Set<String> items, boolean mergeable) {
         StringBuilder builder = new StringBuilder();
 
         Iterator<String> iterator = items.iterator();
@@ -71,7 +88,7 @@ public class CellarUtils {
                 builder.append(",");
             }
         }
-        if (mergable) {
+        if (mergeable) {
             return String.format(MERGABLE, builder.toString());
         } else {
             return builder.toString();
@@ -79,22 +96,22 @@ public class CellarUtils {
     }
 
     /**
-     * Returns true if both {@link java.util.Collection}s contain exactly the same items (order doesn't matter).
+     * Check if two collections contain the same elements.
      *
-     * @param col1
-     * @param col2
-     * @return
+     * @param col1 the first collection.
+     * @param col2 the second collection.
+     * @return true if the two collections
      */
     public static boolean collectionEquals(Collection col1, Collection col2) {
         return collectionSubset(col1, col2) && collectionSubset(col2, col1);
     }
 
     /**
-     * Returns true if one {@link Collection} contains all items of the others
+     * Check if the a collection if a subset of another one.
      *
-     * @param source
-     * @param target
-     * @return
+     * @param source the source collection.
+     * @param target the target collection.
+     * @return true if source is a subset of the target, false else.
      */
     public static boolean collectionSubset(Collection source, Collection target) {
         if (source == null && target == null) {

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/utils/CombinedClassLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/utils/CombinedClassLoader.java b/core/src/main/java/org/apache/karaf/cellar/core/utils/CombinedClassLoader.java
index 8065a77..f31e479 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/utils/CombinedClassLoader.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/utils/CombinedClassLoader.java
@@ -11,13 +11,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.karaf.cellar.core.utils;
 
 import org.osgi.framework.Bundle;
 
 import java.net.URL;
-import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
@@ -25,7 +23,7 @@ import java.util.concurrent.ConcurrentMap;
 /**
  * A class loader which combines multiple bundle class loaders.
  * A bundle can add itself for to this class loader, so that the class loader can load classes from the bundle.
- * It is meant to be used together with the extender pattern in order to extends cellars class space.
+ * It is meant to be used together with the extender pattern in order to extends Cellar class space.
  */
 public class CombinedClassLoader extends ClassLoader {
 
@@ -47,7 +45,7 @@ public class CombinedClassLoader extends ClassLoader {
         bundles.remove(bundle.getBundleId());
     }
 
-
+    @Override
     public Class findClass(String name) throws ClassNotFoundException {
         for (Map.Entry<Long, Bundle> entry : bundles.entrySet()) {
             try {
@@ -62,8 +60,7 @@ public class CombinedClassLoader extends ClassLoader {
         throw new ClassNotFoundException(name);
     }
 
-
-
+    @Override
     public URL getResource(String name) {
         for (Map.Entry<Long, Bundle> entry : bundles.entrySet()) {
             Bundle bundle = entry.getValue();
@@ -76,4 +73,5 @@ public class CombinedClassLoader extends ClassLoader {
         }
         return null;
     }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index f14da2d..851da4e 100644
--- a/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -14,14 +14,10 @@
 -->
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
 
-    <!-- Registry -->
+    <!-- Handlers Registry -->
     <bean id="registry" class="org.apache.karaf.cellar.core.event.EventHandlerServiceRegistry"/>
-
-
-    <!-- Service Registrations -->
     <service ref="registry" interface="org.apache.karaf.cellar.core.event.EventHandlerRegistry"/>
 
-
     <reference-list id="eventHandlers" interface="org.apache.karaf.cellar.core.event.EventHandler" availability="optional">
         <reference-listener bind-method="bind" unbind-method="unbind">
             <ref component-id="registry"/>

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/test/java/org/apache/karaf/cellar/core/CellarSupportTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/karaf/cellar/core/CellarSupportTest.java b/core/src/test/java/org/apache/karaf/cellar/core/CellarSupportTest.java
index 151118b..f8e7681 100644
--- a/core/src/test/java/org/apache/karaf/cellar/core/CellarSupportTest.java
+++ b/core/src/test/java/org/apache/karaf/cellar/core/CellarSupportTest.java
@@ -78,4 +78,5 @@ public class CellarSupportTest {
         result = support.isAllowed(defaultGroup,"config","org.apache.karaf.cellar.instance", EventType.INBOUND);
         assertEquals("Instance config should be allowed",expectedResult,result);
     }
+
 }

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/test/java/org/apache/karaf/cellar/core/utils/CellarUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/karaf/cellar/core/utils/CellarUtilsTest.java b/core/src/test/java/org/apache/karaf/cellar/core/utils/CellarUtilsTest.java
index 28c97d5..7af5f32 100644
--- a/core/src/test/java/org/apache/karaf/cellar/core/utils/CellarUtilsTest.java
+++ b/core/src/test/java/org/apache/karaf/cellar/core/utils/CellarUtilsTest.java
@@ -1,3 +1,16 @@
+/*
+ * Licensed 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.karaf.cellar.core.utils;
 
 import java.util.ArrayList;