当前位置: 首页>>代码示例>>Java>>正文


Java ServiceLoader类代码示例

本文整理汇总了Java中org.jboss.arquillian.core.spi.ServiceLoader的典型用法代码示例。如果您正苦于以下问题:Java ServiceLoader类的具体用法?Java ServiceLoader怎么用?Java ServiceLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ServiceLoader类属于org.jboss.arquillian.core.spi包,在下文中一共展示了ServiceLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
@Before
public void setup() throws Exception {

    serviceProducer.set(serviceLoader);

    final List<GovernorProvider> governorProviders = new ArrayList<GovernorProvider>();
    governorProviders.add(governorProvider);

    Mockito.when(serviceLoader.all(GovernorProvider.class)).thenReturn(governorProviders);

    manager = Mockito.spy(getManager());
    Mockito.when(manager.resolve(ServiceLoader.class)).thenReturn(serviceLoader);

    governorConfiguration = new GovernorConfiguration();
    bind(ApplicationScoped.class, GovernorConfiguration.class, governorConfiguration);

    jiraGovernorConfiguration = new JiraGovernorConfiguration();
    jiraGovernorConfiguration.setServer(JIRA_SERVER_ADDRESS);
    jiraGovernorConfiguration.setUsername(USERNAME);
    jiraGovernorConfiguration.setPassword(PASSWORD);

    bind(ApplicationScoped.class, JiraGovernorConfiguration.class, jiraGovernorConfiguration);

    final JiraGovernorClient jiraGovernorClient = new JiraGovernorClientFactory().build(jiraGovernorConfiguration);
    bind(ApplicationScoped.class, JiraGovernorClient.class, jiraGovernorClient);
}
 
开发者ID:arquillian,项目名称:arquillian-governor,代码行数:27,代码来源:JiraGovernorTestCase.java

示例2: loadAuxiliaryArchives

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
private List<Archive<?>> loadAuxiliaryArchives() {
	List<Archive<?>> archives = new ArrayList<>();

	// load based on the Containers ClassLoader

	ServiceLoader serviceLoader = _serviceLoaderInstance.get();

	Collection<AuxiliaryArchiveAppender> archiveAppenders =
		serviceLoader.all(AuxiliaryArchiveAppender.class);

	for (AuxiliaryArchiveAppender archiveAppender : archiveAppenders) {
		Archive<?> auxiliaryArchive =
			archiveAppender.createAuxiliaryArchive();

		if (auxiliaryArchive != null) {
			archives.add(auxiliaryArchive);
		}
	}

	return archives;
}
 
开发者ID:arquillian,项目名称:arquillian-extension-liferay,代码行数:22,代码来源:OSGiAllInProcessor.java

示例3: init

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
@Before
public void init() throws Exception {
    bind(ApplicationScoped.class, ServiceLoader.class, serviceLoader);
    bind(ApplicationScoped.class, ScreenshooterConfiguration.class, configuration);
    bind(ApplicationScoped.class, Screenshooter.class, screenshooter);
    bind(ApplicationScoped.class, RecorderStrategyRegister.class, recorderStrategyRegister);

    Mockito.when(screenshooter.getScreenshotType()).thenReturn(ScreenshotType.PNG);

    Mockito.doNothing().when(cleaner).clean(configuration);

    Mockito.when(serviceLoader.onlyOne(ScreenshooterEnvironmentCleaner.class, DefaultScreenshooterEnvironmentCleaner.class))
        .thenReturn(cleaner);

    screenshotFile = folder.newFile("screenshot.png");
    URL resource = BlurLevelTestCase.class.getResource("/arquillian_ui_success_256px.png");
    FileUtils.copyURLToFile(resource, screenshotFile);
    originalSize = (int) screenshotFile.length();
    OUTPUT_FILE = screenshotFile.getAbsoluteFile();
}
 
