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