org.talika.tarsis.command.factory.xml
Class XmlCommandsFactory

java.lang.Object
  extended by org.talika.tarsis.service.AbstractService
      extended by org.talika.tarsis.command.factory.CommandFactoryService
          extended by org.talika.tarsis.command.factory.xml.XmlCommandsFactory
All Implemented Interfaces:
CommandFactory, Service

public final class XmlCommandsFactory
extends CommandFactoryService

XML based implementation of CommandFactory interface.

It reads command definitions from an XML file that defaults to /WEB-INF/commands.xml.

Definitions are loaded when factory is initialized.

Version:
$Revision: 269 $
Author:
Jose M. Palomar
See Also:
XmlCommandFactory

Field Summary
static java.lang.String COMMANDS_FILE
          Command definitions file.
 
Constructor Summary
XmlCommandsFactory()
          Creates a new XmlCommandsFactory object.
 
Method Summary
 java.lang.String getCommandsFile()
          Returns command definitions file.
 java.lang.String getName()
          Service name.
 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 loadCommands()
          Load commands from command definitions file.
protected  void loadPackage(java.lang.String packageName)
          Tries to load all command definitions from repository for a given package.
protected  java.util.Map loadXmlCommands(org.xml.sax.InputSource input)
          Loads command definitions from an XML source.
 void setCommandsFile(java.lang.String commandsFile)
          Sets command definitions file.
 
Methods inherited from class org.talika.tarsis.command.factory.CommandFactoryService
addCommand, addCommands, findCommand
 
Methods inherited from class org.talika.tarsis.service.AbstractService
destroy, getContext, getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMANDS_FILE

public static final java.lang.String COMMANDS_FILE
Command definitions file.

See Also:
Constant Field Values
Constructor Detail

XmlCommandsFactory

public XmlCommandsFactory()
Creates a new XmlCommandsFactory object.

Method Detail

init

public void init(Context context)
          throws ServiceException
Called by the framework to indicate that is being placed into service.

Initialization secuence:
  1. Call super init method.
  2. Checks if commandsFile is set if not sets its value to COMMANDS_FILE.
  3. Obtains Logger instance from context.
  4. Loads commands from commandsFile.

Specified by:
init in interface Service
Overrides:
init in class AbstractService
Parameters:
context - Context context that initialized service.
Throws:
ServiceException - if an exception has occurred that interferes with the services's normal operation
See Also:
Service.init(Context)

getName

public java.lang.String getName()
Service name.

Specified by:
getName in interface Service
Specified by:
getName in class AbstractService
Returns:
String service name.
See Also:
Service.getName()

loadCommand

protected void loadCommand(java.lang.String commandName)
Tries to load command definition from repository for a given name.

This implementation does nothing because commands are loaded at init time.

Specified by:
loadCommand in class CommandFactoryService
Parameters:
commandName - String name of command to load.

loadPackage

protected void loadPackage(java.lang.String packageName)
Tries to load all command definitions from repository for a given package.
This implementation does nothing because commands are loaded at init time.

Specified by:
loadPackage in class CommandFactoryService
Parameters:
packageName - String name for package to load.

loadCommands

protected void loadCommands()
Load commands from command definitions file.


loadXmlCommands

protected java.util.Map loadXmlCommands(org.xml.sax.InputSource input)
Loads command definitions from an XML source.

Parameters:
input - InputSource XML source.
Returns:
Map a map with all package commands or null if something wrong happens parsing XML source.

getCommandsFile

public java.lang.String getCommandsFile()
Returns command definitions file.

Returns:
String command definitions file.

setCommandsFile

public void setCommandsFile(java.lang.String commandsFile)
Sets command definitions file.

Parameters:
commandsFile - String command definitions file.


Copyright © 2002-2012 Talika Open Source Group. All Rights Reserved.