Search in sources :

Example 1 with CompositeArtifactExtensionManagerFactory

use of org.mule.runtime.module.deployment.impl.internal.artifact.CompositeArtifactExtensionManagerFactory in project mule by mulesoft.

the class DefaultApplicationPolicyInstance method initPolicyContext.

private void initPolicyContext() throws InitialisationException {
    ArtifactContextBuilder artifactBuilder = newBuilder().setArtifactType(POLICY).setArtifactProperties(new HashMap<>(parametrization.getParameters())).setArtifactName(parametrization.getId()).setConfigurationFiles(parametrization.getConfig().getAbsolutePath()).setExecutionClassloader(template.getArtifactClassLoader().getClassLoader()).setServiceRepository(serviceRepository).setClassLoaderRepository(classLoaderRepository).setArtifactPlugins(artifactPlugins).setParentArtifact(application).setExtensionManagerFactory(new CompositeArtifactExtensionManagerFactory(application, extensionModelLoaderRepository, artifactPlugins, new DefaultExtensionManagerFactory())).setMuleContextListener(muleContextListener);
    artifactBuilder.withServiceConfigurator(customizationService -> {
        Registry applicationRegistry = application.getRegistry();
        /*
       * OBJECT_POLICY_MANAGER_STATE_HANDLER is not proxied as it doesn't implement any lifecycle interfaces (Startable, Stoppable
       * or Disposable)
       */
        customizationService.overrideDefaultServiceImpl(OBJECT_POLICY_MANAGER_STATE_HANDLER, applicationRegistry.lookupByName(OBJECT_POLICY_MANAGER_STATE_HANDLER).get());
        customizationService.overrideDefaultServiceImpl(OBJECT_LOCK_PROVIDER, createLifecycleFilterProxy(applicationRegistry.lookupByName(OBJECT_LOCK_PROVIDER).get()));
        customizationService.overrideDefaultServiceImpl(BASE_PERSISTENT_OBJECT_STORE_KEY, createLifecycleFilterProxy(applicationRegistry.lookupByName(BASE_PERSISTENT_OBJECT_STORE_KEY).get()));
        customizationService.overrideDefaultServiceImpl(BASE_IN_MEMORY_OBJECT_STORE_KEY, createLifecycleFilterProxy(applicationRegistry.lookupByName(BASE_IN_MEMORY_OBJECT_STORE_KEY).get()));
        customizationService.overrideDefaultServiceImpl(OBJECT_TIME_SUPPLIER, createLifecycleFilterProxy(applicationRegistry.lookupByName(OBJECT_TIME_SUPPLIER).get()));
        applicationRegistry.lookupByName(CLUSTER_MANAGER_ID).ifPresent(muleClusterManager -> customizationService.registerCustomServiceImpl(CLUSTER_MANAGER_ID, createLifecycleFilterProxy(muleClusterManager)));
    });
    try {
        policyContext = artifactBuilder.build();
        enableNotificationListeners(parametrization.getNotificationListeners());
        policyContext.getMuleContext().start();
    } catch (MuleException e) {
        throw new InitialisationException(createStaticMessage("Cannot create artifact context for the policy instance"), e, this);
    }
}
Also used : ArtifactContextBuilder(org.mule.runtime.module.deployment.impl.internal.artifact.ArtifactContextBuilder) CompositeArtifactExtensionManagerFactory(org.mule.runtime.module.deployment.impl.internal.artifact.CompositeArtifactExtensionManagerFactory) HashMap(java.util.HashMap) DefaultExtensionManagerFactory(org.mule.runtime.module.extension.api.manager.DefaultExtensionManagerFactory) Registry(org.mule.runtime.api.artifact.Registry) NotificationListenerRegistry(org.mule.runtime.api.notification.NotificationListenerRegistry) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleException(org.mule.runtime.api.exception.MuleException)

Aggregations

HashMap (java.util.HashMap)1 Registry (org.mule.runtime.api.artifact.Registry)1 MuleException (org.mule.runtime.api.exception.MuleException)1 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)1 NotificationListenerRegistry (org.mule.runtime.api.notification.NotificationListenerRegistry)1 ArtifactContextBuilder (org.mule.runtime.module.deployment.impl.internal.artifact.ArtifactContextBuilder)1 CompositeArtifactExtensionManagerFactory (org.mule.runtime.module.deployment.impl.internal.artifact.CompositeArtifactExtensionManagerFactory)1 DefaultExtensionManagerFactory (org.mule.runtime.module.extension.api.manager.DefaultExtensionManagerFactory)1