Skip to content

Commit

Permalink
[MNG-4474] [regression] Wagon manager does not respect instantiation …
Browse files Browse the repository at this point in the history
…strategy of wagons

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@885758 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
bentmann committed Dec 1, 2009
1 parent 411fd3c commit 269c956
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 7 deletions.
Expand Up @@ -46,6 +46,7 @@
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;

Expand All @@ -67,9 +68,6 @@ public class DefaultWagonManager
@Requirement
private PlexusContainer container;

@Requirement(role = Wagon.class)
private Map<String, Wagon> wagons;

@Requirement
private UpdateCheckManager updateCheckManager;

Expand Down Expand Up @@ -686,11 +684,16 @@ public Wagon getWagon( String protocol )
}

String hint = protocol.toLowerCase( java.util.Locale.ENGLISH );
Wagon wagon = (Wagon) wagons.get( hint );

if ( wagon == null )
Wagon wagon;
try
{
wagon = container.lookup( Wagon.class, hint );
}
catch ( ComponentLookupException e )
{
throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: " + protocol );
throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: "
+ protocol, e );
}

return wagon;
Expand Down
Expand Up @@ -383,6 +383,17 @@ public void xtestChecksumVerification()
}
}

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
{
Expand Down
@@ -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 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -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>
Expand Down

0 comments on commit 269c956

Please sign in to comment.