geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r693702 - in /geronimo/server/trunk/framework/modules: geronimo-kernel/src/main/java/org/apache/geronimo/kernel/ geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/ geronimo-kernel/src/main/java/org/apache/geronimo/kernel/proxy/...
Date Wed, 10 Sep 2008 04:15:55 GMT
Author: djencks
Date: Tue Sep  9 21:15:55 2008
New Revision: 693702

URL: http://svn.apache.org/viewvc?rev=693702&view=rev
Log:
GERONIMO-4293 some generics in kernel

Modified:
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/Kernel.java
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/KernelGBean.java
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicKernel.java
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/proxy/ProxyManager.java
    geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/KernelDelegate.java

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/Kernel.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/Kernel.java?rev=693702&r1=693701&r2=693702&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/Kernel.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/Kernel.java
Tue Sep  9 21:15:55 2008
@@ -101,8 +101,8 @@
      */
     Object getGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException,
IllegalStateException;
     Object getGBean(String shortName) throws GBeanNotFoundException, InternalKernelException,
IllegalStateException;
-    Object getGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
-    Object getGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException,
IllegalStateException;
+    <T> T getGBean(Class<T> type) throws GBeanNotFoundException, InternalKernelException,
IllegalStateException;
+    <T> T getGBean(String shortName, Class<T> type) throws GBeanNotFoundException,
InternalKernelException, IllegalStateException;
 
     /**
      * Start a specific GBean.
@@ -226,14 +226,14 @@
      * @param abstractNameQuery the query to execute
      * @return the AbstractNames of all matching GBeans
      */
-    Set listGBeans(AbstractNameQuery abstractNameQuery);
+    Set<AbstractName> listGBeans(AbstractNameQuery abstractNameQuery);
 
     /**
      * Returns a Set of all GBeans matching the set of object name pattern
      * @param abstractNameQueries the queries to execute
      * @return a List of AbstractNameName of matching GBeans registered with this kernel
      */
-    Set listGBeans(Set abstractNameQueries);
+    Set<AbstractName> listGBeans(Set abstractNameQueries);
 
     /**
      * Gets the value of an attribute on the specified gbean
@@ -360,7 +360,7 @@
      *
      * @deprecated Use AbstractNameQuery version instead
      */
-    Set listGBeans(ObjectName pattern);
+    Set<AbstractName> listGBeans(ObjectName pattern);
     /**
      * @deprecated Use AbstractName version instead
      */

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/KernelGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/KernelGBean.java?rev=693702&r1=693701&r2=693702&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/KernelGBean.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/KernelGBean.java
Tue Sep  9 21:15:55 2008
@@ -90,11 +90,11 @@
         return kernel.getGBean(shortName);
     }
 
