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));
}
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);
}
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);
}
}
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);
}
}
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);
}
}
Aggregations