Search in sources :

Example 16 with RootContainer

use of org.exoplatform.container.RootContainer in project kernel by exoplatform.

the class TestManagementProvider method testManagedRegistrationBeforeProviderRegistration.

public void testManagedRegistrationBeforeProviderRegistration() {
    URL url = getClass().getResource("configuration2.xml");
    RootContainer container = new ContainerBuilder().withRoot(url).build();
    ManagementProviderImpl provider = (ManagementProviderImpl) container.getComponentInstanceOfType(ManagementProviderImpl.class);
    assertNull(provider);
    Object foo = container.getComponentInstance("Foo");
    assertNotNull(foo);
    provider = new ManagementProviderImpl();
    container.registerComponentInstance(provider);
    assertEquals(2, provider.managedResources.size());
    ManagedResource fooMR = provider.managedResources.get(1);
    assertSame(foo, fooMR.resource);
    assertEquals(Collections.<ScopedData>emptyList(), fooMR.context.getScopingData(ScopedData.class));
    fooMR.register();
    assertEquals(Collections.singletonList(fooMR.data), fooMR.context.getScopingData(ScopedData.class));
}
Also used : ContainerBuilder(org.exoplatform.container.ContainerBuilder) RootContainer(org.exoplatform.container.RootContainer) URL(java.net.URL)

Example 17 with RootContainer

use of org.exoplatform.container.RootContainer in project kernel by exoplatform.

the class TestContainer method testComponent2.

public void testComponent2() throws Exception {
    RootContainer rootContainer = RootContainer.getInstance();
    PortalContainer pcontainer = rootContainer.getPortalContainer("portal");
    assertNotNull(pcontainer);
    MultibleComponent c = (MultibleComponent) pcontainer.getComponentInstanceOfType(MultibleComponent.class);
    assertNotNull(c);
    c = (MultibleComponent) pcontainer.getComponentInstanceOfType(MultibleComponent.class);
    assertNotNull(c);
    c = (MultibleComponent) pcontainer.getComponentInstanceOfType(MultibleComponent.class);
    assertNotNull(c);
}
Also used : RootContainer(org.exoplatform.container.RootContainer) PortalContainer(org.exoplatform.container.PortalContainer)

Example 18 with RootContainer

use of org.exoplatform.container.RootContainer in project kernel by exoplatform.

the class TestContainer method testPortalContainer.

public void testPortalContainer() throws Exception {
    RootContainer rootContainer = RootContainer.getInstance();
    PortalContainer pcontainer = rootContainer.getPortalContainer("portal");
    Object parent = pcontainer.getParent();
    assertTrue("Root container should not be null", parent != null);
    // performance test
    int INSERTLOOP = 0;
    for (int i = 0; i < INSERTLOOP; i++) {
        rootContainer.getPortalContainer("name-" + Integer.toString(i));
    }
    int LOOP = 10000000;
    for (int i = 0; i < LOOP; i++) {
        pcontainer = (PortalContainer) rootContainer.getComponentInstance("portal");
        assertTrue("not null", pcontainer != null);
    }
}
Also used : RootContainer(org.exoplatform.container.RootContainer) PortalContainer(org.exoplatform.container.PortalContainer)

Example 19 with RootContainer

use of org.exoplatform.container.RootContainer in project kernel by exoplatform.

the class JobEnvironmentConfigListener method jobWasExecuted.

public void jobWasExecuted(JobExecutionContext context, JobExecutionException exception) {
    String containerName = extractContainerName(context);
    ExoContainer container = null;
    if (containerName != null) {
        if (containerName.equals(JobSchedulerServiceImpl.STANDALONE_CONTAINER_NAME)) {
            container = ExoContainerContext.getTopContainer();
        } else {
            RootContainer rootContainer = RootContainer.getInstance();
            container = (ExoContainer) rootContainer.getComponentInstance(containerName);
        }
    }
    if (container != null) {
        List<ComponentRequestLifecycle> components = container.getComponentInstancesOfType(ComponentRequestLifecycle.class);
        for (ComponentRequestLifecycle component : components) {
            component.endRequest(container);
        }
        RequestLifeCycle.end();
        ExoContainerContext.setCurrentContainer(null);
    }
}
Also used : ExoContainer(org.exoplatform.container.ExoContainer) RootContainer(org.exoplatform.container.RootContainer) ComponentRequestLifecycle(org.exoplatform.container.component.ComponentRequestLifecycle)

Example 20 with RootContainer

use of org.exoplatform.container.RootContainer in project kernel by exoplatform.

the class JobEnvironmentConfigListener method jobToBeExecuted.

public void jobToBeExecuted(JobExecutionContext context) {
    String containerName = extractContainerName(context);
    ExoContainer container = null;
    if (containerName != null) {
        if (containerName.equals(JobSchedulerServiceImpl.STANDALONE_CONTAINER_NAME)) {
            container = ExoContainerContext.getTopContainer();
        } else {
            RootContainer rootContainer = RootContainer.getInstance();
            container = (ExoContainer) rootContainer.getComponentInstance(containerName);
        }
    }
    if (container != null) {
        ExoContainerContext.setCurrentContainer(container);
        RequestLifeCycle.begin(container);
    }
}
Also used : ExoContainer(org.exoplatform.container.ExoContainer) RootContainer(org.exoplatform.container.RootContainer)

Aggregations

RootContainer (org.exoplatform.container.RootContainer)38 URL (java.net.URL)14 ContainerBuilder (org.exoplatform.container.ContainerBuilder)14 PortalContainer (org.exoplatform.container.PortalContainer)9 MBeanServer (javax.management.MBeanServer)8 ExoContainer (org.exoplatform.container.ExoContainer)4 ObjectName (javax.management.ObjectName)3 ObjectInstance (javax.management.ObjectInstance)2 ManagedManagementAware (org.exoplatform.container.jmx.support.ManagedManagementAware)2 ManagedWithObjectNameTemplate (org.exoplatform.container.jmx.support.ManagedWithObjectNameTemplate)2 ComponentAdapter (org.exoplatform.container.spi.ComponentAdapter)2 InitParams (org.exoplatform.container.xml.InitParams)2 ObjectParameter (org.exoplatform.container.xml.ObjectParameter)2 Set (java.util.Set)1 ComponentPlugin (org.exoplatform.container.component.ComponentPlugin)1 ComponentRequestLifecycle (org.exoplatform.container.component.ComponentRequestLifecycle)1 ExoContainerFinder (org.exoplatform.container.jmx.support.ExoContainerFinder)1 ManagedByManager (org.exoplatform.container.jmx.support.ManagedByManager)1 ManagedComponentRequestLifeCycle (org.exoplatform.container.jmx.support.ManagedComponentRequestLifeCycle)1 ManagedDependent (org.exoplatform.container.jmx.support.ManagedDependent)1