org.talika.tarsis.context
Class ContextImpl

java.lang.Object
  extended by org.talika.tarsis.context.ContextImpl
All Implemented Interfaces:
Context

public final class ContextImpl
extends java.lang.Object
implements Context

Implementation of Context interface.

Version:
$Revision: 118 $
Author:
Jose M. Palomar

Method Summary
 void destroy()
          Called on shutdown of the Tarsis MVC Framework and put all components out of service.
 Authenticator getAuthenticator()
          Returns default Authenticator for this context.
 Authorizator getAuthorizator()
          Returns default Authorizator for this context.
 CommandFactory getCommandFactory()
          Returns default CommandFactory for this context.
 Factory getFactory(java.lang.String name)
          Returns an object Factory for given name in this context.
 java.lang.String getInitParameter(java.lang.String name)
          Returns an init parameter of this context.
 java.util.Map getInitParameters()
          Returns a map with all the init parameters of this context.
static ContextImpl getInstance()
          Returns singleton ContextImpl instance.
 Logger getLogger()
          Returns Logger of this context.
 java.lang.String getRealPath(java.lang.String path)
          Returns a String containing the real path for a given virtual path.
 java.net.URL getResource(java.lang.String path)
          Returns a URL to the resource that is mapped to a specified path.
 java.io.InputStream getResourceAsStream(java.lang.String path)
          Returns the resource located at the named path as an InputStream object.
 void init(javax.servlet.ServletContext ctx)
          Called on starts up of the Tarsis MVC Framework and put all components in service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ContextImpl getInstance()
Returns singleton ContextImpl instance.

Returns:
Context singleton ContextImpl instance.

init

public void init(javax.servlet.ServletContext ctx)
          throws ConfigException,
                 ServiceException
Called on starts up of the Tarsis MVC Framework and put all components in service.

Initializing sequence is:
  1. Loads context configuration file.
  2. Initializes loggers.
  3. Initializes command factory.
  4. Initializes authenticator and authorizator if any are configured.
  5. Initializes factories if any are configured.

Parameters:
ctx - ServletContext the ServletContext of web application where Tarsis MVC Framework is contained.
Throws:
ConfigException - if there is any problem loading configuration.
ServiceException - if there is any problem initializing services.

destroy

public void destroy()
Called on shutdown of the Tarsis MVC Framework and put all components out of service.


getAuthenticator

public Authenticator getAuthenticator()
Returns default Authenticator for this context.

Specified by:
getAuthenticator in interface Context
Returns:
Authenticator default Authenticator for this context.
See Also:
Context.getAuthenticator()

getAuthorizator

public Authorizator getAuthorizator()
Returns default Authorizator for this context.

Specified by:
getAuthorizator in interface Context
Returns:
Authorizator default Authorizator for this context.
See Also:
Context.getAuthorizator()

getInitParameter

public java.lang.String getInitParameter(java.lang.String name)
Returns an init parameter of this context.

Specified by:
getInitParameter in interface Context
Parameters:
name - String name of parameter.
Returns:
String value of parameter or null if parameter does not exist.
See Also:
Context.getInitParameter(String)

getInitParameters

public java.util.Map getInitParameters()
Returns a map with all the init parameters of this context.

Specified by:
getInitParameters in interface Context
Returns:
Map map with all the init parameters of this context.
See Also:
Context.getInitParameters()

getLogger

public Logger getLogger()
Returns Logger of this context.

Specified by:
getLogger in interface Context
Returns:
Logger Logger of this context.
See Also:
Context.getLogger()

getCommandFactory

public CommandFactory getCommandFactory()
Returns default CommandFactory for this context.

Specified by:
getCommandFactory in interface Context
Returns:
CommandFactory default CommandFactory for this context.
See Also:
Context.getCommandFactory()

getFactory

public Factory getFactory(java.lang.String name)
Returns an object Factory for given name in this context.

Specified by:
getFactory in interface Context
Parameters:
name - String name of factory.
Returns:
Factory object Factory for given name in this context or null if does not exist.
See Also:
Context.getFactory(String)

getResource

public java.net.URL getResource(java.lang.String path)
                         throws java.net.MalformedURLException
Returns a URL to the resource that is mapped to a specified path.

Specified by:
getResource in interface Context
Parameters:
path - String a String specifying the path to the resource.
Returns:
URL the resource located at the named path, or null if there is no resource at that path.
Throws:
java.net.MalformedURLException - if the pathname is not given in the correct form.
See Also:
ServletContext.getResource(java.lang.String), Context.getResource(String)

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String path)
Returns the resource located at the named path as an InputStream object.

Specified by:
getResourceAsStream in interface Context
Parameters:
path - String a String specifying the path to the resource.
Returns:
InputStream the InputStream returned to the servlet, or null if no resource exists at the specified path.
See Also:
ServletContext.getResourceAsStream(java.lang.String), Context.getResourceAsStream(String)

getRealPath

public java.lang.String getRealPath(java.lang.String path)
Returns a String containing the real path for a given virtual path.

Specified by:
getRealPath in interface Context
Parameters:
path - String a String specifying the path to the resource.
Returns:
String a String specifying the real path, or null if the translation cannot be performed
See Also:
ServletContext.getRealPath(java.lang.String), Context.getRealPath(String)


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