craigmcc 2002/07/27 17:17:27
Modified: . STATUS
src/share/org/apache/struts/action Action.java
Log:
Add convenience accessors for application module specific DataSource and
MessageResources instances, based on the "key" values specified in the
<data-source> and <message-resources> elements in your application module's
struts-config.xml file.
PR: #11089
Revision Changes Path
1.46 +2 -3 jakarta-struts/STATUS
Index: STATUS
===================================================================
RCS file: /home/cvs/jakarta-struts/STATUS,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- STATUS 27 Jul 2002 23:49:58 -0000 1.45
+++ STATUS 28 Jul 2002 00:17:27 -0000 1.46
@@ -6,12 +6,11 @@
OUTSTANDING BUGS IN STRUTS 1.1-b1 AND NIGHTLY BUILDS
====================================================
- 11 open bugs to swat!!
+ 10 open bugs to swat!!
Controller:
----------
-11089 Data source keys are global, even when using application modules
Custom Tags:
1.46 +83 -5 jakarta-struts/src/share/org/apache/struts/action/Action.java
Index: Action.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- Action.java 24 Jul 2002 05:06:05 -0000 1.45
+++ Action.java 28 Jul 2002 00:17:27 -0000 1.46
@@ -68,13 +68,16 @@
import java.security.NoSuchAlgorithmException;
import java.util.Locale;
import java.util.Hashtable;
+import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import javax.sql.DataSource;
import org.apache.struts.Globals;
+import org.apache.struts.config.ApplicationConfig;
import org.apache.struts.taglib.html.Constants;
import org.apache.struts.util.MessageResources;
import org.apache.struts.upload.MultipartRequestHandler;
@@ -495,6 +498,51 @@
/**
+ * Return the default data source for the current application module.
+ *
+ * @param request The servlet request we are processing
+ *
+ * @since Struts 1.1b2
+ */
+ protected DataSource getDataSource(HttpServletRequest request) {
+
+ return (getDataSource(request, DATA_SOURCE_KEY));
+
+ }
+
+
+
+ /**
+ * Return the specified data source for the current application
+ * module.
+ *
+ * @param request The servlet request we are processing
+ * @param key The key specified in the
+ * <code><message-resources></code> element for the
+ * requested bundle
+ *
+ * @since Struts 1.1b2
+ */
+ protected DataSource getDataSource(HttpServletRequest request,
+ String key) {
+
+ // Identify the current application module
+ ServletContext context = getServlet().getServletContext();
+ ApplicationConfig appConfig = (ApplicationConfig)
+ request.getAttribute(Action.APPLICATION_KEY);
+ if (appConfig == null) {
+ appConfig = (ApplicationConfig)
+ context.getAttribute(Action.APPLICATION_KEY);
+ }
+
+ // Return the requested data source instance
+ return ((DataSource) context.getAttribute
+ (key + appConfig.getPrefix()));
+
+ }
+
+
+ /**
* Return the user's currently selected Locale.
*
* @param request The request we are processing
@@ -526,7 +574,7 @@
/**
- * Return the message resources for the current application module.
+ * Return the default message resources for the current application module.
*
* @param request The servlet request we are processing
* @since Struts 1.1
@@ -537,6 +585,36 @@
}
+
+
+ /**
+ * Return the specified message resources for the current application
+ * module.
+ *
+ * @param request The servlet request we are processing
+ * @param key The key specified in the
+ * <code><message-resources></code> element for the
+ * requested bundle
+ *
+ * @since Struts 1.1b2
+ */
+ protected MessageResources getResources(HttpServletRequest request,
+ String key) {
+
+ // Identify the current application module
+ ServletContext context = getServlet().getServletContext();
+ ApplicationConfig appConfig = (ApplicationConfig)
+ request.getAttribute(Action.APPLICATION_KEY);
+ if (appConfig == null) {
+ appConfig = (ApplicationConfig)
+ context.getAttribute(Action.APPLICATION_KEY);
+ }
+
+ // Return the requested message resources instance
+ return ((MessageResources) context.getAttribute
+ (key + appConfig.getPrefix()));
+
+ }
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>