geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r332881 [1/2] - in /geronimo/trunk: applications/console-core/src/java/org/apache/geronimo/console/util/ applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/ applications/console-standard/src/java/org/a...
Date Sun, 13 Nov 2005 03:56:28 GMT
Author: ammulder
Date: Sat Nov 12 19:56:12 2005
New Revision: 332881

URL: http://svn.apache.org/viewcvs?rev=332881&view=rev
Log:
GERONIMO-1160 : Finish the first pass at the database pools portlet
 - Better access to dynamic GBean properties (used by connectors)
 - Connector MCF can navigate you to ConnectionManager
 - ResourceAdapterModule captures some basic info from the J2EE DD
 - Added Derby to known databases
 - Now handles XA and non-TranQL JDBC resource adapters
 - Now editing an existing pool works

Added:
    geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/ResourceAdapterModule.java   (with props)
Modified:
    geronimo/trunk/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java
    geronimo/trunk/applications/console-core/src/java/org/apache/geronimo/console/util/ManagementHelper.java
    geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabaseInfo.java
    geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java
    geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/util/PortletManager.java
    geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/basicParams.jsp
    geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/confirmURL.jsp
    geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/edit.jsp
    geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/list.jsp
    geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/selectDatabase.jsp
    geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/selectDownload.jsp
    geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/testConnection.jsp
    geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
    geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ResourceAdapterModuleImpl.java
    geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ResourceAdapterModuleImplGBean.java
    geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandLogin.java
    geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/DynamicGBeanDelegate.java
    geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java

Modified: geronimo/trunk/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java?rev=332881&r1=332880&r2=332881&view=diff
==============================================================================
--- geronimo/trunk/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java (original)
+++ geronimo/trunk/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java Sat Nov 12 19:56:12 2005
@@ -27,7 +27,6 @@
 import org.apache.geronimo.management.AppClientModule;
 import org.apache.geronimo.management.WebModule;
 import org.apache.geronimo.management.EJBModule;
-import org.apache.geronimo.management.ResourceAdapterModule;
 import org.apache.geronimo.management.J2EEResource;
 import org.apache.geronimo.management.JCAResource;
 import org.apache.geronimo.management.JDBCResource;
@@ -42,6 +41,7 @@
 import org.apache.geronimo.management.geronimo.J2EEServer;
 import org.apache.geronimo.management.geronimo.J2EEApplication;
 import org.apache.geronimo.management.geronimo.JVM;
+import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
 import org.apache.geronimo.management.geronimo.WebContainer;
 import org.apache.geronimo.management.geronimo.WebConnector;
 import org.apache.geronimo.management.geronimo.WebManager;
@@ -285,6 +285,62 @@
             log.error("Unable to look up related GBean", e);
         }
         return (ResourceAdapterModule[]) list.toArray(new ResourceAdapterModule[list.size()]);
