]> source.dussan.org Git - archiva.git/commitdiff
fix cli module
authorOlivier Lamy <olamy@apache.org>
Sat, 11 Jun 2011 21:31:07 +0000 (21:31 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 11 Jun 2011 21:31:07 +0000 (21:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1134775 13f79535-47bb-0310-9956-ffa450edef68

archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArchivaCli.java
archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java
archiva-cli/src/main/resources/META-INF/spring-context.xml [new file with mode: 0644]

index 52ed0311315cf7da225fdf92c91b0f688bb5cbf7..a5e5adc062b7c907224f7ffd7358b148f9e72473 100644 (file)
@@ -47,6 +47,7 @@ import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -242,8 +243,20 @@ public class ArchivaCli
     private Map<String, KnownRepositoryContentConsumer> getConsumers()
         throws PlexusSisuBridgeException
     {
-        PlexusSisuBridge plexusSisuBridge = applicationContext.getBean( PlexusSisuBridge.class );
-        return plexusSisuBridge.lookupMap( KnownRepositoryContentConsumer.class );
+        Map<String, KnownRepositoryContentConsumer> beans =
+            applicationContext.getBeansOfType( KnownRepositoryContentConsumer.class );
+        // we use a naming conventions knownRepositoryContentConsumer#hint
+        // with plexus we used only hint so remove before#
+
+        Map<String, KnownRepositoryContentConsumer> smallNames =
+            new HashMap<String, KnownRepositoryContentConsumer>( beans.size() );
+
+        for ( Map.Entry<String, KnownRepositoryContentConsumer> entry : beans.entrySet() )
+        {
+            smallNames.put( StringUtils.substringAfterLast( entry.getKey(), "#" ), entry.getValue() );
+        }
+
+        return smallNames;
     }
 
     private void doConversion( String properties )
index bfc5f6ebc76c6e273581f59904a434567bfb9069..dc4ef781486f7e382d07d678d38eda6d3a8449f1 100644 (file)
@@ -19,33 +19,36 @@ package org.apache.maven.archiva.cli;
  * under the License.
  */
 
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
-
 /**
- * ArtifactCountConsumer 
+ * ArtifactCountConsumer
  *
  * @version $Id$
- * 
- * @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
- *                   role-hint="count-artifacts"
- *                   instantiation-strategy="per-lookup"
+ * plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
+ * role-hint="count-artifacts"
+ * instantiation-strategy="per-lookup"
  */
+@Service("knownRepositoryContentConsumer#count-artifacts")
+@Scope("prototype")
 public class ArtifactCountConsumer
     extends AbstractProgressConsumer
     implements KnownRepositoryContentConsumer
 {
     /**
-     * @plexus.configuration default-value="count-artifacts"
+     * plexus.configuration default-value="count-artifacts"
      */
-    private String id;
+    private String id = "count-artifacts";
 
     /**
-     * @plexus.configuration default-value="Count Artifacts"
+     * plexus.configuration default-value="Count Artifacts"
      */
-    private String description;
+    private String description = "Count Artifacts";
 
     private List<String> includes;
 
diff --git a/archiva-cli/src/main/resources/META-INF/spring-context.xml b/archiva-cli/src/main/resources/META-INF/spring-context.xml
new file mode 100644 (file)
index 0000000..11fa0dd
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+           http://www.springframework.org/schema/context 
+           http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+       default-lazy-init="true">
+
+  <context:annotation-config/>
+  <context:component-scan base-package="org.apache.maven.archiva.cli"/>
+
+</beans>
\ No newline at end of file