Package org.smooks.api
Interface Registry
-
- All Known Implementing Classes:
DefaultRegistry
public interface Registry
Holds system and user objects such asResourceConfig
andContentHandler
.A registry is bound to the application context. It allows Smooks to discover and reference registered objects during a filter execution. Clients should call
deRegisterObject(Object)
to remove a registered object once it is no longer needed.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Cleans up the resources of thisRegistry
and calls thePreDestroy
method of each registered object.void
deRegisterObject(Object key)
Removes a registered object from thisRegistry
.ClassLoader
getClassLoader()
<T> T
lookup(Object key)
Looks up a registered object by its key.<R> R
lookup(Function<Map<Object,Object>,R> function)
Looks up a registered object by function.<T> T
lookup(TypedKey<T> key)
Looks up a registered object by its typed key.void
registerObject(Object value)
Registers an object with its key derived from the object'sResource.name()
attribute or the object's class name.void
registerObject(Object key, Object value)
Adds an object with the given key to thisRegistry
.void
registerResourceConfig(ResourceConfig resourceConfig)
Registers and initialises aResourceConfig
.void
registerResourceConfigSeq(ResourceConfigSeq resourceConfigSeq)
Registers and initialises aResourceConfigSeq
.ResourceConfigSeq
registerResources(String baseURI, InputStream resourceConfigStream)
Registers the set of resources specified in the supplied XML configuration stream.
-
-
-
Method Detail
-
registerObject
void registerObject(Object value)
Registers an object with its key derived from the object'sResource.name()
attribute or the object's class name.- Parameters:
value
- object to register- Throws:
SmooksException
- if the value with the assigned name already existsIllegalArgumentException
- if the value is null
-
registerObject
void registerObject(Object key, Object value)
Adds an object with the given key to thisRegistry
.- Parameters:
key
- object that maps to thevalue
to registervalue
- object to register which can be retrieved by itskey
- Throws:
SmooksException
- if the value with the assigned name already existsIllegalArgumentException
- if the name or the value is null
-
deRegisterObject
void deRegisterObject(Object key)
Removes a registered object from thisRegistry
.- Parameters:
key
- key of the registered object to remove
-
lookup
<R> R lookup(Function<Map<Object,Object>,R> function)
Looks up a registered object by function.- Type Parameters:
R
- type of object to be returned- Parameters:
function
- function to apply for looking up an object- Returns:
- registered object if it exists or null
-
lookup
<T> T lookup(Object key)
Looks up a registered object by its key.- Type Parameters:
T
- type of object to be returned- Parameters:
key
- key of registered object- Returns:
- the registered object if it exists or null
-
lookup
<T> T lookup(TypedKey<T> key)
Looks up a registered object by its typed key.- Type Parameters:
T
- type of object to be returned- Parameters:
key
- typed key of registered object- Returns:
- the registered object if it exists or null
-
registerResources
ResourceConfigSeq registerResources(String baseURI, InputStream resourceConfigStream) throws SAXException, IOException, URISyntaxException
Registers the set of resources specified in the supplied XML configuration stream.- Parameters:
baseURI
- base URI to be associated with the configuration streamresourceConfigStream
- XML resource configuration stream- Returns:
ResourceConfigSeq
created from the added resource configuration- Throws:
SAXException
- if error happens while parsing the resource streamIOException
- if error happens while reading resource streamURISyntaxException
-
registerResourceConfig
void registerResourceConfig(ResourceConfig resourceConfig)
Registers and initialises aResourceConfig
.- Parameters:
resourceConfig
-ResourceConfig
to register
-
registerResourceConfigSeq
void registerResourceConfigSeq(ResourceConfigSeq resourceConfigSeq)
Registers and initialises aResourceConfigSeq
.- Parameters:
resourceConfigSeq
-ResourceConfigSeq
to register
-
close
void close()
Cleans up the resources of thisRegistry
and calls thePreDestroy
method of each registered object.
-
getClassLoader
ClassLoader getClassLoader()
- Returns:
- the class loader of this
Registry
-
-