OSDN Git Service

springのDAO機能を使用するための準備
authorsenju <senju@users.sourceforge.jp>
Sat, 22 Aug 2009 07:02:25 +0000 (16:02 +0900)
committersenju <senju@users.sourceforge.jp>
Sat, 22 Aug 2009 07:02:25 +0000 (16:02 +0900)
PMFの生成をspringで。
既存のPMFクラスとの互換性維持のための場当たり的ハック。

.classpath
src/jp/sourceforge/rabbitBTS/PMF.java
src/jp/sourceforge/rabbitBTS/PMFSupport.java [new file with mode: 0644]
war/WEB-INF/rabbitBTS-servlet.xml

index 1d521d5..d7f892c 100644 (file)
@@ -16,5 +16,6 @@
        <classpathentry kind="lib" path="war/WEB-INF/lib/spring-web.jar"/>
        <classpathentry kind="lib" path="war/WEB-INF/lib/aopalliance.jar"/>
        <classpathentry kind="lib" path="war/WEB-INF/lib/commons-lang-2.4.jar"/>
+       <classpathentry kind="lib" path="war/WEB-INF/lib/spring-orm.jar"/>
        <classpathentry kind="output" path="war/WEB-INF/classes"/>
 </classpath>
index b2b0fa4..ddcf7fa 100644 (file)
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-*/
-
+ */
 
 package jp.sourceforge.rabbitBTS;
 
-import javax.jdo.JDOHelper;
 import javax.jdo.PersistenceManagerFactory;
 
 public final class PMF {
-       private static final PersistenceManagerFactory pmfInstance = JDOHelper
-                       .getPersistenceManagerFactory("transactions-optional");
+       // private static final PersistenceManagerFactory pmfInstance = JDOHelper
+       // .getPersistenceManagerFactory("transactions-optional");
 
        private PMF() {
        };
 
        public static PersistenceManagerFactory get() {
-               return pmfInstance;
+               return PMFSupport.getPmf();
        }
 }
diff --git a/src/jp/sourceforge/rabbitBTS/PMFSupport.java b/src/jp/sourceforge/rabbitBTS/PMFSupport.java
new file mode 100644 (file)
index 0000000..ab0095a
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+   Copyright 2009 senju@users.sourceforge.jp
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+
+package jp.sourceforge.rabbitBTS;
+
+import javax.jdo.PersistenceManagerFactory;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * 一時的に実装するクラス。
+ * 
+ * TODO:DAO化が完了したら削除されるべき
+ */
+public class PMFSupport {
+       private static PersistenceManagerFactory pmf;
+
+       /**
+        * @return the pmf
+        */
+       public static PersistenceManagerFactory getPmf() {
+               return pmf;
+       }
+
+       /**
+        * @param pmf
+        *            the pmf to set
+        */
+       @Autowired
+       public void setPmf(PersistenceManagerFactory pmf) {
+               PMFSupport.pmf = pmf;
+       }
+
+}
index 6e58414..6cb06aa 100644 (file)
                <property name="mappedName"> <value>index</value> </property> </bean>
        -->
 
+       <!-- DAO -->
+       <bean id="persistenceManagerFactory"
+               class="org.springframework.orm.jdo.LocalPersistenceManagerFactoryBean">
+               <property name="persistenceManagerFactoryName" value="transactions-optional" />
+       </bean>
+       
+       <bean class="jp.sourceforge.rabbitBTS.PMFSupport" />
+
 </beans>