|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecthelma.framework.core.Application
public final class Application
The central class of a Helma application. This class keeps a pool of request evaluators (threads with JavaScript interpreters), waits for requests from the Web server or XML-RPC port and dispatches them to the evaluators.
Field Summary | |
---|---|
protected java.util.Vector |
allThreads
|
protected INode |
cachenode
|
protected long |
errorCount
|
protected java.util.Stack |
freeThreads
Collections for evaluator thread pooling |
protected NodeManager |
nmgr
|
protected long |
requestCount
|
protected SkinManager |
skinmgr
The skin manager for this application |
TypeManager |
typemgr
The type manager checks if anything in the application's prototype definitions has been updated prior to each evaluation. |
protected long |
xmlrpcCount
|
Constructor Summary | |
---|---|
Application(java.lang.String name)
Simple constructor for dead application instances. |
|
Application(java.lang.String name,
Repository[] repositories,
java.io.File dbDir)
Build an application with the given name with the given sources. |
|
Application(java.lang.String name,
Server server)
Build an application with the given name and server instance. |
|
Application(java.lang.String name,
Server server,
Repository[] repositories,
java.io.File customAppDir,
java.io.File customDbDir)
Build an application with the given name, server instance, sources and db directory. |
Method Summary | |
---|---|
boolean |
addRepository(Repository rep)
Add a repository to this app's repository list. |
boolean |
authenticate(java.lang.String uname,
java.lang.String password)
In contrast to login, this works outside the Hop user object framework. |
protected void |
checkXmlRpcAccess(java.lang.String proto,
java.lang.String method)
Check if a method may be invoked via XML-RPC on a prototype. |
void |
clearCache()
Reset the application's object cache, causing all objects to be refetched from the database. |
int |
countActiveEvaluators()
|
int |
countEvaluators()
|
int |
countFreeEvaluators()
|
int |
countMaxActiveEvaluators()
|
int |
countSessions()
Returns the number of currenty active sessions. |
int |
countThreads()
|
Session |
createSession(java.lang.String sessionId)
Return the session currently associated with a given Hop session ID. |
boolean |
debug()
Tell other classes whether they should output logging information for this application. |
ResponseTrans |
execute(RequestTrans req)
Execute a request coming in from a web client. |
java.lang.Object |
executeExternal(java.lang.String method,
java.util.Vector args)
|
java.lang.Object |
executeXmlRpc(java.lang.String method,
java.util.Vector args)
Called to execute a method via XML-RPC, usally by helma.main.ApplicationManager which acts as default handler/request dispatcher. |
org.apache.commons.logging.Log |
getAccessLog()
get the app's access log. |
int |
getActiveThreads()
Return the number of currently active threads |
java.util.List |
getActiveUsers()
Return a list of Helma nodes (HopObjects - the database object representing the user, not the session object) representing currently logged in users. |
java.io.File |
getAppDir()
Get the application directory. |
java.lang.String |
getBaseURI()
Returns the baseURI for Hrefs in this application. |
INode |
getCacheNode()
Return a transient node that is shared by all evaluators of this application ("app node") |
int |
getCacheUsage()
Returns the number of elements in the NodeManager's cache |
java.lang.String |
getCharset()
Return the name of the character encoding used by this application |
long |
getChecksum()
Get a checksum that mirrors the state of this application in the sense that if anything in the applciation changes, the checksum hopefully will change, too. |
java.lang.Object |
getChildElement(java.lang.Object obj,
java.lang.String name)
Retrieve a child element of this object by name. |
java.lang.ClassLoader |
getClassLoader()
Return the application's classloader |
RequestEvaluator |
getCurrentRequestEvaluator()
Get the current RequestEvaluator, or null if the calling thread is not evaluating a request. |
java.lang.Object |
getDataRoot()
This method returns the root object of this application's object tree. |
DbMapping |
getDbMapping(java.lang.String typename)
Get the DbMapping associated with a prototype name in this application |
ResourceProperties |
getDbProperties()
Get the application's db properties |
DbSource |
getDbSource(java.lang.String name)
Return a DbSource object for a given name. |
DocApplication |
getDoc()
|
java.lang.String |
getElementName(java.lang.Object obj)
Return the name to be used to get this element from its parent |
long |
getErrorCount()
|
RequestEvaluator |
getEvaluator()
Returns a free evaluator to handle a request. |
org.apache.commons.logging.Log |
getEventLog()
get the app's event log. |
java.lang.String |
getHrefRootPrototype()
Returns the prototype name that Hrefs in this application should start with. |
java.lang.String |
getJavaClassForPrototype(java.lang.String typename)
Return the java class that a given prototype wraps, or null. |
org.apache.commons.logging.Log |
getLogger(java.lang.String logname)
Get a logger object to log events for this application. |
java.lang.String |
getName()
Return the name of this application |
java.lang.String |
getNodeHref(java.lang.Object elem,
java.lang.String actionName)
Return a path to be used in a URL pointing to the given element and action |
NodeManager |
getNodeManager()
Returns the node manager for this application. |
java.lang.Object |
getParentElement(java.lang.Object obj)
Return the parent element of this object. |
ResourceProperties |
getProperties()
Get the application's app properties |
java.lang.String |
getProperty(java.lang.String propname)
Proxy method to get a property from the applications properties. |
java.lang.String |
getProperty(java.lang.String propname,
java.lang.String defvalue)
Proxy method to get a property from the applications properties. |
Prototype |
getPrototype(java.lang.Object obj)
Return a prototype for a given node. |
Prototype |
getPrototypeByName(java.lang.String name)
Return the prototype with the given name, if it exists |
java.lang.String |
getPrototypeName(java.lang.Object obj)
Get the name of the prototype to be used for this object. |
java.util.Collection |
getPrototypes()
Return a collection containing all prototypes defined for this application |
java.util.List |
getRegisteredUsers()
Return a list of Helma nodes (HopObjects - the database object representing the user, not the session object) representing registered users of this application. |
java.util.List |
getRepositories()
Returns the repositories of this application |
int |
getRepositoryIndex(Repository rep)
Searches for the index of the given repository for this app. |
long |
getRequestCount()
|
ResourceComparator |
getResourceComparator()
Get a comparator for comparing Resources according to the order of repositories they're contained in. |
java.lang.String |
getRootHref()
Return the href to the root of this application. |
java.lang.String |
getRootId()
Return the id of the object to be used as this application's root object |
DbMapping |
getRootMapping()
Return the prototype of the object to be used as this application's root object |
java.io.File |
getServerDir()
Return the directory of the Helma server |
Session |
getSession(java.lang.String sessionId)
Return the session currently associated with a given Hop session ID. |
SessionManager |
getSessionManager()
Return the application's session manager |
java.util.Map |
getSessions()
Return the whole session map. |
java.util.List |
getSessionsForUsername(java.lang.String username)
Return an array of SessionBean objects currently associated
with a given Helma user. |
Skin |
getSkin(java.lang.String protoname,
java.lang.String skinname,
java.lang.Object[] skinpath)
Return a skin for a given object. |
long |
getStarttime()
|
UploadStatus |
getUploadStatus(RequestTrans req)
Return the current upload status. |
INode |
getUserNode(java.lang.String uid)
Returns a Node representing a registered user of this application by his or her user name. |
INode |
getUserRoot()
Returns the Object which contains registered users of this application. |
WrappedNodeManager |
getWrappedNodeManager()
Returns a wrapper containing the node manager for this application. |
long |
getXmlrpcCount()
|
java.lang.String |
getXmlRpcHandlerName()
Return the XML-RPC handler name for this app. |
boolean |
hasExplicitBaseURI()
Return true if the baseURI property is defined in the application properties, false otherwise. |
void |
init()
Get the application ready to run, initializing the evaluators and type manager. |
void |
init(java.lang.String ignoreDirs)
Get the application ready to run, initializing the evaluators and type manager. |
boolean |
isJavaPrototype(java.lang.String typename)
Check whether a prototype is for scripting a java class, i.e. |
boolean |
isRunning()
Returns true if this app is currently running |
void |
logAccess(java.lang.String msg)
Log an application access |
void |
logError(java.lang.String msg)
Log an application error |
void |
logError(java.lang.String msg,
java.lang.Throwable error)
Log an application error |
void |
logEvent(java.lang.String msg)
Log a generic application event |
boolean |
loginSession(java.lang.String uname,
java.lang.String password,
Session session)
Log in a user given his or her user name and password. |
void |
logoutSession(Session session)
Log out a session from this application. |
void |
printThreadStats()
Periodically called to log thread stats for this application |
INode |
registerUser(java.lang.String uname,
java.lang.String password)
Register a user with the given user name and password. |
void |
releaseEvaluator(RequestEvaluator ev)
Returns an evaluator back to the pool when the work is done. |
void |
run()
The run method performs periodic tasks like executing the scheduler method and kicking out expired user sessions. |
void |
setBaseURI(java.lang.String uri)
This method sets the base URL of this application which will be prepended to the actual object path. |
protected void |
setCurrentRequestEvaluator(RequestEvaluator eval)
Set the current RequestEvaluator for the calling thread. |
void |
setDataRoot(java.lang.Object root)
Set the application's root element to an arbitrary object. |
boolean |
setNumberOfEvaluators(int n)
This can be used to set the maximum number of evaluators which will be allocated. |
void |
start()
Create and start scheduler and cleanup thread |
void |
stop()
This is called to shut down a running application. |
java.lang.String |
toString()
Return a string representation for this app. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected NodeManager nmgr
public TypeManager typemgr
protected SkinManager skinmgr
protected java.util.Stack freeThreads
protected java.util.Vector allThreads
protected INode cachenode
protected volatile long requestCount
protected volatile long xmlrpcCount
protected volatile long errorCount
Constructor Detail |
---|
public Application(java.lang.String name)
public Application(java.lang.String name, Repository[] repositories, java.io.File dbDir) throws java.rmi.RemoteException, java.lang.IllegalArgumentException
java.rmi.RemoteException
java.lang.IllegalArgumentException
public Application(java.lang.String name, Server server) throws java.rmi.RemoteException, java.lang.IllegalArgumentException
java.rmi.RemoteException
java.lang.IllegalArgumentException
public Application(java.lang.String name, Server server, Repository[] repositories, java.io.File customAppDir, java.io.File customDbDir) throws java.rmi.RemoteException, java.lang.IllegalArgumentException
java.rmi.RemoteException
java.lang.IllegalArgumentException
Method Detail |
---|
public void init() throws DatabaseException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.ClassNotFoundException, java.lang.InterruptedException
DatabaseException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.ClassNotFoundException
java.lang.InterruptedException
public void init(java.lang.String ignoreDirs) throws DatabaseException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.ClassNotFoundException, java.lang.InterruptedException
ignoreDirs
- comma separated list of directory names to ignore
DatabaseException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.ClassNotFoundException
java.lang.InterruptedException
public void start()
public void stop()
public boolean isRunning()
public java.io.File getAppDir()
public ResourceComparator getResourceComparator()
public RequestEvaluator getEvaluator()
public void releaseEvaluator(RequestEvaluator ev)
public boolean setNumberOfEvaluators(int n)
public int getActiveThreads()
public ResponseTrans execute(RequestTrans req)
public java.lang.Object executeXmlRpc(java.lang.String method, java.util.Vector args) throws java.lang.Exception
java.lang.Exception
public java.lang.Object executeExternal(java.lang.String method, java.util.Vector args) throws java.lang.Exception
java.lang.Exception
public void clearCache()
public int getCacheUsage()
public void setDataRoot(java.lang.Object root)
public java.lang.Object getDataRoot()
public DbMapping getRootMapping()
public java.lang.String getRootId()
public INode getUserRoot()
public NodeManager getNodeManager()
public WrappedNodeManager getWrappedNodeManager()
public SessionManager getSessionManager()
public INode getCacheNode()
public INode getUserNode(java.lang.String uid)
public Prototype getPrototype(java.lang.Object obj)
public Prototype getPrototypeByName(java.lang.String name)
public java.util.Collection getPrototypes()
public Skin getSkin(java.lang.String protoname, java.lang.String skinname, java.lang.Object[] skinpath) throws java.io.IOException
java.io.IOException
public Session createSession(java.lang.String sessionId)
public java.util.List getActiveUsers()
public java.util.List getRegisteredUsers()
public java.util.List getSessionsForUsername(java.lang.String username)
SessionBean
objects currently associated
with a given Helma user.
public Session getSession(java.lang.String sessionId)
public java.util.Map getSessions()
public int countSessions()
public INode registerUser(java.lang.String uname, java.lang.String password)
public boolean loginSession(java.lang.String uname, java.lang.String password, Session session)
public void logoutSession(Session session)
public boolean authenticate(java.lang.String uname, java.lang.String password)
public java.lang.String getRootHref() throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public java.lang.String getNodeHref(java.lang.Object elem, java.lang.String actionName) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public java.lang.String getBaseURI()
public void setBaseURI(java.lang.String uri)
public boolean hasExplicitBaseURI()
public java.lang.String getHrefRootPrototype()
public boolean debug()
public RequestEvaluator getCurrentRequestEvaluator()
protected void setCurrentRequestEvaluator(RequestEvaluator eval)
eval
- the RequestEvaluator belonging to the current threadpublic java.lang.ClassLoader getClassLoader()
public java.lang.String getElementName(java.lang.Object obj)
public java.lang.Object getChildElement(java.lang.Object obj, java.lang.String name)
public java.lang.Object getParentElement(java.lang.Object obj)
public java.lang.String getPrototypeName(java.lang.Object obj)
public DocApplication getDoc()
public void logError(java.lang.String msg, java.lang.Throwable error)
public void logError(java.lang.String msg)
public void logEvent(java.lang.String msg)
public void logAccess(java.lang.String msg)
public org.apache.commons.logging.Log getEventLog()
public org.apache.commons.logging.Log getAccessLog()
public org.apache.commons.logging.Log getLogger(java.lang.String logname)
public void run()
run
in interface java.lang.Runnable
public boolean isJavaPrototype(java.lang.String typename)
public java.lang.String getJavaClassForPrototype(java.lang.String typename)
public DbSource getDbSource(java.lang.String name)
public java.lang.String getName()
public boolean addRepository(Repository rep)
rep
- the repository to add
public int getRepositoryIndex(Repository rep)
rep
- one of this app's root repositories.
public java.util.List getRepositories()
public java.io.File getServerDir()
public DbMapping getDbMapping(java.lang.String typename)
public UploadStatus getUploadStatus(RequestTrans req)
req
- the upload RequestTrans
public long getChecksum()
public java.lang.String getProperty(java.lang.String propname)
public java.lang.String getProperty(java.lang.String propname, java.lang.String defvalue)
public ResourceProperties getProperties()
public ResourceProperties getDbProperties()
public java.lang.String getXmlRpcHandlerName()
public java.lang.String toString()
toString
in class java.lang.Object
public int countThreads()
public int countEvaluators()
public int countFreeEvaluators()
public int countActiveEvaluators()
public int countMaxActiveEvaluators()
public long getRequestCount()
public long getXmlrpcCount()
public long getErrorCount()
public long getStarttime()
public java.lang.String getCharset()
public void printThreadStats()
protected void checkXmlRpcAccess(java.lang.String proto, java.lang.String method) throws java.lang.Exception
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |