cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From un...@apache.org
Subject svn commit: rev 55218 - in cocoon/branches/BRANCH_2_1_X: lib lib/optional src/blocks/cron/java/org/apache/cocoon/components/cron src/blocks/databases/lib
Date Thu, 21 Oct 2004 12:51:50 GMT
Author: unico
Date: Thu Oct 21 05:51:49 2004
New Revision: 55218

Added:
   cocoon/branches/BRANCH_2_1_X/lib/optional/excalibur-datasource-1.1.1.jar
      - copied unchanged from rev 54675, cocoon/branches/BRANCH_2_1_X/src/blocks/databases/lib/excalibur-datasource-1.1.1.jar
   cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/DataSourceComponentConnectionProvider.java
Removed:
   cocoon/branches/BRANCH_2_1_X/src/blocks/databases/lib/excalibur-datasource-1.1.1.jar
Modified:
   cocoon/branches/BRANCH_2_1_X/lib/jars.xml
   cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
Log:
ability to use an excalibur DataSourceComponent as the ConnectionProvider 
for the QuartzJobScheduler's JobStore

Modified: cocoon/branches/BRANCH_2_1_X/lib/jars.xml
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/lib/jars.xml	(original)
+++ cocoon/branches/BRANCH_2_1_X/lib/jars.xml	Thu Oct 21 05:51:49 2004
@@ -42,7 +42,7 @@
       support high level server development. 
     </description>
     <used-by>Cocoon</used-by>
-    <lib>databases/lib/excalibur-datasource-1.1.1.jar</lib>
+    <lib>optional/excalibur-datasource-1.1.1.jar</lib>
     <homepage>http://avalon.apache.org/excalibur/</homepage>
   </file>
 

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/DataSourceComponentConnectionProvider.java
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/DataSourceComponentConnectionProvider.java
Thu Oct 21 05:51:49 2004
@@ -0,0 +1,64 @@
+/*
+ * Copyright 1999-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.cocoon.components.cron;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import org.apache.avalon.excalibur.datasource.DataSourceComponent;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.quartz.utils.ConnectionProvider;
+
+/**
+ * Quartz database connection provider that uses the 
+ * Excalibur DataSourceComponent service.
+ */
+public class DataSourceComponentConnectionProvider implements ConnectionProvider {
+
+    private ServiceManager m_manager;
+    private DataSourceComponent m_ds;
+
+    public DataSourceComponentConnectionProvider(String dsName, ServiceManager manager) throws
ConfigurationException {
+        m_manager = manager;
+        try {
+            m_manager.lookup(DataSourceComponent.ROLE + "/" + dsName);            
+        }
+        catch (ServiceException e) {
+            throw new ConfigurationException("No datasource available by that name: " + dsName);
+        }
+    }
+
+    /*
+     * @see org.quartz.utils.ConnectionProvider#getConnection()
+     */
+    public Connection getConnection() throws SQLException {
+        return m_ds.getConnection();
+    }
+
+    /*
+     * @see org.quartz.utils.ConnectionProvider#shutdown()
+     */
+    public void shutdown() throws SQLException {
+        if (m_ds != null) {
+            m_manager.release(m_ds);
+        }
+        m_ds = null;
+        m_manager = null;
+    }
+
+}

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
Thu Oct 21 05:51:49 2004
@@ -734,6 +734,8 @@
         ConnectionProvider provider;
         if (dsType.equals("jndi")) {
             provider = new JNDIConnectionProvider(dsName, false);
+        } else if (dsType.equals("excalibur")) {
+            provider = new DataSourceComponentConnectionProvider(dsName, this.manager);
         } else {
             // assume class name
             try {

Mime
View raw message