tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1292174 - in /openejb/trunk/openejb: ./ container/openejb-core/ examples/webapps/rest-example/ server/openejb-common-cli/ server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/ server/openejb-common-cli/src/main/resources/M...
Date Wed, 22 Feb 2012 08:12:46 GMT
Author: rmannibucau
Date: Wed Feb 22 08:12:45 2012
New Revision: 1292174

URL: http://svn.apache.org/viewvc?rev=1292174&view=rev
Log:
using scan.xml (renamed commands.xml for this usage) to get cli commands

Added:
    openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/META-INF/
    openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/META-INF/org/
    openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/META-INF/org/apache/
    openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/META-INF/org/apache/openejb/
    openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/META-INF/org/apache/openejb/server/
    openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/META-INF/org/apache/openejb/server/commands.xml
Modified:
    openejb/trunk/openejb/container/openejb-core/pom.xml
    openejb/trunk/openejb/examples/webapps/rest-example/pom.xml
    openejb/trunk/openejb/pom.xml
    openejb/trunk/openejb/server/openejb-common-cli/pom.xml
    openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java

Modified: openejb/trunk/openejb/container/openejb-core/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/pom.xml?rev=1292174&r1=1292173&r2=1292174&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/pom.xml (original)
+++ openejb/trunk/openejb/container/openejb-core/pom.xml Wed Feb 22 08:12:45 2012
@@ -517,7 +517,6 @@
     </dependency>
     <dependency>
       <groupId>org.apache.openejb</groupId>
-      <version>0.0.1-SNAPSHOT</version>
       <artifactId>xbean-xml</artifactId>
     </dependency>
     <dependency>

Modified: openejb/trunk/openejb/examples/webapps/rest-example/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/webapps/rest-example/pom.xml?rev=1292174&r1=1292173&r2=1292174&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/webapps/rest-example/pom.xml (original)
+++ openejb/trunk/openejb/examples/webapps/rest-example/pom.xml Wed Feb 22 08:12:45 2012
@@ -113,7 +113,7 @@
             <artifactId>openjpa</artifactId>
             <version>2.2.0</version>
           </dependency>
-          <dependency> <!-- to get the jee6 profile -->
+          <dependency> <!-- to get the jee6 profile without configuration -->
             <groupId>org.apache.openejb</groupId>
             <version>0.0.1-SNAPSHOT</version>
             <artifactId>spi-helper-jee6-profile</artifactId>

Modified: openejb/trunk/openejb/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/pom.xml?rev=1292174&r1=1292173&r2=1292174&view=diff
==============================================================================
--- openejb/trunk/openejb/pom.xml (original)
+++ openejb/trunk/openejb/pom.xml Wed Feb 22 08:12:45 2012
@@ -499,6 +499,11 @@
   <dependencyManagement>
     <dependencies>
       <dependency>
+        <groupId>${project.groupId}</groupId>
+        <artifactId>xbean-xml</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.openejb</groupId>
         <artifactId>javaee-api</artifactId>
         <version>${javaee-api.version}</version>

Modified: openejb/trunk/openejb/server/openejb-common-cli/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-common-cli/pom.xml?rev=1292174&r1=1292173&r2=1292174&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-common-cli/pom.xml (original)
+++ openejb/trunk/openejb/server/openejb-common-cli/pom.xml Wed Feb 22 08:12:45 2012
@@ -19,6 +19,10 @@
       <version>${project.version}</version>
     </dependency>
     <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>xbean-xml</artifactId>
+    </dependency>
+    <dependency>
       <groupId>jline</groupId>
       <artifactId>jline</artifactId>
       <version>0.9.94</version>

Modified: openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java?rev=1292174&r1=1292173&r2=1292174&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java
(original)
+++ openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java
Wed Feb 22 08:12:45 2012
@@ -19,26 +19,34 @@ package org.apache.openejb.server.cli;
 import jline.ConsoleReader;
 import jline.FileNameCompletor;
 import jline.SimpleCompletor;
-import org.apache.openejb.config.NewLoaderLogic;
 import org.apache.openejb.server.cli.command.AbstractCommand;
 import org.apache.openejb.server.cli.command.Command;
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Logger;
 import org.apache.openejb.util.OpenEjbVersion;
