public abstract class AbstractRegistryBootstrap extends Object implements Initialisable, MuleContextAware
registry-bootstrap.properties
into the local registry.
This allows modules and transports to make certain objects available by default. The most common use case is for a
module or transport to load stateless transformers into the registry.
For this file to be located it must be present in the modules META-INF directory under
META-INF/services/org/mule/config/The format of this file is a simple key / value pair. i.e.
myobject=org.foo.MyObjectWill register an instance of MyObject with a key of 'myobject'. If you don't care about the object name and want to ensure that the ojbect gets a unique name you can use -
object.1=org.foo.MyObject object.2=org.bar.MyObjector
myFoo=org.foo.MyObject myBar=org.bar.MyObjectIt's also possible to define if the entry must be applied to a domain, an application, or both by using the parameter applyToArtifactType.
myFoo=org.foo.MyObject will be applied to any mule application since the parameter applyToArtifactType default value is app myFoo=org.foo.MyObject;applyToArtifactType=app will be applied to any mule application myFoo=org.foo.MyObject;applyToArtifactType=domain will be applied to any mule domain myFoo=org.foo.MyObject;applyToArtifactType=app/domain will be applied to any mule application and any mule domainLoading transformers has a slightly different notation since you can define the 'returnClass' with optional mime type, and 'name'of the transformer as parameters i.e.
transformer.1=org.mule.transport.jms.transformers.JMSMessageToObject,returnClass=byte[] transformer.2=org.mule.transport.jms.transformers.JMSMessageToObject,returnClass=java.lang.String:text/xml, name=JMSMessageToString transformer.3=org.mule.transport.jms.transformers.JMSMessageToObject,returnClass=java.util.Hashtable)Note that the key used for transformers must be 'transformer.x' where 'x' is a sequential number. The transformer name will be automatically generated as JMSMessageToXXX where XXX is the return class name i.e. JMSMessageToString unless a 'name' parameter is specified. If no 'returnClass' is specified the default in the transformer will be used. Note that all objects defined have to have a default constructor. They can implement injection interfaces such as
MuleContextAware
and lifecycle interfaces such as Initialisable
.Modifier and Type | Field and Description |
---|---|
protected RegistryBootstrapDiscoverer |
discoverer |
protected org.slf4j.Logger |
logger |
protected MuleContext |
muleContext |
static String |
OBJECT_KEY |
static String |
SINGLE_TX |
protected ArtifactType |
supportedArtifactType |
static String |
TRANSFORMER_KEY |
PHASE_NAME
Constructor and Description |
---|
AbstractRegistryBootstrap()
Creates a default SimpleRegistryBootstrap using a
ClassPathRegistryBootstrapDiscoverer
in order to get the Properties resources from the class path. |
AbstractRegistryBootstrap(RegistryBootstrapDiscoverer discoverer)
Allows to specify a
RegistryBootstrapDiscoverer to discover the Properties
resources to be used. |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
doRegisterObject(String key,
String className,
boolean optional) |
protected abstract void |
doRegisterTransformer(String name,
Class<?> returnClass,
Class<? extends Transformer> transformerClass,
String mime,
boolean optional) |
protected Class |
getClass(String className) |
void |
initialise()
Method used to perform any initialisation work.
|
protected abstract void |
registerTransformers() |
void |
setMuleContext(MuleContext context) |
void |
setSupportedArtifactType(ArtifactType supportedArtifactType)
This attributes define which types or registry bootstrap entries will be
created depending on the entry applyToArtifactType parameter value.
|
protected final transient org.slf4j.Logger logger
public static final String TRANSFORMER_KEY
public static final String OBJECT_KEY
public static final String SINGLE_TX
protected ArtifactType supportedArtifactType
protected final RegistryBootstrapDiscoverer discoverer
protected MuleContext muleContext
public AbstractRegistryBootstrap()
ClassPathRegistryBootstrapDiscoverer
in order to get the Properties resources from the class path.public AbstractRegistryBootstrap(RegistryBootstrapDiscoverer discoverer)
RegistryBootstrapDiscoverer
to discover the Properties
resources to be used.discoverer
- public void setMuleContext(MuleContext context)
setMuleContext
in interface MuleContextAware
public void initialise() throws InitialisationException
InitialisationException
should be thrown,
causing the Mule instance to shutdown. If the error is recoverable, say by
retrying to connect, a RecoverableException
should be thrown.
There is no guarantee that by throwing a Recoverable exception that the Mule
instance will not shut down.initialise
in interface Initialisable
InitialisationException
- if a fatal error occurs causing the Mule instance to shutdownRecoverableException
- if an error occurs that can be recovered fromprotected abstract void doRegisterTransformer(String name, Class<?> returnClass, Class<? extends Transformer> transformerClass, String mime, boolean optional) throws Exception
Exception
protected Class getClass(String className) throws ClassNotFoundException
ClassNotFoundException
protected abstract void registerTransformers() throws MuleException
MuleException
protected abstract void doRegisterObject(String key, String className, boolean optional) throws Exception
Exception
public void setSupportedArtifactType(ArtifactType supportedArtifactType)
supportedArtifactType
- type of the artifact to support.Copyright © 2003–2015 MuleSoft, Inc.. All rights reserved.