add an other hack when using tomcat maven plugin and issue with TCCL not URLClassLoader with sisu

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1158273 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-08-16 13:51:25 +00:00
parent c7607a63e5
commit b39ba2f6c5
8 changed files with 106 additions and 15 deletions

View File

@ -19,6 +19,7 @@ package org.apache.maven.archiva.converter.artifact;
* under the License. * under the License.
*/ */
import org.apache.archiva.common.plexusbridge.DigesterUtils;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@ -78,11 +79,14 @@ public class LegacyToDefaultConverter
* {@link List}<{@link Digester} * {@link List}<{@link Digester}
* plexus.requirement role="org.codehaus.plexus.digest.Digester" * plexus.requirement role="org.codehaus.plexus.digest.Digester"
*/ */
private List<Digester> digesters; private List<? extends Digester> digesters;
@Inject @Inject
private PlexusSisuBridge plexusSisuBridge; private PlexusSisuBridge plexusSisuBridge;
@Inject
private DigesterUtils digesterUtils;
/** /**
* plexus.requirement * plexus.requirement
*/ */
@ -114,7 +118,7 @@ public class LegacyToDefaultConverter
public void initialize() public void initialize()
throws PlexusSisuBridgeException throws PlexusSisuBridgeException
{ {
this.digesters = plexusSisuBridge.lookupList( Digester.class ); this.digesters = digesterUtils.getAllDigesters();
translator = plexusSisuBridge.lookup( ModelConverter.class ); translator = plexusSisuBridge.lookup( ModelConverter.class );
artifactFactory = plexusSisuBridge.lookup( ArtifactFactory.class ); artifactFactory = plexusSisuBridge.lookup( ArtifactFactory.class );
artifactHandlerManager = plexusSisuBridge.lookup( ArtifactHandlerManager.class ); artifactHandlerManager = plexusSisuBridge.lookup( ArtifactHandlerManager.class );
@ -716,7 +720,7 @@ public class LegacyToDefaultConverter
} }
public List<Digester> getDigesters() public List<? extends Digester> getDigesters()
{ {
return digesters; return digesters;
} }

View File

