|
From: <mwl...@us...> - 2009-01-14 22:32:22
|
Revision: 833
http://cishell.svn.sourceforge.net/cishell/?rev=833&view=rev
Author: mwlinnem
Date: 2009-01-14 22:18:44 +0000 (Wed, 14 Jan 2009)
Log Message:
-----------
Does not build. This is a code crime commit.
Added Paths:
-----------
trunk/core/org.cishell.docs/org.cishell.reference.service.database/.classpath
trunk/core/org.cishell.docs/org.cishell.reference.service.database/.project
trunk/core/org.cishell.docs/org.cishell.reference.service.database/.settings/
trunk/core/org.cishell.docs/org.cishell.reference.service.database/META-INF/
trunk/core/org.cishell.docs/org.cishell.reference.service.database/META-INF/MANIFEST.MF
trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/
trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/component.xml
trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/l10n/
trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/l10n/bundle_en.properties
trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/metatype/
trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/metatype/METADATA.XML
trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/service.properties
trunk/core/org.cishell.docs/org.cishell.reference.service.database/build.properties
trunk/core/org.cishell.docs/org.cishell.reference.service.database/src/
trunk/core/org.cishell.docs/org.cishell.reference.service.database/src/org/
trunk/core/org.cishell.docs/org.cishell.reference.service.database/src/org/cishell/
trunk/core/org.cishell.docs/org.cishell.reference.service.database/src/org/cishell/reference/
trunk/core/org.cishell.docs/org.cishell.reference.service.database/src/org/cishell/reference/service/
trunk/core/org.cishell.docs/org.cishell.reference.service.database/src/org/cishell/reference/service/database/
trunk/core/org.cishell.docs/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DatabaseServiceImpl.java
Added: trunk/core/org.cishell.docs/org.cishell.reference.service.database/.classpath
===================================================================
--- trunk/core/org.cishell.docs/org.cishell.reference.service.database/.classpath (rev 0)
+++ trunk/core/org.cishell.docs/org.cishell.reference.service.database/.classpath 2009-01-14 22:18:44 UTC (rev 833)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/core/org.cishell.docs/org.cishell.reference.service.database/.project
===================================================================
--- trunk/core/org.cishell.docs/org.cishell.reference.service.database/.project (rev 0)
+++ trunk/core/org.cishell.docs/org.cishell.reference.service.database/.project 2009-01-14 22:18:44 UTC (rev 833)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.cishell.reference.service.database</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/core/org.cishell.docs/org.cishell.reference.service.database/META-INF/MANIFEST.MF
===================================================================
--- trunk/core/org.cishell.docs/org.cishell.reference.service.database/META-INF/MANIFEST.MF (rev 0)
+++ trunk/core/org.cishell.docs/org.cishell.reference.service.database/META-INF/MANIFEST.MF 2009-01-14 22:18:44 UTC (rev 833)
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Database Plug-in
+Bundle-SymbolicName: org.cishell.reference.service.database
+Bundle-Version: 1.0.0
+Bundle-Activator: org.cishell.reference.service.database.DatabaseServiceImpl
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Import-Package: org.apache.commons.dbcp,
+ org.apache.commons.pool,
+ org.apache.commons.pool.impl,
+ org.cishell.service.database,
+ org.osgi.framework;version="1.4.0",
+ org.osgi.service.component;version="1.0.0",
+ org.osgi.service.log;version="1.3.0"
Added: trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/component.xml
===================================================================
--- trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/component.xml (rev 0)
+++ trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/component.xml 2009-01-14 22:18:44 UTC (rev 833)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component name="org.cishell.reference.service.database.DatabaseService.component" immediate="true">
+ <implementation class="org.cishell.reference.service.database.DatabaseServiceImpl.component"/>
+ <properties entry="OSGI-INF/service.properties"/>
+ <reference name="LOG" interface="org.osgi.service.log.LogService"/>
+
+ <service>
+ <provide interface=
+ "org.cishell.service.database.DatabaseService"/>
+ </service>
+</component>
+
+
+
\ No newline at end of file
Added: trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/l10n/bundle_en.properties
===================================================================
--- trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/l10n/bundle_en.properties (rev 0)
+++ trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/l10n/bundle_en.properties 2009-01-14 22:18:44 UTC (rev 833)
@@ -0,0 +1,7 @@
+#Localization variables for OSGI-INF/metatatype/METADATA.XML
+#
+#Samples:
+#input=Input
+#desc=Enter an integer (that will be converted to a string)
+#name=Input->String
+#name_desc=Converts inputted integer to string
Added: trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/metatype/METADATA.XML
===================================================================
--- trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/metatype/METADATA.XML (rev 0)
+++ trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/metatype/METADATA.XML 2009-01-14 22:18:44 UTC (rev 833)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0">
+ <Designate pid="org.cishell.reference.prefs.admin.PrefAdmin">
+ <Object ocdref="org.cishell.reference.prefs.admin.PrefAdmin.OCD" />
+ </Designate>
+</metatype:MetaData>
Added: trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/service.properties
===================================================================
--- trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/service.properties (rev 0)
+++ trunk/core/org.cishell.docs/org.cishell.reference.service.database/OSGI-INF/service.properties 2009-01-14 22:18:44 UTC (rev 833)
@@ -0,0 +1,2 @@
+service.pid=org.cishell.reference.service.database.DatabaseServiceImpl
+remoteable=true
Added: trunk/core/org.cishell.docs/org.cishell.reference.service.database/build.properties
===================================================================
--- trunk/core/org.cishell.docs/org.cishell.reference.service.database/build.properties (rev 0)
+++ trunk/core/org.cishell.docs/org.cishell.reference.service.database/build.properties 2009-01-14 22:18:44 UTC (rev 833)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: trunk/core/org.cishell.docs/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DatabaseServiceImpl.java
===================================================================
--- trunk/core/org.cishell.docs/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DatabaseServiceImpl.java (rev 0)
+++ trunk/core/org.cishell.docs/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DatabaseServiceImpl.java 2009-01-14 22:18:44 UTC (rev 833)
@@ -0,0 +1,95 @@
+package org.cishell.reference.service.database;
+
+import java.sql.SQLException;
+import java.util.Dictionary;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.dbcp.ConnectionFactory;
+import org.apache.commons.dbcp.DriverManagerConnectionFactory;
+import org.apache.commons.dbcp.PoolableConnectionFactory;
+import org.apache.commons.dbcp.PoolingDataSource;
+import org.apache.commons.pool.KeyedObjectPoolFactory;
+import org.apache.commons.pool.impl.GenericKeyedObjectPoolFactory;
+import org.apache.commons.pool.impl.GenericObjectPool;
+import org.cishell.service.database.DatabaseCopyException;
+import org.cishell.service.database.DatabaseCreationException;
+import org.cishell.service.database.DatabaseService;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.log.LogService;
+public class DatabaseServiceImpl implements DatabaseService {
+
+ //TODO: These variables should be abstracted out in a Preferences page at some point (I guess)
+ private static final String DEFAULT_DRIVER_NAME = "org.apache.derby.jdbc.EmbeddedDriver";
+ private static final String DEFAULT_CONNECTION_STRING_PREFIX = "jdbc:derby";
+ private static final String DEFAULT_CONNECTION_STRING_SUFFIX = ";create=true";
+
+ private static final String DEFAULT_DB_NAME = "ultra_sasquatch";
+ //Give each db a unique (but meaningless) name by counting up from 0 for each new database
+ //TODO: Using a rolling counter like this may have bad implications later on, but it's decent for now
+ private static int dbNameCounter = 0;
+
+ private LogService log;
+
+ protected void activate(ComponentContext ctxt) {
+
+ this.log = (LogService) ctxt.locateService("LOG");
+ }
+
+ protected void deactivate(ComponentContext ctxt) {
+ }
+
+ private void ensureConnectionPoolIsEstablished() {
+ try {
+ Class.forName(DEFAULT_DRIVER_NAME);
+
+ String newDatabaseName = DEFAULT_DB_NAME + Integer.toString(dbNameCounter);
+ String newDatabaseConnectionURL = DEFAULT_CONNECTION_STRING_PREFIX +
+ newDatabaseName +
+ DEFAULT_CONNECTION_STRING_SUFFIX;
+
+ ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(newDatabaseConnectionURL, null, null);
+ GenericObjectPool connectionPool = new GenericObjectPool();
+ } catch (ClassNotFoundException e) {
+ throw new AlgorithmExecutionException("Database driver not found: " + driver, e);
+ }
+ }
+
+ public DataSource createDatabase() throws DatabaseCreationException {
+
+ javax.sql.DataSource dataSource;
+
+ try {
+ Class.forName(DEFAULT_DRIVER_NAME);
+ //Driver jdbcDriver = (Driver) Class.forName(driver).newInstance(); //we can use this later to check acceptsUrl for better error reporting
+
+ String newDatabaseName = DEFAULT_DB_NAME + Integer.toString(dbNameCounter);
+ String newDatabaseConnectionURL = DEFAULT_CONNECTION_STRING_PREFIX +
+ newDatabaseName +
+ DEFAULT_CONNECTION_STRING_SUFFIX;
+
+ ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(newDatabaseConnectionURL, null, null);
+ GenericObjectPool connectionPool = new GenericObjectPool();
+ dataSource = new PoolingDataSource(connectionPool);
+
+ try {
+ dataSource.getConnection().close();
+ } catch (SQLException e) {
+ logger.log(LogService.LOG_WARNING, "Problem opening test connection.", e);
+ }
+
+ //prefuseConnection = prefuse.data.io.sql.ConnectionFactory.getDatabaseConnection(connection);
+
+
+
+ } catch (ClassNotFoundException e) {
+ throw new AlgorithmExecutionException("Database driver not found: " + driver, e);
+ }
+ }
+
+ public DataSource copyDatabase(DataSource database) throws DatabaseCopyException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|