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


Java MutablePicoContainer.getComponent方法代码示例

本文整理汇总了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);
    }
}
 
开发者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: 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

示例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);
}
 
开发者ID:stefanbirkner,项目名称:picover,代码行数:10,代码来源:SpringPicoContainerTest.java

示例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();
}
 
开发者ID:stefanbirkner,项目名称:picover,代码行数:12,代码来源:PicoOnlyApp.java

示例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");
    }
}
 
开发者ID:travisspencer,项目名称:stockholm-java-meetup-java-spark-demo,代码行数:34,代码来源:Router.java

示例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'");
    }
}
 
开发者ID:Arnauld,项目名称:bidij,代码行数:14,代码来源:PicoContainerTest.java

示例8:

import org.picocontainer.MutablePicoContainer; //导入方法依赖的package包/类
private static void 使用容器的方式(String author) throws DataInitException {
	MutablePicoContainer 容器 = 初始化容器();
	
	_store = 容器.getComponent(IStore.class);
	_store.init();
	authorBy(author);
}
 
开发者ID:shiyimin,项目名称:androidtestdebug,代码行数:8,代码来源:App.java


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