<version>${project.version}</version>
<type>ejb</type>
</dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ </dependency>
</dependencies>
<build>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ </dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
package org.wamblee.mythtv;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
/**
*
*/
+@Entity
+@Table(name="channel")
public class Channel {
+ @Id
+ @Column(name="chanid")
private int _id;
+ @Column(name="name")
private String _name;
protected Channel() {
import java.io.Serializable;
import java.util.Date;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
/**
*
*/
+@Entity
+@Table(name="recorded")
+//@IdClass(RecordingPk.class)
public class Recording implements Serializable {
+ //@Id
+ @ManyToOne(targetEntity=Channel.class)
+ @JoinColumn(name="chanid")
private Channel _channel;
+ @Id
+ @Column(name="starttime")
private Date _starttime;
-
+ @Column(name="basename")
private String _basename;
+ @Column(name="progstart")
private Date _progstart;
-
+
+ @Column(name="title")
private String _title;
+ @Column(name="subtitle")
private String _subtitle;
+ @Column(name="filesize")
private long _filesize;
protected Recording() {
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.ejb.TimerService;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
*
*/
@MessageDriven(name = "MythtvTimer")
+// Spring's JTA transaction manager does not work with container managed transactions
+// because it uses the UserTransaction object which glassfish forbids.
+@TransactionManagement(TransactionManagementType.BEAN)
public class TimerBean implements MessageListener {
private static final Log LOG = LogFactory.getLog(TimerBean.class);
<list>
<value>org.wamblee.mythtv.properties.xml</value>
<value>org.wamblee.mythtv.datasource.xml</value>
- <value>org.wamblee.mythtv.hibernatemappings.xml</value>
<value>org.wamblee.mythtv.hibernate.xml</value>
<value>org.wamblee.mythtv.application.xml</value>
</list>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
-
+
<bean id="linkDir" class="java.io.File">
- <constructor-arg><value>${org.wamblee.mythtv.linkdir}</value></constructor-arg>
+ <constructor-arg>
+ <value>${org.wamblee.mythtv.linkdir}</value>
+ </constructor-arg>
</bean>
-
+
<bean id="monitorDir" class="java.io.File">
- <constructor-arg><value>${org.wamblee.mythtv.monitordir}</value></constructor-arg>
+ <constructor-arg>
+ <value>${org.wamblee.mythtv.monitordir}</value>
+ </constructor-arg>
</bean>
-
+
<bean id="fileFilter" class="org.apache.oro.io.AwkFilenameFilter">
- <constructor-arg><value>^[a-zA-Z0-9-_]*.mpg$</value></constructor-arg>
+ <constructor-arg>
+ <value>^[a-zA-Z0-9-_]*.mpg$</value>
+ </constructor-arg>
</bean>
-
-
+
+
<bean id="org.wamblee.mythtv.RecordingDatabase" class="org.wamblee.mythtv.RecordingDatabase"
- init-method="init">
- <property name="hibernateTemplate"><ref bean="hibernateTemplate"/></property>
+ init-method="init">
+ <property name="hibernateTemplate">
+ <ref bean="hibernateTemplate"/>
+ </property>
</bean>
-
- <bean id="org.wamblee.mythtv.LinkStructure" class="org.wamblee.mythtv.LinkStructure">
- <constructor-arg><value>${org.wamblee.mythtv.monitordir}</value></constructor-arg>
- <constructor-arg><ref local="linkDir"/></constructor-arg>
- <constructor-arg><ref local="org.wamblee.mythtv.RecordingDatabase"/></constructor-arg>
+
+ <bean id="org.wamblee.mythtv.LinkStructure"
+ parent="transactionRequiredTemplate">
+ <property name="target">
+ <bean class="org.wamblee.mythtv.LinkStructure">
+ <constructor-arg>
+ <value>${org.wamblee.mythtv.monitordir}</value>
+ </constructor-arg>
+ <constructor-arg>
+ <ref local="linkDir"/>
+ </constructor-arg>
+ <constructor-arg>
+ <ref local="org.wamblee.mythtv.RecordingDatabase"/>
+ </constructor-arg>
+ </bean>
+ </property>
</bean>
-
+
<bean id="org.wamblee.io.DirectoryMonitor" class="org.wamblee.io.DirectoryMonitor">
- <constructor-arg><ref local="monitorDir"/></constructor-arg>
- <constructor-arg><ref local="fileFilter"/></constructor-arg>
- <constructor-arg><ref local="org.wamblee.mythtv.LinkStructure"/></constructor-arg>
+ <constructor-arg>
+ <ref local="monitorDir"/>
+ </constructor-arg>
+ <constructor-arg>
+ <ref local="fileFilter"/>
+ </constructor-arg>
+ <constructor-arg>
+ <ref local="org.wamblee.mythtv.LinkStructure"/>
+ </constructor-arg>
</bean>
-
+
<bean id="org.wamblee.mythtv.ScheduleConfig" class="org.wamblee.mythtv.ScheduleConfig">
- <constructor-arg><value>${org.wamblee.mythtv.pollinterval}</value></constructor-arg>
+ <constructor-arg>
+ <value>${org.wamblee.mythtv.pollinterval}</value>
+ </constructor-arg>
</bean>
-</beans>
+</beans>
<!-- bean id="namingStrategy" class="nl.jmonks.system.hibernate.JMonksNamingStrategy"> </bean -->
- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+ <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<!-- prop key="hibernate.connection.release_mode">after_statement</prop -->
</props>
</property>
- <property name="mappingResources">
- <ref bean="hibernateMappingFiles"/>
+ <property name="annotatedClasses">
+ <list>
+ <value>org.wamblee.mythtv.Channel</value>
+ <value>org.wamblee.mythtv.Recording</value>
+ </list>
</property>
<!-- property name="namingStrategy">
<ref local="namingStrategy"/>
</property>
</bean>
- <bean id="transactionManager"
+ <!-- bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
+ </bean -->
+
+ <bean id="transactionManager"
+ class="org.springframework.transaction.jta.JtaTransactionManager">
+
</bean>
<!-- Abstract bean. Subclass this bean and specify the target property to
</exclusions>\r
</dependency>\r
<dependency>\r
- <groupId>ehcache</groupId>\r
+ <groupId>net.sf.ehcache</groupId>\r
<artifactId>ehcache</artifactId>\r
- <version>1.1</version>\r
+ <version>1.2.3</version>\r
</dependency>\r
<dependency>\r
<groupId>xerces</groupId>\r
<dependency>\r
<groupId>org.hibernate</groupId>\r
<artifactId>hibernate</artifactId>\r
- <version>3.0.5</version>\r
+ <version>3.2.5.ga</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.hibernate</groupId>\r
+ <artifactId>hibernate-entitymanager</artifactId>\r
+ <version>3.3.1.ga</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>javax.persistence</groupId>\r
+ <artifactId>persistence-api</artifactId>\r
+ <version>1.0</version>\r
+ <scope>provided</scope>\r
</dependency>\r
<dependency>\r
<groupId>commons-email</groupId>\r
<artifactId>dom4j</artifactId>
</dependency>
<dependency>
- <groupId>ehcache</groupId>
+ <groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
* @see org.wamblee.cache.Cache#clear()
*/
public void clear() {
- try {
- _cache.removeAll();
- } catch (IOException e) {
- throw new RuntimeException("Problem removing items from cache", e);
- }
+ _cache.removeAll();
}
}