Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 31596 invoked from network); 11 Nov 2005 05:06:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Nov 2005 05:06:43 -0000 Received: (qmail 11237 invoked by uid 500); 11 Nov 2005 05:06:42 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 11227 invoked by uid 500); 11 Nov 2005 05:06:42 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 11216 invoked by uid 99); 11 Nov 2005 05:06:41 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Nov 2005 21:06:41 -0800 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 10 Nov 2005 21:06:33 -0800 Received: (qmail 31212 invoked by uid 65534); 11 Nov 2005 05:06:19 -0000 Message-ID: <20051111050619.31210.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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... Date: Fri, 11 Nov 2005 05:06:17 -0000 To: scm@geronimo.apache.org From: ammulder@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 @@

Create Database Pool -- Step 2: Select Driver, JAR, Parameters

-
+ @@ -40,13 +40,14 @@ - - The JAR holding the selected JDBC driver. Should be installed under GERONIMO/repository/ + The JAR holding the selected JDBC driver. Should be installed under GERONIMO/repository/ (or + ) + 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"%> + + +

Create Database Pool -- Step 2: Select Driver, JAR, Parameters

+ +

This page lets you automatically download a driver for a database where the +driver JARs are available online without login or registration.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Select Driver:
+ +
A driver that Geronimo can download automatically for you.
+ + +
+ + + +<%-- +

+ + ">Select predefined database

+

+ + ">Select "other" database

+--%> + +

+ + ">Return to List

+ +




Here are some other JDBC drivers you might want to download on your own (just save them somewhere under geronimo/repository/):

+ \ 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 {