|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tentackle.appworx.AbstractApplication
org.tentackle.appworx.WebApplication
public class WebApplication
Web Application.
Web applications usually run in a container such as glassfish or in case of JRuby/Rails in a pack of mongrels or a single webrick. Because we cannot make any assumptions about the threading model (single thread/single instance/single jvm as with JRuby/Webrick or full-blown multithreaded as in glassfish or half-way in between like JRuby with mongrel_jcluster) the WebApplication provides a logical Db-pool on top of multiplexed physical database connections. The initial size of the logical Db pool is 2 on 1 physical connection. This will not waste resources in single thread per JVM setups (like Rails/Webrick) but will dynamically grow otherwise.
Web applications need some mapping between sessions and
AppUserInfo-objects that in turn carry the user id
and a SecurityManager. For the time of a web-roundtrip
a logical Db is picked from the pool and associated with that
user info (i.e. "session"). Notice that there may be more than
one session per user (but each gets its own user info). That's
why user infos are mapped by a session key object and not by
the user id. Furthermore, depending on the container's session
model, it is not sure that the container's session carries
the user id at all.
| Constructor Summary | |
|---|---|
WebApplication()
Creates an instance of a web application. |
|
| Method Summary | |
|---|---|
void |
addSession(Object sessionKey,
AppUserInfo userInfo)
Adds a mapping between a session and a user info. |
ConnectionManager |
createConnectionManager()
Creates the connection manager for the client sessions. |
DbPool |
createDbPool()
Creates the logical DbPool. |
protected void |
doFinishStartup()
Finishes the startup. The default implementation starts the modification thread, unless "--nomodthread" given, creates the connection manager, the Db pool,
and the DbServer instance. |
protected void |
doLogin()
Connects the server to the database backend. |
protected void |
doStop()
Terminates the application gracefully. |
Db |
getDb(Object sessionKey)
Gets a logical db connection by a session key. |
static WebApplication |
getInstance(Class<? extends WebApplication> clazz,
Properties props)
Gets the current web application instance or starts a new instance if not already running. |
static WebApplication |
getWebApplication()
Gets the current web application instance. |
void |
putDb(Db db)
Release a logical db connection. |
void |
removeSession(Object sessionKey)
Removes a mapping between a session and a user info. |
void |
start(Properties props)
Starts the application. |
void |
stop()
Gracefully terminates the web application server. |
| Methods inherited from class org.tentackle.appworx.AbstractApplication |
|---|
createContextDb, createDb, createModificationThread, createUserInfo, detectEE, detectJNLP, doConfigureApplication, doInitialize, getContextDb, getDb, getProperties, getProperty, getRunningApplication, getUser, getUser, getUserInfo, installPreferences, installSecurityManager, isDeployedByEE, isDeployedByJNLP, register, securityRulesChanged, setContextDb, setProperties, setUserInfo, unregister, updateUserId |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WebApplication()
| Method Detail |
|---|
public static WebApplication getWebApplication()
This is just a convenience method to AbstractApplication.getRunningApplication().
public static WebApplication getInstance(Class<? extends WebApplication> clazz,
Properties props)
throws ApplicationException
Web containers should use this method to make sure that only one instance is started per JVM/classloader-context.
If the application runs in a container (tomcat, glassfish, etc...) additional properties may be appended/overwritten to/in the given props-argument. In web.xml add the following lines:
<env-entry>
<env-entry-name>tentackle.properties</env-entry-name>
<env-entry-value>../myapplication.properties</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
This will load the properties-file myapplication.properties from
the WEB-INF-directory (without "../" from WEB-INF/classes)
and modify the properties given by props.
clazz - the application classprops - the properties to configure the application
ApplicationException - if failed
public void addSession(Object sessionKey,
AppUserInfo userInfo)
sessionKey - the (unique) session keyuserInfo - the user infopublic void removeSession(Object sessionKey)
sessionKey - the (unique) session keypublic Db getDb(Object sessionKey)
sessionKey - the session key
public void putDb(Db db)
db - the db to release
public void start(Properties props)
throws ApplicationException
props - the properties to configure the application
ApplicationException - if startup failedAbstractApplication.setProperties(java.util.Properties)public void stop()
public ConnectionManager createConnectionManager()
public DbPool createDbPool()
protected void doLogin()
throws ApplicationException
ApplicationException
protected void doFinishStartup()
throws ApplicationException
"--nomodthread" given, creates the connection manager, the Db pool,
and the DbServer instance.
doFinishStartup in class AbstractApplicationApplicationExceptionprotected void doStop()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||