本文整理汇总了Java中org.picocontainer.MutablePicoContainer.getComponent方法的典型用法代码示例。如果您正苦于以下问题:Java MutablePicoContainer.getComponent方法的具体用法?Java MutablePicoContainer.getComponent怎么用?Java MutablePicoContainer.getComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.picocontainer.MutablePicoContainer
的用法示例。
在下文中一共展示了MutablePicoContainer.getComponent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
示例4: 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);
}
示例5: 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();
}
示例6: router
import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
private <T extends Controllable> void router(Class<T> controllerClass, PicoContainer appContainer,
Map<String, Object> model, Request request, Response response)
{
MutablePicoContainer requestContainer = new DefaultPicoContainer(appContainer);
ContainerComposer.composeRequest(requestContainer);
try
{
Controllable controller = requestContainer.getComponent(controllerClass);
// TODO: Weave output of before into process and then into after
boolean continue_ = controller.before(request, response);
if (continue_)
{
// Fire the controller's method depending on the HTTP method of the request
String httpMethod = request.requestMethod().toLowerCase();
Method method = controllerClass.getMethod(httpMethod, Request.class, Response.class, Map.class);
Object result = method.invoke(controller, request, response, model);
if (Boolean.TRUE.equals(result))
{
controller.after(request, response);
}
}
}
catch (Exception e)
{
halt(500, "Server Error");
}
}
示例7: 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'");
}
}
示例8:
import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
private static void 使用容器的方式(String author) throws DataInitException {
MutablePicoContainer 容器 = 初始化容器();
_store = 容器.getComponent(IStore.class);
_store.init();
authorBy(author);
}