mirror of https://github.com/apache/maven.git
[MNG-4474] [regression] Wagon manager does not respect instantiation strategy of wagons
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@885758 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
411fd3c42b
commit
269c956ea6
|
@ -46,6 +46,7 @@ import org.codehaus.plexus.PlexusContainer;
|
|||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
|
@ -67,9 +68,6 @@ public class DefaultWagonManager
|
|||
@Requirement
|
||||
private PlexusContainer container;
|
||||
|
||||
@Requirement(role = Wagon.class)
|
||||
private Map<String, Wagon> wagons;
|
||||
|
||||
@Requirement
|
||||
private UpdateCheckManager updateCheckManager;
|
||||
|
||||
|
@ -686,11 +684,16 @@ public class DefaultWagonManager
|
|||
}
|
||||
|
||||
String hint = protocol.toLowerCase( java.util.Locale.ENGLISH );
|
||||
Wagon wagon = (Wagon) wagons.get( hint );
|
||||
|
||||
if ( wagon == null )
|
||||
Wagon wagon;
|
||||
try
|
||||
{
|
||||
throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: " + protocol );
|
||||
wagon = container.lookup( Wagon.class, hint );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: "
|
||||
+ protocol, e );
|
||||
}
|
||||
|
||||
return wagon;
|
||||
|
|
|
@ -383,6 +383,17 @@ public class DefaultWagonManagerTest
|
|||
}
|
||||
}
|
||||
|
||||
public void testPerLookupInstantiation()
|
||||
throws Exception
|
||||
{
|
||||
String protocol = "perlookup";
|
||||
|
||||
Wagon one = wagonManager.getWagon( protocol );
|
||||
Wagon two = wagonManager.getWagon( protocol );
|
||||
|
||||
assertNotSame( one, two );
|
||||
}
|
||||
|
||||
private void assertWagon( String protocol )
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package org.apache.maven.repository.legacy;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import org.apache.maven.wagon.Wagon;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
|
||||
/**
|
||||
* Wagon with per-lookup instantiation strategy.
|
||||
*/
|
||||
@Component( role = Wagon.class, hint = "perlookup", instantiationStrategy = "per-lookup" )
|
||||
public class PerLookupWagon
|
||||
extends WagonMock
|
||||
{
|
||||
|
||||
public String[] getSupportedProtocols()
|
||||
{
|
||||
return new String[] { "perlookup" };
|
||||
}
|
||||
|
||||
}
|
2
pom.xml
2
pom.xml
|
@ -41,7 +41,7 @@
|
|||
<commonsCliVersion>1.2</commonsCliVersion>
|
||||
<easyMockVersion>1.2_Java1.3</easyMockVersion>
|
||||
<junitVersion>3.8.2</junitVersion>
|
||||
<plexusVersion>1.5.1</plexusVersion>
|
||||
<plexusVersion>1.5.2</plexusVersion>
|
||||
<plexusInterpolationVersion>1.11</plexusInterpolationVersion>
|
||||
<plexusPluginManagerVersion>1.0-alpha-1</plexusPluginManagerVersion>
|
||||
<plexusUtilsVersion>2.0.1</plexusUtilsVersion>
|
||||
|
|
Loading…
Reference in New Issue