本文整理汇总了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);
}
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例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'");
}
}
示例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));
}
示例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;
}
示例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);
}
示例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));
}