]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Improve JCR DAO
authorMathieu Baudier <mbaudier@argeo.org>
Mon, 22 Feb 2010 09:44:55 +0000 (09:44 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Mon, 22 Feb 2010 09:44:55 +0000 (09:44 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@3382 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

demo/agent.properties
demo/pom.xml
demo/site/org.argeo.slc.demo.minimal/slc/main.xml
eclipse/plugins/org.argeo.slc.ide.ui/src/main/java/org/argeo/slc/ide/ui/launch/osgi/OsgiBootEquinoxLaunchConfiguration.java
modules/server/org.argeo.slc.server.hibernate/META-INF/spring/db-osgi.xml
modules/server/org.argeo.slc.server.jcr/META-INF/MANIFEST.MF
modules/server/org.argeo.slc.server.jcr/META-INF/spring/jcr-osgi.xml [new file with mode: 0644]
modules/server/org.argeo.slc.server.jcr/META-INF/spring/jcr.xml [new file with mode: 0644]
runtime/org.argeo.slc.support.jcr/build.properties
runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/SlcExecutionDaoJcr.java

index 52e27bcfdde72ff2ac39714cad4eca1c24017a17..7bc17a29fd6f4dc378150dc24202c68b8ac73c2b 100644 (file)
@@ -2,5 +2,6 @@ argeo.osgi.start=\
 org.springframework.osgi.extender,\
 org.argeo.slc.support.equinox,\
 org.argeo.slc.agent,\
-org.argeo.slc.agent.jmx
-com.sun.management.jmxremote=
+org.argeo.slc.agent.jms
+#org.argeo.slc.agent.jmx
+#com.sun.management.jmxremote=
index 5859b72068e08128cfcba954db054e86d31e0461..d3a3da7595a91159cd1d48ce89c5bbf0c101d93d 100644 (file)
@@ -42,6 +42,7 @@
                                                                        org.springframework.osgi.extender,
                                                                        org.argeo.server.ads.server,
                                                                        org.argeo.slc.server.hsqldb,
+                                                                       org.argeo.slc.server.jcr,
                                                                        org.argeo.slc.server.main,
                                                                        org.argeo.slc.ria
                                                                </argeo.osgi.start>
index e0e35d0723321225398d76259bcc7de59d528ad6..3ae5293312e75811b65053a352342822fc6f1024 100644 (file)
@@ -4,7 +4,7 @@
        xmlns:aop="http://www.springframework.org/schema/aop"\r
        xsi:schemaLocation="\r
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"><!--\r
 \r
        <bean id="main" class="org.argeo.slc.core.execution.DefaultExecutionFlow">\r
                <property name="executables">\r
@@ -14,4 +14,4 @@
                </property>\r
        </bean>\r
 \r
-</beans>
\ No newline at end of file
+--></beans>
\ No newline at end of file
index e619e44f13fa89354ac1b5c4ced5f3e4c7092a8e..cbd84cbe75bf3ee3b3b48654c6e56b03ba2b40f7 100644 (file)
@@ -36,8 +36,8 @@ public class OsgiBootEquinoxLaunchConfiguration extends
                IFile propertiesFile = (IFile) configuration.getMappedResources()[0];
                propertiesFile.getParent().refreshLocal(IResource.DEPTH_INFINITE,
                                monitor);
-//             propertiesFile.getProject().refreshLocal(IResource.DEPTH_INFINITE,
-//                             monitor);
+               // propertiesFile.getProject().refreshLocal(IResource.DEPTH_INFINITE,
+               // monitor);
        }
 
        @Override
@@ -83,6 +83,14 @@ public class OsgiBootEquinoxLaunchConfiguration extends
                wc.doSave();
 
                super.preLaunchCheck(configuration, launch, monitor);
+
+               // Note that if a Java project contains a build.properties it has to
+               // declare the sources otherwise it will be skipped in the generation of
+               // the dev.properties file!
+
+               // for(Object bundleId:fAllBundles.keySet()){
+               // System.out.println(bundleId+"="+fAllBundles.get(bundleId));
+               // }
        }
 
 }
