本文整理汇总了Java中org.codehaus.plexus.DefaultContainerConfiguration.setComponentVisibility方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultContainerConfiguration.setComponentVisibility方法的具体用法?Java DefaultContainerConfiguration.setComponentVisibility怎么用?Java DefaultContainerConfiguration.setComponentVisibility使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.DefaultContainerConfiguration
的用法示例。
在下文中一共展示了DefaultContainerConfiguration.setComponentVisibility方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTest
import org.codehaus.plexus.DefaultContainerConfiguration; //导入方法依赖的package包/类
@Override
protected Object createTest()
throws Exception
{
final TestClass testClass = getTestClass();
final DefaultContainerConfiguration config = new DefaultContainerConfiguration();
config.setAutoWiring( true );
config.setClassPathScanning( PlexusConstants.SCANNING_ON );
config.setComponentVisibility( PlexusConstants.GLOBAL_VISIBILITY );
config.setName( testClass.getName() );
final DefaultPlexusContainer container = new DefaultPlexusContainer( config );
final ClassSpace cs = new URLClassSpace( Thread.currentThread()
.getContextClassLoader() );
container.addPlexusInjector( Arrays.<PlexusBeanModule> asList( new PlexusAnnotatedBeanModule(
cs,
Collections.emptyMap() ) ) );
return container.lookup( testClass.getJavaClass() );
}
示例2: initialize
import org.codehaus.plexus.DefaultContainerConfiguration; //导入方法依赖的package包/类
@PostConstruct
public void initialize()
throws PlexusSisuBridgeException
{
DefaultContainerConfiguration conf = new DefaultContainerConfiguration();
conf.setAutoWiring( containerAutoWiring );
conf.setClassPathScanning( containerClassPathScanning );
conf.setComponentVisibility( containerComponentVisibility );
conf.setContainerConfigurationURL( overridingComponentsXml );
ClassWorld classWorld = new ClassWorld();
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
containerRealm = new ClassRealm( classWorld, "maven", tccl );
// olamy hackhish but plexus-sisu need a URLClassLoader with URL filled
if ( tccl instanceof URLClassLoader )
{
URL[] urls = ( (URLClassLoader) tccl ).getURLs();
for ( URL url : urls )
{
containerRealm.addURL( url );
}
}
conf.setRealm( containerRealm );
//conf.setClassWorld( classWorld );
ClassLoader ori = Thread.currentThread().getContextClassLoader();
try
{
Thread.currentThread().setContextClassLoader( containerRealm );
plexusContainer = new DefaultPlexusContainer( conf );
}
catch ( PlexusContainerException e )
{
throw new PlexusSisuBridgeException( e.getMessage(), e );
}
finally
{
Thread.currentThread().setContextClassLoader( ori );
}
}