|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.talika.tarsis.service.AbstractService org.talika.tarsis.command.factory.CommandFactoryService org.talika.tarsis.command.factory.xml.XmlCommandFactory
public final class XmlCommandFactory
XML based implementation of CommandFactory
interface.
It reads command definitions from an XML file. It supports multiple definitions
files stored in a package directory, typically /WEB-INF/packages/
.
File name is considered to be package name and to have all commands of a single
package.
Commands packages are loaded on demand when they are invoked. When a command
is lodaded is initialized and its action is put into service.
XmlCommandsFactory
Field Summary | |
---|---|
static java.lang.String |
PACKAGE_EXTENSION
Default package file extension. |
static java.lang.String |
PACKAGES_DIR
Default directory for package files. |
Constructor Summary | |
---|---|
XmlCommandFactory()
Creates a new XmlCommandFactory object. |
Method Summary | |
---|---|
void |
destroy()
Called by the framework to indicate that is being placed out of service. |
java.lang.String |
getName()
Service name. |
java.lang.String |
getPackakesDir()
Returns packages directory. |
void |
init(Context context)
Called by the framework to indicate that is being placed into service. |
protected void |
loadCommand(java.lang.String commandName)
Tries to load command definition from repository for a given name. |
protected void |
loadPackage(java.lang.String packageName)
Tries to load all command definitions from repository for a given package. |
protected java.util.Map |
loadXmlPackage(org.xml.sax.InputSource input)
Loads command definitions from an XML source. |
void |
setPackagesDir(java.lang.String packagesDir)
Sets packages directory. |
Methods inherited from class org.talika.tarsis.command.factory.CommandFactoryService |
---|
addCommand, addCommands, findCommand |
Methods inherited from class org.talika.tarsis.service.AbstractService |
---|
getContext, getLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PACKAGES_DIR
public static final java.lang.String PACKAGE_EXTENSION
Constructor Detail |
---|
public XmlCommandFactory()
XmlCommandFactory
object.
Method Detail |
---|
public void init(Context context) throws ServiceException
init
method.packagesDir
is set if not sets its value to
PACKAGES_DIR
.Logger
instance from context.packsLoaded
to an empty Set
.
init
in interface Service
init
in class AbstractService
context
- Context context that initialized service.
ServiceException
- if an exception has occurred that interferes with the
services's normal operationService.init(Context)
public void destroy()
packsLoaded
.destroy
method.
destroy
in interface Service
destroy
in class AbstractService
Service.destroy()
public java.lang.String getName()
getName
in interface Service
getName
in class AbstractService
Service.getName()
protected void loadCommand(java.lang.String commandName)
loadCommand
in class CommandFactoryService
commandName
- String name of command to load.protected void loadPackage(java.lang.String packageName)
loadPackage
in class CommandFactoryService
packageName
- String name for package to load.protected java.util.Map loadXmlPackage(org.xml.sax.InputSource input)
input
- InputSource XML source.
null
if something
wrong happens parsing XML source.public java.lang.String getPackakesDir()
public void setPackagesDir(java.lang.String packagesDir)
packagesDir
- String sets packages directory.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |