now using JPA annotations.
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Tue, 12 Feb 2008 21:00:03 +0000 (21:00 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Tue, 12 Feb 2008 21:00:03 +0000 (21:00 +0000)
trunk/mythtv/ear/pom.xml
trunk/mythtv/monitor/pom.xml
trunk/mythtv/monitor/src/main/java/org/wamblee/mythtv/Channel.java
trunk/mythtv/monitor/src/main/java/org/wamblee/mythtv/Recording.java
trunk/mythtv/timer/src/main/java/org/wamblee/timer/TimerBean.java
trunk/mythtv/war/src/main/resources/beanRefContext.xml
trunk/mythtv/war/src/main/resources/org.wamblee.mythtv.application.xml
trunk/mythtv/war/src/main/resources/org.wamblee.mythtv.hibernate.xml
trunk/pom.xml
trunk/support/pom.xml
trunk/support/src/main/java/org/wamblee/cache/EhCache.java

index 8174614155b1d1336d7fa7d9bf51e44415a4bfcb..a1e1aa802fa1c29fc1f35a1ced7115feac4cd8eb 100644 (file)
         <version>${project.version}</version>
         <type>ejb</type>
     </dependency>
+    <dependency>
+        <groupId>org.hibernate</groupId>
+        <artifactId>hibernate-entitymanager</artifactId>
+    </dependency>
   </dependencies>
 
   <build>
index 52333044dfc63826303fcc45569362afdc177c3e..9c031a2fc82f4f78ab9ba78cc648be10a2d0d7ab 100644 (file)
          <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>
index 104e3aac368a8902613a6075da0c7cfd3307e850..e5ef7047039fddf7e312aa2700b32117f8d1d60c 100644 (file)
 
 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() {
index cab43a6b76affb79b3c5b9fe1a5a3bd854154672..ca0ab1cb93ed0b7e6276e60dcadc55b5e5e94841 100644 (file)
@@ -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() {
index 45e6e220fa1c3b968d54f0d616e6fd1538937855..ca9103017dc7dfa7a3c94ad63974123da2df3b02 100644 (file)
@@ -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);
index fff0f4c3fe78a0f627079238372814cba3bb262d..5288aba37e37eb4f5c771664c05efc3fca931c8d 100644 (file)
@@ -9,7 +9,6 @@
              <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>
index 1017fffaece98c48766287cb24f1c536523c0666..1a8d0106d10fe489ff69da6d0c68ef10a3e40f0f 100644 (file)
@@ -2,39 +2,66 @@
 <!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>
index 4d34ac8d70a2a36285bc84b964554574289ab529..03a664affcd18a5b2efab6c4af67f19040eddcd9 100644 (file)
@@ -5,7 +5,7 @@
 
        <!-- 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
index 9654850b84b52aac2ba30073001292c0899ccefb..1fb054a746776b233ffb4783b475013064ac1414 100644 (file)
         </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
index f5791a43feb328d169da0071867e039be57b8c34..83977a67de46ae9d5b7df70b12d9fe8f13d150a2 100644 (file)
@@ -45,7 +45,7 @@
       <artifactId>dom4j</artifactId>
     </dependency>
     <dependency>
-      <groupId>ehcache</groupId>
+      <groupId>net.sf.ehcache</groupId>
       <artifactId>ehcache</artifactId>
     </dependency>
     <dependency>
index ca11ab3f72c71f13aa92341afb6f5ba13fd064e2..0dcb2b7a2fcf3907b8d24e60ed363d64b91c9bcf 100644 (file)
@@ -117,10 +117,6 @@ public class EhCache<KeyType extends Serializable, ValueType extends Serializabl
      * @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();
     }
 }