Author: unico
Date: Thu Oct 21 06:06:08 2004
New Revision: 55222
Added:
cocoon/trunk/lib/optional/excalibur-datasource-1.1.1.jar
- copied unchanged from rev 54676,
cocoon/trunk/src/blocks/databases/lib/excalibur-datasource-1.1.1.jar
cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/DataSourceComponentConnectionProvider.java
Removed:
cocoon/trunk/src/blocks/databases/lib/excalibur-datasource-1.1.1.jar
Modified:
cocoon/trunk/lib/jars.xml
cocoon/trunk/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/trunk/lib/jars.xml
==============================================================================
--- cocoon/trunk/lib/jars.xml (original)
+++ cocoon/trunk/lib/jars.xml Thu Oct 21 06:06:08 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/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/DataSourceComponentConnectionProvider.java
==============================================================================
--- (empty file)
+++
cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/DataSourceComponentConnectionProvider.java
Thu Oct 21 06:06:08 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_ds = (DataSourceComponent)
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/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
==============================================================================
---
cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
(original)
+++
cocoon/trunk/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
Thu Oct 21 06:06:08 2004
@@ -42,12 +42,12 @@
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SimpleTrigger;
import org.quartz.Trigger;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
import org.quartz.impl.DirectSchedulerFactory;
import org.quartz.impl.jdbcjobstore.InvalidConfigurationException;
import org.quartz.impl.jdbcjobstore.JobStoreSupport;
@@ -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 {