@ -19,6 +19,7 @@ package org.apache.maven.archiva.consumers.core;
* under the License. * under the License.
*/ */
import org.apache.archiva.common.plexusbridge.DigesterUtils;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
@ -81,11 +82,14 @@ public class ValidateChecksumConsumer
/** /**
* plexus.requirement role="org.codehaus.plexus.digest.Digester" * plexus.requirement role="org.codehaus.plexus.digest.Digester"
*/ */
private List<Digester> digesterList; private List<Digester> allDigesters;
@Inject @Inject
private PlexusSisuBridge plexusSisuBridge; private PlexusSisuBridge plexusSisuBridge;
@Inject
private DigesterUtils digesterUtils;
private File repositoryDir; private File repositoryDir;
private List<String> includes = new ArrayList<String>(); private List<String> includes = new ArrayList<String>();
@ -163,7 +167,7 @@ public class ValidateChecksumConsumer
} }
} }
public void processFile( String path, boolean executeOnEntireRepo ) public void processFile( String path, boolean executeOnEntireReDpo )
throws Exception throws Exception
{ {
processFile( path ); processFile( path );
@ -174,10 +178,9 @@ public class ValidateChecksumConsumer
throws PlexusSisuBridgeException throws PlexusSisuBridgeException
{ {
checksum = plexusSisuBridge.lookup( ChecksumFile.class ); checksum = plexusSisuBridge.lookup( ChecksumFile.class );
digesterList = plexusSisuBridge.lookupList( Digester.class ); List<Digester> allDigesters = new ArrayList<Digester>( digesterUtils.getAllDigesters() );
for ( Iterator<Digester> itDigesters = digesterList.iterator(); itDigesters.hasNext(); ) for ( Digester digester : allDigesters )
{ {
Digester digester = itDigesters.next();
includes.add( "**/*" + digester.getFilenameExtension() ); includes.add( "**/*" + digester.getFilenameExtension() );
} }
} }

View File

@ -53,5 +53,15 @@
<groupId>org.apache.maven.indexer</groupId> <groupId>org.apache.maven.indexer</groupId>
<artifactId>indexer-core</artifactId> <artifactId>indexer-core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-digest</artifactId>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,74 @@
package org.apache.archiva.common.plexusbridge;
/*
* 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.codehaus.plexus.digest.Digester;
import org.codehaus.plexus.digest.Md5Digester;
import org.codehaus.plexus.digest.Sha1Digester;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
import java.util.Arrays;
import java.util.List;
/**
* @author Olivier Lamy
* @since 1.4
*/
@Service( "digesterUtils" )
public class DigesterUtils
{
private Logger log = LoggerFactory.getLogger( getClass() );
private List<? extends Digester> allDigesters;
@Inject
public DigesterUtils( PlexusSisuBridge plexusSisuBridge )
throws PlexusSisuBridgeException
{
this.allDigesters = plexusSisuBridge.lookupList( Digester.class );
if ( allDigesters == null || allDigesters.isEmpty() )
{
// olamy when the TCL is not a URLClassLoader lookupList fail !
// when using tomcat maven plugin so adding a simple hack
log.warn( "using lookList from sisu plexus failed so build plexus Digesters manually" );
allDigesters = Arrays.asList( new Sha1Digester(), new Md5Digester() );
}
log.debug( "allIndexCreators {}", allDigesters );
}
public List<? extends Digester> getAllDigesters()
{
return allDigesters;
}
public void setAllDigesters( List<? extends Digester> allDigesters )
{
this.allDigesters = allDigesters;
}
}

View File

@ -49,19 +49,19 @@ public abstract class AbstractTransactionEvent
/** /**
* {@link List}&lt;{@link Digester}> * {@link List}&lt;{@link Digester}>
*/ */
private List<Digester> digesters; private List<? extends Digester> digesters;
protected AbstractTransactionEvent() protected AbstractTransactionEvent()
{ {
this( new ArrayList<Digester>( 0 ) ); this( new ArrayList<Digester>( 0 ) );
} }
protected AbstractTransactionEvent( List<Digester> digesters ) protected AbstractTransactionEvent( List<? extends Digester> digesters )
{ {
this.digesters = digesters; this.digesters = digesters;
} }
protected List<Digester> getDigesters() protected List<? extends Digester> getDigesters()
{ {
return digesters; return digesters;
} }

View File

@ -44,7 +44,7 @@ public class CopyFileEvent
* @param destination * @param destination
* @param digesters {@link List}&lt;{@link Digester}> digesters to use for checksumming * @param digesters {@link List}&lt;{@link Digester}> digesters to use for checksumming
*/ */
public CopyFileEvent( File source, File destination, List<Digester> digesters ) public CopyFileEvent( File source, File destination, List<? extends Digester> digesters )
{ {
super( digesters ); super( digesters );
this.source = source; this.source = source;

View File

@ -43,7 +43,7 @@ public class CreateFileEvent
* @param destination * @param destination
* @param digesters {@link List}&lt;{@link Digester}> digesters to use for checksumming * @param digesters {@link List}&lt;{@link Digester}> digesters to use for checksumming
*/ */
public CreateFileEvent( String content, File destination, List<Digester> digesters ) public CreateFileEvent( String content, File destination, List<? extends Digester> digesters )
{ {
super( digesters ); super( digesters );
this.content = content; this.content = content;

View File

@ -79,7 +79,7 @@ public class FileTransaction
* @param destination * @param destination
* @param digesters {@link List}&lt;{@link org.codehaus.plexus.digest.Digester}> digesters to use for checksumming * @param digesters {@link List}&lt;{@link org.codehaus.plexus.digest.Digester}> digesters to use for checksumming
*/ */
public void copyFile( File source, File destination, List<Digester> digesters ) public void copyFile( File source, File destination, List<? extends Digester> digesters )
{ {
events.add( new CopyFileEvent( source, destination, digesters ) ); events.add( new CopyFileEvent( source, destination, digesters ) );
} }
@ -89,7 +89,7 @@ public class FileTransaction
* @param destination * @param destination
* @param digesters {@link List}&lt;{@link org.codehaus.plexus.digest.Digester}> digesters to use for checksumming * @param digesters {@link List}&lt;{@link org.codehaus.plexus.digest.Digester}> digesters to use for checksumming
*/ */
public void createFile( String content, File destination, List<Digester> digesters ) public void createFile( String content, File destination, List<? extends Digester> digesters )
{ {
events.add( new CreateFileEvent( content, destination, digesters ) ); events.add( new CreateFileEvent( content, destination, digesters ) );
} }