1
14
15 package com.liferay.portal.scheduler.quartz;
16
17 import com.liferay.portal.dao.db.DB2DB;
18 import com.liferay.portal.dao.db.HypersonicDB;
19 import com.liferay.portal.dao.db.PostgreSQLDB;
20 import com.liferay.portal.dao.db.SQLServerDB;
21 import com.liferay.portal.dao.db.SybaseDB;
22 import com.liferay.portal.kernel.dao.db.DB;
23 import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
24 import com.liferay.portal.kernel.log.Log;
25 import com.liferay.portal.kernel.log.LogFactoryUtil;
26
27 import org.quartz.impl.jdbcjobstore.DB2v8Delegate;
28 import org.quartz.impl.jdbcjobstore.DriverDelegate;
29 import org.quartz.impl.jdbcjobstore.HSQLDBDelegate;
30 import org.quartz.impl.jdbcjobstore.JobStoreTX;
31 import org.quartz.impl.jdbcjobstore.MSSQLDelegate;
32 import org.quartz.impl.jdbcjobstore.NoSuchDelegateException;
33 import org.quartz.impl.jdbcjobstore.PostgreSQLDelegate;
34 import org.quartz.impl.jdbcjobstore.StdJDBCDelegate;
35
36
41 public class PortalJobStore extends JobStoreTX {
42
43 protected DriverDelegate getDelegate() throws NoSuchDelegateException {
44 if (_driverDelegate != null) {
45 return _driverDelegate;
46 }
47
48 try {
49 Class<?> driverDelegateClass = StdJDBCDelegate.class;
50
51 DB db = DBFactoryUtil.getDB();
52
53 if (db instanceof DB2DB) {
54 driverDelegateClass = DB2v8Delegate.class;
55 }
56 else if (db instanceof HypersonicDB) {
57 driverDelegateClass = HSQLDBDelegate.class;
58 }
59 else if (db instanceof PostgreSQLDB) {
60 driverDelegateClass = PostgreSQLDelegate.class;
61 }
62 else if (db instanceof SQLServerDB) {
63 driverDelegateClass = MSSQLDelegate.class;
64 }
65 else if (db instanceof SybaseDB) {
66 driverDelegateClass = MSSQLDelegate.class;
67 }
68
69 if (_log.isDebugEnabled()) {
70 _log.debug("Instantiating " + driverDelegateClass);
71 }
72
73 setDriverDelegateClass(driverDelegateClass.getName());
74
75 _driverDelegate = super.getDelegate();
76
77 if (_log.isInfoEnabled()) {
78 _log.info(
79 "Using driver delegate " +
80 _driverDelegate.getClass().getName());
81 }
82
83 return _driverDelegate;
84 }
85 catch (NoSuchDelegateException nsde) {
86 throw nsde;
87 }
88 catch (Exception e) {
89 throw new NoSuchDelegateException(e.getMessage());
90 }
91 }
92
93 private static Log _log = LogFactoryUtil.getLog(PortalJobStore.class);
94
95 private DriverDelegate _driverDelegate;
96
97 }