From e2d85ef4598dd1f83cb7822c64601047325ecdb0 Mon Sep 17 00:00:00 2001 From: erik Date: Tue, 12 Feb 2008 21:00:03 +0000 Subject: [PATCH] now using JPA annotations. --- trunk/mythtv/ear/pom.xml | 4 ++ trunk/mythtv/monitor/pom.xml | 4 ++ .../main/java/org/wamblee/mythtv/Channel.java | 10 +++ .../java/org/wamblee/mythtv/Recording.java | 25 ++++++- .../java/org/wamblee/timer/TimerBean.java | 7 ++ .../war/src/main/resources/beanRefContext.xml | 1 - .../org.wamblee.mythtv.application.xml | 71 +++++++++++++------ .../org.wamblee.mythtv.hibernate.xml | 16 +++-- trunk/pom.xml | 17 ++++- trunk/support/pom.xml | 2 +- .../main/java/org/wamblee/cache/EhCache.java | 6 +- 11 files changed, 125 insertions(+), 38 deletions(-) diff --git a/trunk/mythtv/ear/pom.xml b/trunk/mythtv/ear/pom.xml index 81746141..a1e1aa80 100644 --- a/trunk/mythtv/ear/pom.xml +++ b/trunk/mythtv/ear/pom.xml @@ -33,6 +33,10 @@ ${project.version} ejb + + org.hibernate + hibernate-entitymanager + diff --git a/trunk/mythtv/monitor/pom.xml b/trunk/mythtv/monitor/pom.xml index 52333044..9c031a2f 100644 --- a/trunk/mythtv/monitor/pom.xml +++ b/trunk/mythtv/monitor/pom.xml @@ -24,6 +24,10 @@ javax.servlet servlet-api + + javax.persistence + persistence-api + log4j log4j diff --git a/trunk/mythtv/monitor/src/main/java/org/wamblee/mythtv/Channel.java b/trunk/mythtv/monitor/src/main/java/org/wamblee/mythtv/Channel.java index 104e3aac..e5ef7047 100644 --- a/trunk/mythtv/monitor/src/main/java/org/wamblee/mythtv/Channel.java +++ b/trunk/mythtv/monitor/src/main/java/org/wamblee/mythtv/Channel.java @@ -16,13 +16,23 @@ 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() { diff --git a/trunk/mythtv/monitor/src/main/java/org/wamblee/mythtv/Recording.java b/trunk/mythtv/monitor/src/main/java/org/wamblee/mythtv/Recording.java index cab43a6b..ca0ab1cb 100644 --- a/trunk/mythtv/monitor/src/main/java/org/wamblee/mythtv/Recording.java +++ b/trunk/mythtv/monitor/src/main/java/org/wamblee/mythtv/Recording.java @@ -19,23 +19,44 @@ package org.wamblee.mythtv; 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() { diff --git a/trunk/mythtv/timer/src/main/java/org/wamblee/timer/TimerBean.java b/trunk/mythtv/timer/src/main/java/org/wamblee/timer/TimerBean.java index 45e6e220..ca910301 100644 --- a/trunk/mythtv/timer/src/main/java/org/wamblee/timer/TimerBean.java +++ b/trunk/mythtv/timer/src/main/java/org/wamblee/timer/TimerBean.java @@ -21,6 +21,10 @@ import javax.ejb.MessageDriven; 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; @@ -36,6 +40,9 @@ import org.wamblee.io.DirectoryMonitor; * */ @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); diff --git a/trunk/mythtv/war/src/main/resources/beanRefContext.xml b/trunk/mythtv/war/src/main/resources/beanRefContext.xml index fff0f4c3..5288aba3 100644 --- a/trunk/mythtv/war/src/main/resources/beanRefContext.xml +++ b/trunk/mythtv/war/src/main/resources/beanRefContext.xml @@ -9,7 +9,6 @@ org.wamblee.mythtv.properties.xml org.wamblee.mythtv.datasource.xml - org.wamblee.mythtv.hibernatemappings.xml org.wamblee.mythtv.hibernate.xml org.wamblee.mythtv.application.xml diff --git a/trunk/mythtv/war/src/main/resources/org.wamblee.mythtv.application.xml b/trunk/mythtv/war/src/main/resources/org.wamblee.mythtv.application.xml index 1017fffa..1a8d0106 100644 --- a/trunk/mythtv/war/src/main/resources/org.wamblee.mythtv.application.xml +++ b/trunk/mythtv/war/src/main/resources/org.wamblee.mythtv.application.xml @@ -2,39 +2,66 @@ - + - ${org.wamblee.mythtv.linkdir} + + ${org.wamblee.mythtv.linkdir} + - + - ${org.wamblee.mythtv.monitordir} + + ${org.wamblee.mythtv.monitordir} + - + - ^[a-zA-Z0-9-_]*.mpg$ + + ^[a-zA-Z0-9-_]*.mpg$ + - - + + - + init-method="init"> + + + - - - ${org.wamblee.mythtv.monitordir} - - + + + + + + ${org.wamblee.mythtv.monitordir} + + + + + + + + + - + - - - + + + + + + + + + - + - ${org.wamblee.mythtv.pollinterval} + + ${org.wamblee.mythtv.pollinterval} + - + diff --git a/trunk/mythtv/war/src/main/resources/org.wamblee.mythtv.hibernate.xml b/trunk/mythtv/war/src/main/resources/org.wamblee.mythtv.hibernate.xml index 4d34ac8d..03a664af 100644 --- a/trunk/mythtv/war/src/main/resources/org.wamblee.mythtv.hibernate.xml +++ b/trunk/mythtv/war/src/main/resources/org.wamblee.mythtv.hibernate.xml @@ -5,7 +5,7 @@ - + @@ -19,8 +19,11 @@ - - + + + org.wamblee.mythtv.Channel + org.wamblee.mythtv.Recording + + + +