You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hise-commits@incubator.apache.org by wi...@apache.org on 2010/09/17 09:50:35 UTC

svn commit: r998040 - in /incubator/hise/trunk: hise-bundle/src/main/resources/META-INF/spring/hise-ds.xml hise-bundle/src/main/resources/META-INF/spring/hise.xml hise-services/src/main/java/org/apache/hise/engine/HISEScheduler.java

Author: witek
Date: Fri Sep 17 09:50:35 2010
New Revision: 998040

URL: http://svn.apache.org/viewvc?rev=998040&view=rev
Log:
Scheduler delay configuration

Modified:
    incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise-ds.xml
    incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEScheduler.java

Modified: incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise-ds.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise-ds.xml?rev=998040&r1=998039&r2=998040&view=diff
==============================================================================
--- incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise-ds.xml (original)
+++ incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise-ds.xml Fri Sep 17 09:50:35 2010
@@ -46,6 +46,7 @@
         <prop key="db.testOnBorrow">true</prop>
         <prop key="db.testWhileIdle">true</prop>
         <prop key="db.timeBetweenEvictionRunsMillis">5000</prop>
+        <prop key="scheduler.jobDelaySec">600</prop>
     </osgix:cm-properties>
 
     <ctx:property-placeholder properties-ref="preProps" />

Modified: incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml?rev=998040&r1=998039&r2=998040&view=diff
==============================================================================
--- incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml (original)
+++ incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml Fri Sep 17 09:50:35 2010
@@ -1,7 +1,21 @@
 <?xml version="1.0" encoding="UTF-8"?>
-  <!--
-    ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements. See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership. The ASF licenses this file ~ to you 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.
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
   -->
 <beans xmlns="http://www.springframework.org/schema/beans" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
@@ -28,11 +42,6 @@
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
        http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
-<!--
-  <import resource="classpath:META-INF/cxf/cxf.xml"/>
-  <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
-  <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
--->
     <import resource="classpath:META-INF/cxf/cxf.xml" />
     <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
     <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
@@ -50,40 +59,41 @@
   </bean>
    -->
 
-  <bean id="hiseDao" class="org.apache.hise.dao.HISEDao">
-    <property name="entityManagerFactory" ref="htEntityManagerFactory"/>
-  </bean>
-
-  <bean id="hiseEngine" class="org.apache.hise.engine.HISEEngineImpl">
-    <property name="hiseDao" ref="hiseDao"/>
-    <property name="hiseScheduler" ref="hiseScheduler"/>
-    <property name="hiseUserDetails" ref="hiseUserDetails"/>
-    <property name="peopleQueryProviders">
-        <osgi:list interface="org.apache.hise.api.PeopleQueryProvider" cardinality="0..N"/>
-    </property>
-  </bean>
-
-  <osgi:service id="hiseEngineOsgi" ref="hiseEngine" interface="org.apache.hise.api.HISEEngine" />
+    <bean id="hiseDao" class="org.apache.hise.dao.HISEDao">
+	    <property name="entityManagerFactory" ref="htEntityManagerFactory" />
+    </bean>
+
+	<bean id="hiseEngine" class="org.apache.hise.engine.HISEEngineImpl">
+		<property name="hiseDao" ref="hiseDao" />
+		<property name="hiseScheduler" ref="hiseScheduler" />
+		<property name="hiseUserDetails" ref="hiseUserDetails" />
+		<property name="peopleQueryProviders">
+			<osgi:list interface="org.apache.hise.api.PeopleQueryProvider" cardinality="0..N" />
+		</property>
+	</bean>
+
+	<osgi:service id="hiseEngineOsgi" ref="hiseEngine" interface="org.apache.hise.api.HISEEngine" />
+
+	<bean id="management" class="org.apache.hise.engine.ManagementImpl">
+		<property name="hiseEngine" ref="hiseEngine" />
+		<property name="adminOperations" ref="taskOperationsAdministrative" />
+	</bean>
   
-  <bean id="management" class="org.apache.hise.engine.ManagementImpl">
-  <property name="hiseEngine" ref="hiseEngine"/>
-  <property name="adminOperations" ref="taskOperationsAdministrative"/>
-  </bean>
-  
-  <osgi:service id="managmentOsgi" ref="management" interface="org.apache.hise.api.Management"/>
-  
-  <bean id="hiseUserDetails" class="org.apache.hise.engine.DefaultHISEUserDetails">
-    <property name="hiseDao" ref="hiseDao"/>
-  </bean>
+    <osgi:service id="managmentOsgi" ref="management" interface="org.apache.hise.api.Management"/>
 
