You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2002/05/06 00:44:22 UTC
cvs commit: jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources DataSourceForm.java DataSourcesForm.java DeleteDataSourcesAction.java ListDataSourcesAction.java SetUpDataSourceAction.java ListEnvEntriesAction.java ResourceUtils.java ResourcesTreeBuilder.java
manveen 02/05/05 15:44:22
Modified: webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources
ListEnvEntriesAction.java ResourceUtils.java
ResourcesTreeBuilder.java
Added: webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources
DataSourceForm.java DataSourcesForm.java
DeleteDataSourcesAction.java
ListDataSourcesAction.java
SetUpDataSourceAction.java
Log:
Link to display global resources.
Implemented displaying resources list.
Placeholders for displaying and editing datasources.
Revision Changes Path
1.2 +5 -5 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/ListEnvEntriesAction.java
Index: ListEnvEntriesAction.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/ListEnvEntriesAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ListEnvEntriesAction.java 4 May 2002 05:17:53 -0000 1.1
+++ ListEnvEntriesAction.java 5 May 2002 22:44:21 -0000 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/ListEnvEntriesAction.java,v 1.1 2002/05/04 05:17:53 manveen Exp $
- * $Revision: 1.1 $
- * $Date: 2002/05/04 05:17:53 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/ListEnvEntriesAction.java,v 1.2 2002/05/05 22:44:21 manveen Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/05/05 22:44:21 $
*
* ====================================================================
*
@@ -86,11 +86,11 @@
* requires the following request parameters to be set:</p>
* <ul>
* <li><strong>forward</strong> - Global forward to which we should
- * go after stashing the users list.</li>
+ * go after stashing the env entries list.</li>
* </ul>
*
* @author Manveen Kaur
- * @version $Revision: 1.1 $ $Date: 2002/05/04 05:17:53 $
+ * @version $Revision: 1.2 $ $Date: 2002/05/05 22:44:21 $
* @since 4.1
*/
1.2 +22 -17 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/ResourceUtils.java
Index: ResourceUtils.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/ResourceUtils.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ResourceUtils.java 4 May 2002 05:17:53 -0000 1.1
+++ ResourceUtils.java 5 May 2002 22:44:21 -0000 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/ResourceUtils.java,v 1.1 2002/05/04 05:17:53 manveen Exp $
- * $Revision: 1.1 $
- * $Date: 2002/05/04 05:17:53 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/ResourceUtils.java,v 1.2 2002/05/05 22:44:21 manveen Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/05/05 22:44:21 $
*
* ====================================================================
*
@@ -66,18 +66,18 @@
import javax.management.MBeanServer;
import javax.management.ObjectName;
-
/**
* <p>Shared utility methods for the resource administration module.</p>
*
* @author Manveen Kaur
- * @version $Revision: 1.1 $ $Date: 2002/05/04 05:17:53 $
+ * @version $Revision: 1.2 $ $Date: 2002/05/05 22:44:21 $
* @since 4.1
*/
public class ResourceUtils {
public final static String ENVIRONMENT_TYPE = "Catalina:type=Environment";
+ public final static String RESOURCE_TYPE = "Catalina:type=Resource";
public final static String NAMINGRESOURCES_TYPE = "Catalina:type=NamingResources";
// --------------------------------------------------------- Public Methods
@@ -91,7 +91,6 @@
*
* @exception Exception if an error occurs
*/
- //public static EnvEntriesForm getEnvEntriesForm(MBeanServer mserver)
public static EnvEntriesForm getEnvEntriesForm(MBeanServer mserver)
throws Exception {
@@ -111,7 +110,7 @@
}
/**
- * Construct and return a DatasourcesForm identifying all currently defined
+ * Construct and return a DataSourcesForm identifying all currently defined
* datasources in the specified resource database.
*
* @param mserver MBeanServer to be consulted
@@ -119,23 +118,29 @@
*
* @exception Exception if an error occurs
*/
- /*
- public static DatasourcesForm getDatasourcesForm(MBeanServer mserver,
- String databaseName)
+ public static DataSourcesForm getDataSourcesForm(MBeanServer mserver)
throws Exception {
-
- ObjectName dname = new ObjectName(databaseName);
+
+ ObjectName rname = new ObjectName( NAMINGRESOURCES_TYPE );
String results[] =
- (String[]) mserver.getAttribute(dname, "datasources");
+ (String[]) mserver.getAttribute(rname, "resources");
+
+ /*
+ ObjectName rname = new ObjectName( RESOURCE_TYPE +
+ ",class=" + "javax.sql.DataSource");
+
+ // display only JDBC Resources for the DataSources screen
+ String[] results = (String[]) (mserver.queryMBeans(rname, null).toArray());
+ */
+
if (results == null) {
results = new String[0];
- }
+ }
Arrays.sort(results);
- DatasourcesForm datasourcesForm = new DatasourcesForm();
- datasourcesForm.setDatasources(results);
- return (datasourcesForm);
+ DataSourcesForm dataSourcesForm = new DataSourcesForm();
+ dataSourcesForm.setDataSources(results);
+ return (dataSourcesForm);
}
- */
}
1.3 +6 -6 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/ResourcesTreeBuilder.java
Index: ResourcesTreeBuilder.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/ResourcesTreeBuilder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ResourcesTreeBuilder.java 4 May 2002 05:17:53 -0000 1.2
+++ ResourcesTreeBuilder.java 5 May 2002 22:44:21 -0000 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/ResourcesTreeBuilder.java,v 1.2 2002/05/04 05:17:53 manveen Exp $
- * $Revision: 1.2 $
- * $Date: 2002/05/04 05:17:53 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/ResourcesTreeBuilder.java,v 1.3 2002/05/05 22:44:21 manveen Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/05/05 22:44:21 $
*
* ====================================================================
*
@@ -76,7 +76,7 @@
* for administering the resources (data sources).
*
* @author Manveen Kaur
- * @version $Revision: 1.2 $ $Date: 2002/05/04 05:17:53 $
+ * @version $Revision: 1.3 $ $Date: 2002/05/05 22:44:21 $
* @since 4.1
*/
@@ -133,8 +133,8 @@
("Global Administer Data Sources",
"Datasource.gif",
resources.getMessage("resources.treeBuilder.datasources"),
- // FIX ME -- add URL once its implemented
- null,
+ "resources/listDataSources.do?forward=" +
+ URLEncoder.encode("DataSources List Setup"),
"content",
false);
TreeControlNode envs = new TreeControlNode
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/DataSourceForm.java
Index: DataSourceForm.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/DataSourceForm.java,v 1.1 2002/05/05 22:44:21 manveen Exp $
* $Revision: 1.1 $
* $Date: 2002/05/05 22:44:21 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.webapp.admin.resources;
import java.util.List;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.webapp.admin.LabelValueBean;
/**
* Form bean for the individual data source page.
*
* @author Manveen Kaur
* @version $Revision: 1.1 $ $Date: 2002/05/05 22:44:21 $
* @since 4.1
*/
public final class DataSourceForm extends BaseForm {
// ----------------------------------------------------- Instance Variables
// ------------------------------------------------------------- Properties
/**
* The url of the data source.
*/
private String url = null;
public String getUrl() {
return (this.url);
}
public void setUrl(String url) {
this.url = url;
}
/**
* The JDBC driver class of the data source.
*/
private String driverClass = null;
public String getDriverClass() {
return (this.driverClass);
}
public void setDriverClass(String driverClass) {
this.driverClass = driverClass;
}
/**
* The username of the databse corresponding to the data source.
*/
private String username = null;
public String getUsername() {
return (this.username);
}
public void setUsername(String username) {
this.username = username;
}
/**
* The password of the database corresponding to the data source.
*/
private String password = null;
public String getPassword() {
return (this.password);
}
public void setPassword(String password) {
this.password = password;
}
/**
* The max number of active sessions to the data source.
*/
private String active = null;
public String getActive() {
return (this.active);
}
public void setActive(String active) {
this.active = active;
}
/**
* The max number of idle connections to the data source.
*/
private String idle = null;
public String getIdle() {
return (this.idle);
}
public void setIdle(String idle) {
this.idle = idle;
}
/**
* The maximum wait for a connection to the data source.
*/
private String wait = null;
public String getWait() {
return (this.wait);
}
public void setWait(String wait) {
this.wait = wait;
}
/**
* The validation query to the data source.
*/
private String query = null;
public String getQuery() {
return (this.query);
}
public void setQuery(String query) {
this.query = query;
}
// --------------------------------------------------------- Public Methods
/**
* Reset all properties to their default values.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
super.reset(mapping, request);
url = null;
driverClass = null;
username = null;
password = null;
active = null;
idle = null;
wait = null;
query = null;
}
/**
* Validate the properties that have been set from this HTTP request,
* and return an <code>ActionErrors</code> object that encapsulates any
* validation errors that have been found. If no errors are found, return
* <code>null</code> or an <code>ActionErrors</code> object with no
* recorded error messages.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
private ActionErrors errors = null;
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
errors = new ActionErrors();
String submit = request.getParameter("submit");
if (submit != null) {
// name is a required field
if ((url == null) || (url.length() < 1)) {
errors.add("url",
new ActionError("resources.error.url.required"));
}
// driverClass is a required field
if ((driverClass == null) || (driverClass.length() < 1)) {
errors.add("driverClass",
new ActionError("resources.error.driverClass.required"));
}
// username is a required field
if ((username == null) || (username.length() < 1)) {
errors.add("username",
new ActionError("users.error.username.required"));
}
// password is a required field
if ((password == null) || (password.length() < 1)) {
errors.add("password",
new ActionError("error.userPassword.required"));
}
// FIX ME -- need to do a range check
numberCheck("active", active , false, 0, 10000);
numberCheck("idle", idle , false, 0, 10000);
numberCheck("wait", wait , false, 0, 10000);
// Quotes not allowed in username
if ((username != null) && (username.indexOf('"') >= 0)) {
errors.add("username",
new ActionError("users.error.quotes"));
}
// Quotes not allowed in password
if ((password != null) && (password.indexOf('"') > 0)) {
errors.add("password",
new ActionError("users.error.quotes"));
}
}
return (errors);
}
/*
* Helper method to check that it is a required number and
* is a valid integer within the given range. (min, max).
*
* @param field The field name in the form for which this error occured.
* @param numText The string representation of the number.
* @param rangeCheck Boolean value set to true of reange check should be performed.
*
* @param min The lower limit of the range
* @param max The upper limit of the range
*
*/
private void numberCheck(String field, String numText, boolean rangeCheck,
int min, int max) {
// Check for 'is required'
if ((numText == null) || (numText.length() < 1)) {
errors.add(field, new ActionError("resources.error."+field+".required"));
} else {
// check for 'must be a number' in the 'valid range'
try {
int num = Integer.parseInt(numText);
// perform range check only if required
if (rangeCheck) {
if ((num < min) || (num > max ))
errors.add( field,
new ActionError("resources.error."+ field +".range"));
}
} catch (NumberFormatException e) {
errors.add(field,
new ActionError("resources.integer.error"));
}
}
}
}
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/DataSourcesForm.java
Index: DataSourcesForm.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/DataSourcesForm.java,v 1.1 2002/05/05 22:44:21 manveen Exp $
* $Revision: 1.1 $
* $Date: 2002/05/05 22:44:21 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.webapp.admin.resources;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
/**
* Form bean for the delete data sources page.
*
* @author Manveen Kaur
* @version $Revision: 1.1 $ $Date: 2002/05/05 22:44:21 $
* @since 4.1
*/
public final class DataSourcesForm extends BaseForm {
// ----------------------------------------------------- Instance Variables
// ------------------------------------------------------------- Properties
/**
* The object names of the specified environment entries.
*/
private String dataSources[] = null;
public String[] getDataSources() {
return (this.dataSources);
}
public void setDataSources(String dataSources[]) {
this.dataSources = dataSources;
}
// --------------------------------------------------------- Public Methods
/**
* Reset all properties to their default values.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
super.reset(mapping, request);
this.dataSources = null;
}
}
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/DeleteDataSourcesAction.java
Index: DeleteDataSourcesAction.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/DeleteDataSourcesAction.java,v 1.1 2002/05/05 22:44:21 manveen Exp $
* $Revision: 1.1 $
* $Date: 2002/05/05 22:44:21 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-envEntry documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.webapp.admin.resources;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import javax.management.Attribute;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.QueryExp;
import javax.management.Query;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.JMException;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanOperationInfo;
import javax.management.MBeanInfo;
import org.apache.struts.util.MessageResources;
import org.apache.webapp.admin.ApplicationServlet;
/**
* <p>Implementation of <strong>Action</strong> that deletes the
* specified set of dataSource entries.</p>
*
* @author Manveen Kaur
* @version $Revision: 1.1 $ $Date: 2002/05/05 22:44:21 $
* @since 4.1
*/
public final class DeleteDataSourcesAction extends Action {
// ----------------------------------------------------- Instance Variables
/**
* The MBeanServer we will be interacting with.
*/
private MBeanServer mserver = null;
/**
* The MessageResources we will be retrieving messages from.
*/
private MessageResources resources = null;
// --------------------------------------------------------- Public Methods
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
* Return an <code>ActionForward</code> instance describing where and how
* control should be forwarded, or <code>null</code> if the response has
* already been completed.
*
* @param mapping The ActionMapping used to select this instance
* @param actionForm The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Look up the components we will be using as needed
if (mserver == null) {
mserver = ((ApplicationServlet) getServlet()).getServer();
}
if (resources == null) {
resources = getServlet().getResources();
}
HttpSession session = request.getSession();
Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
// Has this transaction been cancelled?
if (isCancelled(request)) {
return (mapping.findForward("List DataSources Setup"));
}
// Check the transaction token
if (!isTokenValid(request)) {
response.sendError
(HttpServletResponse.SC_BAD_REQUEST,
resources.getMessage(locale, "users.error.token"));
return (null);
}
// Perform any extra validation that is required
DataSourcesForm dataSourcesForm = (DataSourcesForm) form;
String dataSources[] = dataSourcesForm.getDataSources();
if (dataSources == null) {
dataSources = new String[0];
}
// Perform "Delete EnvEntry" transactions as required
try {
// Construct the MBean Name for the naming source
ObjectName dname = new ObjectName(ResourceUtils.NAMINGRESOURCES_TYPE);
String signature[] = new String[1];
signature[0] = "java.lang.String";
Object params[] = new String[1];
for (int i = 0; i < dataSources.length; i++) {
ObjectName oname = new ObjectName(dataSources[i]);
params[0] = oname.getKeyProperty("name");
mserver.invoke(dname, "removeResource",
params, signature);
}
} catch (Throwable t) {
getServlet().log
(resources.getMessage(locale, "users.error.invoke",
"removeResource"), t);
response.sendError
(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
resources.getMessage(locale, "users.error.invoke",
"removeResource"));
return (null);
}
// Proceed to the list envEntrys screen
return (mapping.findForward("DataSources List Setup"));
}
}
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/ListDataSourcesAction.java
Index: ListDataSourcesAction.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/ListDataSourcesAction.java,v 1.1 2002/05/05 22:44:21 manveen Exp $
* $Revision: 1.1 $
* $Date: 2002/05/05 22:44:21 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.webapp.admin.resources;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.Locale;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;
import org.apache.webapp.admin.ApplicationServlet;
/**
* <p>Retrieve the set of MBean names for all currently defined data sources,
* and expose them in a request attribute named "dataSourcesForm". This action
* requires the following request parameters to be set:</p>
* <ul>
* <li><strong>forward</strong> - Global forward to which we should
* go after stashing the dataSources list.</li>
* </ul>
*
* @author Manveen Kaur
* @version $Revision: 1.1 $ $Date: 2002/05/05 22:44:21 $
* @since 4.1
*/
public class ListDataSourcesAction extends Action {
// ----------------------------------------------------- Instance Variables
/**
* The MBeanServer we will be interacting with.
*/
private MBeanServer mserver = null;
/**
* The MessageResources we will be retrieving messages from.
*/
private MessageResources resources = null;
// --------------------------------------------------------- Public Methods
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
* Return an <code>ActionForward</code> instance describing where and how
* control should be forwarded, or <code>null</code> if the response has
* already been completed.
*
* @param mapping The ActionMapping used to select this instance
* @param actionForm The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Look up the components we will be using as needed
if (mserver == null) {
mserver = ((ApplicationServlet) getServlet()).getServer();
}
if (resources == null) {
resources = getServlet().getResources();
}
HttpSession session = request.getSession();
Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
// Create a form bean containing the requested MBean Names
DataSourcesForm dataSourcesForm = null;
try {
dataSourcesForm = ResourceUtils.getDataSourcesForm(mserver);
} catch (Exception e) {
getServlet().log(resources.getMessage
(locale,
"users.error.attribute.get", "resources"), e);
response.sendError
(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
resources.getMessage
(locale, "users.error.attribute.get", "resources"));
}
// Stash the results in request scope
request.setAttribute("dataSourcesForm", dataSourcesForm);
saveToken(request);
String forward =
URLDecoder.decode(request.getParameter("forward"));
return (mapping.findForward(forward));
}
}
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/SetUpDataSourceAction.java
Index: SetUpDataSourceAction.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/resources/SetUpDataSourceAction.java,v 1.1 2002/05/05 22:44:21 manveen Exp $
* $Revision: 1.1 $
* $Date: 2002/05/05 22:44:21 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-DataSource documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.webapp.admin.resources;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.Iterator;
import java.util.Locale;
import javax.management.Attribute;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.QueryExp;
import javax.management.Query;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.JMException;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanOperationInfo;
import javax.management.MBeanInfo;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;
import org.apache.webapp.admin.ApplicationServlet;
/**
* <p>Implementation of <strong>Action</strong> that sets up and stashes
* a <code>DataSourceForm</code> bean in request scope. The form bean will have
* a null <code>objectName</code> property if this form represents a DataSource
* being added, or a non-null value for an existing DataSource.</p>
*
* @author Manveen Kaur
* @version $Revision: 1.1 $ $Date: 2002/05/05 22:44:21 $
* @since 4.1
*/
public final class SetUpDataSourceAction extends Action {
// ----------------------------------------------------- Instance Variables
/**
* The MBeanServer we will be interacting with.
*/
private MBeanServer mserver = null;
/**
* The MessageResources we will be retrieving messages from.
*/
private MessageResources resources = null;
// --------------------------------------------------------- Public Methods
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
* Return an <code>ActionForward</code> instance describing where and how
* control should be forwarded, or <code>null</code> if the response has
* already been completed.
*
* @param mapping The ActionMapping used to select this instance
* @param actionForm The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Look up the components we will be using as needed
if (mserver == null) {
mserver = ((ApplicationServlet) getServlet()).getServer();
}
if (resources == null) {
resources = getServlet().getResources();
}
HttpSession session = request.getSession();
Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
// Set up the form bean based on the creating or editing state
String objectName = request.getParameter("objectName");
DataSourceForm dataSourceForm = new DataSourceForm();
if (objectName == null) {
dataSourceForm.setNodeLabel
(resources.getMessage(locale, "resources.actions.datasrc.create"));
dataSourceForm.setObjectName(null);
} else {
dataSourceForm.setNodeLabel
(resources.getMessage(locale, "resources.actions.datasrc.edit"));
dataSourceForm.setObjectName(objectName);
String attribute = null;
try {
ObjectName oname = new ObjectName(objectName);
attribute = "url";
dataSourceForm.setUrl
((String) mserver.getAttribute(oname, attribute));
attribute = "driverClassName";
dataSourceForm.setDriverClass
((String) mserver.getAttribute(oname, attribute));
attribute = "username";
dataSourceForm.setUsername
((String) mserver.getAttribute(oname, attribute));
attribute = "password";
dataSourceForm.setPassword
((String) mserver.getAttribute(oname, attribute));
attribute = "maxActive";
dataSourceForm.setActive
(((Integer) mserver.getAttribute(oname, attribute)).toString());
attribute = "maxWait";
dataSourceForm.setWait
(((Integer) mserver.getAttribute(oname, attribute)).toString());
attribute = "maxIdle";
dataSourceForm.setIdle
(((Integer) mserver.getAttribute(oname, attribute)).toString());
attribute = "validationQuery";
dataSourceForm.setQuery
((String) mserver.getAttribute(oname, attribute));
} catch (Exception e) {
getServlet().log
(resources.getMessage(locale,
"users.error.attribute.get", attribute), e);
response.sendError
(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
resources.getMessage
(locale, "users.error.attribute.get", attribute));
return (null);
}
}
// Stash the form bean and forward to the display page
saveToken(request);
request.setAttribute("dataSourceForm", dataSourceForm);
return (mapping.findForward("DataSource"));
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>