You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by am...@apache.org on 2005/11/11 06:06:17 UTC
svn commit: r332454 - in /geronimo/trunk:
applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/
applications/console-standard/src/webapp/WEB-INF/view/dbwizard/
modules/kernel/src/java/org/apache/geronimo/kernel/repo...
Author: ammulder
Date: Thu Nov 10 21:06:00 2005
New Revision: 332454
URL: http://svn.apache.org/viewcvs?rev=332454&view=rev
Log:
Enhance the WriteableRepository a bit
Update the console so that it can download JDBC drivers into the repository.
GERONIMO-1156
Added:
geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DriverDownloader.java (with props)
geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/selectDownload.jsp (with props)
geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/repository/FileWriteMonitor.java (with props)
Modified:
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/webapp/WEB-INF/view/dbwizard/basicParams.jsp
geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/repository/WriteableRepository.java
geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java
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=332454&r1=332453&r2=332454&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 Thu Nov 10 21:06:00 2005
@@ -22,6 +22,8 @@
import java.util.List;
/**
+ * Information about common database drivers.
+ *
* @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
*/
public class DatabaseInfo {
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=332454&r1=332453&r2=332454&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 Thu Nov 10 21:06:00 2005
@@ -49,6 +49,7 @@
import javax.portlet.RenderResponse;
import javax.portlet.WindowState;
import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
import javax.management.ObjectName;
import javax.management.MalformedObjectNameException;
import javax.enterprise.deploy.spi.DeploymentManager;
@@ -56,8 +57,6 @@
import javax.enterprise.deploy.spi.Target;
import javax.enterprise.deploy.spi.TargetModuleID;
import javax.enterprise.deploy.spi.status.ProgressObject;
-import javax.enterprise.deploy.spi.exceptions.InvalidModuleException;
-import javax.enterprise.deploy.model.exceptions.DDBeanCreateException;
import javax.enterprise.deploy.model.DDBeanRoot;
import org.apache.geronimo.console.BasePortlet;
import org.apache.geronimo.console.util.PortletManager;
@@ -65,6 +64,8 @@
import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
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.repository.FileWriteMonitor;
import org.apache.geronimo.deployment.tools.loader.ConnectorDeployable;
import org.apache.geronimo.connector.deployment.jsr88.Connector15DCBRoot;
import org.apache.geronimo.connector.deployment.jsr88.ConnectorDCB;
@@ -79,6 +80,8 @@
import org.apache.commons.logging.LogFactory;
/**
+ * A portlet that lets you configure and deploy JDBC connection pools.
+ *
* @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
*/
public class DatabasePoolPortlet extends BasePortlet {
@@ -88,18 +91,23 @@
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 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";
private static final String SELECT_RDBMS_VIEW = "/WEB-INF/view/dbwizard/selectDatabase.jsp";
private static final String BASIC_PARAMS_VIEW = "/WEB-INF/view/dbwizard/basicParams.jsp";
private static final String CONFIRM_URL_VIEW = "/WEB-INF/view/dbwizard/confirmURL.jsp";
private static final String TEST_CONNECTION_VIEW = "/WEB-INF/view/dbwizard/testConnection.jsp";
+ private static final String DOWNLOAD_VIEW = "/WEB-INF/view/dbwizard/selectDownload.jsp";
private static final String LIST_MODE = "list";
private static final String EDIT_MODE = "edit";
private static final String SELECT_RDBMS_MODE = "rdbms";
private static final String BASIC_PARAMS_MODE = "params";
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 SAVE_MODE = "save";
private static final String MODE_KEY = "mode";
@@ -109,6 +117,7 @@
private PortletRequestDispatcher basicParamsView;
private PortletRequestDispatcher confirmURLView;
private PortletRequestDispatcher testConnectionView;
+ private PortletRequestDispatcher downloadView;
public void init(PortletConfig portletConfig) throws PortletException {
super.init(portletConfig);
@@ -118,6 +127,7 @@
basicParamsView = portletConfig.getPortletContext().getRequestDispatcher(BASIC_PARAMS_VIEW);
confirmURLView = portletConfig.getPortletContext().getRequestDispatcher(CONFIRM_URL_VIEW);
testConnectionView = portletConfig.getPortletContext().getRequestDispatcher(TEST_CONNECTION_VIEW);
+ downloadView = portletConfig.getPortletContext().getRequestDispatcher(DOWNLOAD_VIEW);
}
public void destroy() {
@@ -127,9 +137,26 @@
basicParamsView = null;
confirmURLView = null;
testConnectionView = null;
+ downloadView = null;
super.destroy();
}
+ public DriverDownloader.DriverInfo[] getDriverInfo(PortletRequest request) {
+ PortletSession session = request.getPortletSession(true);
+ DriverDownloader.DriverInfo[] results = (DriverDownloader.DriverInfo[]) session.getAttribute(DRIVER_SESSION_KEY, PortletSession.APPLICATION_SCOPE);
+ if(results == null) {
+ DriverDownloader downloader = new DriverDownloader();
+ try {
+ results = downloader.loadDriverInfo(new URL(DRIVER_INFO_URL));
+ session.setAttribute(DRIVER_SESSION_KEY, results, PortletSession.APPLICATION_SCOPE);
+ } catch (MalformedURLException e) {
+ log.error("Unable to download driver data", e);
+ results = new DriverDownloader.DriverInfo[0];
+ }
+ }
+ return results;
+ }
+
public void processAction(ActionRequest actionRequest,
ActionResponse actionResponse) throws PortletException, IOException {
String mode = actionRequest.getParameter(MODE_KEY);
@@ -147,6 +174,42 @@
}
actionResponse.setRenderParameter(MODE_KEY, BASIC_PARAMS_MODE);
}
+ } else if(mode.equals("process-"+DOWNLOAD_MODE)) {
+ String name = actionRequest.getParameter("driverName");
+ DriverDownloader.DriverInfo[] drivers = getDriverInfo(actionRequest);
+ DriverDownloader.DriverInfo found = null;
+ for (int i = 0; i < drivers.length; i++) {
+ DriverDownloader.DriverInfo driver = drivers[i];
+ if(driver.getName().equals(name)) {
+ found = driver;
+ break;
+ }
+ }
+ if(found != null) {
+ DriverDownloader downloader = new DriverDownloader();
+ WriteableRepository repo = PortletManager.getWritableRepositories(actionRequest)[0];
+ try {
+ downloader.loadDriver(repo, found, new FileWriteMonitor() {
+ public void writeStarted(String fileDescription) {
+ System.out.println("Downloading "+fileDescription);
+ }
+
+ public void writeProgress(int bytes) {
+ System.out.print("\rDownload progress: "+(bytes/1024)+"kB");
+ System.out.flush();
+ }
+
+ public void writeComplete(int bytes) {
+ System.out.println();
+ System.out.println("Finished downloading "+bytes+"b");
+ }
+ });
+ data.jar1 = found.getRepositoryPath();
+ } catch (IOException e) {
+ log.error("Unable to download JDBC driver", e);
+ }
+ }
+ actionResponse.setRenderParameter(MODE_KEY, BASIC_PARAMS_MODE);
} else if(mode.equals("process-"+BASIC_PARAMS_MODE)) {
DatabaseInfo info = null;
info = getDatabaseInfo(data);
@@ -206,6 +269,8 @@
renderEdit(renderRequest, renderResponse);
} else if(mode.equals(SELECT_RDBMS_MODE)) {
renderSelectRDBMS(renderRequest, renderResponse);
+ } else if(mode.equals(DOWNLOAD_MODE)) {
+ renderDownload(renderRequest, renderResponse);
} else if(mode.equals(BASIC_PARAMS_MODE)) {
renderBasicParams(renderRequest, renderResponse, data);
} else if(mode.equals(CONFIRM_URL_MODE)) {
@@ -243,6 +308,11 @@
selectRDBMSView.include(renderRequest, renderResponse);
}
+ private void renderDownload(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
+ renderRequest.setAttribute("drivers", getDriverInfo(renderRequest));
+ downloadView.include(renderRequest, renderResponse);
+ }
+
private void renderBasicParams(RenderRequest renderRequest, RenderResponse renderResponse, PoolData data) throws IOException, PortletException {
// List the available JARs
List list = new ArrayList();
@@ -251,11 +321,17 @@
ListableRepository repo = repos[i];
try {
final URI[] uris = repo.listURIs();
- final String[] strings = new String[uris.length];
- for (int j = 0; j < strings.length; j++) {
- strings[j] = uris[j].toString();
+ outer:
+ for (int j = 0; j < uris.length; j++) {
+ String test = uris[j].toString();
+ for (int k = 0; k < SKIP_ENTRIES_WITH.length; k++) {
+ String skip = SKIP_ENTRIES_WITH[k];
+ if(test.indexOf(skip) > -1) {
+ continue outer;
+ }
+ }
+ list.add(test);
}
- list.addAll(Arrays.asList(strings));
} catch (URISyntaxException e) {
e.printStackTrace();
}
Added: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DriverDownloader.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DriverDownloader.java?rev=332454&view=auto
==============================================================================
--- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DriverDownloader.java (added)
+++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DriverDownloader.java Thu Nov 10 21:06:00 2005
@@ -0,0 +1,289 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.console.databasemanager.wizard;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.kernel.repository.WriteableRepository;
+import org.apache.geronimo.kernel.repository.FileWriteMonitor;
+
+import java.net.URL;
+import java.net.URI;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.File;
+import java.io.OutputStream;
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.util.Properties;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Random;
+import java.util.Collections;
+import java.util.jar.JarFile;
+import java.util.jar.JarEntry;
+
+/**
+ * A utility that handles listing and downloading available JDBC driver JARs.
+ * It can handle straight JARs and also JARs in ZIP files.
+ *
+ * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
+ */
+public class DriverDownloader {
+ private final static Log log = LogFactory.getLog(DriverDownloader.class);
+ Random random;
+
+ public Properties readDriverFile(URL url) {
+ try {
+ InputStream in = url.openStream();
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ return props;
+ } catch (IOException e) {
+ log.error("Unable to download driver properties", e);
+ return null;
+ }
+ }
+
+ public DriverInfo[] loadDriverInfo(URL driverInfoFile) {
+ List list = new ArrayList();
+ Properties props = readDriverFile(driverInfoFile);
+ if(props == null) {
+ return new DriverInfo[0];
+ }
+ Set drivers = new HashSet();
+ for (Iterator it = props.keySet().iterator(); it.hasNext();) {
+ String key = (String) it.next();
+ if(!key.startsWith("driver.")) {
+ continue;
+ }
+ int pos = key.indexOf('.', 7);
+ if(pos > -1) {
+ drivers.add(key.substring(7, pos));
+ }
+ }
+ List urls = new ArrayList();
+ for (Iterator it = drivers.iterator(); it.hasNext();) {
+ String driver = (String) it.next();
+ String name = props.getProperty("driver."+driver+".name");
+ String repository = props.getProperty("driver."+driver+".repository");
+ String unzip = props.getProperty("driver."+driver+".unzip");
+ String rename = props.getProperty("driver."+driver+".rename");
+ urls.clear();
+ int index = 1;
+ while(true) {
+ String url = props.getProperty("driver."+driver+".url."+index);
+ if(url != null) {
+ ++index;
+ try {
+ urls.add(new URL(url));
+ } catch (MalformedURLException e) {
+ log.error("Unable to process URL from driver list", e);
+ }
+ } else {
+ break;
+ }
+ }
+ if(name != null && repository != null && urls.size() > 0) {
+ DriverInfo info = new DriverInfo(name, repository);
+ info.setUnzipPath(unzip);
+ info.setRenameTo(rename);
+ info.setUrls((URL[]) urls.toArray(new URL[urls.size()]));
+ list.add(info);
+ }
+ }
+ Collections.sort(list);
+ return (DriverInfo[]) list.toArray(new DriverInfo[list.size()]);
+ }
+
+ /**
+ * Downloads a driver and loads it into the local repository.
+ */
+ public void loadDriver(WriteableRepository repo, DriverInfo driver, FileWriteMonitor monitor) throws IOException {
+ try {
+ int urlIndex = 0;
+ if(driver.urls.length > 1) {
+ if(random == null) {
+ random = new Random();
+ }
+ urlIndex = random.nextInt(driver.urls.length);
+ }
+ URL url = driver.urls[urlIndex];
+ InputStream in;
+ String fileName = driver.getRepositoryPath();
+ if(driver.unzipPath != null) {
+ byte[] buf = new byte[1024];
+ int size;
+ int total = 0;
+ int threshold = 10240;
+ InputStream net = url.openStream();
+ JarFile jar = null;
+ File download = null;
+ try {
+ download = File.createTempFile("geronimo-driver-download", ".zip");
+ OutputStream out = new BufferedOutputStream(new FileOutputStream(download));
+ if(monitor != null) {
+ monitor.writeStarted("Download driver archive to "+download);
+ }
+ try {
+ while((size = net.read(buf)) > -1) {
+ out.write(buf, 0, size);
+ if(monitor != null) {
+ total += size;
+ if(total > threshold) {
+ monitor.writeProgress(total);
+ threshold += 10240;
+ }
+ }
+ }
+ out.flush();
+ out.close();
+ } finally {
+ if(monitor != null) {
+ monitor.writeComplete(total);
+ }
+ }
+ jar = new JarFile(download);
+ JarEntry entry = jar.getJarEntry(driver.unzipPath);
+ if(entry == null) {
+ log.error("Cannot extract driver JAR "+driver.unzipPath+" from download file "+url);
+ } else {
+ in = jar.getInputStream(entry);
+ repo.copyToRepository(in, new URI(fileName), monitor);
+ }
+ } finally {
+ if(jar != null) try{jar.close();}catch(IOException e) {log.error("Unable to close JAR file", e);}
+ if(download != null) {download.delete();}
+ }
+ } else {
+ in = url.openStream();
+ repo.copyToRepository(in, new URI(fileName), monitor);
+ }
+ } catch (URISyntaxException e) {
+ throw new IOException("Unable to save to repository URI: "+e.getMessage());
+ }
+ }
+
+// public static void main(String[] args) {
+// Random random = new Random();
+// DriverDownloader test = new DriverDownloader();
+// try {
+// DriverInfo[] all = test.loadDriverInfo(new URL("file:///Users/ammulder/driver-downloads.properties"));
+// org.apache.geronimo.system.serverinfo.ServerInfo info = new org.apache.geronimo.system.serverinfo.BasicServerInfo("/Users/ammulder");
+// org.apache.geronimo.system.repository.FileSystemRepository repo = new org.apache.geronimo.system.repository.FileSystemRepository(new URI("temp/"), info);
+// repo.doStart();
+// test.loadDriver(repo, all[random.nextInt(all.length)], new FileWriteMonitor() {
+// public void writeStarted(String description) {
+// System.out.println("Writing "+description);
+// }
+//
+// public void writeProgress(int bytes) {
+// System.out.print("\r"+(bytes/1024)+"kB complete");
+// System.out.flush();
+// }
+//
+// public void writeComplete(int bytes) {
+// System.out.println();
+// System.out.println("Finished writing: "+bytes+"b");
+// }
+// });
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// }
+
+ public static class DriverInfo implements Comparable {
+ private String name;
+ private String repositoryDir;
+ private String unzipPath;
+ private String renameTo;
+ private URL[] urls;
+
+ public DriverInfo(String name, String repositoryDir) {
+ this.name = name;
+ this.repositoryDir = repositoryDir;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getRepositoryDir() {
+ return repositoryDir;
+ }
+
+ public void setRepositoryDir(String repositoryDir) {
+ this.repositoryDir = repositoryDir;
+ }
+
+ public String getUnzipPath() {
+ return unzipPath;
+ }
+
+ public void setUnzipPath(String unzipPath) {
+ this.unzipPath = unzipPath;
+ }
+
+ public URL[] getUrls() {
+ return urls;
+ }
+
+ public void setUrls(URL[] urls) {
+ this.urls = urls;
+ }
+
+ public String getRenameTo() {
+ return renameTo;
+ }
+
+ public void setRenameTo(String renameTo) {
+ this.renameTo = renameTo;
+ }
+
+ public String getRepositoryPath() {
+ String fileName;
+ if(unzipPath != null) {
+ if(renameTo != null) {
+ fileName = renameTo;
+ } else {
+ fileName = unzipPath;
+ }
+ } else {
+ fileName = urls[0].toString();
+ }
+ int pos = fileName.lastIndexOf('/');
+ if(pos > -1) {
+ fileName = fileName.substring(pos+1);
+ }
+ return repositoryDir+"/jars/"+fileName;
+ }
+
+ public int compareTo(Object o) {
+ return name.compareTo(((DriverInfo)o).name);
+ }
+ }
+}
Propchange: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DriverDownloader.java
------------------------------------------------------------------------------
svn:eol-style = native
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=332454&r1=332453&r2=332454&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 Thu Nov 10 21:06:00 2005
@@ -6,7 +6,7 @@
<p><b>Create Database Pool</b> -- Step 2: Select Driver, JAR, Parameters</p>
<!-- FORM TO COLLECT DATA FOR THIS PAGE -->
-<form name="<portlet:namespace/>" action="<portlet:actionURL/>">
+<form name="<portlet:namespace/>DatabaseForm" action="<portlet:actionURL/>">
<input type="hidden" name="mode" value="process-params" />
<input type="hidden" name="name" value="${pool.name}" />
<input type="hidden" name="dbtype" value="${pool.dbtype}" />
@@ -40,13 +40,14 @@
<c:forEach var="jar" items="${jars}">
<option <c:if test="${jar == pool.jar1}">selected</c:if>>${jar}</option>
</c:forEach>
- <option>Other</option>
</select>
</td>
</tr>
<tr>
<td></td>
- <td>The JAR holding the selected JDBC driver. Should be installed under GERONIMO/repository/</td>
+ <td>The JAR holding the selected JDBC driver. Should be installed under GERONIMO/repository/ (or
+ <input type="button" value="Download a Driver" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='download';document.<portlet:namespace/>DatabaseForm.submit();return false;" />)
+ </td>
</tr>
<!-- ENTRY FIELD: Username -->
<tr>
Added: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/selectDownload.jsp
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/selectDownload.jsp?rev=332454&view=auto
==============================================================================
--- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/selectDownload.jsp (added)
+++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/selectDownload.jsp Thu Nov 10 21:06:00 2005
@@ -0,0 +1,84 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
+<portlet:defineObjects/>
+
+<p><b>Create Database Pool</b> -- Step 2: Select Driver, JAR, Parameters</p>
+
+<p>This page lets you automatically download a driver for a database where the
+driver JARs are available online without login or registration.</p>
+
+<!-- FORM TO COLLECT DATA FOR THIS PAGE -->
+<form name="<portlet:namespace/>DatabaseForm" action="<portlet:actionURL/>">
+ <input type="hidden" name="mode" value="process-download" />
+ <input type="hidden" name="name" value="${pool.name}" />
+ <input type="hidden" name="dbtype" value="${pool.dbtype}" />
+ <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="urlPrototype" value="${pool.urlPrototype}" />
+ <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="minSize" value="${pool.minSize}" />
+ <input type="hidden" name="maxSize" value="${pool.maxSize}" />
+ <input type="hidden" name="idleTimeout" value="${pool.idleTimeout}" />
+ <input type="hidden" name="blockingTimeout" value="${pool.blockingTimeout}" />
+ <c:forEach var="prop" items="${pool.properties}">
+ <input type="hidden" name="${prop.key}" value="${prop.value}" />
+ </c:forEach>
+ <table border="0">
+ <!-- ENTRY FIELD: DRIVER TYPE -->
+ <tr>
+ <th><div align="right">Select Driver:</div></th>
+ <td>
+ <select name="driverName">
+ <c:forEach var="driver" items="${drivers}">
+ <option>${driver.name}</option>
+ </c:forEach>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>A driver that Geronimo can download automatically for you.</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>
+ <input type="submit" value="Next" />
+ <input type="button" value="Cancel" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='params';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
+ </td>
+ </tr>
+ </table>
+</form>
+<!-- END OF FORM TO COLLECT DATA FOR THIS PAGE -->
+
+<%--
+<p><a href="<portlet:actionURL portletMode="view">
+ <portlet:param name="mode" value="params" />
+ </portlet:actionURL>">Select predefined database</a></p>
+<p><a href="<portlet:actionURL portletMode="view">
+ <portlet:param name="mode" value="edit" />
+ </portlet:actionURL>">Select "other" database</a></p>
+--%>
+
+<p><a href="<portlet:actionURL portletMode="view">
+ <portlet:param name="mode" value="list" />
+ </portlet:actionURL>">Return to List</a></p>
+
+<p><br /><br /><br />Here are some other JDBC drivers you might want to download on your own (just save them somewhere under geronimo/repository/):</p>
+<ul>
+ <li><a href="http://www.daffodildb.com/download/index.jsp">DaffodilDB</a></li>
+ <li><a href="http://www.frontbase.com/cgi-bin/WebObjects/FrontBase">FrontBase</a></li>
+ <li><a href="http://www.datadirect.com/products/jdbc/index.ssp">DataDirect SQL Server, DB2, Oracle, Informix, Sybase</a></li>
+ <li><a href="http://www-306.ibm.com/software/data/informix/tools/jdbc/">Informix</a></li>
+ <li><a href="http://www.intersystems.com/cache/downloads/index.html">InterSystems Cache</a></li>
+ <li><a href="http://www.borland.com/products/downloads/download_jdatastore.html">JDataStore</a></li>
+ <li><a href="http://developer.mimer.com/downloads/index.htm">Mimer</a></li>
+ <li><a href="http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html">Oracle</a></li>
+ <li><a href="http://www.pervasive.com/developerzone/access_methods/jdbc.asp">Pervasive</a></li>
+ <li><a href="http://www.pointbase.com/products/downloads/">Pointbase</a></li>
+ <li><a href="http://www.progress.com/esd/index.ssp">Progress</a></li>
+ <li><a href="http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/jdbc.mspx">Microsoft SQL Server</a></li>
+</ul>
\ No newline at end of file
Propchange: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/selectDownload.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/repository/FileWriteMonitor.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/repository/FileWriteMonitor.java?rev=332454&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/repository/FileWriteMonitor.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/repository/FileWriteMonitor.java Thu Nov 10 21:06:00 2005
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.kernel.repository;
+
+/**
+ * An interface for getting notifications on the progress of file writes.
+ *
+ * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
+ */
+public interface FileWriteMonitor {
+ public void writeStarted(String fileDescription);
+ public void writeProgress(int bytes);
+ public void writeComplete(int bytes);
+}
Propchange: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/repository/FileWriteMonitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/repository/WriteableRepository.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/repository/WriteableRepository.java?rev=332454&r1=332453&r2=332454&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/repository/WriteableRepository.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/repository/WriteableRepository.java Thu Nov 10 21:06:00 2005
@@ -19,6 +19,7 @@
import java.net.URI;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
/**
* A repository that accepts new entries.
@@ -33,5 +34,14 @@
* the server is just going to turn around and upload it to some
* other remote location.
*/
- public void copyToRepository(File source, URI destination) throws IOException;
+ public void copyToRepository(File source, URI destination, FileWriteMonitor monitor) throws IOException;
+
+ /**
+ * Copies the contents of an arbitrary stream into the repository.
+ * Obviously to use this remotely, you must have some other way
+ * to upload the content to the server's JVM, even if the the server
+ * is just going to turn around and upload it to some other remote
+ * location. The source will be closed when the write completes.
+ */
+ public void copyToRepository(InputStream source, URI destination, FileWriteMonitor monitor) throws IOException;
}
Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java?rev=332454&r1=332453&r2=332454&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java Thu Nov 10 21:06:00 2005
@@ -23,7 +23,7 @@
import java.io.FileOutputStream;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
-import java.io.FileFilter;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
@@ -40,19 +40,32 @@
import org.apache.geronimo.kernel.repository.Repository;
import org.apache.geronimo.kernel.repository.ListableRepository;
import org.apache.geronimo.kernel.repository.WriteableRepository;
+import org.apache.geronimo.kernel.repository.FileWriteMonitor;
import org.apache.geronimo.system.serverinfo.ServerInfo;
/**
+ * A listable, writeable repository that stores its entries in a directory on
+ * the local filesystem.
+ *
* @version $Rev$ $Date$
*/
public class FileSystemRepository implements Repository, ListableRepository, WriteableRepository, GBeanLifecycle {
private static final Log log = LogFactory.getLog(FileSystemRepository.class);
+ private final static int TRANSFER_NOTIFICATION_SIZE = 10240; // announce every this many bytes
+ private final static int TRANSFER_BUF_SIZE = 10240; // try this many bytes at a time
private final URI root;
private final ServerInfo serverInfo;
private URI rootURI;
private File rootFile;
public FileSystemRepository(URI root, ServerInfo serverInfo) {
+ if(!root.toString().endsWith("/")) {
+ try {
+ root = new URI(root.toString()+"/");
+ } catch (URISyntaxException e) {
+ throw new RuntimeException("Invalid repository root (does not end with / ) and can't add myself", e);
+ }
+ }
this.root = root;
this.serverInfo = serverInfo;
}
@@ -103,10 +116,14 @@
return (String[]) list.toArray(new String[list.size()]);
}
- public void copyToRepository(File source, URI destination) throws IOException {
+ public void copyToRepository(File source, URI destination, FileWriteMonitor monitor) throws IOException {
if(!source.exists() || !source.canRead() || source.isDirectory()) {
throw new IllegalArgumentException("Cannot read source file at "+source.getAbsolutePath());
}
+ copyToRepository(new FileInputStream(source), destination, monitor);
+ }
+
+ public void copyToRepository(InputStream source, URI destination, FileWriteMonitor monitor) throws IOException {
File dest = new File(rootURI.resolve(destination));
if(dest.exists()) {
throw new IllegalArgumentException("Destination "+dest.getAbsolutePath()+" already exists!");
@@ -115,17 +132,34 @@
if(!parent.exists() && !parent.mkdirs()) {
throw new RuntimeException("Unable to create directories from "+rootFile.getAbsolutePath()+" to "+parent.getAbsolutePath());
}
- log.debug("Copying "+source.getAbsolutePath()+" to "+dest.getAbsolutePath());
- BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(dest));
- BufferedInputStream in = new BufferedInputStream(new FileInputStream(source));
- byte[] buf = new byte[1024];
- int count;
- while((count = in.read(buf)) > -1) {
- out.write(buf, 0, count);
- }
- out.flush();
- out.close();
- in.close();
+ if(monitor != null) {
+ monitor.writeStarted(destination.toString());
+ }
+ int total = 0;
+ try {
+ int threshold = TRANSFER_NOTIFICATION_SIZE;
+ BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(dest));
+ BufferedInputStream in = new BufferedInputStream(source);
+ byte[] buf = new byte[TRANSFER_BUF_SIZE];
+ int count;
+ while((count = in.read(buf)) > -1) {
+ out.write(buf, 0, count);
+ if(monitor != null) {
+ total += count;
+ if(total > threshold) {
+ threshold += TRANSFER_NOTIFICATION_SIZE;
+ monitor.writeProgress(total);
+ }
+ }
+ }
+ out.flush();
+ out.close();
+ in.close();
+ } finally {
+ if(monitor != null) {
+ monitor.writeComplete(total);
+ }
+ }
}
public void doStart() throws Exception {
@@ -139,7 +173,7 @@
throw new IllegalStateException("FileSystemRepository must have a root that's a valid writable directory (not "+rootFile.getAbsolutePath()+")");
}
}
- log.info("Repository root is " + rootFile.getAbsolutePath());
+ log.debug("Repository root is " + rootFile.getAbsolutePath());
}
public void doStop() throws Exception {