fix cli module

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1134775 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-06-11 21:31:07 +00:00
parent 0ad81d8bc6
commit 27b5c1a52b
3 changed files with 62 additions and 13 deletions

View File

@ -47,6 +47,7 @@ import java.net.MalformedURLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@ -242,8 +243,20 @@ public class ArchivaCli
private Map<String, KnownRepositoryContentConsumer> getConsumers() private Map<String, KnownRepositoryContentConsumer> getConsumers()
throws PlexusSisuBridgeException throws PlexusSisuBridgeException
{ {
PlexusSisuBridge plexusSisuBridge = applicationContext.getBean( PlexusSisuBridge.class ); Map<String, KnownRepositoryContentConsumer> beans =
return plexusSisuBridge.lookupMap( KnownRepositoryContentConsumer.class ); 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 ) private void doConversion( String properties )

View File

@ -19,33 +19,36 @@ package org.apache.maven.archiva.cli;
* under the License. * 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.ArrayList;
import java.util.List; import java.util.List;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
/** /**
* ArtifactCountConsumer * ArtifactCountConsumer
* *
* @version $Id$ * @version $Id$
* * plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
* @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer" * role-hint="count-artifacts"
* role-hint="count-artifacts" * instantiation-strategy="per-lookup"
* instantiation-strategy="per-lookup"
*/ */
@Service("knownRepositoryContentConsumer#count-artifacts")
@Scope("prototype")
public class ArtifactCountConsumer public class ArtifactCountConsumer
extends AbstractProgressConsumer extends AbstractProgressConsumer
implements KnownRepositoryContentConsumer 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; private List<String> includes;

View File

@ -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>