|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.activemath.config.ServletContextConfigurator
public class ServletContextConfigurator
Run-once class to adjust the directories of ActiveMath when deployed as web-application. The principle behind this class is that the whole web-application directory should be read-only for the web-application, so as to allow developers to unpack a new war or to upload a new directory distribution, hence have the data-directories (like the user-model storage, the user's database, the session-Manager freezer) be in separate directories. These separate directories are, as the only work-oriented directory provided by the servlet specifications, the so-called "temporary" directory. Installers are encouraged to provide properties to indicate another directory writable by the web-application and should be aware that some servlet-containers empty the working directory at each startup. (this is not the case of the Tomcat 4 servlet container).
The re-configuration will happen iff the system-property activemath.home
is not defined and iff the manager is not already initted
(as given by Manager.isInitted()).
This class is built with a ServletContext object whose properties are used
to adjust the distribution of paths within ActiveMath.
Invoke this class by creating a new instance then invoking it run() method.
The goal of these modifications is to be able to completely separate the web-archive from the data of the life of the servers, thereby allowing a new web-application to be dropped, and reloaded if made possible by the servlet-container, without loosing information for the users of ActiveMath.
The temporary directory as defined by servlets 2.3 is used as main storage place (hence is NOT ASSUMED TO BE TEMPORARY !) in this setting, unless a property directories.webapp.stateStorage is given which is then considered to be an absolute path or a path relative to the activemathHome.
This class also achieves two overridings. Among others, it converts:
activemath.home to the WEB-INF directory of the web-app,
(which is supposed to be for read-only purposes) directories.tempDir to the temporary directory
provided by the servlet-context (TODO: provide a way to remove
properties using properties, hence allowing this overriding to
take place only when the property is not defined).These values can be overriden by the web.xml (as context-init-parameter) and the override can be cancelled by setting the value to empty. All the log-messages in this class use the servlet-context's log and not the log4j log !
| Field Summary | |
|---|---|
protected static Logger |
thisLogCat
|
| Constructor Summary | |
|---|---|
ServletContextConfigurator(ServletContext context)
|
|
| Method Summary | |
|---|---|
void |
contextDestroyed(ServletContextEvent sce)
|
void |
contextInitialized(ServletContextEvent sce)
|
void |
run()
Performs the needed configurations, returning if it has already run, if the system property activemath.home exists or if the manager is already initted. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static Logger thisLogCat
| Constructor Detail |
|---|
public ServletContextConfigurator(ServletContext context)
| Method Detail |
|---|
public void contextDestroyed(ServletContextEvent sce)
contextDestroyed in interface ServletContextListenerpublic void contextInitialized(ServletContextEvent sce)
contextInitialized in interface ServletContextListener
public void run()
throws IOException
This methods considers it has run even if errors appear.
BadConfigurationException - if the Manager can't init
IOException - if some files are wrong
(this may happen, e.g., when the servlet is loaded
from an unexpanded war file)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||