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


Java MutablePicoContainer.addComponent方法代码示例

本文整理汇总了Java中org.picocontainer.MutablePicoContainer.addComponent方法的典型用法代码示例。如果您正苦于以下问题:Java MutablePicoContainer.addComponent方法的具体用法?Java MutablePicoContainer.addComponent怎么用?Java MutablePicoContainer.addComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.picocontainer.MutablePicoContainer的用法示例。


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

示例1: newFactory

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
public static <T> T newFactory(@NotNull final Class<T> clusterClientInterface,
                               @NotNull final Config clusterConfig,
                               @NotNull final ActorRegistry actorRegistry) {

    requireNonNull(clusterClientInterface);
    requireNonNull(clusterConfig);
    requireNonNull(actorRegistry);

    String factoryClassName = clusterConfig.getString(FACTORY_CLASS);
    Config factoryConfig = clusterConfig.getConfig(FACTORY_CONFIG);

    MutablePicoContainer container = new DefaultPicoContainer();
    container.addComponent(factoryConfig);
    container.addComponent(actorRegistry);

    try {
        Class<? extends T> factoryClass = Class.forName(factoryClassName) // NOSONAR
                .asSubclass(clusterClientInterface); // NOSONAR
        container.addComponent(factoryClass);
        return container.getComponent(factoryClass);
    } catch (ClassNotFoundException e) {
        throw propagate(e);
    }
}
 
开发者ID:florentw,项目名称:bench,代码行数:25,代码来源:ClusterClients.java

示例2: createReactor

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
/**
 * Inject dependencies to create a reactor.
 */
private Reactor<Serializable> createReactor(final ActorKey key, //
                                            final Metrics metrics, //
                                            final Class<? extends Reactor> clazz, //
                                            final ActorClusterClient client, //
                                            final Config config) {

    MutablePicoContainer pico = new DefaultPicoContainer();

    pico.addComponent(key);

    pico.addComponent(config);

    pico.addComponent((Sender) (to, payload) -> {
        requireNonNull(to);
        requireNonNull(payload);

        client.actorSender().send(new ActorKey(to), ActorInputMessage.message(key.getName(), payload));
    });

    pico.addComponent(metrics);

    pico.addComponent(clazz);

    return pico.getComponent(clazz);
}
 
开发者ID:florentw,项目名称:bench,代码行数:29,代码来源:Actors.java

示例3: createPicoContatiner

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
private MutablePicoContainer createPicoContatiner() {
	final MutablePicoContainer picoContainer = new PicoBuilder()
			.withBehaviors(new OptInCaching())
			.withComponentFactory(new CompositeInjection(new AnnotatedFieldInjection(Inject.class)))
			.build();

	picoContainer.addComponent(PicoContainer.class, picoContainer);
	picoContainer.as(Characteristics.CACHE).addComponent(Pico2InjectContext.class);

	picoContainer.as(Characteristics.CACHE).addComponent(TestLazySingleton.class);
	picoContainer.as(Characteristics.CACHE).addComponent(TestEagerSingleton.class);
	picoContainer.addComponent(TestPrototype.class);

	picoContainer.addComponent("key", "value");

	return picoContainer;
}
 
开发者ID:sdif4j,项目名称:sdif4j,代码行数:18,代码来源:Pico2Test.java

