geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r939337 - /geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java
Date Thu, 29 Apr 2010 15:01:03 GMT
Author: gawor
Date: Thu Apr 29 15:01:03 2010
New Revision: 939337

URL: http://svn.apache.org/viewvc?rev=939337&view=rev
Log:
Avoid creating gbean proxies in GeronimoAsMavenServlet

Modified:
    geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java

Modified: geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java?rev=939337&r1=939336&r2=939337&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java
(original)
+++ geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java
Thu Apr 29 15:01:03 2010
@@ -186,7 +186,7 @@ public class GeronimoAsMavenServlet exte
         // Step 2: check if it's in a repository
         Set<AbstractName> repos = kernel.listGBeans(new AbstractNameQuery(Repository.class.getName()));
         for (AbstractName name : repos) {
-            Repository repo = (Repository) kernel.getProxyManager().createProxy(name, Repository.class);
+            Repository repo = getGBean(kernel, name, Repository.class);
             if(repo.contains(configId)) {
                 File path = repo.getLocation(configId);
                 if(!path.exists()) throw new IllegalStateException("Can't find file '"+path.getAbsolutePath()+"'
though repository said there's an artifact there!");
@@ -226,7 +226,20 @@ public class GeronimoAsMavenServlet exte
         if(names.size() == 0) {
             return null;
         }
-        return (PluginInstaller) kernel.getProxyManager().createProxy((AbstractName) names.iterator().next(),
PluginInstaller.class);
+        return getGBean(kernel, names.iterator().next(), PluginInstaller.class);
+    }
+
+    private <T> T getGBean(Kernel kernel, AbstractName name, Class<T> clazz)
{
+        boolean createProxy = false;
+        if (createProxy) {
+            return kernel.getProxyManager().createProxy(name, clazz);
+        } else {
+            try {
+                return clazz.cast(kernel.getGBean(name));
+            } catch (GBeanNotFoundException e) {
+                throw new IllegalStateException("No implementation for " + clazz.getName(),
e);
+            }
+        }
     }
 
     private void generateMavenFile(Kernel kernel, PrintWriter writer, String groupId, String
artifactId, boolean reply) throws ParserConfigurationException, TransformerException {



Mime
View raw message