Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* $Id: DefaultMuleConfiguration.java 24223 2012-04-03 19:13:22Z pablo.kraan $
* --------------------------------------------------------------------------------------
* Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
*
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/
package org.mule.config;
import org.mule.api.MuleContext;
import org.mule.api.config.MuleConfiguration;
import org.mule.api.config.MuleProperties;
import org.mule.api.context.MuleContextAware;
import org.mule.api.lifecycle.FatalException;
import org.mule.api.lifecycle.Initialisable;
import org.mule.api.lifecycle.Startable;
import org.mule.config.i18n.CoreMessages;
import org.mule.util.FileUtils;
import org.mule.util.NumberUtils;
import org.mule.util.StringUtils;
import org.mule.util.UUID;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.SAXParserFactory;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Configuration info. which can be set when creating the MuleContext but becomes
* immutable after starting the MuleContext.
*/
public class DefaultMuleConfiguration implements MuleConfiguration, MuleContextAware
{
public static final boolean DEFAULT_TRANSFORMATION_RESOLVE_NON_DIRECT = true;
public static final String[] DEFAULT_STACKTRACE_FILTER = (
"org.mule.processor.AbstractInterceptingMessageProcessor," +
"org.mule.processor.chain")
.split(",");
/**
* When false (default), some internal Mule entries are removed from exception stacktraces for readability.
* @see #stackTraceFilter
*/
public static boolean fullStackTraces = false;
/**
* When false (default), only a summary of the root exception
* and trail is provided. If this flag is false, full exception information is reported.
* Switching on DEBUG level logging with automatically set this flag to true.
*/
public static boolean verboseExceptions = false;
/**
* A comma-separated list of internal packages/classes which are removed from sanitized stacktraces.
* Matching is done via string.startsWith().
* @see #fullStackTraces
*/
public static String[] stackTraceFilter = DEFAULT_STACKTRACE_FILTER;
private boolean synchronous = false;
/**
* The type of model used for the internal system model where system created
* services are registered
*/
private String systemModelType = "seda";
private String encoding = "UTF-8";
/**
* When running sychronously, return events can be received over transports that
* support ack or replyTo This property determines how long to wait for a receive
*/
private int responseTimeout = 10000;
/**
* The default transaction timeout value used if no specific transaction time out
* has been set on the transaction config
*/
private int defaultTransactionTimeout = 30000;
/**
* The default queue timeout value used when polling queues.
*/
private int defaultQueueTimeout = 200;
/**
* The default graceful shutdown timeout used when shutting stopping mule cleanly
* without message loss.
*/
private int shutdownTimeout = 5000;
/**
* Where Mule stores any runtime files to disk. Note that in container
* mode each app will have its working dir set one level under this dir
* (with app's name) in the {@link #setMuleContext} callback.
*
*/
private String workingDirectory = "./.mule";
/**
* Whether the server instance is running in client mode, which means that some
* services will not be started
*/
private boolean clientMode = false;
/** the unique id for this Mule instance */
private String id;
/** If this node is part of a cluster then this is the shared cluster Id */
private String clusterId = "";
/** The domain name that this instance belongs to. */
private String domainId;
// Debug options
private boolean cacheMessageAsBytes = true;
private boolean cacheMessageOriginalPayload = true;
private boolean enableStreaming = true;
private boolean autoWrapMessageAwareTransform = true;
protected transient Log logger = LogFactory.getLog(DefaultMuleConfiguration.class);
private MuleContext muleContext;
private boolean containerMode;
/**
* By default the Mule Expression parser will perform basic syntax checking on expressions in order to provide
* early feedback if an expression is malformed. Part of the check is checking that all open braces are closed at
* some point. For some expressions such as groovy, there could be a scenario where a brace is deliberately used without
* being closed; this would cause the validation to fail. Users can turn off validation using this flag.
*/
private boolean validateExpressions = true;
private boolean useExtendedTransformations = DEFAULT_TRANSFORMATION_RESOLVE_NON_DIRECT;
private boolean flowEndingWithOneWayEndpointReturnsNull;
/**
* Generic string/string map of properties in addition to standard Mule props.
* Used as an extension point e.g. in MMC.
*/
private Map extendedProperties = new HashMap();
/**
* Global exception strategy name to be used as default exception strategy for flows and services
*/
private String defaultExceptionStrategyName;
public DefaultMuleConfiguration()
{
this(false);
}
public DefaultMuleConfiguration(boolean containerMode)
{
this.containerMode = containerMode;
// Apply any settings which come from the JVM system properties.
applySystemProperties();
if (id == null)
{
id = UUID.getUUID();
}
if (domainId == null)
{
try
{
domainId = InetAddress.getLocalHost().getHostName();
}
catch (UnknownHostException e)
{
logger.warn(e);
domainId = "org.mule";
}
}
try
{
validateEncoding();
validateXML();
}
catch (FatalException e)
{
throw new RuntimeException(e);
}
}
public void setMuleContext(MuleContext context)
{
this.muleContext = context;
if (containerMode)
{
final String muleHome = System.getProperty("mule.home");
// in container mode the id is the app name, have each app isolate its work dir
if (!isStandalone()) {
// fallback to current dir as a parent
this.workingDirectory = String.format("%s/%s", getWorkingDirectory(), getId());
}
else
{
this.workingDirectory = String.format("%s/%s/%s", muleHome.trim(), getWorkingDirectory(), getId());
}
}
else if (isStandalone())
{
this.workingDirectory = String.format("%s/%s", getWorkingDirectory(), getId());
}
}
/**
* Apply any settings which come from the JVM system properties.
*/
protected void applySystemProperties()
{
String p;
p = System.getProperty(MuleProperties.MULE_ENCODING_SYSTEM_PROPERTY);
if (p != null)
{
encoding = p;
}
else
{
System.setProperty(MuleProperties.MULE_ENCODING_SYSTEM_PROPERTY, encoding);
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "endpoints.synchronous");
if (p != null)
{
synchronous = BooleanUtils.toBoolean(p);
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "systemModelType");
if (p != null)
{
systemModelType = p;
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "timeout.synchronous");
if (p != null)
{
responseTimeout = NumberUtils.toInt(p);
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "timeout.transaction");
if (p != null)
{
defaultTransactionTimeout = NumberUtils.toInt(p);
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "workingDirectory");
if (p != null)
{
workingDirectory = p;
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "clientMode");
if (p != null)
{
clientMode = BooleanUtils.toBoolean(p);
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "serverId");
if (p != null)
{
id = p;
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "domainId");
if (p != null)
{
domainId = p;
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "message.cacheBytes");
if (p != null)
{
cacheMessageAsBytes = BooleanUtils.toBoolean(p);
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "message.cacheOriginal");
if (p != null)
{
cacheMessageOriginalPayload = BooleanUtils.toBoolean(p);
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "streaming.enable");
if (p != null)
{
enableStreaming = BooleanUtils.toBoolean(p);
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "transform.autoWrap");
if (p != null)
{
autoWrapMessageAwareTransform = BooleanUtils.toBoolean(p);
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "stacktrace.full");
if (p != null)
{
fullStackTraces = false;
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "stacktrace.filter");
if (p != null)
{
stackTraceFilter = p.split(",");
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "verbose.exceptions");
if (p != null)
{
verboseExceptions = BooleanUtils.toBoolean(p);
}
else
{
verboseExceptions = logger.isDebugEnabled();
}
p = System.getProperty(MuleProperties.SYSTEM_PROPERTY_PREFIX + "validate.expressions");
if (p != null)
{
validateExpressions = Boolean.valueOf(p);
}
}
protected void validateEncoding() throws FatalException
{
//Check we have a valid and supported encoding
if (!Charset.isSupported(encoding))
{
throw new FatalException(CoreMessages.propertyHasInvalidValue("encoding", encoding), this);
}
}
/**
* Mule needs a proper JAXP implementation and will complain when run with a plain JDK
* 1.4. Use the supplied launcher or specify a proper JAXP implementation via
* -Djava.endorsed.dirs. See the following URLs for more information:
*