-    public Object getGBean(Class type) throws GBeanNotFoundException, InternalKernelException,
IllegalStateException {
+    public <T> T getGBean(Class<T> type) throws GBeanNotFoundException, InternalKernelException,
IllegalStateException {
         return kernel.getGBean(type);
     }
 
-    public Object getGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException,
IllegalStateException {
+    public <T> T getGBean(String shortName, Class<T> type) throws GBeanNotFoundException,
InternalKernelException, IllegalStateException {
         return kernel.getGBean(shortName, type);
     }
 
@@ -266,11 +266,11 @@
         return kernel.getGBeanData(shortName, type);
     }
 
-    public Set listGBeans(ObjectName pattern) {
+    public Set<AbstractName> listGBeans(ObjectName pattern) {
         return kernel.listGBeans(pattern);
     }
 
-    public Set listGBeans(Set patterns) {
+    public Set<AbstractName> listGBeans(Set patterns) {
         return kernel.listGBeans(patterns);
     }
 
@@ -386,7 +386,7 @@
         return kernel.isRunning();
     }
 
-    public Set listGBeans(AbstractNameQuery refInfoQuery) {
+    public Set<AbstractName> listGBeans(AbstractNameQuery refInfoQuery) {
         return kernel.listGBeans(refInfoQuery);
     }
 

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicKernel.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicKernel.java?rev=693702&r1=693701&r2=693702&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicKernel.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicKernel.java
Tue Sep  9 21:15:55 2008
@@ -276,16 +276,16 @@
         return getGBean(shortName, null);
     }
 
-    public Object getGBean(Class type) throws GBeanNotFoundException, InternalKernelException,
IllegalStateException {
+    public <T> T getGBean(Class<T> type) throws GBeanNotFoundException, InternalKernelException,
IllegalStateException {
         return getGBean(null, type);
     }
 
-    public Object getGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException,
IllegalStateException {
+    public <T> T getGBean(String shortName, Class<T> type) throws GBeanNotFoundException,
InternalKernelException, IllegalStateException {
         GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
         if (gbeanInstance.getState() != State.RUNNING_INDEX) {
             throw new IllegalStateException("GBean is not running: " + gbeanInstance.getAbstractName());
         }
-        return gbeanInstance.getTarget();
+        return (T)gbeanInstance.getTarget();
     }
 
     public Object getGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException,
IllegalStateException  {
@@ -496,56 +496,52 @@
         return gbeanInstance.getStartTime();
     }
 
-    public Set listGBeans(ObjectName pattern) {
-        Set gbeans = registry.listGBeans(pattern);
+    public Set<AbstractName> listGBeans(ObjectName pattern) {
+        Set<GBeanInstance> gbeans = registry.listGBeans(pattern);
 
-        Set result = new HashSet(gbeans.size());
-        for (Iterator i = gbeans.iterator(); i.hasNext();) {
-            GBeanInstance instance = (GBeanInstance) i.next();
-            result.add(instance.getObjectNameObject());
+        Set<AbstractName> result = new HashSet<AbstractName>(gbeans.size());
+        for (GBeanInstance instance : gbeans) {
+            result.add(instance.getAbstractName());
         }
         return result;
     }
 
-    public Set listGBeans(Set patterns) {
-        Set gbeans = new HashSet();
-        for (Iterator iterator = patterns.iterator(); iterator.hasNext();) {
-            Object pattern = iterator.next();
+    public Set<AbstractName> listGBeans(Set patterns) {
+        Set<AbstractName> gbeans = new HashSet<AbstractName>();
+        for (Object pattern : patterns) {
             if (pattern instanceof ObjectName) {
-                gbeans.addAll(listGBeans((ObjectName)pattern));
+                gbeans.addAll(listGBeans((ObjectName) pattern));
             } else if (pattern instanceof AbstractNameQuery) {
-                gbeans.addAll(listGBeans((AbstractNameQuery)pattern));
+                gbeans.addAll(listGBeans((AbstractNameQuery) pattern));
             }
         }
         return gbeans;
     }
 
-    public Set listGBeans(AbstractNameQuery query) {
-        Set gbeans = registry.listGBeans(query);
-        Set result = new HashSet(gbeans.size());
-        for (Iterator i = gbeans.iterator(); i.hasNext();) {
-            GBeanInstance instance = (GBeanInstance) i.next();
+    public Set<AbstractName> listGBeans(AbstractNameQuery query) {
+        Set<GBeanInstance> gbeans = registry.listGBeans(query);
+        Set<AbstractName> result = new HashSet<AbstractName>(gbeans.size());
+        for (GBeanInstance instance : gbeans) {
             result.add(instance.getAbstractName());
         }
         return result;
     }
 
-    public Set listGBeansByInterface(String[] interfaces) {
-        Set gbeans = new HashSet();
-        Set all = listGBeans((AbstractNameQuery)null);
-        for (Iterator it = all.iterator(); it.hasNext();) {
-            AbstractName name = (AbstractName) it.next();
+    public Set<AbstractName> listGBeansByInterface(String[] interfaces) {
+        Set<AbstractName> gbeans = new HashSet<AbstractName>();
+        Set<AbstractName> all = listGBeans((AbstractNameQuery)null);
+        for (AbstractName name : all) {
             try {
                 GBeanInfo info = getGBeanInfo(name);
-                Set intfs = info.getInterfaces();
-                for (int i = 0; i < interfaces.length; i++) {
-                    String candidate = interfaces[i];
-                    if(intfs.contains(candidate)) {
+                Set<String> intfs = info.getInterfaces();
+                for (String candidate : interfaces) {
+                    if (intfs.contains(candidate)) {
                         gbeans.add(name);
                         break;
                     }
                 }
-            } catch (GBeanNotFoundException e) {}
+            } catch (GBeanNotFoundException e) {
+            }
         }
         return gbeans;
     }

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java?rev=693702&r1=693701&r2=693702&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java
Tue Sep  9 21:15:55 2008
@@ -78,7 +78,7 @@
         return new ManagedProxyFactory(types, classLoader);
     }
 
-    public Object createProxy(AbstractName target, Class type) {
+    public <T> T createProxy(AbstractName target, Class<T> type) {
         if (target == null) throw new NullPointerException("target is null");
         if (type == null) throw new NullPointerException("type is null");
 
@@ -100,7 +100,7 @@
             if (types == null) types = new ArrayList();
             types.add(type);
 
-            return createProxyFactory((Class[]) types.toArray(new Class[types.size()]), classLoader).createProxy(target);
+            return (T) createProxyFactory((Class[]) types.toArray(new Class[types.size()]),
classLoader).createProxy(target);
         } catch (GBeanNotFoundException e) {
             throw new IllegalArgumentException("Could not get GBeanInfo for target object:
" + target, e);
         }

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/proxy/ProxyManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/proxy/ProxyManager.java?rev=693702&r1=693701&r2=693702&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/proxy/ProxyManager.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/proxy/ProxyManager.java
Tue Sep  9 21:15:55 2008
@@ -41,7 +41,7 @@
 
     public Object createProxy(AbstractName target, ClassLoader loader);
 
-    public Object createProxy(AbstractName target, Class type);
+    public <T> T createProxy(AbstractName target, Class<T> type);
 
     /**
      * Cleans up and resources associated with the proxy

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/KernelDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/KernelDelegate.java?rev=693702&r1=693701&r2=693702&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/KernelDelegate.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/KernelDelegate.java
Tue Sep  9 21:15:55 2008
@@ -100,21 +100,17 @@
         }
     }
 
-    public Object getGBean(Class type) throws GBeanNotFoundException, InternalKernelException,
IllegalStateException {
-        try {
-            return invokeKernel("getGBean", new Object[] {type}, new String[] {Class.class.getName()});
-        } catch (GBeanNotFoundException e) {
-            throw e;
-        } catch (RuntimeException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new InternalKernelException(e);
+    public <T> T getGBean(Class<T> type) throws GBeanNotFoundException, InternalKernelException,
IllegalStateException {
+        Set<AbstractName> set = listGBeans(new AbstractNameQuery(type.getName()));
+        for (AbstractName name : set) {
+            return proxyManager.createProxy(name, type);
         }
+        throw new GBeanNotFoundException("No implementation found for type " + type.getName(),
null, set);
     }
 
-    public Object getGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException,
IllegalStateException {
+    public <T> T getGBean(String shortName, Class<T> type) throws GBeanNotFoundException,
InternalKernelException, IllegalStateException {
         try {
-            return invokeKernel("getGBean", new Object[] {shortName, type}, new String[]
{String.class.getName(), Class.class.getName()});
+            return (T)invokeKernel("getGBean", new Object[] {shortName, type}, new String[]
{String.class.getName(), Class.class.getName()});
         } catch (GBeanNotFoundException e) {
             throw e;
         } catch (RuntimeException e) {
@@ -663,9 +659,9 @@
         }
     }
 
-    public Set listGBeans(ObjectName pattern) {
+    public Set<AbstractName> listGBeans(ObjectName pattern) {
         try {
-            return (Set) invokeKernel("listGBeans", new Object[] {pattern}, new String[]
{ObjectName.class.getName()});
+            return (Set<AbstractName>) invokeKernel("listGBeans", new Object[] {pattern},
new String[] {ObjectName.class.getName()});
         } catch (RuntimeException e) {
             throw e;
         } catch (Exception e) {
@@ -673,9 +669,9 @@
         }
     }
 
-    public Set listGBeans(Set patterns) {
+    public Set<AbstractName> listGBeans(Set patterns) {
         try {
-            return (Set) invokeKernel("listGBeans", new Object[] {patterns}, new String[]
{Set.class.getName()});
+            return (Set<AbstractName>) invokeKernel("listGBeans", new Object[] {patterns},
new String[] {Set.class.getName()});
         } catch (RuntimeException e) {
             throw e;
         } catch (Exception e) {
@@ -832,9 +828,9 @@
         return ((Boolean) getKernelAttribute("running")).booleanValue();
     }
 
-    public Set listGBeans(AbstractNameQuery query) {
+    public Set<AbstractName> listGBeans(AbstractNameQuery query) {
         try {
-            return (Set) invokeKernel("listGBeans", new Object[] {query}, new String[] {AbstractNameQuery.class.getName()});
+            return (Set<AbstractName>) invokeKernel("listGBeans", new Object[] {query},
new String[] {AbstractNameQuery.class.getName()});
         } catch (RuntimeException e) {
             throw e;
         } catch (Exception e) {



Mime
View raw message