-  <bean id="hisePasswordCallback" class="org.apache.hise.engine.HISEPasswordCallback">
-    <property name="hiseUserDetails" ref="hiseUserDetails"/>
-  </bean>
-  
-  <bean id="hiseScheduler" class="org.apache.hise.engine.HISEScheduler" init-method="init" destroy-method="destroy">
-    <property name="hiseEngine" ref="hiseEngine"/>
-    <property name="transactionManager" ref="transactionManager"/>
-  </bean>
+	<bean id="hiseUserDetails" class="org.apache.hise.engine.DefaultHISEUserDetails">
+		<property name="hiseDao" ref="hiseDao" />
+	</bean>
+
+	<bean id="hisePasswordCallback" class="org.apache.hise.engine.HISEPasswordCallback">
+		<property name="hiseUserDetails" ref="hiseUserDetails" />
+	</bean>
+
+	<bean id="hiseScheduler" class="org.apache.hise.engine.HISEScheduler" init-method="init" destroy-method="destroy">
+		<property name="hiseEngine" ref="hiseEngine" />
+		<property name="transactionManager" ref="transactionManager" />
+		<property name="jobDelay" value="${scheduler.jobDelaySec}"/>
+	</bean>
 
   <tx:annotation-driven transaction-manager="transactionManager"/>
 
@@ -92,20 +102,20 @@
   -->
 
   <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
-    <property name="entityManagerFactory" ref="htEntityManagerFactory"/>
-    <property name="dataSource" ref="dataSource"/>
+      <property name="entityManagerFactory" ref="htEntityManagerFactory"/>
+      <property name="dataSource" ref="dataSource"/>
   </bean>
 
   <osgi:service id="transactionManagerOsgi" interface="org.springframework.transaction.PlatformTransactionManager" ref="transactionManager"/>
 
   <bean id="taskOperationsAdministrative" class="org.apache.hise.engine.jaxws.TaskOperationsAdministrativeImpl">
-    <property name="hiseEngine" ref="hiseEngine"/>
-    <property name="administrationMode" value="true"/>
+      <property name="hiseEngine" ref="hiseEngine"/>
+      <property name="administrationMode" value="true"/>
   </bean>
 
   <bean name="taskOperations" class="org.apache.hise.engine.jaxws.TaskOperationsImpl" init-method="init">
-    <property name="hiseEngine" ref="hiseEngine"/>
-        <property name="administrationMode" value="false"/>
+      <property name="hiseEngine" ref="hiseEngine"/>
+      <property name="administrationMode" value="false"/>
   </bean>
 
   <jaxws:endpoint id="taskOperationsEndpoint" name="taskOperationsEndpoint" address="/taskOperations/" implementor="#taskOperations" serviceName="htdaw:taskOperations" publish="true" wsdlLocation="classpath:ws-humantask.wsdl">

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEScheduler.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEScheduler.java?rev=998040&r1=998039&r2=998040&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEScheduler.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEScheduler.java Fri Sep 17 09:50:35 2010
@@ -41,17 +41,22 @@ import org.springframework.transaction.s
  */
 public class HISEScheduler {
     
-    private static final Log log = LogFactory.getLog(HISEScheduler.class);
+    private final Log log = LogFactory.getLog(HISEScheduler.class);
     
+    //TODO use interface?
     private HISEEngineImpl hiseEngine;
     private ScheduledExecutorService executor;
     private PlatformTransactionManager transactionManager;
     
-    public void setTransactionManager(PlatformTransactionManager transactionManager) {
-        this.transactionManager = transactionManager;
-    }
-
+    /**
+     * Delay the delay between the termination of one
+     * execution and the commencement of the next. In seconds.
+     */
+    private int jobDelay = 60;
+    
     private class CheckJobs implements Runnable {
+    	
+    	private final Log log = LogFactory.getLog(CheckJobs.class);
 
         public void run() {
             final Date currentEventDateTime = Calendar.getInstance().getTime();
@@ -96,16 +101,7 @@ public class HISEScheduler {
     
     public void init() {
         executor = Executors.newSingleThreadScheduledExecutor();
-        executor.scheduleWithFixedDelay(new CheckJobs(), 1000, 1000, TimeUnit.MILLISECONDS);
-    }
-    
-    
-    public HISEEngineImpl getHiseEngine() {
-        return hiseEngine;
-    }
-
-    public void setHiseEngine(HISEEngineImpl hiseEngine) {
-        this.hiseEngine = hiseEngine;
+        executor.scheduleWithFixedDelay(new CheckJobs(), 1, jobDelay, TimeUnit.SECONDS);
     }
     
     public Job createJob(Date when, String action, Task task) {
@@ -117,8 +113,31 @@ public class HISEScheduler {
         return job;
     }
     
-
     public void destroy() {
         executor.shutdown();
     }
+    
+    /**
+     * IoC setter.
+     * @param hiseEngine
+     */
+    public void setHiseEngine(HISEEngineImpl hiseEngine) {
+        this.hiseEngine = hiseEngine;
+    }
+    
+    /**
+     * IoC setter.
+     * @param transactionManager
+     */
+    public void setTransactionManager(PlatformTransactionManager transactionManager) {
+        this.transactionManager = transactionManager;
+    }
+    
+    /**
+     * IoC setter.
+     * @param jobDelay
+     */
+    public void setJobDelay(int jobDelay) {
+        this.jobDelay = jobDelay;
+    }
 }