use of org.mule.runtime.core.internal.lifecycle.MuleLifecycleInterceptor in project mule by mulesoft.
the class TransientRegistryTestCase method testLifecycleStateOutOfSequenceDisposeFirstWithTransientRegistryDirectly.
@Test
public void testLifecycleStateOutOfSequenceDisposeFirstWithTransientRegistryDirectly() throws Exception {
TransientRegistry reg = new TransientRegistry(UUID.getUUID(), muleContext, new MuleLifecycleInterceptor());
reg.fireLifecycle(Disposable.PHASE_NAME);
InterfaceBasedTracker tracker = new InterfaceBasedTracker();
try {
reg.registerObject(TEST_KEY, tracker);
fail("Cannot register objects on a disposed registry");
} catch (RegistrationException e) {
// Expected
}
}
use of org.mule.runtime.core.internal.lifecycle.MuleLifecycleInterceptor in project mule by mulesoft.
the class RegistryBrokerTestCase method testConcurrentRegistryAddRemove.
@Test
public void testConcurrentRegistryAddRemove() throws Exception {
MuleLifecycleInterceptor lifecycleInterceptor = new MuleLifecycleInterceptor();
final RegistryBroker broker = new DefaultRegistryBroker(muleContext, lifecycleInterceptor);
final int N = 50;
final CountDownLatch start = new CountDownLatch(1);
final CountDownLatch end = new CountDownLatch(N);
final AtomicInteger errors = new AtomicInteger(0);
for (int i = 0; i < N; i++) {
new Thread(() -> {
try {
start.await();
broker.addRegistry(new TransientRegistry(getUUID(), muleContext, lifecycleInterceptor));
broker.lookupByType(Object.class);
} catch (Exception e) {
errors.incrementAndGet();
} finally {
end.countDown();
}
}, "thread-eval-" + i).start();
}
start.countDown();
end.await();
if (errors.get() > 0) {
fail();
}
}
use of org.mule.runtime.core.internal.lifecycle.MuleLifecycleInterceptor in project mule by mulesoft.
the class TryProcessorFactoryBeanTestCase method setUp.
@Before
public void setUp() throws RegistrationException {
registry = new SimpleRegistry(muleContextMock, new MuleLifecycleInterceptor());
registry.registerObject("txFactory", new TransactionFactoryLocator());
}
use of org.mule.runtime.core.internal.lifecycle.MuleLifecycleInterceptor in project mule by mulesoft.
the class ExtensionPluginMetadataGenerator method createExtensionManager.
/**
* Creates a {@link ExtensionManager} needed for generating the metadata for an extension. It would be later discarded due to
* the manager would have references to classes loaded with the launcher class loader instead of the hierarchical class loaders
* created as result of the classification process.
*
* @return an {@link ExtensionManager} that would be used to register the extensions.
*/
private ExtensionManager createExtensionManager() {
DefaultExtensionManager extensionManager = new DefaultExtensionManager();
extensionManager.setMuleContext(new DefaultMuleContext() {
private ErrorTypeRepository errorTypeRepository = createDefaultErrorTypeRepository();
private ErrorTypeLocator errorTypeLocator = createDefaultErrorTypeLocator(errorTypeRepository);
@Override
public MuleRegistry getRegistry() {
return new MuleRegistryHelper(new DefaultRegistryBroker(this, new MuleLifecycleInterceptor()), this);
}
@Override
public ErrorTypeLocator getErrorTypeLocator() {
return errorTypeLocator;
}
@Override
public ErrorTypeRepository getErrorTypeRepository() {
return errorTypeRepository;
}
});
try {
extensionManager.initialise();
} catch (InitialisationException e) {
throw new RuntimeException("Error while initialising the extension manager", e);
}
return extensionManager;
}
use of org.mule.runtime.core.internal.lifecycle.MuleLifecycleInterceptor in project mule by mulesoft.
the class RegistryBrokerTestCase method testCrossRegistryLifecycleOrder.
@Test
public void testCrossRegistryLifecycleOrder() throws MuleException {
TransientRegistry reg1 = new TransientRegistry(getUUID(), muleContext, new MuleLifecycleInterceptor());
reg1.initialise();
TransientRegistry reg2 = new TransientRegistry(getUUID(), muleContext, new MuleLifecycleInterceptor());
reg2.initialise();
reg1.registerObject("flow", new LifecycleTrackerFlow("flow", muleContext));
reg2.registerObject("flow2", new LifecycleTrackerFlow("flow2", muleContext));
((MuleContextWithRegistries) muleContext).addRegistry(reg1);
((MuleContextWithRegistries) muleContext).addRegistry(reg2);
muleContext.start();
// Both connectors are started before either flow
assertEquals("flow2-start flow-start ", tracker.toString());
tracker = new String();
muleContext.stop();
// Both services are stopped before either connector
assertEquals("flow2-stop flow-stop ", tracker);
}
Aggregations