index 381fae8648ad43fce3bea01a4a132ae22bb7d095..d17489ba397c25072e2f5d8694b85f72444812bb 100644 (file)
@@ -6,14 +6,15 @@
        http://www.springframework.org/schema/beans   \r
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
 \r
+       <service interface="org.argeo.slc.dao.process.SlcExecutionDao"\r
+               ref="slcExecutionDao" />\r
+\r
        <service interface="org.argeo.slc.dao.test.tree.TreeTestResultDao"\r
                ref="testResultDao" />\r
        <service interface="org.argeo.slc.dao.test.tree.TreeTestResultCollectionDao"\r
                ref="testResultCollectionDao" />\r
        <service interface="org.argeo.slc.dao.test.TestRunDescriptorDao"\r
                ref="testRunDescriptorDao" />\r
-       <service interface="org.argeo.slc.dao.process.SlcExecutionDao"\r
-               ref="slcExecutionDao" />\r
        <service interface="org.argeo.slc.dao.runtime.SlcAgentDescriptorDao"\r
                ref="slcAgentDescriptorDao" />\r
 \r
index 4b2524ddf5caf179d72da13aaf301ab90f338bef..01f56609147e7ec4d602f3d9b09d04e7c802488e 100644 (file)
@@ -2,3 +2,13 @@ Manifest-Version: 1.0
 Bundle-Version: 0.12.2.SNAPSHOT
 Bundle-SymbolicName: org.argeo.slc.server.jcr
 Bundle-Name: Server JCR
+Import-Package: javax.jcr,
+ org.argeo.jcr,
+ org.argeo.server.jackrabbit,
+ org.argeo.slc.core.execution,
+ org.argeo.slc.dao.process,
+ org.argeo.slc.execution,
+ org.argeo.slc.jcr.dao,
+ org.argeo.slc.process,
+ org.springframework.beans.factory.config,
+ org.springframework.osgi.util
diff --git a/modules/server/org.argeo.slc.server.jcr/META-INF/spring/jcr-osgi.xml b/modules/server/org.argeo.slc.server.jcr/META-INF/spring/jcr-osgi.xml
new file mode 100644 (file)
index 0000000..f47df14
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
+       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+       http://www.springframework.org/schema/beans   \r
+       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <service interface="org.argeo.slc.dao.process.SlcExecutionDao"\r
+               ref="slcExecutionDao" />\r
+               <!-- \r
+       <service interface="org.argeo.slc.dao.test.tree.TreeTestResultDao"\r
+               ref="testResultDao" />\r
+       <service interface="org.argeo.slc.dao.test.tree.TreeTestResultCollectionDao"\r
+               ref="testResultCollectionDao" />\r
+       <service interface="org.argeo.slc.dao.test.TestRunDescriptorDao"\r
+               ref="testRunDescriptorDao" />\r
+       <service interface="org.argeo.slc.dao.runtime.SlcAgentDescriptorDao"\r
+               ref="slcAgentDescriptorDao" />\r
+\r
+       <reference id="sessionFactory" interface="org.hibernate.SessionFactory" />\r
+ -->\r
+</beans:beans>
\ No newline at end of file
diff --git a/modules/server/org.argeo.slc.server.jcr/META-INF/spring/jcr.xml b/modules/server/org.argeo.slc.server.jcr/META-INF/spring/jcr.xml
new file mode 100644 (file)
index 0000000..ecba7b5
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <bean\r
+               class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">\r
+               <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />\r
+               <property name="ignoreUnresolvablePlaceholders" value="true" />\r
+       </bean>\r
+\r
+       <bean id="beanNodeMapper" class="org.argeo.jcr.BeanNodeMapper">\r
+               <property name="classLoader">\r
+                       <bean class="org.springframework.osgi.util.BundleDelegatingClassLoader"\r
+                               factory-method="createBundleClassLoaderFor">\r
+                               <constructor-arg>\r
+                                       <bean factory-bean="bundleContext" factory-method="getBundle" />\r
+                               </constructor-arg>\r
+                       </bean>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="slcExecutionDao" class="org.argeo.slc.jcr.dao.SlcExecutionDaoJcr"\r
+               init-method="init">\r
+               <property name="session" ref="argeo.jcr.session.inMemory" />\r
+               <property name="beanNodeMapper" ref="beanNodeMapper"/>\r
+       </bean>\r
+\r
+       <bean id="argeo.jcr.session.inMemory" factory-bean="argeo.jcr.repository.inMemory"\r
+               factory-method="login" destroy-method="logout">\r
+               <constructor-arg>\r
+                       <bean class="javax.jcr.SimpleCredentials">\r
+                               <constructor-arg value="demo" />\r
+                               <constructor-arg value="demo" />\r
+                       </bean>\r
+               </constructor-arg>\r
+       </bean>\r
+\r
+       <bean id="argeo.jcr.repository.inMemory" class="org.argeo.server.jackrabbit.JackrabbitContainer">\r
+               <property name="homeDirectory" value="${java.io.tmpdir}/jackrabbit-slc-unit" />\r
+               <property name="configuration"\r
+                       value="classpath:/org/argeo/server/jackrabbit/repository-inMemory.xml" />\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
index ba373b6d7f0eb3d9ce1f34607dea7bdf0e47b01d..db3216bdb687a2c48dff81136e7ea0a737b33d0d 100644 (file)
@@ -5,4 +5,8 @@ additional.bundles = org.springframework.core,\
                      org.argeo.slc.support.castor,\
                      com.springsource.javax.xml.stream,\
                      com.springsource.org.apache.xerces
