Search in sources :

Example 1 with DefaultRegistry

use of com.ctrip.xpipe.lifecycle.DefaultRegistry in project x-pipe by ctripcorp.

the class AbstractTest method beforeAbstractTest.

@Before
public void beforeAbstractTest() throws Exception {
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);
    // clear interrupt
    Thread.interrupted();
    executors = Executors.newCachedThreadPool(XpipeThreadFactory.create(getTestName()));
    scheduled = Executors.newScheduledThreadPool(OsUtils.getCpuCount(), XpipeThreadFactory.create(getTestName()));
    orginProperties = (Properties) System.getProperties().clone();
    doBeforeAbstractTest();
    logger.info(remarkableMessage("[begin test][{}]"), name.getMethodName());
    componentRegistry = new DefaultRegistry(new CreatedComponentRedistry(), getSpringRegistry());
    startedComponentRegistry = new CreatedComponentRedistry();
    startedComponentRegistry.initialize();
    startedComponentRegistry.start();
    Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
    InputStream fins = getClass().getClassLoader().getResourceAsStream("xpipe-test.properties");
    try {
        properties.load(fins);
    } finally {
        if (fins != null) {
            fins.close();
        }
    }
    File file = new File(getTestFileDir());
    if (file.exists() && deleteTestDirBeforeTest()) {
        deleteTestDir();
    }
    if (!file.exists()) {
        boolean testSucceed = file.mkdirs();
        if (!testSucceed) {
            throw new IllegalStateException("test dir make failed!" + file);
        }
    }
}
Also used : CreatedComponentRedistry(com.ctrip.xpipe.lifecycle.CreatedComponentRedistry) DefaultRegistry(com.ctrip.xpipe.lifecycle.DefaultRegistry) DefaultExceptionHandler(com.ctrip.xpipe.exception.DefaultExceptionHandler)

Example 2 with DefaultRegistry

use of com.ctrip.xpipe.lifecycle.DefaultRegistry in project x-pipe by ctripcorp.

the class AppTest method initComponentRegistry.

private void initComponentRegistry(ConfigurableApplicationContext context) throws Exception {
    ComponentRegistry registry = new DefaultRegistry(new CreatedComponentRedistry(), new SpringComponentRegistry(context));
    registry.initialize();
    registry.start();
    ComponentRegistryHolder.initializeRegistry(registry);
}
Also used : SpringComponentRegistry(com.ctrip.xpipe.lifecycle.SpringComponentRegistry) CreatedComponentRedistry(com.ctrip.xpipe.lifecycle.CreatedComponentRedistry) ComponentRegistry(com.ctrip.xpipe.api.lifecycle.ComponentRegistry) SpringComponentRegistry(com.ctrip.xpipe.lifecycle.SpringComponentRegistry) DefaultRegistry(com.ctrip.xpipe.lifecycle.DefaultRegistry)

Example 3 with DefaultRegistry

use of com.ctrip.xpipe.lifecycle.DefaultRegistry in project x-pipe by ctripcorp.

the class KeeperContainerApplication method initComponentRegistry.

private static ComponentRegistry initComponentRegistry(ConfigurableApplicationContext context) throws Exception {
    final ComponentRegistry registry = new DefaultRegistry(new CreatedComponentRedistry(), new SpringComponentRegistry(context));
    registry.initialize();
    registry.start();
    ComponentRegistryHolder.initializeRegistry(registry);
    return registry;
}
Also used : SpringComponentRegistry(com.ctrip.xpipe.lifecycle.SpringComponentRegistry) CreatedComponentRedistry(com.ctrip.xpipe.lifecycle.CreatedComponentRedistry) ComponentRegistry(com.ctrip.xpipe.api.lifecycle.ComponentRegistry) SpringComponentRegistry(com.ctrip.xpipe.lifecycle.SpringComponentRegistry) DefaultRegistry(com.ctrip.xpipe.lifecycle.DefaultRegistry)

Aggregations

CreatedComponentRedistry (com.ctrip.xpipe.lifecycle.CreatedComponentRedistry)3 DefaultRegistry (com.ctrip.xpipe.lifecycle.DefaultRegistry)3 ComponentRegistry (com.ctrip.xpipe.api.lifecycle.ComponentRegistry)2 SpringComponentRegistry (com.ctrip.xpipe.lifecycle.SpringComponentRegistry)2 DefaultExceptionHandler (com.ctrip.xpipe.exception.DefaultExceptionHandler)1