示例4: newPicoLifecycleException

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
private PicoLifecycleException newPicoLifecycleException(boolean initialCheckedException) {
  MutablePicoContainer container = ComponentContainer.createPicoContainer().as(Characteristics.CACHE);
  if (initialCheckedException) {
    container.addComponent(CheckedFailureComponent.class);
  } else {
    container.addComponent(UncheckedFailureComponent.class);
  }
  try {
    container.start();
    return null;

  } catch (PicoLifecycleException e) {
    return e;
  }
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:16,代码来源:PicoUtilsTest.java

示例5: Plugin

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
public Plugin(final String name, final URL url, final PicoContainer context) throws InvalidPluginException {
  MutablePicoContainer container = new DefaultPicoContainer(context);
  for (Class<?> clazz : getContributedClasses(url)) {
    container.addComponent(clazz);
  }
  _container = container;
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:8,代码来源:Plugin.java

示例6: AbstractSession

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
public AbstractSession(final AbstractSession parent, final Object... bonusImplementations) {
  _parentContainer = parent == null ? null : parent._container;
  MutablePicoContainer container = new PicoBuilder(_parentContainer).withCaching().withLifecycle().build();
  for (Object o : bonusImplementations) {
    container.addComponent(o);
  }
  configure(container);
  _container = container;
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:10,代码来源:AbstractSession.java

示例7: configure

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
public void configure(final MutablePicoContainer container) {
  container.addComponent(ApplicationSession.class, this);
  container.addComponent(RequestCompletedHandler.class, RequestCompletedHandlerImpl.class);
  container.addComponent(Dispatcher.class, DispatcherImpl.class);
  container.addComponent(DataDir.class, DataDirImpl.class);
  container.addComponent(DeploymentConfiguration.class, PropertiesDeploymentConfiguration.class);
  container.addComponent(ListWikis.class, ListWikisImpl.class);
  container.addComponent(JumpToWikiUrl.class, JumpToWikiUrlImpl.class);
  container.addComponent(WikiChoiceImpl.class);
  container.addComponent(RequestLifecycleAwareManager.class, RequestLifecycleAwareManagerImpl.class);
  container.addComponent(ApplicationUrls.class, RequestScopedApplicationUrls.class);
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:13,代码来源:ApplicationSessionImpl.java

示例8: run

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
@Override
public String run() {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("/application-context-color-supplier.xml");
    SpringPicoContainer springPicoContainer = new SpringPicoContainer(applicationContext);
    MutablePicoContainer pico = new DefaultPicoContainer(springPicoContainer);
    pico.addComponent(Description.class);
    pico.addComponent(LocationSupplier.class);
    pico.addComponent(ColoredCarSupplier.class);
    pico.addComponent(CarSupplier.class);
    Description description = pico.getComponent(Description.class);
    return description.getDescription();
}
 
开发者ID:stefanbirkner,项目名称:picover,代码行数:13,代码来源:PicoAndSpringMixedApp.java

示例9: handlesUnsatisfiableDependencies

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
@Test
public void handlesUnsatisfiableDependencies() {
    ApplicationContext applicationContext = new AnnotationConfigApplicationContext(Application.class);
    SpringPicoContainer springPicoContainer = new SpringPicoContainer(applicationContext);
    MutablePicoContainer pico = new DefaultPicoContainer(springPicoContainer);
    pico.addComponent(B.class);
    thrown.expect(AbstractInjector.UnsatisfiableDependenciesException.class);
    pico.getComponent(B.class);
}
 
开发者ID:stefanbirkner,项目名称:picover,代码行数:10,代码来源:SpringPicoContainerTest.java

示例10: run

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
@Override
public String run() {
    MutablePicoContainer pico = new DefaultPicoContainer();
    pico.addComponent(Description.class);
    pico.addComponent(LocationSupplier.class);
    pico.addComponent(ColoredCarSupplier.class);
    pico.addComponent(ColorSupplier.class);
    pico.addComponent(CarSupplier.class);
    Description description = pico.getComponent(Description.class);
    return description.getDescription();
}
 
开发者ID:stefanbirkner,项目名称:picover,代码行数:12,代码来源:PicoOnlyApp.java

示例11: usecase_direct_picocontainer

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
@Test
public void usecase_direct_picocontainer() throws Throwable {
    MutablePicoContainer pico = new DefaultPicoContainer();
    pico.addComponent(RawHttpStepdefs.class);
    pico.start();

    try {
        pico.getComponent(RawHttpStepdefs.class);
        fail("Actually all dependencies must be declared within pico");
    } catch (Exception e) {
        assertThat(e).hasMessageContaining("unsatisfied dependency 'class bdi.glue.http.common.HttpWorld'");
    }
}
 
开发者ID:Arnauld,项目名称:bidij,代码行数:14,代码来源:PicoContainerTest.java

示例12: configure

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
public void configure(MutablePicoContainer container) {
    container.addComponent(StoryControls.class, new StoryControls().doDryRun(false).doSkipScenariosAfterFailure(false));
    container.addComponent(StoryLoader.class, new LoadFromClasspath(this.getClass().getClassLoader()));
    container.addComponent(StepPatternParser.class, new RegexPrefixCapturingPatternParser("%"));
    container.addComponent(ParameterConverter.class, new DateConverter(new SimpleDateFormat("yyyy-MM-dd")));
    container.addComponent(new StoryReporterBuilder().withDefaultFormats().withFormats(CONSOLE, HTML, TXT, XML)
            .withCodeLocation(CodeLocations.codeLocationFromClass(this.getClass())).withFailureTrace(true));
}
 
开发者ID:vactowb,项目名称:jbehave-core,代码行数:9,代码来源:AnnotatedPathRunnerUsingPico.java

示例13: createPicoContainer

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
private PicoContainer createPicoContainer() {
    MutablePicoContainer container = new DefaultPicoContainer(new Caching().wrap(new ConstructorInjection()));
    container.addComponent(TradingService.class);
    container.addComponent(TraderSteps.class);
    container.addComponent(BeforeAfterSteps.class);
    container.addComponent(AndSteps.class);
    container.addComponent(CalendarSteps.class);
    container.addComponent(PendingSteps.class);
    container.addComponent(PriorityMatchingSteps.class);
    container.addComponent(SandpitSteps.class);
    container.addComponent(SearchSteps.class);
    return container;
}
 
开发者ID:vactowb,项目名称:jbehave-core,代码行数:14,代码来源:TraderStoriesUsingPico.java

示例14: assertThatStepsWithStepsWithDependencyCanBeCreated

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
@Test
public void assertThatStepsWithStepsWithDependencyCanBeCreated() throws NoSuchFieldException, IllegalAccessException {
    MutablePicoContainer parent = createPicoContainer();
    parent.as(Characteristics.USE_NAMES).addComponent(FooStepsWithDependency.class);
    parent.addComponent(Integer.class, 42);
    // When
    PicoStepsFactory factory = new PicoStepsFactory(new MostUsefulConfiguration(), parent);
    List<CandidateSteps> steps = factory.createCandidateSteps();
    // Then
    assertFooStepsFound(steps);
    assertEquals(42, (int) ((FooStepsWithDependency) stepsInstance(steps.get(0))).integer);
}
 
开发者ID:vactowb,项目名称:jbehave-core,代码行数:13,代码来源:PicoStepsFactoryBehaviour.java

示例15: configure

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
public void configure(MutablePicoContainer container) {
    container.addComponent(StoryControls.class, new StoryControls().doDryRun(true).doSkipScenariosAfterFailure(true));
    container.addComponent(FailureStrategy.class, SilentlyAbsorbingFailure.class);
    container.addComponent(StepPatternParser.class, new RegexPrefixCapturingPatternParser("MyPrefix"));
    container.addComponent(StoryLoader.class, new LoadFromURL());
    container.addComponent(ParameterConverter.class, new DateConverter(new SimpleDateFormat("yyyy-MM-dd")));
    Properties viewResources = new Properties();
    viewResources.setProperty("index", "my-reports-index.ftl");
    viewResources.setProperty("decorateNonHtml", "true");
    container.addComponent(new StoryReporterBuilder().withDefaultFormats().withFormats(CONSOLE, HTML, TXT, XML)
            .withKeywords(new LocalizedKeywords(Locale.ITALIAN)).withRelativeDirectory("my-output-directory")
            .withViewResources(viewResources).withFailureTrace(true));
}
 
开发者ID:vactowb,项目名称:jbehave-core,代码行数:14,代码来源:PicoAnnotationBuilderBehaviour.java


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