1 /** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one or more 4 * contributor license agreements. See the NOTICE file distributed with 5 * this work for additional information regarding copyright ownership. 6 * The ASF licenses this file to You under the Apache License, Version 2.0 7 * (the "License"); you may not use this file except in compliance with 8 * the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 package org.apache.geronimo.timer.jdbc; 20 21 import java.sql.SQLException; 22 import javax.sql.DataSource; 23 import javax.transaction.TransactionManager; 24 25 import edu.emory.mathcs.backport.java.util.concurrent.Executor; 26 27 import org.apache.geronimo.connector.outbound.ConnectionFactorySource; 28 import org.apache.geronimo.gbean.GBeanInfo; 29 import org.apache.geronimo.gbean.GBeanInfoBuilder; 30 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 31 import org.apache.geronimo.kernel.Kernel; 32 import org.apache.geronimo.timer.PersistentTimer; 33 import org.apache.geronimo.timer.ThreadPooledTimer; 34 import org.apache.geronimo.timer.TransactionalExecutorTaskFactory; 35 36 /** 37 * 38 * 39 * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $ 40 * 41 */ 42 public class JDBCStoreThreadPooledTransactionalTimer extends ThreadPooledTimer { 43 44 public JDBCStoreThreadPooledTransactionalTimer(int repeatCount, 45 TransactionManager transactionManager, 46 ConnectionFactorySource managedConnectionFactoryWrapper, 47 Executor threadPool, 48 Kernel kernel) throws SQLException { 49 super(new TransactionalExecutorTaskFactory(transactionManager, repeatCount), 50 new JDBCWorkerPersistence(kernel.getKernelName(), (DataSource)managedConnectionFactoryWrapper.$getResource(), false), threadPool, transactionManager); 51 } 52 53 54 public static final GBeanInfo GBEAN_INFO; 55 56 static { 57 GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(JDBCStoreThreadPooledTransactionalTimer.class); 58 infoFactory.addInterface(PersistentTimer.class); 59 60 infoFactory.addAttribute("repeatCount", int.class, true); 61 infoFactory.addReference("TransactionManager", TransactionManager.class, NameFactory.TRANSACTION_MANAGER); 62 infoFactory.addReference("ManagedConnectionFactoryWrapper", ConnectionFactorySource.class, NameFactory.JCA_MANAGED_CONNECTION_FACTORY); 63 infoFactory.addReference("ThreadPool", Executor.class, NameFactory.GERONIMO_SERVICE); 64 infoFactory.addAttribute("kernel", Kernel.class, false); 65 66 infoFactory.setConstructor(new String[] {"repeatCount", "TransactionManager", "ManagedConnectionFactoryWrapper", "ThreadPool", "kernel"}); 67 GBEAN_INFO = infoFactory.getBeanInfo(); 68 } 69 70 public static GBeanInfo getGBeanInfo() { 71 return GBEAN_INFO; 72 } 73 }