+    }
+
+    public JCAManagedConnectionFactory[] getOutboundFactories(ResourceAdapterModule module) {
+        List list = new ArrayList();
+        try {
+            ResourceAdapter[] adapters = getResourceAdapters(module);
+            for (int j = 0; j < adapters.length; j++) {
+                ResourceAdapter adapter = adapters[j];
+                JCAResource[] resources = getRAResources(adapter);
+                for (int k = 0; k < resources.length; k++) {
+                    JCAResource resource = resources[k];
+                    JCAConnectionFactory[] factories = getConnectionFactories(resource);
+                    for (int l = 0; l < factories.length; l++) {
+                        JCAConnectionFactory factory = factories[l];
+                        JCAManagedConnectionFactory mcf = getManagedConnectionFactory(factory);
+                        list.add(mcf);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error("Unable to look up related GBean", e);
+        }
+        return (JCAManagedConnectionFactory[]) list.toArray(new JCAManagedConnectionFactory[list.size()]);
+    }
+
+    public JCAManagedConnectionFactory[] getOutboundFactories(ResourceAdapterModule module, String connectionFactoryInterface) {
+        List list = new ArrayList();
+        try {
+            ResourceAdapter[] adapters = getResourceAdapters(module);
+            for (int j = 0; j < adapters.length; j++) {
+                ResourceAdapter adapter = adapters[j];
+                JCAResource[] resources = getRAResources(adapter);
+                for (int k = 0; k < resources.length; k++) {
+                    JCAResource resource = resources[k];
+                    JCAConnectionFactory[] factories = getConnectionFactories(resource);
+                    for (int l = 0; l < factories.length; l++) {
+                        JCAConnectionFactory factory = factories[l];
+                        JCAManagedConnectionFactory mcf = getManagedConnectionFactory(factory);
+                        if(mcf.getConnectionFactoryInterface().equals(connectionFactoryInterface)) {
+                            list.add(mcf);
+                            continue;
+                        }
+                        for (int m = 0; m < mcf.getImplementedInterfaces().length; m++) {
+                            String iface = mcf.getImplementedInterfaces()[m];
+                            if(iface.equals(connectionFactoryInterface)) {
+                                list.add(mcf);
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error("Unable to look up related GBean", e);
+        }
+        return (JCAManagedConnectionFactory[]) list.toArray(new JCAManagedConnectionFactory[list.size()]);
     }
 
     public J2EEResource[] getResources(J2EEServer server) {

Modified: geronimo/trunk/applications/console-core/src/java/org/apache/geronimo/console/util/ManagementHelper.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-core/src/java/org/apache/geronimo/console/util/ManagementHelper.java?rev=332881&r1=332880&r2=332881&view=diff
==============================================================================
--- geronimo/trunk/applications/console-core/src/java/org/apache/geronimo/console/util/ManagementHelper.java (original)
+++ geronimo/trunk/applications/console-core/src/java/org/apache/geronimo/console/util/ManagementHelper.java Sat Nov 12 19:56:12 2005
@@ -16,27 +16,39 @@
  */
 package org.apache.geronimo.console.util;
 
-import org.apache.geronimo.management.J2EEDomain;
-import org.apache.geronimo.management.J2EEDeployedObject;
-import org.apache.geronimo.management.J2EEResource;
+import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.management.AppClientModule;
-import org.apache.geronimo.management.WebModule;
+import org.apache.geronimo.management.EJB;
 import org.apache.geronimo.management.EJBModule;
-import org.apache.geronimo.management.ResourceAdapterModule;
+import org.apache.geronimo.management.J2EEDeployedObject;
+import org.apache.geronimo.management.J2EEDomain;
 import org.apache.geronimo.management.J2EEModule;
+import org.apache.geronimo.management.J2EEResource;
+import org.apache.geronimo.management.JCAConnectionFactory;
 import org.apache.geronimo.management.JCAResource;
-import org.apache.geronimo.management.JDBCResource;
-import org.apache.geronimo.management.JMSResource;
 import org.apache.geronimo.management.JDBCDataSource;
 import org.apache.geronimo.management.JDBCDriver;
-import org.apache.geronimo.management.JCAConnectionFactory;
-import org.apache.geronimo.management.EJB;
-import org.apache.geronimo.management.Servlet;
+import org.apache.geronimo.management.JDBCResource;
+import org.apache.geronimo.management.JMSResource;
 import org.apache.geronimo.management.ResourceAdapter;
-import org.apache.geronimo.management.geronimo.*;
-import org.apache.geronimo.system.logging.SystemLog;
+import org.apache.geronimo.management.Servlet;
+import org.apache.geronimo.management.WebModule;
+import org.apache.geronimo.management.geronimo.EJBConnector;
+import org.apache.geronimo.management.geronimo.EJBManager;
+import org.apache.geronimo.management.geronimo.J2EEApplication;
+import org.apache.geronimo.management.geronimo.J2EEServer;
+import org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory;
+import org.apache.geronimo.management.geronimo.JMSBroker;
+import org.apache.geronimo.management.geronimo.JMSConnector;
+import org.apache.geronimo.management.geronimo.JMSManager;
+import org.apache.geronimo.management.geronimo.JVM;
+import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
+import org.apache.geronimo.management.geronimo.WebAccessLog;
+import org.apache.geronimo.management.geronimo.WebConnector;
+import org.apache.geronimo.management.geronimo.WebContainer;
+import org.apache.geronimo.management.geronimo.WebManager;
 import org.apache.geronimo.pool.GeronimoExecutor;
-import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.system.logging.SystemLog;
 
 /**
  * A helper interface to navigate between management objects.  This is not
@@ -112,6 +124,8 @@
     EJB[] getEJBs(EJBModule module);
     Servlet[] getServlets(WebModule module);
     ResourceAdapter[] getResourceAdapters(ResourceAdapterModule module);
+    JCAManagedConnectionFactory[] getOutboundFactories(ResourceAdapterModule module);
+    JCAManagedConnectionFactory[] getOutboundFactories(ResourceAdapterModule module, String connectionFactoryInterface);
 
     // resource adapter properties
     JCAResource[] getRAResources(ResourceAdapter adapter);

Modified: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabaseInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabaseInfo.java?rev=332881&r1=332880&r2=332881&view=diff
==============================================================================
--- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabaseInfo.java (original)
+++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabaseInfo.java Sat Nov 12 19:56:12 2005
@@ -27,36 +27,50 @@
  * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
  */
 public class DatabaseInfo {
+    /**
+     * todo: EVIL!!!  Should be replaced with something, somehow!
+     */
+    private final static String TRANQL_RAR_NAME = "tranql/rars/tranql-connector-1.0.rar";
+    private final static String DERBY_EMBEDDED_RAR_NAME = "tranql/rars/tranql-connector-derby-embed-xa-1.0.rar";
+    private final static String DERBY_NETWORK_RAR_NAME = "tranql/rars/tranql-connector-derby-client-xa-1.0.rar";
+
+    //todo: Load this from a config file or something
     public static final DatabaseInfo[] ALL_DATABASES = new DatabaseInfo[]{
-        new DatabaseInfo("DaffodilDB Embedded","jdbc:daffodilDB_embedded:<database>","in.co.daffodil.db.jdbc.DaffodilDBDriver"),
-        new DatabaseInfo("DaffodilDB Server","jdbc:daffodilDB://<host>:<port>/<database>","in.co.daffodil.db.rmi.RmiDaffodilDBDriver", 3456),
-        new DatabaseInfo("DB2","jdbc:db2://<host>:<port>/<database>","com.ibm.db2.jcc.DB2Driver", 50000),
-        new DatabaseInfo("DB2 (DataDirect)","jdbc:datadirect:db2://<host>:<port>;DatabaseName=<database>","com.ddtek.jdbc.db2.DB2Driver", 50000),
-        new DatabaseInfo("FrontBase","jdbc:FrontBase://<host>:<port>/<database>","com.frontbase.jdbc.FBJDriver"),
-        new DatabaseInfo("HSQLDB embedded","jdbc:hsqldb:<database>","org.hsqldb.jdbcDriver"),
-        new DatabaseInfo("HSQLDB server","jdbc:hsqldb:hsql://<host>:<port>/<database>","org.hsqldb.jdbcDriver"),
-        new DatabaseInfo("Informix","jdbc:informix-sqli://<host>:<port>/<database>:informixserver=<dbservername>","com.informix.jdbc.IfxDriver"),
-        new DatabaseInfo("Informix (DataDirect)","jdbc:datadirect:informix://<host>:<port>;informixServer=<dbservername>;DatabaseName=<database>","com.ddtek.jdbc.informix.InformixDriver"),
-        new DatabaseInfo("InterSystems Cache","jdbc:Cache://<host>:<port>/<namespace>","com.intersys.jdbc.CacheDriver"),
+        new DatabaseInfo("DaffodilDB Embedded","jdbc:daffodilDB_embedded:<Database>","in.co.daffodil.db.jdbc.DaffodilDBDriver"),
+        new DatabaseInfo("DaffodilDB Server","jdbc:daffodilDB://<Host>:<Port>/<Database>","in.co.daffodil.db.rmi.RmiDaffodilDBDriver", 3456),
+        new DatabaseInfo("DB2","jdbc:db2://<Host>:<Port>/<Database>","com.ibm.db2.jcc.DB2Driver", 50000),
+        new DatabaseInfo("DB2 (DataDirect)","jdbc:datadirect:db2://<Host>:<Port>;DatabaseName=<Database>","com.ddtek.jdbc.db2.DB2Driver", 50000),
+        new DatabaseInfo("Derby embedded","jdbc:derby:<Database>","org.apache.derby.jdbc.EmbeddedDriver"),
+        new DatabaseInfo("Derby network","jdbc:derby://<Host>:<Port>/<Database>","org.apache.derby.jdbc.ClientDriver", 1527),
+        new DatabaseInfo("Derby embedded XA", DERBY_EMBEDDED_RAR_NAME),
+        new DatabaseInfo("Derby network XA", DERBY_NETWORK_RAR_NAME),
+        new DatabaseInfo("FrontBase","jdbc:FrontBase://<Host>:<Port>/<Database>","com.frontbase.jdbc.FBJDriver"),
+        new DatabaseInfo("HSQLDB embedded","jdbc:hsqldb:<Database>","org.hsqldb.jdbcDriver"),
+        new DatabaseInfo("HSQLDB server","jdbc:hsqldb:hsql://<Host>:<Port>/<Database>","org.hsqldb.jdbcDriver"),
+        new DatabaseInfo("Informix","jdbc:informix-sqli://<Host>:<Port>/<Database>:informixserver=<dbservername>","com.informix.jdbc.IfxDriver"),
+        new DatabaseInfo("Informix (DataDirect)","jdbc:datadirect:informix://<Host>:<Port>;informixServer=<dbservername>;DatabaseName=<Database>","com.ddtek.jdbc.informix.InformixDriver"),
+        new DatabaseInfo("InterSystems Cache","jdbc:Cache://<Host>:<Port>/<namespace>","com.intersys.jdbc.CacheDriver"),
         new DatabaseInfo("JDataStore","jdbc:borland:dslocal:<file>","com.borland.datastore.jdbc.DataStoreDriver"),
         new DatabaseInfo("JDBC/ODBC Bridge","jdbc:odbc:<datasource>","sun.jdbc.odbc.JdbcOdbcDriver"),
-        new DatabaseInfo("McKoi","jdbc:mckoi://<host>/","com.mckoi.JDBCDriver"),
-        new DatabaseInfo("Mimer","jdbc:mimer://<host>:<port>/<database>","com.mimer.jdbc.Driver"),
-        new DatabaseInfo("MySQL","jdbc:mysql://<host>:<port>/<database>","com.mysql.jdbc.Driver", 3306),
-        new DatabaseInfo("Oracle Thin","jdbc:oracle:thin:@<host>:<port>:<sid>","oracle.jdbc.OracleDriver", 1521),
-        new DatabaseInfo("Oracle OCI","jdbc:oracle:oci:@<host>:<port>:<sid>","oracle.jdbc.OracleDriver", 1521),
-        new DatabaseInfo("Oracle (DataDirect)","jdbc:datadirect:oracle://<host>:<port>;ServiceName=<sid>","com.ddtek.jdbc.oracle.OracleDriver", 1521),
-        new DatabaseInfo("Pervasive","jdbc:pervasive://<host>:<port>/<database>","com.pervasive.jdbc.v2.Driver"),
-        new DatabaseInfo("Pointbase server","jdbc:pointbase:server://<host>:<port>/<database>","com.pointbase.jdbc.jdbcUniversalDriver"),
-        new DatabaseInfo("PostgreSQL","jdbc:postgresql://<host>:<port>/<database>","org.postgresql.Driver", 5432),
-        new DatabaseInfo("Progress","jdbc:jdbcProgress:T:<host>:<port>:<database>","com.progress.sql.jdbc.JdbcProgressDriver"),
-        new DatabaseInfo("MaxDB","jdbc:sapdb://<host>:<port>/<database>","com.sap.dbtech.jdbc.DriverSapDB"),
-        new DatabaseInfo("SQL Server","jdbc:microsoft:sqlserver://<host>:<port>;DatabaseName=<database>","com.microsoft.jdbc.sqlserver.SQLServerDriver", 1433),
-        new DatabaseInfo("SQL Server (jTDS)","jdbc:jtds:sqlserver://<host>:<port>;DatabaseName=<database>","net.sourceforge.jtds.jdbc.Driver", 1433),
-        new DatabaseInfo("SQL Server (DataDirect)","jdbc:datadirect:sqlserver://<host>:<port>;DatabaseName=<database>","com.ddtek.jdbc.sqlserver.SQLServerDriver", 1433),
-        new DatabaseInfo("Sybase ASE","jdbc:sybase:Tds:<host>:<port>/<database>","com.sybase.jdbc3.jdbc.SybDriver", 2048),
-        new DatabaseInfo("Sybase ASA","jdbc:sybase:Tds:<host>:<port>/<database>","com.sybase.jdbc3.jdbc.SybDriver", 2638),
-        new DatabaseInfo("Sybase (DataDirect)","jdbc:datadirect:sybase://<host>:<port>;DatabaseName=<database>","com.ddtek.jdbc.sybase.SybaseDriver"),
+        new DatabaseInfo("McKoi embedded","jdbc:mckoi:local://<ConfigPath>/<Schema>/","com.mckoi.JDBCDriver"),
+        new DatabaseInfo("McKoi server","jdbc:mckoi://<Host>:<Port>/<Schema>/","com.mckoi.JDBCDriver"),
+        new DatabaseInfo("Mimer","jdbc:mimer://<Host>:<Port>/<Database>","com.mimer.jdbc.Driver"),
+        new DatabaseInfo("MySQL","jdbc:mysql://<Host>:<Port>/<Database>","com.mysql.jdbc.Driver", 3306),
+        new DatabaseInfo("Oracle Thin","jdbc:oracle:thin:@<Host>:<Port>:<SID>","oracle.jdbc.OracleDriver", 1521),
+        new DatabaseInfo("Oracle OCI","jdbc:oracle:oci:@<Host>:<Port>:<SID>","oracle.jdbc.OracleDriver", 1521),
+        new DatabaseInfo("Oracle (DataDirect)","jdbc:datadirect:oracle://<Host>:<Port>;ServiceName=<SID>","com.ddtek.jdbc.oracle.OracleDriver", 1521),
+        new DatabaseInfo("Pervasive","jdbc:pervasive://<Host>:<Port>/<Database>","com.pervasive.jdbc.v2.Driver"),
+        new DatabaseInfo("Pointbase server","jdbc:pointbase:server://<Host>:<Port>/<Database>","com.pointbase.jdbc.jdbcUniversalDriver"),
+        new DatabaseInfo("PostgreSQL","jdbc:postgresql://<Host>:<Port>/<Database>","org.postgresql.Driver", 5432),
+        new DatabaseInfo("Progress","jdbc:jdbcProgress:T:<Host>:<Port>:<Database>","com.progress.sql.jdbc.JdbcProgressDriver"),
+        new DatabaseInfo("MaxDB","jdbc:sapdb://<Host>:<Port>/<Database>","com.sap.dbtech.jdbc.DriverSapDB"),
+        new DatabaseInfo("SQL Server","jdbc:microsoft:sqlserver://<Host>:<Port>;DatabaseName=<Database>","com.microsoft.jdbc.sqlserver.SQLServerDriver", 1433),
+        new DatabaseInfo("SQL Server (jTDS)","jdbc:jtds:sqlserver://<Host>:<Port>;DatabaseName=<Database>","net.sourceforge.jtds.jdbc.Driver", 1433),
+        new DatabaseInfo("SQL Server (DataDirect)","jdbc:datadirect:sqlserver://<Host>:<Port>;DatabaseName=<Database>","com.ddtek.jdbc.sqlserver.SQLServerDriver", 1433),
+        new DatabaseInfo("Sybase ASE","jdbc:sybase:Tds:<Host>:<Port>/<Database>","com.sybase.jdbc3.jdbc.SybDriver", 2048),
+        new DatabaseInfo("Sybase ASA","jdbc:sybase:Tds:<Host>:<Port>/<Database>","com.sybase.jdbc3.jdbc.SybDriver", 2638),
+        new DatabaseInfo("Sybase (DataDirect)","jdbc:datadirect:sybase://<Host>:<Port>;DatabaseName=<Database>","com.ddtek.jdbc.sybase.SybaseDriver"),
+        new DatabaseInfo("Other","",""),
     };
     private final static Pattern PARAM_PATTERN = Pattern.compile("<.+?>");
 
@@ -64,11 +78,15 @@
     private String url;
     private String driverClass;
     private int defaultPort;
+    private boolean xa;
+    private String rarPath;
 
     public DatabaseInfo(String name, String url, String driverClass) {
         this.name = name;
         this.url = url;
         this.driverClass = driverClass;
+        xa = false;
+        rarPath = TRANQL_RAR_NAME;
     }
 
     public DatabaseInfo(String name, String url, String driverClass, int defaultPort) {
@@ -76,6 +94,14 @@
         this.url = url;
         this.driverClass = driverClass;
         this.defaultPort = defaultPort;
+        xa = false;
+        rarPath = TRANQL_RAR_NAME;
+    }
+
+    public DatabaseInfo(String name, String rarPath) {
+        this.name = name;
+        xa = true;
+        this.rarPath = rarPath;
     }
 
     public String getName() {
@@ -92,6 +118,14 @@
 
     public int getDefaultPort() {
         return defaultPort;
+    }
+
+    public boolean isXA() {
+        return xa;
+    }
+
+    public String getRarPath() {
+        return rarPath;
     }
 
     public String[] getUrlParameters() {

Modified: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java?rev=332881&r1=332880&r2=332881&view=diff
==============================================================================
--- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java (original)
+++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java Sat Nov 12 19:56:12 2005
@@ -23,12 +23,12 @@
 import java.io.File;
 import java.io.BufferedOutputStream;
 import java.io.FileOutputStream;
+import java.io.StringReader;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.Properties;
 import java.net.URISyntaxException;
@@ -58,9 +58,13 @@
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.status.ProgressObject;
 import javax.enterprise.deploy.model.DDBeanRoot;
+import javax.enterprise.deploy.model.DDBean;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
 import org.apache.geronimo.console.BasePortlet;
 import org.apache.geronimo.console.util.PortletManager;
 import org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory;
+import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.repository.ListableRepository;
 import org.apache.geronimo.kernel.repository.Repository;
@@ -76,8 +80,14 @@
 import org.apache.geronimo.connector.deployment.jsr88.ConfigPropertySetting;
 import org.apache.geronimo.connector.deployment.jsr88.ConnectionManager;
 import org.apache.geronimo.connector.deployment.jsr88.SinglePool;
+import org.apache.geronimo.connector.outbound.PoolingAttributes;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
 
 /**
  * A portlet that lets you configure and deploy JDBC connection pools.
@@ -85,14 +95,10 @@
  * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
  */
 public class DatabasePoolPortlet extends BasePortlet {
-    /**
-     * todo: EVIL!!!  Should be replaced with something, somehow!
-     */
-    private final static String TRANQL_RAR_NAME = "tranql/rars/tranql-connector-1.0.rar";
-
     private final static Log log = LogFactory.getLog(DatabasePoolPortlet.class);
     private final static String[] SKIP_ENTRIES_WITH = new String[]{"geronimo", "tomcat", "tranql", "commons", "directory", "activemq"};
     private final static String DRIVER_SESSION_KEY = "org.apache.geronimo.console.dbpool.Drivers";
+    private final static String CONFIG_SESSION_KEY = "org.apache.geronimo.console.dbpool.ConfigParam";
     private final static String DRIVER_INFO_URL    = "http://people.apache.org/~ammulder/driver-downloads.properties";
     private static final String LIST_VIEW            = "/WEB-INF/view/dbwizard/list.jsp";
     private static final String EDIT_VIEW            = "/WEB-INF/view/dbwizard/edit.jsp";
@@ -108,6 +114,7 @@
     private static final String CONFIRM_URL_MODE     = "url";
     private static final String TEST_CONNECTION_MODE = "test";
     private static final String DOWNLOAD_MODE        = "download";
+    private static final String EDIT_EXISTING_MODE   = "editExisting";
     private static final String SAVE_MODE            = "save";
     private static final String MODE_KEY = "mode";
 
@@ -157,22 +164,62 @@
         return results;
     }
 
+    /**
+     * Loads data about a resource adapter.  Depending on what we already have, may load
+     * the name and description, but always loads the config property descriptions.
+     * @param request            Pass it or die
+     * @param rarPath            If we're creating a new RA, the path to identify it
+     * @param displayName        If we're editing an existing RA, its name
+     * @param adapterObjectName  If we're editing an existing RA, its ObjectName
+     * @return
+     */
+    public ResourceAdapterParams getRARConfiguration(PortletRequest request, String rarPath, String displayName, String adapterObjectName) {
+        PortletSession session = request.getPortletSession(true);
+        if(rarPath != null && !rarPath.equals("")) {
+            ResourceAdapterParams results = (ResourceAdapterParams) session.getAttribute(CONFIG_SESSION_KEY+"-"+rarPath, PortletSession.APPLICATION_SCOPE);
+            if(results == null) {
+                results = loadConfigPropertiesByPath(request, rarPath);
+                session.setAttribute(CONFIG_SESSION_KEY+"-"+rarPath, results, PortletSession.APPLICATION_SCOPE);
+                session.setAttribute(CONFIG_SESSION_KEY+"-"+results.displayName, results, PortletSession.APPLICATION_SCOPE);
+            }
+            return results;
+        } else if(displayName != null && !displayName.equals("") && adapterObjectName != null && !adapterObjectName.equals("")) {
+            ResourceAdapterParams results = (ResourceAdapterParams) session.getAttribute(CONFIG_SESSION_KEY+"-"+displayName, PortletSession.APPLICATION_SCOPE);
+            if(results == null) {
+                results = loadConfigPropertiesByObjectName(request, adapterObjectName);
+                session.setAttribute(CONFIG_SESSION_KEY+"-"+displayName, results, PortletSession.APPLICATION_SCOPE);
+            }
+            return results;
+        } else {
+            throw new IllegalArgumentException();
+        }
+    }
+
     public void processAction(ActionRequest actionRequest,
             ActionResponse actionResponse) throws PortletException, IOException {
         String mode = actionRequest.getParameter(MODE_KEY);
         PoolData data = new PoolData();
         data.load(actionRequest);
         if(mode.equals("process-"+SELECT_RDBMS_MODE)) {
-            if(data.getDbtype().equals("Other")) {
-                actionResponse.setRenderParameter(MODE_KEY, EDIT_MODE);
-            } else {
-                DatabaseInfo info = null;
-                info = getDatabaseInfo(data);
-                if(info != null) {
-                    data.driverClass = info.getDriverClass();
-                    data.urlPrototype = info.getUrl();
+            DatabaseInfo info = null;
+            info = getDatabaseInfo(data);
+            if(info != null) {
+                data.rarPath = info.getRarPath();
+                if(info.isXA()) {
+                    data.adapterDisplayName="Unknown"; // will pick these up when we process the RA type in the render request
+                    data.adapterDescription="Unknown";
+                    actionResponse.setRenderParameter(MODE_KEY, EDIT_MODE);
+                } else {
+                    if(data.getDbtype().equals("Other")) {
+                        actionResponse.setRenderParameter(MODE_KEY, EDIT_MODE);
+                    } else {
+                        data.driverClass = info.getDriverClass();
+                        data.urlPrototype = info.getUrl();
+                        actionResponse.setRenderParameter(MODE_KEY, BASIC_PARAMS_MODE);
+                    }
                 }
-                actionResponse.setRenderParameter(MODE_KEY, BASIC_PARAMS_MODE);
+            } else {
+                actionResponse.setRenderParameter(MODE_KEY, SELECT_RDBMS_MODE);
             }
         } else if(mode.equals("process-"+DOWNLOAD_MODE)) {
             String name = actionRequest.getParameter("driverName");
@@ -209,12 +256,16 @@
                     log.error("Unable to download JDBC driver", e);
                 }
             }
-            actionResponse.setRenderParameter(MODE_KEY, BASIC_PARAMS_MODE);
+            if(data.getDbtype() == null || data.getDbtype().equals("Other")) {
+                actionResponse.setRenderParameter(MODE_KEY, EDIT_MODE);
+            } else {
+                actionResponse.setRenderParameter(MODE_KEY, BASIC_PARAMS_MODE);
+            }
         } else if(mode.equals("process-"+BASIC_PARAMS_MODE)) {
             DatabaseInfo info = null;
             info = getDatabaseInfo(data);
             if(info != null) {
-                data.url = populateURL(info.getUrl(), info.getUrlParameters(), data.getProperties());
+                data.url = populateURL(info.getUrl(), info.getUrlParameters(), data.getUrlProperties());
             }
             if(attemptDriverLoad(actionRequest, data) != null) {
                 actionResponse.setRenderParameter(MODE_KEY, CONFIRM_URL_MODE);
@@ -245,12 +296,158 @@
             }
         } else if(mode.equals(SAVE_MODE)) {
             save(actionRequest, data);
+        } else if(mode.equals(EDIT_EXISTING_MODE)) {
+            final String name = actionRequest.getParameter("adapterObjectName");
+            loadConnectionFactory(actionRequest, name, data.getObjectName(), data);
+            actionResponse.setRenderParameter("adapterObjectName", name);
+            actionResponse.setRenderParameter(MODE_KEY, EDIT_MODE);
+        } else if(mode.equals(SELECT_RDBMS_MODE)) {
+            if(data.getAdapterDisplayName() == null) { // Set a default for a new pool
+                data.adapterDisplayName = "TranQL Generic JDBC Resource Adapter";
+            }
+            actionResponse.setRenderParameter(MODE_KEY, mode);
         } else {
             actionResponse.setRenderParameter(MODE_KEY, mode);
         }
         data.store(actionResponse);
     }
 
+    private ResourceAdapterParams loadConfigPropertiesByPath(PortletRequest request, String rarPath) {
+        DeploymentManager mgr = PortletManager.getDeploymentManager(request);
+        try {
+            URL url = getRAR(request, rarPath);
+            ConnectorDeployable deployable = new ConnectorDeployable(url);
+            final DDBeanRoot ddBeanRoot = deployable.getDDBeanRoot();
+            String adapterName = null, adapterDesc = null;
+            String[] test = ddBeanRoot.getText("connector/display-name");
+            if(test != null && test.length > 0) {
+                adapterName = test[0];
+            }
+            test = ddBeanRoot.getText("connector/description");
+            if(test != null && test.length > 0) {
+                adapterDesc = test[0];
+            }
+            DDBean[] definitions = ddBeanRoot.getChildBean("connector/resourceadapter/outbound-resourceadapter/connection-definition");
+            List configs = new ArrayList();
+            if(definitions != null) {
+                for (int i = 0; i < definitions.length; i++) {
+                    DDBean definition = definitions[i];
+                    String iface = definition.getText("connectionfactory-interface")[0];
+                    if(iface.equals("javax.sql.DataSource")) {
+                        DDBean[] beans = definition.getChildBean("config-property");
+                        for (int j = 0; j < beans.length; j++) {
+                            DDBean bean = beans[j];
+                            String name = bean.getText("config-property-name")[0].trim();
+                            String type = bean.getText("config-property-type")[0].trim();
+                            test = bean.getText("config-property-value");
+                            String value = test == null || test.length == 0 ? null : test[0].trim();
+                            test = bean.getText("description");
+                            String desc = test == null || test.length == 0 ? null : test[0].trim();
+                            configs.add(new ConfigParam(name, type, desc, value));
+                        }
+                    }
+                }
+            }
+            return new ResourceAdapterParams(adapterName, adapterDesc, (ConfigParam[]) configs.toArray(new ConfigParam[configs.size()]));
+        } catch (Exception e) {
+            log.error("Unable to read configuration properties", e);
+            return null;
+        } finally {
+            if(mgr != null) mgr.release();
+        }
+    }
+
+    private ResourceAdapterParams loadConfigPropertiesByObjectName(PortletRequest request, String objectName) {
+        ResourceAdapterModule module = (ResourceAdapterModule) PortletManager.getManagedBean(request, objectName);
+        String dd = module.getDeploymentDescriptor();
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setValidating(false);
+        factory.setNamespaceAware(true);
+        try {
+            DocumentBuilder builder = factory.newDocumentBuilder();
+            final StringReader reader = new StringReader(dd);
+            Document doc = builder.parse(new InputSource(reader));
+            reader.close();
+            Element elem = doc.getDocumentElement(); // connector
+            String displayName = getFirstText(elem.getElementsByTagName("display-name"));
+            String description = getFirstText(elem.getElementsByTagName("description"));
+            elem = (Element) elem.getElementsByTagName("resourceadapter").item(0);
+            elem = (Element) elem.getElementsByTagName("outbound-resourceadapter").item(0);
+            NodeList defs = elem.getElementsByTagName("connection-definition");
+            List all = new ArrayList();
+            for(int i=0; i<defs.getLength(); i++) {
+                final Element def = (Element)defs.item(i);
+                String iface = getFirstText(def.getElementsByTagName("connectionfactory-interface")).trim();
+                if(iface.equals("javax.sql.DataSource")) {
+                    NodeList configs = def.getElementsByTagName("config-property");
+                    for(int j=0; j<configs.getLength(); j++) {
+                        Element config = (Element) configs.item(j);
+                        String name = getFirstText(config.getElementsByTagName("config-property-name")).trim();
+                        String type = getFirstText(config.getElementsByTagName("config-property-type")).trim();
+                        String test = getFirstText(config.getElementsByTagName("config-property-value"));
+                        String value = test == null ? null : test.trim();
+                        test = getFirstText(config.getElementsByTagName("description"));
+                        String desc = test == null ? null : test.trim();
+                        all.add(new ConfigParam(name, type, desc, value));
+                    }
+                }
+            }
+            return new ResourceAdapterParams(displayName, description, (ConfigParam[]) all.toArray(new ConfigParam[all.size()]));
+        } catch (Exception e) {
+            log.error("Unable to read resource adapter DD", e);
+            return null;
+        }
+    }
+
+    private String getFirstText(NodeList list) {
+        if(list.getLength() == 0) {
+            return null;
+        }
+        Element first = (Element) list.item(0);
+        StringBuffer buf = new StringBuffer();
+        NodeList all = first.getChildNodes();
+        for(int i=0; i<all.getLength(); i++) {
+            Node node = all.item(i);
+            if(node.getNodeType() == Node.TEXT_NODE) {
+                buf.append(node.getNodeValue());
+            }
+        }
+        return buf.toString();
+    }
+
+    private void loadConnectionFactory(ActionRequest actionRequest, String adapterName, String factoryName, PoolData data) {
+        ResourceAdapterModule adapter = (ResourceAdapterModule) PortletManager.getManagedBean(actionRequest, adapterName);
+        JCAManagedConnectionFactory factory = (JCAManagedConnectionFactory) PortletManager.getManagedBean(actionRequest, factoryName);
+        data.adapterDisplayName = adapter.getDisplayName();
+        data.adapterDescription = adapter.getDescription();
+        try {
+            ObjectName oname = ObjectName.getInstance(factoryName);
+            data.name = oname.getKeyProperty("name");
+            if(data.isGeneric()) {
+                data.url = (String) factory.getConfigProperty("connectionURL");
+                data.driverClass = (String) factory.getConfigProperty("driver");
+                data.user = (String) factory.getConfigProperty("userName");
+                data.password = (String) factory.getConfigProperty("password");
+            } else {
+                ResourceAdapterParams params = getRARConfiguration(actionRequest, data.getRarPath(), data.getAdapterDisplayName(), adapterName);
+                for(int i=0; i<params.getConfigParams().length; i++) {
+                    ConfigParam cp = params.getConfigParams()[i];
+                    Object value = factory.getConfigProperty(cp.getName());
+                    data.properties.put("property-"+cp.getName(), value == null ? null : value.toString());
+                }
+            }
+        } catch (Exception e) {
+            log.error("Unable to look up connection property", e);
+        }
+        //todo: push the lookup into ManagementHelper
+        PoolingAttributes pool = (PoolingAttributes) PortletManager.getManagedBean(actionRequest, factory.getConnectionManager());
+        data.minSize = Integer.toString(pool.getPartitionMinSize());
+        data.maxSize = Integer.toString(pool.getPartitionMaxSize());
+        data.blockingTimeout = Integer.toString(pool.getBlockingTimeoutMilliseconds());
+        data.idleTimeout = Integer.toString(pool.getIdleTimeoutMinutes());
+
+    }
+
     protected void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
         if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
             return;
@@ -266,7 +463,7 @@
             if(mode.equals(LIST_MODE)) {
                 renderList(renderRequest, renderResponse);
             } else if(mode.equals(EDIT_MODE)) {
-                renderEdit(renderRequest, renderResponse);
+                renderEdit(renderRequest, renderResponse, data);
             } else if(mode.equals(SELECT_RDBMS_MODE)) {
                 renderSelectRDBMS(renderRequest, renderResponse);
             } else if(mode.equals(DOWNLOAD_MODE)) {
@@ -284,23 +481,49 @@
     }
 
     private void renderList(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
-        JCAManagedConnectionFactory[] databases = PortletManager.getOutboundFactories(renderRequest, "javax.sql.DataSource");
-        ConnectionPool[] pools = new ConnectionPool[databases.length];
-        for (int i = 0; i < databases.length; i++) {
-            JCAManagedConnectionFactory db = databases[i];
-            try {
-                ObjectName name = ObjectName.getInstance(db.getObjectName());
-                pools[i] = new ConnectionPool(name.getCanonicalName(), name.getKeyProperty(NameFactory.J2EE_NAME));
-            } catch (MalformedObjectNameException e) {
-                e.printStackTrace();
+        ResourceAdapterModule[] modules = PortletManager.getOutboundRAModules(renderRequest, "javax.sql.DataSource");
+        List list = new ArrayList();
+        for (int i = 0; i < modules.length; i++) {
+            ResourceAdapterModule module = modules[i];
+            JCAManagedConnectionFactory[] databases = PortletManager.getOutboundFactoriesForRA(renderRequest, module, "javax.sql.DataSource");
+            for (int j = 0; j < databases.length; j++) {
+                JCAManagedConnectionFactory db = databases[j];
+                try {
+                    ObjectName name = ObjectName.getInstance(db.getObjectName());
+                    list.add(new ConnectionPool(module.getObjectName(), db.getObjectName(), name.getKeyProperty(NameFactory.J2EE_NAME)));
+                } catch (MalformedObjectNameException e) {
+                    e.printStackTrace();
+                }
             }
         }
-        renderRequest.setAttribute("pools", pools);
+        Collections.sort(list);
+        renderRequest.setAttribute("pools", list);
         listView.include(renderRequest, renderResponse);
     }
 
-    private void renderEdit(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
-        loadDriverJARList(renderRequest);
+    private void renderEdit(RenderRequest renderRequest, RenderResponse renderResponse, PoolData data) throws IOException, PortletException {
+        if(data.objectName == null || data.objectName.equals("")) {
+            loadDriverJARList(renderRequest);
+        }
+        if(!data.isGeneric()) {
+            ResourceAdapterParams params = getRARConfiguration(renderRequest, data.getRarPath(), data.getAdapterDisplayName(), renderRequest.getParameter("adapterObjectName"));
+            data.adapterDisplayName = params.getDisplayName();
+            data.adapterDescription = params.getDescription();
+            Map map = new HashMap();
+            boolean more = false;
+            for (int i = 0; i < params.getConfigParams().length; i++) {
+                ConfigParam param = params.getConfigParams()[i];
+                if(!data.properties.containsKey("property-"+param.getName())) {
+                    data.properties.put("property-"+param.getName(), param.getDefaultValue());
+                    more = true;
+                }
+                map.put("property-"+param.getName(), param);
+            }
+            if(more) {
+                data.loadPropertyNames();
+            }
+            renderRequest.setAttribute("ConfigParams", map);
+        }
         editView.include(renderRequest, renderResponse);
     }
 
@@ -322,9 +545,9 @@
             String[] params = info.getUrlParameters();
             for (int i = 0; i < params.length; i++) {
                 String param = params[i];
-                final String key = "property-"+param;
-                if(!data.getProperties().containsKey(key)) {
-                    data.getProperties().put(key, param.equals("port") && info.getDefaultPort() > 0 ? new Integer(info.getDefaultPort()) : null);
+                final String key = "urlproperty-"+param;
+                if(!data.getUrlProperties().containsKey(key)) {
+                    data.getUrlProperties().put(key, param.equalsIgnoreCase("port") && info.getDefaultPort() > 0 ? new Integer(info.getDefaultPort()) : null);
                 }
             }
         }
@@ -391,98 +614,131 @@
     }
 
     private static void save(PortletRequest request, PoolData data) {
-        URL url = getTranQLRAR(request);
-        DeploymentManager mgr = PortletManager.getDeploymentManager(request);
-        try {
-            ConnectorDeployable deployable = new ConnectorDeployable(url);
-            DeploymentConfiguration config = mgr.createConfiguration(deployable);
-            final DDBeanRoot ddBeanRoot = deployable.getDDBeanRoot();
-            Connector15DCBRoot root = (Connector15DCBRoot) config.getDConfigBeanRoot(ddBeanRoot);
-            ConnectorDCB connector = (ConnectorDCB) root.getDConfigBean(ddBeanRoot.getChildBean(root.getXpaths()[0])[0]);
-            connector.setConfigID("DatabasePool"+data.getName());
-            connector.setParentID("org/apache/geronimo/Server");
-            if(data.jar1 != null && !data.jar1.equals("")) {
-                Dependency dep = new Dependency();
-                connector.setDependency(new Dependency[]{dep});
-                dep.setURI(data.jar1);
-            }
-            if(data.jar2 != null && !data.jar2.equals("")) {
-                Dependency dep = new Dependency();
-                Dependency[] old = connector.getDependency();
-                Dependency[] longer = new Dependency[old.length+1];
-                System.arraycopy(old, 0, longer, 0, old.length);
-                longer[old.length] = dep;
-                connector.setDependency(longer);
-                dep.setURI(data.jar2);
-            }
-            if(data.jar3 != null && !data.jar3.equals("")) {
-                Dependency dep = new Dependency();
-                Dependency[] old = connector.getDependency();
-                Dependency[] longer = new Dependency[old.length+1];
-                System.arraycopy(old, 0, longer, 0, old.length);
-                longer[old.length] = dep;
-                connector.setDependency(longer);
-                dep.setURI(data.jar3);
-            }
-            ResourceAdapter adapter = connector.getResourceAdapter()[0];
-            ConnectionDefinition definition = new ConnectionDefinition();
-            adapter.setConnectionDefinition(new ConnectionDefinition[]{definition});
-            definition.setConnectionFactoryInterface("javax.sql.DataSource");
-            ConnectionDefinitionInstance instance = new ConnectionDefinitionInstance();
-            definition.setConnectionInstance(new ConnectionDefinitionInstance[]{instance});
-            instance.setName(data.getName());
-            ConfigPropertySetting[] settings = instance.getConfigPropertySetting();
-            for (int i = 0; i < settings.length; i++) {
-                ConfigPropertySetting setting = settings[i];
-                if(setting.getName().equals("UserName")) {
-                    setting.setValue(data.user);
-                } else if(setting.getName().equals("Password")) {
-                    setting.setValue(data.password);
-                } else if(setting.getName().equals("ConnectionURL")) {
-                    setting.setValue(data.url);
-                } else if(setting.getName().equals("Driver")) {
-                    setting.setValue(data.driverClass);
-                }
-            }
-            ConnectionManager manager = instance.getConnectionManager();
-            manager.setTransactionLocal(true);
-            SinglePool pool = new SinglePool();
-            manager.setPoolSingle(pool);
-            pool.setMatchOne(true);
-            if(data.minSize != null && !data.minSize.equals("")) {
-                pool.setMinSize(new Integer(data.minSize));
-            }
-            if(data.maxSize != null && !data.maxSize.equals("")) {
-                pool.setMaxSize(new Integer(data.maxSize));
-            }
-            if(data.blockingTimeout != null && !data.blockingTimeout.equals("")) {
-                pool.setBlockingTimeoutMillis(new Integer(data.blockingTimeout));
-            }
-            if(data.idleTimeout != null && !data.idleTimeout.equals("")) {
-                pool.setIdleTimeoutMinutes(new Integer(data.idleTimeout));
-            }
-            File tempFile = File.createTempFile("console-deployment",".xml");
-            tempFile.deleteOnExit();
-            log.debug("Writing database pool deployment plan to "+tempFile.getAbsolutePath());
-            BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile));
-            config.save(out);
-            out.flush();
-            out.close();
-            Target[] targets = mgr.getTargets();
-            ProgressObject po = mgr.distribute(targets, new File(url.getPath()), tempFile);
-            waitForProgress(po);
-            if(po.getDeploymentStatus().isCompleted()) {
-                TargetModuleID[] ids = po.getResultTargetModuleIDs();
-                po = mgr.start(ids);
+        if(data.objectName == null || data.objectName.equals("")) { // we're creating a new pool
+            data.name = data.name.replaceAll("\\s", "");
+            DeploymentManager mgr = PortletManager.getDeploymentManager(request);
+            try {
+                URL url = getRAR(request, data.getRarPath());
+                ConnectorDeployable deployable = new ConnectorDeployable(url);
+                DeploymentConfiguration config = mgr.createConfiguration(deployable);
+                final DDBeanRoot ddBeanRoot = deployable.getDDBeanRoot();
+                Connector15DCBRoot root = (Connector15DCBRoot) config.getDConfigBeanRoot(ddBeanRoot);
+                ConnectorDCB connector = (ConnectorDCB) root.getDConfigBean(ddBeanRoot.getChildBean(root.getXpaths()[0])[0]);
+                connector.setConfigID("DatabasePool"+data.getName());
+                connector.setParentID("org/apache/geronimo/Server");
+                if(data.jar1 != null && !data.jar1.equals("")) {
+                    Dependency dep = new Dependency();
+                    connector.setDependency(new Dependency[]{dep});
+                    dep.setURI(data.jar1);
+                }
+                if(data.jar2 != null && !data.jar2.equals("")) {
+                    Dependency dep = new Dependency();
+                    Dependency[] old = connector.getDependency();
+                    Dependency[] longer = new Dependency[old.length+1];
+                    System.arraycopy(old, 0, longer, 0, old.length);
+                    longer[old.length] = dep;
+                    connector.setDependency(longer);
+                    dep.setURI(data.jar2);
+                }
+                if(data.jar3 != null && !data.jar3.equals("")) {
+                    Dependency dep = new Dependency();
+                    Dependency[] old = connector.getDependency();
+                    Dependency[] longer = new Dependency[old.length+1];
+                    System.arraycopy(old, 0, longer, 0, old.length);
+                    longer[old.length] = dep;
+                    connector.setDependency(longer);
+                    dep.setURI(data.jar3);
+                }
+                ResourceAdapter adapter = connector.getResourceAdapter()[0];
+                ConnectionDefinition definition = new ConnectionDefinition();
+                adapter.setConnectionDefinition(new ConnectionDefinition[]{definition});
+                definition.setConnectionFactoryInterface("javax.sql.DataSource");
+                ConnectionDefinitionInstance instance = new ConnectionDefinitionInstance();
+                definition.setConnectionInstance(new ConnectionDefinitionInstance[]{instance});
+                instance.setName(data.getName());
+                ConfigPropertySetting[] settings = instance.getConfigPropertySetting();
+                if(data.isGeneric()) { // it's a generic TranQL JDBC pool
+                    for (int i = 0; i < settings.length; i++) {
+                        ConfigPropertySetting setting = settings[i];
+                        if(setting.getName().equals("UserName")) {
+                            setting.setValue(data.user);
+                        } else if(setting.getName().equals("Password")) {
+                            setting.setValue(data.password);
+                        } else if(setting.getName().equals("ConnectionURL")) {
+                            setting.setValue(data.url);
+                        } else if(setting.getName().equals("Driver")) {
+                            setting.setValue(data.driverClass);
+                        }
+                    }
+                } else { // it's an XA driver or non-TranQL RA
+                    for (int i = 0; i < settings.length; i++) {
+                        ConfigPropertySetting setting = settings[i];
+                        String value = (String) data.properties.get("property-"+setting.getName());
+                        setting.setValue(value == null ? "" : value);
+                    }
+                }
+                ConnectionManager manager = instance.getConnectionManager();
+                manager.setTransactionLocal(true);
+                SinglePool pool = new SinglePool();
+                manager.setPoolSingle(pool);
+                pool.setMatchOne(true);
+                if(data.minSize != null && !data.minSize.equals("")) {
+                    pool.setMinSize(new Integer(data.minSize));
+                }
+                if(data.maxSize != null && !data.maxSize.equals("")) {
+                    pool.setMaxSize(new Integer(data.maxSize));
+                }
+                if(data.blockingTimeout != null && !data.blockingTimeout.equals("")) {
+                    pool.setBlockingTimeoutMillis(new Integer(data.blockingTimeout));
+                }
+                if(data.idleTimeout != null && !data.idleTimeout.equals("")) {
+                    pool.setIdleTimeoutMinutes(new Integer(data.idleTimeout));
+                }
+                File tempFile = File.createTempFile("console-deployment",".xml");
+                tempFile.deleteOnExit();
+                log.debug("Writing database pool deployment plan to "+tempFile.getAbsolutePath());
+                BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile));
+                config.save(out);
+                out.flush();
+                out.close();
+                Target[] targets = mgr.getTargets();
+                ProgressObject po = mgr.distribute(targets, new File(url.getPath()), tempFile);
                 waitForProgress(po);
                 if(po.getDeploymentStatus().isCompleted()) {
-                    System.out.println("Deployment completed successfully!");
+                    TargetModuleID[] ids = po.getResultTargetModuleIDs();
+                    po = mgr.start(ids);
+                    waitForProgress(po);
+                    if(po.getDeploymentStatus().isCompleted()) {
+                        System.out.println("Deployment completed successfully!");
+                    }
                 }
+            } catch (Exception e) {
+                log.error("Unable to save connection pool", e);
+            } finally {
+                if(mgr != null) mgr.release();
+            }
+        } else { // We're saving updates to an existing pool
+            try {
+                JCAManagedConnectionFactory factory = (JCAManagedConnectionFactory) PortletManager.getManagedBean(request, data.getObjectName());
+                if(data.isGeneric()) {
+                    factory.setConfigProperty("connectionURL", data.getUrl());
+                    factory.setConfigProperty("userName", data.getUser());
+                    factory.setConfigProperty("password", data.getPassword());
+                } else {
+                    for (Iterator it = data.getProperties().entrySet().iterator(); it.hasNext();) {
+                        Map.Entry entry = (Map.Entry) it.next();
+                        factory.setConfigProperty(((String) entry.getKey()).substring("property-".length()), entry.getValue());
+                    }
+                }
+                //todo: push the lookup into ManagementHelper
+                PoolingAttributes pool = (PoolingAttributes) PortletManager.getManagedBean(request, factory.getConnectionManager());
+                pool.setPartitionMinSize(data.minSize == null || data.minSize.equals("") ? 0 : Integer.parseInt(data.minSize));
+                pool.setPartitionMaxSize(data.maxSize == null || data.maxSize.equals("") ? 10 : Integer.parseInt(data.maxSize));
+                pool.setBlockingTimeoutMilliseconds(data.blockingTimeout == null || data.blockingTimeout.equals("") ? 5000 : Integer.parseInt(data.blockingTimeout));
+                pool.setIdleTimeoutMinutes(data.idleTimeout == null || data.idleTimeout.equals("") ? 15 : Integer.parseInt(data.idleTimeout));
+            } catch (Exception e) {
+                log.error("Unable to save connection pool", e);
             }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            if(mgr != null) mgr.release();
         }
     }
 
@@ -496,13 +752,9 @@
         }
     }
 
-    /**
-     * todo: This is not ideal...  Should look up the RAR name somehow...
-     * Maybe eventually should not assume the RAR is on the local filesystem...
-     */
-    private static URL getTranQLRAR(PortletRequest request) {
+    private static URL getRAR(PortletRequest request, String rarPath) {
         try {
-            URI uri = new URI(TRANQL_RAR_NAME);
+            URI uri = new URI(rarPath);
             Repository[] repos = PortletManager.getRepositories(request);
             for (int i = 0; i < repos.length; i++) {
                 Repository repo = repos[i];
@@ -573,8 +825,8 @@
     private static String populateURL(String url, String[] keys, Map properties) {
         for (int i = 0; i < keys.length; i++) {
             String key = keys[i];
-            String value = (String) properties.get("property-"+key);
-            if(value == null) {
+            String value = (String) properties.get("urlproperty-"+key);
+            if(value == null || value.equals("")) {
                 int begin = url.indexOf("<"+key+">");
                 int end = begin + key.length() + 2;
                 for(int j=begin-1; j>=0; j--) {
@@ -583,6 +835,9 @@
                         begin = j;
                         break;
                     } else if(c == '/') {
+                        if(url.length() >= end && url.charAt(end) == '/') {
+                            begin = j; // Don't leave // if foo is null for /<foo>/
+                        }
                         break;
                     }
                 }
@@ -611,7 +866,9 @@
         private String dbtype;
         private String user;
         private String password;
-        private Map properties = new HashMap();
+        private Map properties = new HashMap(); // Configuration for non-Generic drivers
+        private Map urlProperties = new HashMap(); // URL substitution for Generic drivers
+        private Map propertyNames; //todo: store these in the ConfigParam instead
         private String driverClass;
         private String url;
         private String urlPrototype;
@@ -622,6 +879,10 @@
         private String maxSize;
         private String blockingTimeout;
         private String idleTimeout;
+        private String objectName;
+        private String adapterDisplayName;
+        private String adapterDescription;
+        private String rarPath;
 
         public void load(PortletRequest request) {
             name = request.getParameter("name");
@@ -638,13 +899,53 @@
             maxSize = request.getParameter("maxSize");
             blockingTimeout = request.getParameter("blockingTimeout");
             idleTimeout = request.getParameter("idleTimeout");
+            objectName = request.getParameter("objectName");
+            adapterDisplayName = request.getParameter("adapterDisplayName");
+            adapterDescription = request.getParameter("adapterDescription");
+            rarPath = request.getParameter("rarPath");
             Map map = request.getParameterMap();
+            propertyNames = new HashMap();
             for (Iterator it = map.keySet().iterator(); it.hasNext();) {
                 String key = (String) it.next();
-                if(key.startsWith("property-")) {
+                if(key.startsWith("urlproperty-")) {
+                    urlProperties.put(key, request.getParameter(key));
+                } else if(key.startsWith("property-")) {
                     properties.put(key, request.getParameter(key));
+                    propertyNames.put(key, getPropertyName(key));
+                }
+            }
+        }
+
+        public void loadPropertyNames() {
+            propertyNames = new HashMap();
+            for (Iterator it = properties.keySet().iterator(); it.hasNext();) {
+                String key = (String) it.next();
+                propertyNames.put(key, getPropertyName(key));
+            }
+        }
+
+        private static String getPropertyName(String key) {
+            int pos = key.indexOf('-');
+            key = Character.toUpperCase(key.charAt(pos+1))+key.substring(pos+2);
+            StringBuffer buf = new StringBuffer();
+            pos = 0;
+            for(int i=1; i<key.length(); i++) {
+                if(Character.isUpperCase(key.charAt(i))) {
+                    if(Character.isUpperCase(key.charAt(i-1))) { // ongoing capitalized word
+
+                    } else { // start of a new word
+                        buf.append(key.substring(pos, i)).append(" ");
+                        pos = i;
+                    }
+                } else {
+                    if(Character.isUpperCase(key.charAt(i-1)) && i-pos > 1) { // first lower-case after a series of caps
+                        buf.append(key.substring(pos, i-1)).append(" ");
+                        pos = i-1;
+                    }
                 }
             }
+            buf.append(key.substring(pos));
+            return buf.toString();
         }
 
         public void store(ActionResponse response) {
@@ -653,8 +954,8 @@
             if(driverClass != null) response.setRenderParameter("driverClass", driverClass);
             if(user != null) response.setRenderParameter("user", user);
             if(password != null) response.setRenderParameter("password", password);
-            if(url != null) response.setRenderParameter("urlPrototype", urlPrototype);
-            if(urlPrototype != null) response.setRenderParameter("url", url);
+            if(url != null) response.setRenderParameter("url", url);
+            if(urlPrototype != null) response.setRenderParameter("urlPrototype", urlPrototype);
             if(jar1 != null) response.setRenderParameter("jar1", jar1);
             if(jar2 != null) response.setRenderParameter("jar2", jar2);
             if(jar3 != null) response.setRenderParameter("jar3", jar3);
@@ -662,6 +963,16 @@
             if(maxSize != null) response.setRenderParameter("maxSize", maxSize);
             if(blockingTimeout != null) response.setRenderParameter("blockingTimeout", blockingTimeout);
             if(idleTimeout != null) response.setRenderParameter("idleTimeout", idleTimeout);
+            if(objectName != null) response.setRenderParameter("objectName", objectName);
+            if(adapterDisplayName != null) response.setRenderParameter("adapterDisplayName", adapterDisplayName);
+            if(adapterDescription != null) response.setRenderParameter("adapterDescription", adapterDescription);
+            if(rarPath != null) response.setRenderParameter("rarPath", rarPath);
+            for (Iterator it = urlProperties.entrySet().iterator(); it.hasNext();) {
+                Map.Entry entry = (Map.Entry) it.next();
+                if(entry.getValue() != null) {
+                    response.setRenderParameter((String)entry.getKey(), (String)entry.getValue());
+                }
+            }
             for (Iterator it = properties.entrySet().iterator(); it.hasNext();) {
                 Map.Entry entry = (Map.Entry) it.next();
                 if(entry.getValue() != null) {
@@ -690,6 +1001,14 @@
             return properties;
         }
 
+        public Map getPropertyNames() {
+            return propertyNames;
+        }
+
+        public Map getUrlProperties() {
+            return urlProperties;
+        }
+
         public String getUrl() {
             return url;
         }
@@ -730,44 +1049,107 @@
             return urlPrototype;
         }
 
-        public String toString() {
-            String temp= "NAME="+name+"\n"+
-                    "DB="+dbtype+"\n"+
-                    "CLASS="+driverClass+"\n"+
-                    "FORMAT="+urlPrototype+"\n"+
-                    "URL="+url+"\n"+
-                    "USER="+user+"\n"+
-                    "PASS="+password+"\n"+
-                    "JAR1="+jar1+"\n"+
-                    "JAR2="+jar2+"\n"+
-                    "JAR3="+jar3+"\n"+
-                    "MIN="+minSize+"\n"+
-                    "MAX="+maxSize+"\n"+
-                    "BLOCK="+blockingTimeout+"\n"+
-                    "IDLE="+idleTimeout;
-            for (Iterator it = properties.entrySet().iterator(); it.hasNext();) {
-                Map.Entry entry = (Map.Entry) it.next();
-                temp+="\n"+entry.getKey()+"="+entry.getValue();
-            }
-            return temp;
+        public String getObjectName() {
+            return objectName;
+        }
+
+        public String getAdapterDisplayName() {
+            return adapterDisplayName;
+        }
+
+        public String getAdapterDescription() {
+            return adapterDescription;
+        }
+
+        public String getRarPath() {
+            return rarPath;
+        }
+
+        public boolean isGeneric() {
+            //todo: is there any better way to tell?
+            return adapterDisplayName == null || adapterDisplayName.equals("TranQL Generic JDBC Resource Adapter");
         }
     }
 
-    public static class ConnectionPool implements Serializable {
-        private String objectName;
-        private String name;
+    public static class ConnectionPool implements Serializable, Comparable {
+        private final String adapterObjectName;
+        private final String factoryObjectName;
+        private final String name;
 
-        public ConnectionPool(String objectName, String name) {
-            this.objectName = objectName;
+        public ConnectionPool(String adapterObjectName, String factoryObjectName, String name) {
+            this.adapterObjectName = adapterObjectName;
+            this.factoryObjectName = factoryObjectName;
             this.name = name;
         }
 
-        public String getObjectName() {
-            return objectName;
+        public String getAdapterObjectName() {
+            return adapterObjectName;
+        }
+
+        public String getFactoryObjectName() {
+            return factoryObjectName;
         }
 
         public String getName() {
             return name;
+        }
+
+        public int compareTo(Object o) {
+            return name.compareTo(((ConnectionPool)o).name);
+        }
+    }
+
+    public static class ResourceAdapterParams {
+        private String displayName;
+        private String description;
+        private ConfigParam[] configParams;
+
+        public ResourceAdapterParams(String displayName, String description, ConfigParam[] configParams) {
+            this.displayName = displayName;
+            this.description = description;
+            this.configParams = configParams;
+        }
+
+        public String getDisplayName() {
+            return displayName;
+        }
+
+        public String getDescription() {
+            return description;
+        }
+
+        public ConfigParam[] getConfigParams() {
+            return configParams;
+        }
+    }
+
+    public static class ConfigParam {
+        private String name;
+        private String type;
+        private String description;
+        private String defaultValue;
+
+        public ConfigParam(String name, String type, String description, String defaultValue) {
+            this.name = name;
+            this.type = type;
+            this.description = description;
+            this.defaultValue = defaultValue;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public String getType() {
+            return type;
+        }
+
+        public String getDescription() {
+            return description;
+        }
+
+        public String getDefaultValue() {
+            return defaultValue;
         }
     }
 }

Modified: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/util/PortletManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/util/PortletManager.java?rev=332881&r1=332880&r2=332881&view=diff
==============================================================================
--- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/util/PortletManager.java (original)
+++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/util/PortletManager.java Sat Nov 12 19:56:12 2005
@@ -16,29 +16,39 @@
  */
 package org.apache.geronimo.console.util;
 
-import java.util.List;
 import java.util.ArrayList;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletSession;
+import java.util.List;
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
 import javax.servlet.http.HttpSession;
-import javax.enterprise.deploy.spi.DeploymentManager;
-import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
-import org.apache.geronimo.kernel.KernelRegistry;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.kernel.KernelRegistry;
+import org.apache.geronimo.kernel.proxy.GeronimoManagedBean;
 import org.apache.geronimo.kernel.repository.ListableRepository;
+import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.kernel.repository.WriteableRepository;
-import org.apache.geronimo.kernel.proxy.GeronimoManagedBean;
 import org.apache.geronimo.management.J2EEDomain;
-import org.apache.geronimo.management.ResourceAdapterModule;
-import org.apache.geronimo.management.geronimo.*;
-import org.apache.geronimo.system.logging.SystemLog;
+import org.apache.geronimo.management.geronimo.EJBManager;
+import org.apache.geronimo.management.geronimo.J2EEServer;
+import org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory;
+import org.apache.geronimo.management.geronimo.JMSBroker;
+import org.apache.geronimo.management.geronimo.JMSConnector;
+import org.apache.geronimo.management.geronimo.JMSManager;
+import org.apache.geronimo.management.geronimo.JVM;
+import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
+import org.apache.geronimo.management.geronimo.WebAccessLog;
+import org.apache.geronimo.management.geronimo.WebConnector;
+import org.apache.geronimo.management.geronimo.WebContainer;
+import org.apache.geronimo.management.geronimo.WebManager;
 import org.apache.geronimo.pool.GeronimoExecutor;
-import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.system.logging.SystemLog;
 
 /**
  * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
@@ -166,9 +176,29 @@
         return helper.getOutboundRAModules(getCurrentServer(request), iface);
     }
 
-    public static JCAManagedConnectionFactory[] getOutboundFactories(PortletRequest request, String iface) {
+    public static JCAManagedConnectionFactory[] getOutboundFactoriesOfType(PortletRequest request, String iface) {
         ManagementHelper helper = getManagementHelper(request);
         return helper.getOutboundFactories(getCurrentServer(request), iface);
+    }
+
+    public static JCAManagedConnectionFactory[] getOutboundFactoriesForRA(PortletRequest request, String resourceAdapterModuleName) {
+        ManagementHelper helper = getManagementHelper(request);
+        return helper.getOutboundFactories((ResourceAdapterModule)helper.getObject(resourceAdapterModuleName));
+    }
+
+    public static JCAManagedConnectionFactory[] getOutboundFactoriesForRA(PortletRequest request, String resourceAdapterModuleName, String iface) {
+        ManagementHelper helper = getManagementHelper(request);
+        return helper.getOutboundFactories((ResourceAdapterModule)helper.getObject(resourceAdapterModuleName), iface);
+    }
+
+    public static JCAManagedConnectionFactory[] getOutboundFactoriesForRA(PortletRequest request, ResourceAdapterModule module) {
+        ManagementHelper helper = getManagementHelper(request);
+        return helper.getOutboundFactories(module);
+    }
+
+    public static JCAManagedConnectionFactory[] getOutboundFactoriesForRA(PortletRequest request, ResourceAdapterModule module, String iface) {
+        ManagementHelper helper = getManagementHelper(request);
+        return helper.getOutboundFactories(module, iface);
     }
 
     public static String[] getWebManagerNames(PortletRequest request) {

Modified: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/basicParams.jsp
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/basicParams.jsp?rev=332881&r1=332880&r2=332881&view=diff
==============================================================================
--- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/basicParams.jsp (original)
+++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/basicParams.jsp Sat Nov 12 19:56:12 2005
@@ -18,6 +18,12 @@
     <input type="hidden" name="maxSize" value="${pool.maxSize}" />
     <input type="hidden" name="idleTimeout" value="${pool.idleTimeout}" />
     <input type="hidden" name="blockingTimeout" value="${pool.blockingTimeout}" />
+    <input type="hidden" name="adapterDisplayName" value="${pool.adapterDisplayName}" />
+    <input type="hidden" name="adapterDescription" value="${pool.adapterDescription}" />
+    <input type="hidden" name="rarPath" value="${pool.rarPath}" />
+  <c:forEach var="prop" items="${pool.properties}">
+    <input type="hidden" name="${prop.key}" value="${prop.value}" />
+  </c:forEach>
     <table border="0">
     <!-- ENTRY FIELD: Driver Class -->
       <tr>
@@ -75,9 +81,9 @@
         <th><div align="right">Typical JDBC URL:</div></th>
         <td><c:out value="${pool.urlPrototype}" /></td>
       </tr>
-  <c:forEach var="prop" items="${pool.properties}">
+  <c:forEach var="prop" items="${pool.urlProperties}">
       <tr>
-        <th><div align="right">${fn:substringAfter(prop.key,"property-")}:</div></th>
+        <th><div align="right">${fn:substringAfter(prop.key,"urlproperty-")}:</div></th>
         <td><input name="${prop.key}" type="text" size="20" value="${prop.value}"></td>
       </tr>
       <tr>

Modified: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/confirmURL.jsp
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/confirmURL.jsp?rev=332881&r1=332880&r2=332881&view=diff
==============================================================================
--- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/confirmURL.jsp (original)
+++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/confirmURL.jsp Sat Nov 12 19:56:12 2005
@@ -17,9 +17,15 @@
     <input type="hidden" name="jar1" value="${pool.jar1}" />
     <input type="hidden" name="jar2" value="${pool.jar2}" />
     <input type="hidden" name="jar3" value="${pool.jar3}" />
+    <input type="hidden" name="adapterDisplayName" value="${pool.adapterDisplayName}" />
+    <input type="hidden" name="adapterDescription" value="${pool.adapterDescription}" />
+    <input type="hidden" name="rarPath" value="${pool.rarPath}" />
   <c:forEach var="prop" items="${pool.properties}">
     <input type="hidden" name="${prop.key}" value="${prop.value}" />
   </c:forEach>
+  <c:forEach var="prop" items="${pool.urlProperties}">
+    <input type="hidden" name="${prop.key}" value="${prop.value}" />
+  </c:forEach>
     <table border="0">
     <!-- ENTRY FIELD: URL -->
       <tr>
@@ -85,14 +91,6 @@
     </table>
 </form>
 <!--   END OF FORM TO COLLECT DATA FOR THIS PAGE   -->
-
-<p><a href="<portlet:actionURL portletMode="view">
-              <portlet:param name="mode" value="test" />
-            </portlet:actionURL>">Test Connection</a></p>
-<p><a href="<portlet:actionURL portletMode="view">
-              <portlet:param name="mode" value="save" />
-            </portlet:actionURL>">Skip Test & Save</a></p>
-
 
 <p><a href="<portlet:actionURL portletMode="view">
               <portlet:param name="mode" value="list" />

Modified: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/edit.jsp
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/edit.jsp?rev=332881&r1=332880&r2=332881&view=diff
==============================================================================
--- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/edit.jsp (original)
+++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/edit.jsp Sat Nov 12 19:56:12 2005
@@ -1,4 +1,5 @@
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
 <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
 <portlet:defineObjects/>
 
@@ -13,28 +14,62 @@
     <input type="hidden" name="urlPrototype" value="${pool.urlPrototype}" />
     <input type="hidden" name="jar2" value="${pool.jar2}" />
     <input type="hidden" name="jar3" value="${pool.jar3}" />
-  <c:forEach var="prop" items="${pool.properties}">
+  <c:forEach var="prop" items="${pool.urlProperties}">
     <input type="hidden" name="${prop.key}" value="${prop.value}" />
   </c:forEach>
+    <input type="hidden" name="objectName" value="${pool.objectName}" />
+    <input type="hidden" name="adapterDisplayName" value="${pool.adapterDisplayName}" />
+    <input type="hidden" name="adapterDescription" value="${pool.adapterDescription}" />
+    <input type="hidden" name="rarPath" value="${pool.rarPath}" />
 
     <table border="0">
     <!-- ENTRY FIELD: NAME -->
       <tr>
-        <th><div align="right">Name of Database Pool:</div></th>
-        <td><input name="name" type="text" size="30" value="${pool.name}"></td>
+        <th><div align="right">Pool Name:</div></th>
+        <td>
+      <c:choose> <%-- Can't change the pool name after deployment because it's wired into all the ObjectNames --%>
+        <c:when test="${empty pool.objectName}">
+          <input name="name" type="text" size="30" value="${pool.name}">
+        </c:when>
+        <c:otherwise>
+          <b><c:out value="${pool.name}" /></b>
+        </c:otherwise>
+      </c:choose>
+        </td>
       </tr>
       <tr>
         <td></td>
-        <td>A name that is different than the name for any other database pools in the server</td>
+        <td>A name that is different than the name for any other database pools in the server (no spaces in the name please).</td>
+      </tr>
+    <!-- STATUS FIELD: Display Name -->
+      <tr>
+        <th><div align="right">Pool Type:</div></th>
+        <td><i><c:out value="${pool.adapterDisplayName}" /></i></td>
+      </tr>
+      <tr>
+        <td />
+        <td><c:out value="${pool.adapterDescription}" /></td>
       </tr>
     <!-- HEADER -->
       <tr>
         <th colspan="2">Basic Connection Properties</th>
       </tr>
+<c:choose>
+  <c:when test="${pool.generic}"> <%-- This is a standard TranQL JDBC pool -- we know what parameters it wants --%>
     <!-- ENTRY FIELD: Driver Class -->
       <tr>
         <th><div align="right">JDBC Driver Class:</div></th>
-        <td><input name="driverClass" type="text" size="30" value="${pool.driverClass}"></td>
+        <td>
+      <c:choose>
+        <c:when test="${empty pool.objectName}">
+          <input name="driverClass" type="text" size="30" value="${pool.driverClass}">
+        </c:when>
+        <c:otherwise>
+          <input type="hidden" name="driverClass" value="${pool.driverClass}" />
+          <i><c:out value="${pool.driverClass}" /></i>
+        </c:otherwise>
+      </c:choose>
+        </td>
       </tr>
       <tr>
         <td></td>
@@ -44,6 +79,8 @@
         </td>
       </tr>
     <!-- ENTRY FIELD: Driver JAR -->
+  <c:choose> <%-- Can't set JAR after deployment because we don't know how to dig through dependencies yet --%>
+    <c:when test="${empty pool.objectName}">
       <tr>
         <th><div align="right">Driver JAR:</div></th>
         <td>
@@ -61,6 +98,11 @@
           <input type="button" value="Download a Driver" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='download';document.<portlet:namespace/>DatabaseForm.submit();return false;" />)
         </td>
       </tr>
+    </c:when>
+    <c:otherwise>
+      <input type="hidden" name="jar1" value="${pool.jar1}" />
+    </c:otherwise>
+  </c:choose>
     <!-- ENTRY FIELD: URL -->
       <tr>
         <th><div align="right">JDBC Connect URL:</div></th>
@@ -86,8 +128,36 @@
       </tr>
       <tr>
         <td></td>
-        <td>The password used to connect to the database</td>
+        <td>The password used to connect to the database
+
+        <%-- Just to be safe, save all the non-Generic properties since we're not going to edit them here --%>
+  <c:forEach var="prop" items="${pool.properties}">
+    <input type="hidden" name="${prop.key}" value="${prop.value}" />
+  </c:forEach>
+        </td>
       </tr>
+  </c:when>
+  <c:otherwise> <%-- This is an XA or other connection factory that we don't have special parameter handling for --%>
+    <c:forEach var="prop" items="${pool.properties}">
+      <tr>
+        <th><div align="right">${pool.propertyNames[prop.key]}:</div></th>
+        <td><input name="${prop.key}" type="<c:choose><c:when test="${fn:containsIgnoreCase(prop.key, 'password')}">password</c:when><c:otherwise>text</c:otherwise></c:choose>" size="20" value="${prop.value}"></td>
+      </tr>
+      <tr>
+        <td></td>
+        <td>${ConfigParams[prop.key].description}</td>
+      </tr>
+    </c:forEach>
+      <tr><td colspan="2">
+        <%-- Just to be safe, save all the Generic properties since we're not going to edit them here --%>
+        <input type="hidden" name="user" value="${pool.user}" />
+        <input type="hidden" name="password" value="${pool.password}" />
+        <input type="hidden" name="driverClass" value="${pool.driverClass}" />
+        <input type="hidden" name="url" value="${pool.url}" />
+        <input type="hidden" name="jar1" value="${pool.jar1}" />
+      </td></tr>
+  </c:otherwise>
+</c:choose>
     <!-- HEADER -->
       <tr>
         <th colspan="2">Connection Pool Parameters</th>
@@ -99,7 +169,7 @@
       </tr>
       <tr>
         <td></td>
-        <td>The minimum number of connections in the pool.  Leave blank for default.</td>
+        <td>The minimum number of connections in the pool.  The default is 0.</td>
       </tr>
     <!-- ENTRY FIELD: Max Size -->
       <tr>
@@ -108,7 +178,7 @@
       </tr>
       <tr>
         <td></td>
-        <td>The maximum number of connections in the pool.  Leave blank for default.</td>
+        <td>The maximum number of connections in the pool.  The default is 10.</td>
       </tr>
     <!-- ENTRY FIELD: Blocking Timeout -->
       <tr>
@@ -117,7 +187,7 @@
       </tr>
       <tr>
         <td></td>
-        <td>The length of time a caller will wait for a connection.  Leave blank for default.</td>
+        <td>The length of time a caller will wait for a connection.  The default is 5000.</td>
       </tr>
     <!-- ENTRY FIELD: Idle timeout -->
       <tr>
@@ -126,14 +196,29 @@
       </tr>
       <tr>
         <td></td>
-        <td>How long a connection can be idle before being closed.  Leave blank for default.</td>
+        <td>How long a connection can be idle before being closed.  The default is 15.</td>
       </tr>
 
     <!-- SUBMIT BUTTON -->
       <tr>
         <td></td>
-        <td><input type="submit" value="Test Connection" />
+        <td>
+<c:choose> <%-- Don't know how to test a non-generic pool, so you can only save it --%>
+  <c:when test="${pool.generic}">
+    <c:choose> <%-- Can't test after deployment because we don't know what JAR to put on the ClassPath --%>
+      <c:when test="${empty pool.objectName}">
+          <input type="submit" value="Test Connection" />
           <input type="button" value="Skip Test" onclick="document.<portlet:namespace/>DatabaseForm.test.value='false';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
+      </c:when>
+      <c:otherwise>
+          <input type="button" value="Save" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='save';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
+      </c:otherwise>
+    </c:choose>
+  </c:when>
+  <c:otherwise>
+          <input type="button" value="Save" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='save';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
+  </c:otherwise>
+</c:choose>
         </td>
       </tr>
     </table>

Modified: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/list.jsp
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/list.jsp?rev=332881&r1=332880&r2=332881&view=diff
==============================================================================
--- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/list.jsp (original)
+++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/list.jsp Sat Nov 12 19:56:12 2005
@@ -5,7 +5,11 @@
 <p>This page lists all the available database pools.</p>
 <ul>
 <c:forEach var="pool" items="${pools}">
-  <li>${pool.name}</li>
+  <li>${pool.name} (<a href="<portlet:actionURL portletMode="view">
+              <portlet:param name="mode" value="editExisting" />
+              <portlet:param name="adapterObjectName" value="${pool.adapterObjectName}" />
+              <portlet:param name="objectName" value="${pool.factoryObjectName}" />
+            </portlet:actionURL>">edit</a>)</li>
 </c:forEach>
 </ul>
 

Modified: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/selectDatabase.jsp
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/selectDatabase.jsp?rev=332881&r1=332880&r2=332881&view=diff
==============================================================================
--- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/selectDatabase.jsp (original)
+++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/selectDatabase.jsp Sat Nov 12 19:56:12 2005
@@ -19,9 +19,15 @@
     <input type="hidden" name="maxSize" value="${pool.maxSize}" />
     <input type="hidden" name="idleTimeout" value="${pool.idleTimeout}" />
     <input type="hidden" name="blockingTimeout" value="${pool.blockingTimeout}" />
+    <input type="hidden" name="adapterDisplayName" value="${pool.adapterDisplayName}" />
+    <input type="hidden" name="adapterDescription" value="${pool.adapterDescription}" />
+    <input type="hidden" name="rarPath" value="${pool.rarPath}" />
   <c:forEach var="prop" items="${pool.properties}">
     <input type="hidden" name="${prop.key}" value="${prop.value}" />
   </c:forEach>
+  <c:forEach var="prop" items="${pool.urlProperties}">
+    <input type="hidden" name="${prop.key}" value="${prop.value}" />
+  </c:forEach>
     <table border="0">
     <!-- ENTRY FIELD: NAME -->
       <tr>
@@ -30,7 +36,7 @@
       </tr>
       <tr>
         <td></td>
-        <td>A name that is different than the name for any other database pools in the server</td>
+        <td>A name that is different than the name for any other database pools in the server (no spaces in the name please).</td>
       </tr>
     <!-- ENTRY FIELD: DB TYPE -->
       <tr>
@@ -40,7 +46,6 @@
         <c:forEach var="db" items="${databases}">
             <option <c:if test="${db.name == pool.dbtype}">selected</c:if>>${db.name}</option>
         </c:forEach>
-            <option>Other</option>
           </select>
         </td>
       </tr>



Mime
View raw message