protected boolean verifyContextNotInitialized() { if (muleContext != null && muleContext.getLifecycleManager().isPhaseComplete(Initialisable.PHASE_NAME)) { logger.warn("Cannot modify MuleConfiguration once the MuleContext has been initialized. Modification will be ignored."); return false; } else { return true; } }
protected boolean verifyContextNotStarted() { if (muleContext != null && muleContext.getLifecycleManager().isPhaseComplete(Startable.PHASE_NAME)) { logger.warn("Cannot modify MuleConfiguration once the MuleContext has been started. Modification will be ignored."); return false; } else { return true; } }
@Override public void onNotification(MuleContextNotification notification) { int action = notification.getAction(); if (action == MuleContextNotification.CONTEXT_INITIALISED || action == MuleContextNotification.CONTEXT_STARTED || action == MuleContextNotification.CONTEXT_STOPPED || action == MuleContextNotification.CONTEXT_DISPOSED) { updateStatusFor(muleContext.getLifecycleManager().getCurrentPhase()); } } };
@Override public void stop() if (this.muleContext == null || !this.muleContext.getLifecycleManager().isDirectTransition(Stoppable.PHASE_NAME)) muleContext.getLifecycleManager().checkPhase(Stoppable.PHASE_NAME);
/** * Will configure a MuleContext object based on the builders configuration settings. * This method will delegate the actual processing to {@link #doConfigure(org.mule.api.MuleContext)} * * @param muleContext The current {@link org.mule.api.MuleContext} * @throws ConfigurationException if the configuration fails i.e. an object cannot be created or * initialised properly */ @Override public void configure(MuleContext muleContext) throws ConfigurationException { try { doConfigure(muleContext); applyLifecycle(muleContext.getLifecycleManager()); configured = true; } catch (Exception e) { throw new ConfigurationException(e); } }
protected void doConfigure(MuleContext muleContext) throws Exception { Registry registry; if (parentContext != null) { if (appContext instanceof ConfigurableApplicationContext) { registry = new SpringRegistry((ConfigurableApplicationContext) appContext, parentContext, muleContext); } else { throw new ConfigurationException(MessageFactory.createStaticMessage("Cannot set a parent context if the ApplicationContext does not implement ConfigurableApplicationContext")); } } else { registry = new SpringRegistry(appContext, muleContext); } // Note: The SpringRegistry must be created before applicationContext.refresh() gets called because // some beans may try to look up other beans via the Registry during preInstantiateSingletons(). muleContext.addRegistry(registry); if (muleContext.getLifecycleManager().isPhaseComplete(Initialisable.PHASE_NAME)) { registry.initialise(); } }
@Override protected void prepareBeanFactory(ConfigurableListableBeanFactory beanFactory) { super.prepareBeanFactory(beanFactory); registerEditors(beanFactory); addBeanPostProcessors(beanFactory, new MuleContextPostProcessor(muleContext), new ExpressionEvaluatorPostProcessor(muleContext), new GlobalNamePostProcessor(), new ExpressionEnricherPostProcessor(muleContext), new AnnotatedTransformerObjectPostProcessor(muleContext), new PostRegistrationActionsPostProcessor(this, (MuleRegistryHelper) muleContext.getRegistry()), new DiscardedOptionalBeanPostProcessor(optionalObjectsController, (DefaultListableBeanFactory) beanFactory), new LifecycleStatePostProcessor(muleContext.getLifecycleManager().getState()) ); beanFactory.registerSingleton(OBJECT_MULE_CONTEXT, muleContext); }