1package org.apache.archiva.common.plexusbridge;
23/*4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122import org.codehaus.plexus.digest.Digester;
23import org.codehaus.plexus.digest.Md5Digester;
24import org.codehaus.plexus.digest.Sha1Digester;
25import org.slf4j.Logger;
26import org.slf4j.LoggerFactory;
27import org.springframework.stereotype.Service;
2829import javax.inject.Inject;
30import java.util.Arrays;
31import java.util.List;
3233/**34 * @author Olivier Lamy35 * @since 1.4-M136 */37 @Service( "digesterUtils" )
38publicclassDigesterUtils39 {
4041private Logger log = LoggerFactory.getLogger( getClass() );
4243private List<? extends Digester> allDigesters;
4445 @Inject
46publicDigesterUtils( PlexusSisuBridge plexusSisuBridge )
47throwsPlexusSisuBridgeException48 {
49this.allDigesters = plexusSisuBridge.lookupList( Digester.class );
5051if ( allDigesters == null || allDigesters.isEmpty() )
52 {
53// olamy when the TCL is not a URLClassLoader lookupList fail !54// when using tomcat maven plugin so adding a simple hack55 log.warn( "using lookupList from sisu plexus failed so build plexus Digesters manually" );
5657 allDigesters = Arrays.asList( new Sha1Digester(), new Md5Digester() );
5859 }
6061if ( allDigesters == null || allDigesters.isEmpty() )
62 {
63thrownew PlexusSisuBridgeException( "no way to initiliaze IndexCreator" );
64 }
6566 log.debug( "allIndexCreators {}", allDigesters );
6768 }
6970public List<? extends Digester> getAllDigesters()
71 {
72return allDigesters;
73 }
7475publicvoid setAllDigesters( List<? extends Digester> allDigesters )
76 {
77this.allDigesters = allDigesters;
78 }
79 }