-import org.apache.openejb.util.URLs;
-
+import org.apache.openejb.xbean.xml.XMLAnnotationFinderHelper;
 import org.apache.xbean.finder.Annotated;
-import org.apache.xbean.finder.ClassFinder;
-import org.apache.xbean.finder.UrlSet;
+import org.apache.xbean.finder.IAnnotationFinder;
+import org.apache.xbean.finder.ResourceFinder;
 import org.apache.xbean.recipe.ObjectRecipe;
 import org.apache.xbean.recipe.Option;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.URL;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
 public class CliRunnable implements Runnable {
+    private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB_SERVER, CliRunnable.class);
+
+    public static final String SERVICE_FOLDER = "META-INF/org/apache/openejb/server";
+    public static final String SERVICE_FILE = "commands.xml";
+
     private static final String BRANDING_FILE = "branding.properties";
     private static final String WELCOME_KEY_PREFIX = "welcome_";
     private static final String WELCOME_COMMON_KEY = WELCOME_KEY_PREFIX + "common";
@@ -77,24 +85,40 @@ public class CliRunnable implements Runn
             // no-op
         }
 
+        final ClassLoader loader = CliRunnable.class.getClassLoader();
         try {
-            final UrlSet forceCommonCli = new UrlSet(CliRunnable.class.getClassLoader()).matching(".*openejb-common-cli.*");
-            UrlSet urls = new UrlSet(CliRunnable.class.getClassLoader());
-            urls = NewLoaderLogic.applyBuiltinExcludes(urls);
-            urls = URLs.cullSystemAndOpenEJBJars(urls);
-            urls = urls.include(forceCommonCli);
+            final ResourceFinder finder = new ResourceFinder(SERVICE_FOLDER, loader);
+            final List<URL> urls = finder.findAll(SERVICE_FILE);
 
-            final ClassFinder finder = new ClassFinder(CliRunnable.class.getClassLoader(),
urls.getUrls());
-            for (Annotated<Class<?>> cmd : finder.findMetaAnnotatedClasses(Command.class))
{
+            for (URL url : urls) {
+                final IAnnotationFinder commandFinder;
+                final String ext = url.toExternalForm();
                 try {
-                    final Command annotation = cmd.getAnnotation(Command.class);
-                    COMMANDS.put(annotation.name(), cmd.get());
+                    final String jar = ext.substring(0, ext.length() - SERVICE_FILE.length()
- SERVICE_FOLDER.length() - 1);
+                    commandFinder = XMLAnnotationFinderHelper.finderFromXml(url.openStream(),
loader, Arrays.asList(new URL(jar)));
                 } catch (Exception e) {
-                    // command ignored
+                    LOGGER.error("can't parse command list in " + url.toExternalForm());
+                    continue;
+                }
+
+                for (Annotated<Class<?>> cmd : commandFinder.findMetaAnnotatedClasses(Command.class))
{
+                    try {
+                        final Command annotation = cmd.getAnnotation(Command.class);
+                        final String key = annotation.name();
+                        if (!COMMANDS.containsKey(key)) {
+                            COMMANDS.put(key, cmd.get());
+                        } else {
+                            LOGGER.warning("command " + key + " already exists, this one
will be ignored (from " + url.toExternalForm() + ")");
+                        }
+                    } catch (Exception e) {
+                        // command ignored
+                    }
                 }
             }
-        } catch (Exception e) {
-            // ignored
+        } catch (RuntimeException e) {
+            LOGGER.error("an error occured while getting commands", e);
+        } catch (IOException e) {
+            LOGGER.error("can't get commands");
         }
     }
 

Added: openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/META-INF/org/apache/openejb/server/commands.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/META-INF/org/apache/openejb/server/commands.xml?rev=1292174&view=auto
==============================================================================
--- openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/META-INF/org/apache/openejb/server/commands.xml
(added)
+++ openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/META-INF/org/apache/openejb/server/commands.xml
Wed Feb 22 08:12:45 2012
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scan>
+  <packages>
+      <package>org.apache.openejb.server.cli.command</package>
+  </packages>
+</scan>



Mime
View raw message