You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2014/07/04 11:50:49 UTC

[07/45] git commit: Deprecate BrooklynCatalog.addItem and remove addToClasspath

Deprecate BrooklynCatalog.addItem and remove addToClasspath


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/edcaee4d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/edcaee4d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/edcaee4d

Branch: refs/heads/master
Commit: edcaee4d5df5ec1b2b1a577ead0646b335735516
Parents: 0263fa1
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Mon Jun 30 17:23:37 2014 +0100
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Tue Jul 1 13:37:37 2014 +0100

----------------------------------------------------------------------
 .../java/brooklyn/catalog/BrooklynCatalog.java  | 42 ++++++++++----------
 .../catalog/internal/BasicBrooklynCatalog.java  | 21 +---------
 2 files changed, 24 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/edcaee4d/api/src/main/java/brooklyn/catalog/BrooklynCatalog.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/catalog/BrooklynCatalog.java b/api/src/main/java/brooklyn/catalog/BrooklynCatalog.java
index 720a2bc..29fd1c8 100644
--- a/api/src/main/java/brooklyn/catalog/BrooklynCatalog.java
+++ b/api/src/main/java/brooklyn/catalog/BrooklynCatalog.java
@@ -4,47 +4,49 @@ import com.google.common.base.Predicate;
 
 public interface BrooklynCatalog {
 
-    /** finds the item with the given ID, or null if not found */
+    /** @return The item with the given ID, or null if not found */
     CatalogItem<?> getCatalogItem(String id);
-    
+
+
     /** variant of {@link #getCatalogItem(String)} which checks (and casts) type for convenience
      * (returns null if type does not match) */
     <T> CatalogItem<T> getCatalogItem(Class<T> type, String id);
-    
-    /** returns all items in the catalog */
+
+    /** @return All items in the catalog */
     <T> Iterable<CatalogItem<T>> getCatalogItems();
 
     /** convenience for filtering items in the catalog; see CatalogPredicates for useful filters */
     <T> Iterable<CatalogItem<T>> getCatalogItems(Predicate<? super CatalogItem<T>> filter);
 
-    /** returns the classloader which should be used to load classes and entities;
+    /** @return The classloader which should be used to load classes and entities;
      * this includes all the catalog's classloaders in the right order */
     public ClassLoader getRootClassLoader();
-    
+
     /** throws exceptions if any problems */
     <T> Class<? extends T> loadClass(CatalogItem<T> item);
     <T> Class<? extends T> loadClassByType(String typeName, Class<T> typeClass);
-    
-    /** adds an item to the 'manual' catalog;
-     * this does not update the classpath or have a record to the java Class,
-     * so callers of this method will typically also need to call 
-     * {@link #addToClasspath(String)} or {@link #addToClasspath(ClassLoader)} */
+
+    /**
+     * adds an item to the 'manual' catalog;
+     * this does not update the classpath or have a record to the java Class
+     *
+     * @deprecated since 0.7.0 Construct catalogs with OSGi bundles instead
+     */
+    @Deprecated
     void addItem(CatalogItem<?> item);
-    
+
     /** creates a catalog item and adds it to the 'manual' catalog,
      * with the corresponding Class definition (loaded by a classloader)
      * registered and available in the classloader.
-     * <p> 
+     * <p>
      * note that the class will be available for this session only,
      * although the record of the item will appear in the catalog DTO if exported,
      * so it is recommended to edit the 'manual' catalog DTO if using it to
-     * generate a catalog, either adding the appropriate classpath URL or removing this entry. */
+     * generate a catalog, either adding the appropriate classpath URL or removing this entry.
+     *
+     * @deprecated since 0.7.0 Construct catalogs with OSGi bundles instead
+     */
+    @Deprecated
     CatalogItem<?> addItem(Class<?> clazz);
 
-    /** adds a classpath entry which will be used by the 'manual' catalog */
-    void addToClasspath(ClassLoader loader);
-
-    /** adds a classpath entry which will be used by the 'manual' catalog */
-    void addToClasspath(String url);
-    
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/edcaee4d/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java b/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java
index 02cbcf1..d6b5ff0 100644
--- a/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java
+++ b/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java
@@ -1,7 +1,5 @@
 package brooklyn.catalog.internal;
 
-import java.net.MalformedURLException;
-import java.net.URL;
 import java.util.NoSuchElementException;
 
 import javax.annotation.Nullable;
@@ -134,23 +132,8 @@ public class BasicBrooklynCatalog implements BrooklynCatalog {
         manualAdditionsClasses.addClass(type);
         return manualAdditionsCatalog.classpath.addCatalogEntry(type);
     }
-    
-    @Override
-    public void addToClasspath(ClassLoader loader) {
-        if (manualAdditionsCatalog==null) loadManualAdditionsCatalog();
-        manualAdditionsCatalog.classpath.addToClasspath(loader);
-    }
-    
-    @Override
-    public void addToClasspath(String url) {
-        if (manualAdditionsCatalog==null) loadManualAdditionsCatalog();
-        try {
-            manualAdditionsCatalog.classpath.addToClasspath(new URL(url), true);
-        } catch (MalformedURLException e) {
-            throw Exceptions.propagate(e);
-        }
-    }
-    
+
+    @Deprecated
     private synchronized void loadManualAdditionsCatalog() {
         if (manualAdditionsCatalog!=null) return;
         CatalogDto manualAdditionsCatalogDto = CatalogDto.newNamedInstance(