mirror of https://github.com/apache/maven.git
[MNG-4296] allow core extensions configure new classrealms
Submitted by: Igor Fedorenko git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@803811 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d198f32117
commit
6e302e26c9
|
@ -0,0 +1,34 @@
|
|||
package org.apache.maven.classrealm;
|
||||
|
||||
/*
|
||||
* 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.classworlds.realm.ClassRealm;
|
||||
|
||||
/**
|
||||
* ClassRealmManagerDelegate is used to perform addition configuration of
|
||||
* class realms created by ClassRealmManager.
|
||||
*
|
||||
* @author igor
|
||||
*/
|
||||
public interface ClassRealmManagerDelegate
|
||||
{
|
||||
void setupRealm( ClassRealm classRealm );
|
||||
}
|
|
@ -19,6 +19,8 @@ package org.apache.maven.classrealm;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
|
@ -31,6 +33,7 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
|||
import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
||||
/**
|
||||
|
@ -93,6 +96,11 @@ public class DefaultClassRealmManager
|
|||
|
||||
importMavenApi( classRealm );
|
||||
|
||||
for ( ClassRealmManagerDelegate delegate : getDelegates() )
|
||||
{
|
||||
delegate.setupRealm( classRealm );
|
||||
}
|
||||
|
||||
return classRealm;
|
||||
}
|
||||
}
|
||||
|
@ -178,4 +186,16 @@ public class DefaultClassRealmManager
|
|||
return "plugin>" + plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + version;
|
||||
}
|
||||
|
||||
private List<ClassRealmManagerDelegate> getDelegates()
|
||||
{
|
||||
try
|
||||
{
|
||||
return container.lookupList( ClassRealmManagerDelegate.class );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue