protected LifecycleAdapter createLifecycleAdaptor() throws Exception
{
//Todo this could be moved to the LCAFactory potentially
Object object = objectFactory.getInstance(muleContext);
LifecycleAdapter lifecycleAdapter;
if (lifecycleAdapterFactory != null)
{
// Custom lifecycleAdapterFactory set on component
lifecycleAdapter =
lifecycleAdapterFactory.create(object, this, flowConstruct, entryPointResolverSet, muleContext);
}
else if (objectFactory.isExternallyManagedLifecycle())
{
// If no lifecycleAdapterFactory is configured explicitly and object factory returns
// externally managed instance then use NullLifecycleAdapter so that lifecycle
// is not propagated
lifecycleAdapter =
new NullLifecycleAdapter(object, this, flowConstruct, entryPointResolverSet, muleContext);
}
else if (flowConstruct instanceof Service)
{
// Inherit lifecycleAdapterFactory from model
lifecycleAdapter = ((Service) flowConstruct).getModel().getLifecycleAdapterFactory().create(
object, this, flowConstruct, entryPointResolverSet, muleContext);
}
else
{
lifecycleAdapter = new DefaultComponentLifecycleAdapterFactory().create(object, this,
flowConstruct, entryPointResolverSet, muleContext);
}
lifecycleAdapter.initialise();
return lifecycleAdapter;
}