001
014
015 package com.liferay.portal.scheduler.quartz;
016
017 import com.liferay.portal.kernel.dao.db.DB;
018 import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
019 import com.liferay.portal.kernel.log.Log;
020 import com.liferay.portal.kernel.log.LogFactoryUtil;
021
022 import org.quartz.impl.jdbcjobstore.DB2v8Delegate;
023 import org.quartz.impl.jdbcjobstore.DriverDelegate;
024 import org.quartz.impl.jdbcjobstore.HSQLDBDelegate;
025 import org.quartz.impl.jdbcjobstore.JobStoreTX;
026 import org.quartz.impl.jdbcjobstore.MSSQLDelegate;
027 import org.quartz.impl.jdbcjobstore.NoSuchDelegateException;
028 import org.quartz.impl.jdbcjobstore.PostgreSQLDelegate;
029 import org.quartz.impl.jdbcjobstore.StdJDBCDelegate;
030
031
034 public class PortalJobStore extends JobStoreTX {
035
036 @Override
037 protected DriverDelegate getDelegate() throws NoSuchDelegateException {
038 if (_driverDelegate != null) {
039 return _driverDelegate;
040 }
041
042 try {
043 Class<?> driverDelegateClass = StdJDBCDelegate.class;
044
045 DB db = DBFactoryUtil.getDB();
046
047 String dbType = db.getType();
048
049 if (dbType.equals(DB.TYPE_DB2)) {
050 driverDelegateClass = DB2v8Delegate.class;
051 }
052 else if (dbType.equals(DB.TYPE_HYPERSONIC)) {
053 driverDelegateClass = HSQLDBDelegate.class;
054 }
055 else if (dbType.equals(DB.TYPE_POSTGRESQL)) {
056 driverDelegateClass = PostgreSQLDelegate.class;
057 }
058 else if (dbType.equals(DB.TYPE_SQLSERVER)) {
059 driverDelegateClass = MSSQLDelegate.class;
060 }
061 else if (dbType.equals(DB.TYPE_SYBASE)) {
062 driverDelegateClass = SybaseDelegate.class;
063 }
064
065 if (_log.isDebugEnabled()) {
066 _log.debug("Instantiating " + driverDelegateClass);
067 }
068
069 setDriverDelegateClass(driverDelegateClass.getName());
070
071 _driverDelegate = super.getDelegate();
072
073 if (_log.isInfoEnabled()) {
074 _log.info(
075 "Using driver delegate " +
076 _driverDelegate.getClass().getName());
077 }
078
079 return _driverDelegate;
080 }
081 catch (NoSuchDelegateException nsde) {
082 throw nsde;
083 }
084 catch (Exception e) {
085 throw new NoSuchDelegateException(e.getMessage());
086 }
087 }
088
089 private static Log _log = LogFactoryUtil.getLog(PortalJobStore.class);
090
091 private DriverDelegate _driverDelegate;
092
093 }