protected ConfigResource[] loadConfigResources(String[] configs) throws ConfigurationException { try { configResources = new ConfigResource[configs.length]; for (int i = 0; i < configs.length; i++) { configResources[i] = new ConfigResource(configs[i]); } return configResources; } catch (IOException e) { throw new ConfigurationException(e); } }
protected ConfigResource[] loadConfigResources(String[] configs) throws ConfigurationException { try { configResources = new ConfigResource[configs.length]; for (int i = 0; i < configs.length; i++) { configResources[i] = new ServletContextOrClassPathConfigResource(configs[i]); } return configResources; } catch (IOException e) { throw new ConfigurationException(e); } }
private void createRegistryWithParentContext(MuleContext muleContext, ApplicationContext applicationContext, ApplicationContext parentContext) throws ConfigurationException { if (applicationContext instanceof ConfigurableApplicationContext) { registry = new SpringRegistry((ConfigurableApplicationContext) applicationContext, parentContext, muleContext); } else { throw new ConfigurationException( MessageFactory.createStaticMessage("Cannot set a parent context if the ApplicationContext does not implement ConfigurableApplicationContext")); } }
/** * Override to check for existence of configResouce before invocation, and set * resources n configuration afterwards. */ @Override public void configure(MuleContext muleContext) throws ConfigurationException { if (configResources == null) { throw new ConfigurationException(CoreMessages.objectIsNull("Configuration Resources")); } super.configure(muleContext); logger.info(CoreMessages.configurationBuilderSuccess(this, createConfigResourcesString())); }
@Override public Object doGetObject() throws Exception { EndpointFactory ef = muleContext.getEndpointFactory(); if (ef != null) { return ef.getInboundEndpoint(this); } else { throw new ConfigurationException(MessageFactory.createStaticMessage("EndpointFactory not found in Registry")); } }
@Override public Object doGetObject() throws Exception { uriBuilder = new URIBuilder("polling://" + hashCode(), muleContext); properties.put(MessageProcessorPollingMessageReceiver.SOURCE_MESSAGE_PROCESSOR_PROPERTY_NAME, messageProcessor); properties.put(MessageProcessorPollingMessageReceiver.POLL_OVERRIDE_PROPERTY_NAME, override); properties.put(MessageProcessorPollingMessageReceiver.SCHEDULER_FACTORY_PROPERTY_NAME, schedulerFactory == null ? defaultSchedulerFactory() : schedulerFactory); properties.put(AbstractConnector.PROPERTY_POLLING_FREQUENCY, frequency); EndpointFactory ef = muleContext.getEndpointFactory(); if (ef != null) { return ef.getInboundEndpoint(this); } else { throw new ConfigurationException( MessageFactory.createStaticMessage("EndpointFactory not found in Registry")); } }
protected ConfigurationBuilder createConfigurationBuilder() throws ConfigurationException { try { return (ConfigurationBuilder) ClassUtils.instanciateClass(getConfigBuilderClassName(), new Object[]{ configurationResources }, MuleServer.class); } catch (Exception e) { throw new ConfigurationException(CoreMessages.failedToLoad(getConfigBuilderClassName()), e); } }
/** * 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); } }
private WSProxy buildStaticWsdlContentsWSProxy(final MuleContext muleContext) throws MuleException { try { return new WSProxy(name, muleContext, getOrBuildInboundEndpoint(muleContext), getOrBuildOutboundEndpoint(muleContext), transformers, responseTransformers, FileUtils.readFileToString(wsdlFile)); } catch (final IOException ioe) { throw new ConfigurationException(ioe); } }
public MuleMessage generateMessage(String endpoint, Object payloadObject, Map messageProperties, MessageExchangePattern mep) throws Exception { String processName = (String)messageProperties.get(Process.PROPERTY_PROCESS_TYPE); Object processId = messageProperties.get(Process.PROPERTY_PROCESS_ID); // Look up a receiver for this process. ProcessMessageReceiver receiver = lookupReceiver(processName, processId); if (receiver == null) { throw new ConfigurationException(MessageFactory .createStaticMessage("No corresponding receiver found for processName = " + processName + ", processId = " + processId)); } logger.debug("Generating Mule message for process name = " + processName + " id = " + processId + ", synchronous = " + mep.hasResponse()); if (mep.hasResponse()) { // Send the process-generated Mule message synchronously. return receiver.generateSynchronousEvent(endpoint, payloadObject, messageProperties); } else { // Dispatch the process-generated Mule message asynchronously. receiver.generateAsynchronousEvent(endpoint, payloadObject, messageProperties); return null; } }
/** * if {@code temporaryObject} is a {@link String} then it tries to evaluate it * using the {@link ExpressionManager} in {@code muleContext}. Otherwise, it simply * returns {@code temporaryObject} * * @param muleEvent the current mule event * @param object an object * @return {@code temporaryObject} or the result of evaluating it as a expression if it's a String * @throws ConfigurationException */ private Object evaluateIfExpression(MuleEvent muleEvent, Object object) throws ConfigurationException { if (object instanceof String) { object = (muleContext.getExpressionManager().evaluate(((String) object), muleEvent, true)); if (object == null) { throw new ConfigurationException( MessageFactory.createStaticMessage("Cannot find object by config name")); } } return object; }
muleContext.getRegistry().registerObject(moduleClass.getName(), temporaryObject); } else { throw new ConfigurationException(MessageFactory.createStaticMessage("Cannot find object")); temporaryObject = ((O) muleContext.getExpressionManager().evaluate(((String) temporaryObject), muleEvent, true)); if (temporaryObject == null) { throw new ConfigurationException(MessageFactory.createStaticMessage("Cannot find object by config name"));
@Override public Object doGetObject() throws Exception { EndpointFactory ef = muleContext.getEndpointFactory(); if (ef != null) { InboundEndpoint inboundEndpoint = ef.getInboundEndpoint(this); if (inboundEndpoint instanceof AbstractEndpoint) { AbstractEndpoint.class.cast(inboundEndpoint).setAnnotations(getAnnotations()); } return inboundEndpoint; } else { throw new ConfigurationException(MessageFactory.createStaticMessage("EndpointFactory not found in Registry")); } }
/** * Obtains the expression manager from the Mule context and initialises the connector. If a target object has not been set already it will search the Mule registry for a default one. * * @throws InstantiationException * @throws ConfigurationException * @throws IllegalAccessException * @throws RegistrationException */ protected void findOrCreate(Class moduleClass, boolean shouldAutoCreate, MuleEvent muleEvent) throws IllegalAccessException, InstantiationException, ConfigurationException, RegistrationException { if (moduleObject == null) { moduleObject = ((O) muleContext.getRegistry().lookupObject(moduleClass)); if (moduleObject == null) { if (shouldAutoCreate) { moduleObject = ((O) moduleClass.newInstance()); muleContext.getRegistry().registerObject(moduleClass.getName(), moduleObject); } else { throw new ConfigurationException(MessageFactory.createStaticMessage("Cannot find object")); } } } if (moduleObject instanceof String) { moduleObject = ((O) muleContext.getExpressionManager().evaluate(((String) moduleObject), muleEvent, true)); if (moduleObject == null) { throw new ConfigurationException(MessageFactory.createStaticMessage("Cannot find object by config name")); } } }
@Override protected void doConfigure(MuleContext muleContext) throws Exception { Set<Class<?>> ibeanClasses = new HashSet<Class<?>>(); ClasspathScanner scanner = createClasspathScanner(); try { //There will be some overlap here but only ibeanClasses.addAll(scanner.scanFor(Call.class, ClasspathScanner.INCLUDE_INTERFACE)); ibeanClasses.addAll(scanner.scanFor(Template.class, ClasspathScanner.INCLUDE_INTERFACE)); //Some ibeans will extend other iBeans but have not methods of there own ibeanClasses.addAll(scanner.scanFor(IBeanGroup.class, ClasspathScanner.INCLUDE_INTERFACE)); } catch (IOException e) { throw new ConfigurationException(e); } for (Class<?> ibeanClass : ibeanClasses) { muleContext.getRegistry().registerObject(IBeanHolder.getId(ibeanClass), new IBeanHolder(ibeanClass)); } } }
protected <T> T lookupConfig(String location, Class<T> type) throws ConfigurationException { if (StringUtils.isEmpty(location)) { return null; } Object o = muleContext.getRegistry().lookupObject(location + ENDPOINT_BUILDER_POSTFIX); if (o == null) { o = muleContext.getRegistry().lookupObject(location); if (o == null) { return null; //throw new ConfigurationException(CoreMessages.objectNotFound(location)); } } if (type.isInstance(o)) { return (T) o; } else { throw new ConfigurationException(CoreMessages.objectNotOfCorrectType(o.getClass(), type)); } }
/** * Watermark route preparation carries the value from the source event to the * flow event */ @Override public MuleEvent prepareRouting(MuleEvent sourceEvent, MuleEvent event) throws ConfigurationException { if (!event.isSynchronous()) { throw new ConfigurationException(CoreMessages.watermarkRequiresSynchronousProcessing()); } String variableName = this.watermark.resolveVariable(event); event.setFlowVariable(variableName, sourceEvent.getFlowVariable(variableName)); return event; }
/** * Creates an outbound endpoint for the service address. */ public MessageProcessor createOutboundMessageProcessor() throws MuleException { Preconditions.checkState(StringUtils.isNotEmpty(serviceAddress), "No serviceAddress provided in WS consumer config"); if (connectorConfig != null && connector != null) { throw new ConfigurationException(CoreMessages.createStaticMessage("Cannot set both connector-config and connector-ref attributes. Set either one of them, or none for default behavior.")); } if (useHttpModule()) { return createHttpRequester(); } else { return createOutboundEndpoint(); } }
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(); } }
public Object getObject() throws Exception { MuleConfiguration configuration = muleContext.getConfiguration(); if (configuration instanceof DefaultMuleConfiguration) { DefaultMuleConfiguration defaultConfig = (DefaultMuleConfiguration) configuration; defaultConfig.setDefaultResponseTimeout(config.getDefaultResponseTimeout()); defaultConfig.setDefaultTransactionTimeout(config.getDefaultTransactionTimeout()); defaultConfig.setShutdownTimeout(config.getShutdownTimeout()); defaultConfig.setUseExtendedTransformations(config.useExtendedTransformations()); defaultConfig.setFlowEndingWithOneWayEndpointReturnsNull(config.isFlowEndingWithOneWayEndpointReturnsNull()); defaultConfig.setDefaultExceptionStrategyName(config.getDefaultExceptionStrategyName()); defaultConfig.setEnricherPropagatesSessionVariableChanges(config.isEnricherPropagatesSessionVariableChanges()); defaultConfig.setExtensions(config.getExtensions()); defaultConfig.setMaxQueueTransactionFilesSize(config.getMaxQueueTransactionFilesSizeInMegabytes()); determineDefaultProcessingStrategy(defaultConfig); validateDefaultExceptionStrategy(); applyDefaultIfNoObjectSerializerSet(defaultConfig); return configuration; } else { throw new ConfigurationException(MessageFactory.createStaticMessage("Unable to set properties on read-only MuleConfiguration: " + configuration.getClass())); } }