hlship 2005/05/10 07:07:14
Modified: . status.xml
framework/src/java/org/apache/tapestry
ApplicationServlet.java
Log:
Store the Registry in the ServletContext for access by other servlets.
Revision Changes Path
1.101 +1 -0 jakarta-tapestry/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/jakarta-tapestry/status.xml,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- status.xml 10 May 2005 13:26:49 -0000 1.100
+++ status.xml 10 May 2005 14:07:14 -0000 1.101
@@ -57,6 +57,7 @@
<action type="add" dev="PF" fixes-bug="TAPESTRY-317">Fixed workbench
build script so that generated war file will include the required ognl
jar.</action>
<action type="fix" dev="HLS" fixes-bug="TAPESTRY-166">Allow Submits to
defer invoking their listener.</action>
<action type="fix" dev="HLS" fixes-bug="TAPESTRY-320"> Property
seperate data from different users stored using the
tapestry.persist.ClientPropertyPersistenceStrategy service.</action>
+ <action type="add" dev="HLS"> Store the Registry as a ServletContext
attribute, so that it may be accessed from other servlets. </action>
</release>
<release version="4.0-alpha-2" date="May 5 2005">
<action type="update" dev="HLS"> Coordinate Locale changes with the
hivemind.ThreadLocale service. </action>
1.16 +25 -30
jakarta-tapestry/framework/src/java/org/apache/tapestry/ApplicationServlet.java
Index: ApplicationServlet.java
===================================================================
RCS file:
/home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/ApplicationServlet.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ApplicationServlet.java 18 Apr 2005 17:06:42 -0000 1.15
+++ ApplicationServlet.java 10 May 2005 14:07:14 -0000 1.16
@@ -75,6 +75,16 @@
public class ApplicationServlet extends HttpServlet
{
+ /**
+ * Prefix used to store the HiveMind Registry into the ServletContext.
This string is suffixed
+ * with the servlet name (in case multiple Tapestry applications are
executing within a single
+ * web application).
+ *
+ * @since 4.0
+ */
+
+ private static final String REGISTRY_KEY_PREFIX =
"org.apache.tapestry.Registry:";
+
private static final Log LOG =
LogFactory.getLog(ApplicationServlet.class);
/**
@@ -96,6 +106,14 @@
private ClassResolver _resolver;
/**
+ * The key used to store the registry into the ServletContext.
+ *
+ * @since 4.0
+ */
+
+ private String _registryKey;
+
+ /**
* @since 4.0
*/
@@ -121,7 +139,7 @@
try
{
_registry.setupThread();
-
+
_requestServicer.service(request, response);
}
catch (ServletException ex)
@@ -182,6 +200,8 @@
{
String name = config.getServletName();
+ _registryKey = REGISTRY_KEY_PREFIX + name;
+
long startTime = System.currentTimeMillis();
long elapsedToRegistry = 0;
@@ -191,12 +211,13 @@
try
{
-
_registry = constructRegistry(config);
elapsedToRegistry = System.currentTimeMillis() - startTime;
initializeApplication();
+
+ config.getServletContext().setAttribute(_registryKey, _registry);
}
catch (Exception ex)
{
@@ -227,23 +248,6 @@
}
/**
- * Closes the stream, ignoring any exceptions.
- */
-
- protected void close(InputStream stream)
- {
- try
- {
- if (stream != null)
- stream.close();
- }
- catch (IOException ex)
- {
- // Ignore it.
- }
- }
-
- /**
* Invoked from [EMAIL PROTECTED] #init(ServletConfig)}to construct the
Registry to be used by the
* application.
* <p>
@@ -307,27 +311,18 @@
}
/**
- * Returns the Registry used by the application.
- *
- * @since 4.0
- */
- public Registry getRegistry()
- {
- return _registry;
- }
-
- /**
* Shuts down the registry (if it exists).
*
* @since 4.0
*/
public void destroy()
{
+ getServletContext().removeAttribute(_registryKey);
+
if (_registry != null)
{
_registry.shutdown();
_registry = null;
}
}
-
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]