开发者ID:arquillian,项目名称:arquillian-recorder,代码行数:21,代码来源:BlurLevelTestCase.java

示例4: init

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
@Before
public void init() {
    cubeRegistry = new LocalCubeRegistry();
    dockerContainerObjectFactory = new DockerContainerObjectFactory();
    cubeController = mock(CubeController.class);
    dockerClientExecutor = mock(DockerClientExecutor.class);
    injector = mock(Injector.class);
    serviceLoader = mock(ServiceLoader.class);
    when(serviceLoader.all(any(Class.class))).thenReturn(Collections.emptyList());

    dockerContainerObjectFactory.serviceLoaderInstance = () -> serviceLoader;
    dockerContainerObjectFactory.dockerClientExecutorInstance = () -> dockerClientExecutor;
    dockerContainerObjectFactory.cubeRegistryInstance = () -> cubeRegistry;
    dockerContainerObjectFactory.cubeControllerInstance = () -> cubeController;
    dockerContainerObjectFactory.injectorInstance = () -> injector;

    //We asure that there is no previous executions there.
    deleteTestDirectory();
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:20,代码来源:CubeContainerObjectTestEnricherTest.java

示例5: initializeReporterAndRegisterServices

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
@Before
public final void initializeReporterAndRegisterServices() {
    initMocks(this);

    initiateStringKeys();
    bind(ApplicationScoped.class, ServiceLoader.class, serviceLoader);

    fire(new InitiateReporterEvent(lifecycleManager));
    registerBuilders();
}
 
开发者ID:arquillian,项目名称:arquillian-reporter,代码行数:11,代码来源:AbstractReporterTestBase.java

示例6: getCommandService

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
private CommandService getCommandService() {
    ServiceLoader loader = serviceLoader.get();
    if (loader == null) {
        throw new IllegalStateException("No " + ServiceLoader.class.getName() + " found in context");
    }
    CommandService service = loader.onlyOne(CommandService.class);
    if (service == null) {
        throw new IllegalStateException("No " + CommandService.class.getName() + " found in context");
    }
    return service;
}
 
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:12,代码来源:RemoteConsumerPactTest.java

示例7: registerInstance

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
/**
 * Method which observes {@link ContainerRegistry}. Gets called by Arquillian at startup time.
 * 
 * @param registry
 *           contains containers defined in arquillian.xml
 * @param serviceLoader
 */
public void registerInstance(@Observes ContainerRegistry registry, ServiceLoader serviceLoader) {
   GenericContainer dockerContainer = new GenericContainer(DOCKER_IMAGE)
      .withExposedPorts(WILDFLY_MANAGEMENT_PORT);
   dockerContainer.start();

   configureArquillianForRemoteWildfly(dockerContainer, registry);

   setupDb(dockerContainer);
}
 
开发者ID:kaiwinter,项目名称:testcontainers-examples,代码行数:17,代码来源:WildflyMariaDBDockerExtension.java

示例8: setup

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
@Before
public void setup() {
    t = new ToxicProxyHandler();
    t.networkChaosConfigurationInstance = () -> {
        Mockito.when(networkChaosConfiguration.isToxifyPortBinding()).thenReturn(false);
        return networkChaosConfiguration;
    };
    Mockito.when(loader.onlyOne(ProxyManager.class)).thenReturn(t);
    bind(ApplicationScoped.class, ServiceLoader.class, loader);
}
 
开发者ID:arquillian,项目名称:arquillian-cube-q,代码行数:11,代码来源:InstallProxyTestCase.java

示例9: setup

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
@Before
public void setup() {

    Proxy p = new Proxy.Builder().build();

    bind(ApplicationScoped.class, ArquillianDescriptor.class, descriptor);
    bind(ApplicationScoped.class, ServiceLoader.class, serviceLoader);

    Mockito.when(serviceLoader.onlyOne(ProxyManager.class)).thenReturn(proxyManager);
    Mockito.when(proxyManager.install(Mockito.any(DockerCompositions.class))).thenReturn(p);
}
 
开发者ID:arquillian,项目名称:arquillian-cube-q,代码行数:12,代码来源:InstallProxyTestCase.java

示例10: setup

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
@Before
public void setup() throws Exception {

    serviceProducer.set(serviceLoader);

    final List<GovernorProvider> governorProviders = new ArrayList<GovernorProvider>();
    governorProviders.add(governorProvider);

    Mockito.when(serviceLoader.all(GovernorProvider.class)).thenReturn(governorProviders);

    manager = Mockito.spy(getManager());
    Mockito.when(manager.resolve(ServiceLoader.class)).thenReturn(serviceLoader);

    governorConfiguration = new GovernorConfiguration();
    bind(ApplicationScoped.class, GovernorConfiguration.class, governorConfiguration);

    redminebGovernorConfiguration = new RedmineGovernorConfiguration();
    redminebGovernorConfiguration.setApiKey("apikey");
    redminebGovernorConfiguration.setServer("http://localhost");
    redminebGovernorConfiguration.setForce(true);
    redminebGovernorConfiguration.setClosePassed(true);

    bind(ApplicationScoped.class, RedmineGovernorConfiguration.class, redminebGovernorConfiguration);

    final RedmineGovernorClient redmineGovernorClient = new RedmineGovernorClientFactory().build(redminebGovernorConfiguration);
    bind(ApplicationScoped.class, RedmineGovernorClient.class, redmineGovernorClient);
}
 
开发者ID:arquillian,项目名称:arquillian-governor,代码行数:28,代码来源:RedmineGovernorTestCase.java

示例11: setup

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
@Before
public void setup() throws Exception {

    serviceProducer.set(serviceLoader);

    final List<GovernorProvider> governorProviders = new ArrayList<GovernorProvider>();
    governorProviders.add(governorProvider);

    Mockito.when(serviceLoader.all(GovernorProvider.class)).thenReturn(governorProviders);

    manager = Mockito.spy(getManager());
    Mockito.when(manager.resolve(ServiceLoader.class)).thenReturn(serviceLoader);

    governorConfiguration = new GovernorConfiguration();
    bind(ApplicationScoped.class, GovernorConfiguration.class, governorConfiguration);

    gitHubGovernorConfiguration = new GitHubGovernorConfiguration();
    gitHubGovernorConfiguration.setRepository(REPOSITORY_NAME);
    gitHubGovernorConfiguration.setRepositoryUser(REPOSITORY_USERNAME);
    gitHubGovernorConfiguration.setForce(true);
    gitHubGovernorConfiguration.setClosePassed(true);

    if (!TOKEN.equals(EMPTY_STRING)) {
        gitHubGovernorConfiguration.setToken(TOKEN);
    }

    gitHubGovernorConfiguration.setUsername(USERNAME);
    gitHubGovernorConfiguration.setPassword(PASSWORD);

    bind(ApplicationScoped.class, GitHubGovernorConfiguration.class, gitHubGovernorConfiguration);

    final GitHubGovernorClient gitHubGovernorClient = new GitHubGovernorClientFactory().build(gitHubGovernorConfiguration);
    bind(ApplicationScoped.class, GitHubGovernorClient.class, gitHubGovernorClient);
}
 
开发者ID:arquillian,项目名称:arquillian-governor,代码行数:35,代码来源:GitHubGovernorTestCase.java

示例12: setup

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
@Before
public void setup() {
    serviceProducer.set(serviceLoader);

    final List<GovernorProvider> governorProviders = new ArrayList<GovernorProvider>();
    governorProviders.add(governorProvider);

    Mockito.when(serviceLoader.all(GovernorProvider.class)).thenReturn(governorProviders);

    manager = Mockito.spy(getManager());
    Mockito.when(manager.resolve(ServiceLoader.class)).thenReturn(serviceLoader);

    governorConfiguration = new GovernorConfiguration();
    bind(ApplicationScoped.class, GovernorConfiguration.class, governorConfiguration);
}
 
开发者ID:arquillian,项目名称:arquillian-governor,代码行数:16,代码来源:GovernorTestCase.java

示例13: createInstanceProducer

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
public void createInstanceProducer(
	@Observes ArquillianDescriptor arquillianDescriptor) {

	ServiceLoader serviceLoader = _serviceLoaderInstance.get();

	_importPackageManagerInstanceProducer.set(
		serviceLoader.onlyOne(ImportPackageManager.class));

	_manifestManagerInstanceProducer.set(
		serviceLoader.onlyOne(ManifestManager.class));

	_bundleActivatorsManagerInstanceProducer.set(
		serviceLoader.onlyOne(BundleActivatorsManager.class));
}
 
开发者ID:arquillian,项目名称:arquillian-extension-liferay,代码行数:15,代码来源:OSGiAllInBundleInstanceProducer.java

示例14: setMocks

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
@org.junit.Before
public void setMocks() throws Exception {
    bind(ApplicationScoped.class, ServiceLoader.class, serviceLoader);
    bind(ApplicationScoped.class, ScreenshooterConfiguration.class, configuration);
    bind(ApplicationScoped.class, Screenshooter.class, screenshooter);
    bind(ApplicationScoped.class, RecorderStrategyRegister.class, recorderStrategyRegister);

    Mockito.when(screenshooter.getScreenshotType()).thenReturn(ScreenshotType.PNG);

    Mockito.doNothing().when(cleaner).clean(configuration);

    Mockito.when(serviceLoader.onlyOne(ScreenshooterEnvironmentCleaner.class, DefaultScreenshooterEnvironmentCleaner.class))
        .thenReturn(cleaner);
}
 
开发者ID:arquillian,项目名称:arquillian-recorder,代码行数:15,代码来源:ScreenshooterLifecycleObserverTestCase.java

示例15: setup

import org.jboss.arquillian.core.spi.ServiceLoader; //导入依赖的package包/类
@org.junit.Before
    public void setup() throws Exception {
        bind(ApplicationScoped.class, ServiceLoader.class, serviceLoader);
        bind(ApplicationScoped.class, VideoConfiguration.class, configuration);
        bind(ApplicationScoped.class, Recorder.class, recorder);
        bind(ApplicationScoped.class, TakenResourceRegister.class, takenResourceRegister);

        strategy.setConfiguration(configuration);
        bind(ApplicationScoped.class, VideoStrategy.class, strategy);

        Mockito.when(recorder.getVideoType()).thenReturn(VideoType.MP4);

        Mockito.doNothing().when(cleaner).clean(configuration);

        Mockito.when(serviceLoader.onlyOne(VideoRecorderEnvironmentCleaner.class, DefaultVideoRecorderEnvironmentCleaner.class))
            .thenReturn(cleaner);

//        Mockito.when(serviceLoader.onlyOne(VideoStrategy.class, DefaultVideoStrategy.class))
//            .thenReturn(strategy);

        videoFile = File.createTempFile("fakeVideo", recorder.getVideoType().toString().toLowerCase());

        Mockito.when(configuration.getVideoName()).thenReturn("record");

        Mockito.when(video.getResource()).thenReturn(videoFile);
        Mockito.when(video.getResourceType()).thenReturn(VideoType.MP4);
        Mockito.when(video.getWidth()).thenReturn(100);
        Mockito.when(video.getHeight()).thenReturn(100);

        Mockito.when(recorder.stopRecording()).thenReturn(video);
    }
 
开发者ID:arquillian,项目名称:arquillian-recorder,代码行数:32,代码来源:RecorderLifecycleObserverTestCase.java


注:本文中的org.jboss.arquillian.core.spi.ServiceLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。