+source.. = src/main/java/,\
+           src/main/resources/,\
+           src/test/java/,\
+           src/test/resources/
                      
\ No newline at end of file
index f57102d324c982712dc652fbebe9874d40b47c24..2cc32b0a3bf7406dfdd5f782a370d407041f9fdb 100644 (file)
@@ -15,6 +15,8 @@ import javax.jcr.query.Query;
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.argeo.jcr.BeanNodeMapper;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.SlcException;
@@ -23,6 +25,7 @@ import org.argeo.slc.process.SlcExecution;
 import org.argeo.slc.process.SlcExecutionStep;
 
 public class SlcExecutionDaoJcr implements SlcExecutionDao {
+       private final static Log log = LogFactory.getLog(SlcExecutionDaoJcr.class);
        private Session session;
        private Workspace workspace;
        private QueryManager queryManager;
@@ -48,6 +51,9 @@ public class SlcExecutionDaoJcr implements SlcExecutionDao {
        }
 
        public void create(SlcExecution slcExecution) {
+               if (log.isDebugEnabled())
+                       log.debug("create");
+
                try {
                        beanNodeMapper.save(getSession(), basePath(slcExecution),
                                        slcExecution);
@@ -66,6 +72,9 @@ public class SlcExecutionDaoJcr implements SlcExecutionDao {
        }
 
        public SlcExecution getSlcExecution(String uuid) {
+               if (log.isDebugEnabled())
+                       log.debug("getSlcExecution");
+
                try {
                        // TODO: optimize query
                        String queryString = "//process[@uuid='" + uuid + "']";
@@ -80,6 +89,9 @@ public class SlcExecutionDaoJcr implements SlcExecutionDao {
        }
 
        public List<SlcExecution> listSlcExecutions() {
+               if (log.isDebugEnabled())
+                       log.debug("listSlcExecutions");
+               
                List<SlcExecution> res = new ArrayList<SlcExecution>();
                // TODO: optimize query
                String queryString = "//process";
@@ -104,6 +116,9 @@ public class SlcExecutionDaoJcr implements SlcExecutionDao {
        }
 
        public void update(SlcExecution slcExecution) {
+               if (log.isDebugEnabled())
+                       log.debug("update");
+
                // TODO: optimize query
                String queryString = "//process[@uuid='" + slcExecution.getUuid()
                                + "']";
@@ -111,6 +126,7 @@ public class SlcExecutionDaoJcr implements SlcExecutionDao {
                        Query query = queryManager.createQuery(queryString, Query.XPATH);
                        Node node = JcrUtils.querySingleNode(query);
                        beanNodeMapper.update(node, slcExecution);
+                       session.save();
                } catch (Exception e) {
                        throw new SlcException("Cannot update " + slcExecution, e);
                }