You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2014/01/02 16:33:08 UTC
svn commit: r1554832 - in /syncope/trunk: ./ core/
core/src/main/java/org/apache/syncope/core/init/
core/src/main/java/org/apache/syncope/core/quartz/ core/src/main/resources/
core/src/test/java/org/apache/syncope/core/rest/ core/src/test/resources/
co...
Author: ilgrosso
Date: Thu Jan 2 15:33:08 2014
New Revision: 1554832
URL: http://svn.apache.org/r1554832
Log:
[SYNCOPE-460] Merge from 1_1_X
Modified:
syncope/trunk/ (props changed)
syncope/trunk/core/pom.xml
syncope/trunk/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/quartz/AbstractTaskJob.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/quartz/SpringBeanJobFactory.java
syncope/trunk/core/src/main/resources/persistence.properties
syncope/trunk/core/src/main/resources/persistenceContext.xml
syncope/trunk/core/src/main/resources/schedulingContext.xml
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
syncope/trunk/core/src/test/resources/mysql/persistence.properties
syncope/trunk/core/src/test/resources/oracle/persistence.properties
syncope/trunk/core/src/test/resources/persistence.properties
syncope/trunk/core/src/test/resources/postgres/persistence.properties
syncope/trunk/core/src/test/resources/sqlserver/persistence.properties
syncope/trunk/pom.xml
Propchange: syncope/trunk/
------------------------------------------------------------------------------
Merged /syncope/branches/1_1_X:r1554778-1554829
Modified: syncope/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/pom.xml?rev=1554832&r1=1554831&r2=1554832&view=diff
==============================================================================
--- syncope/trunk/core/pom.xml (original)
+++ syncope/trunk/core/pom.xml Thu Jan 2 15:33:08 2014
@@ -236,6 +236,11 @@ under the License.
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-persistence-jdbc</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
@@ -1021,14 +1026,14 @@ under the License.
<profile>
<id>postgres-it</id>
<properties>
- <jdbcdriver.groupId>postgresql</jdbcdriver.groupId>
+ <jdbcdriver.groupId>org.postgresql</jdbcdriver.groupId>
<jdbcdriver.artifactId>postgresql</jdbcdriver.artifactId>
</properties>
<dependencies>
<dependency>
- <groupId>postgresql</groupId>
+ <groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
- <version>9.1-901-1.jdbc4</version>
+ <version>9.3-1100-jdbc41</version>
<scope>test</scope>
</dependency>
</dependencies>
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java?rev=1554832&r1=1554831&r2=1554832&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java Thu Jan 2 15:33:08 2014
@@ -30,6 +30,7 @@ import org.apache.syncope.core.persisten
import org.apache.syncope.core.persistence.beans.SyncTask;
import org.apache.syncope.core.persistence.beans.Task;
import org.apache.syncope.core.persistence.dao.ConfDAO;
+import org.apache.syncope.core.persistence.dao.NotFoundException;
import org.apache.syncope.core.persistence.dao.ReportDAO;
import org.apache.syncope.core.persistence.dao.TaskDAO;
import org.apache.syncope.core.quartz.TaskJob;
@@ -183,6 +184,18 @@ public class JobInstanceLoader {
registerJob(getJobName(task), jobInstance, cronExpression);
}
+ @Transactional(readOnly = true)
+ public void registerTaskJob(final Long taskId)
+ throws ClassNotFoundException, SchedulerException, ParseException {
+
+ SchedTask task = taskDAO.find(taskId);
+ if (task == null) {
+ throw new NotFoundException("Task " + taskId);
+ } else {
+ registerJob(task, task.getJobClassName(), task.getCronExpression());
+ }
+ }
+
public void registerJob(final Report report) throws SchedulerException, ParseException {
Job jobInstance = (Job) ApplicationContextProvider.getBeanFactory().
createBean(ReportJob.class, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false);
@@ -191,6 +204,16 @@ public class JobInstanceLoader {
registerJob(getJobName(report), jobInstance, report.getCronExpression());
}
+ @Transactional(readOnly = true)
+ public void registerReportJob(final Long reportId) throws SchedulerException, ParseException {
+ Report report = reportDAO.find(reportId);
+ if (report == null) {
+ throw new NotFoundException("Report " + reportId);
+ } else {
+ registerJob(report);
+ }
+ }
+
private void unregisterJob(final String jobName) {
try {
scheduler.getScheduler().unscheduleJob(new TriggerKey(jobName, Scheduler.DEFAULT_GROUP));
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/quartz/AbstractTaskJob.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/quartz/AbstractTaskJob.java?rev=1554832&r1=1554831&r2=1554832&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/quartz/AbstractTaskJob.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/quartz/AbstractTaskJob.java Thu Jan 2 15:33:08 2014
@@ -39,7 +39,7 @@ import org.springframework.beans.factory
/**
* Abstract job implementation that delegates to concrete implementation the actual job execution and provides some
* base features.
- * <strong>Extending ttis class will not provide support transaction management.</strong><br/>
+ * <strong>Extending this class will not provide support transaction management.</strong><br/>
* Extend <tt>AbstractTransactionalTaskJob</tt> for this purpose.
*
* @see AbstractTransactionalTaskJob
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/quartz/SpringBeanJobFactory.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/quartz/SpringBeanJobFactory.java?rev=1554832&r1=1554831&r2=1554832&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/quartz/SpringBeanJobFactory.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/quartz/SpringBeanJobFactory.java Thu Jan 2 15:33:08 2014
@@ -19,10 +19,6 @@
package org.apache.syncope.core.quartz;
import org.apache.syncope.core.init.JobInstanceLoader;
-import org.apache.syncope.core.persistence.beans.Report;
-import org.apache.syncope.core.persistence.beans.SchedTask;
-import org.apache.syncope.core.persistence.dao.ReportDAO;
-import org.apache.syncope.core.persistence.dao.TaskDAO;
import org.quartz.SchedulerContext;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.BeanWrapper;
@@ -58,27 +54,20 @@ public class SpringBeanJobFactory extend
*/
@Override
protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception {
-
final ApplicationContext ctx = ((ConfigurableApplicationContext) schedulerContext.get("applicationContext"));
// Try to re-create job bean from underlying task (useful for managing failover scenarios)
if (!ctx.containsBean(bundle.getJobDetail().getKey().getName())) {
Long taskId = JobInstanceLoader.getTaskIdFromJobName(bundle.getJobDetail().getKey().getName());
if (taskId != null) {
- TaskDAO taskDAO = ctx.getBean(TaskDAO.class);
- SchedTask task = taskDAO.find(taskId);
-
JobInstanceLoader jobInstanceLoader = ctx.getBean(JobInstanceLoader.class);
- jobInstanceLoader.registerJob(task, task.getJobClassName(), task.getCronExpression());
+ jobInstanceLoader.registerTaskJob(taskId);
}
Long reportId = JobInstanceLoader.getReportIdFromJobName(bundle.getJobDetail().getKey().getName());
if (reportId != null) {
- ReportDAO reportDAO = ctx.getBean(ReportDAO.class);
- Report report = reportDAO.find(reportId);
-
JobInstanceLoader jobInstanceLoader = ctx.getBean(JobInstanceLoader.class);
- jobInstanceLoader.registerJob(report);
+ jobInstanceLoader.registerReportJob(reportId);
}
}
@@ -96,7 +85,6 @@ public class SpringBeanJobFactory extend
} else {
for (String propName : this.ignoredUnknownProperties) {
if (pvs.contains(propName) && !wrapper.isWritableProperty(propName)) {
-
pvs.removePropertyValue(propName);
}
}
Modified: syncope/trunk/core/src/main/resources/persistence.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/persistence.properties?rev=1554832&r1=1554831&r2=1554832&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/persistence.properties (original)
+++ syncope/trunk/core/src/main/resources/persistence.properties Thu Jan 2 15:33:08 2014
@@ -19,6 +19,8 @@ jpa.url=jdbc:postgresql://localhost:5432
jpa.username=syncope
jpa.password=syncope
jpa.dialect=org.apache.openjpa.jdbc.sql.PostgresDictionary
+jpa.pool.validationQuery=SELECT 1
+#note: other connection pool settings can also be configured here, see persistenceContext.xml
quartz.jobstore=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
quartz.sql=tables_postgres.sql
audit.sql=audit.sql
Modified: syncope/trunk/core/src/main/resources/persistenceContext.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/persistenceContext.xml?rev=1554832&r1=1554831&r2=1554832&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/persistenceContext.xml (original)
+++ syncope/trunk/core/src/main/resources/persistenceContext.xml Thu Jan 2 15:33:08 2014
@@ -21,12 +21,17 @@ under the License.
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd">
+ http://www.springframework.org/schema/tx/spring-tx.xsd
+ http://www.springframework.org/schema/aop
+ http://www.springframework.org/schema/aop/spring-aop.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
<import resource="persistenceContextEMFactory.xml"/>
@@ -43,16 +48,32 @@ under the License.
<property name="defaultObject" ref="localDataSource"/>
</bean>
- <bean id="localDataSource" class="org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter">
- <property name="targetDataSource">
- <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <property name="driverClassName" value="${jpa.driverClassName}"/>
- <property name="url" value="${jpa.url}"/>
- <property name="username" value="${jpa.username}"/>
- <property name="password" value="${jpa.password}"/>
- </bean>
+ <bean id="localDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+ <property name="driverClassName" value="${jpa.driverClassName}"/>
+ <property name="url" value="${jpa.url}"/>
+ <property name="username" value="${jpa.username}"/>
+ <property name="password" value="${jpa.password}"/>
+ <!-- connection pool configuration - transaction isolation, default READ_COMMITTED (see SYNCOPE-202) -->
+ <property name="defaultTransactionIsolation">
+ <util:constant static-field="${jpa.pool.defaultTransactionIsolation:java.sql.Connection.TRANSACTION_READ_COMMITTED}"/>
</property>
- <property name="isolationLevelName" value="ISOLATION_READ_COMMITTED"/>
+ <!-- connection pool configuration - default values taken from BasicDataSource default values -->
+ <property name="initialSize" value="${jpa.pool.initialSize:0}"/>
+ <property name="maxActive" value="${jpa.pool.maxActive:8}"/>
+ <property name="maxIdle" value="${jpa.pool.maxIdle:8}"/>
+ <property name="minIdle" value="${jpa.pool.minIdle:0}"/>
+ <property name="maxWait" value="${jpa.pool.maxWait:-1}"/>
+ <property name="validationQuery" value="${jpa.pool.validationQuery}"/>
+ <property name="validationQueryTimeout" value="${jpa.pool.validationQueryTimeout:-1}"/>
+ <property name="testOnBorrow" value="${jpa.pool.testOnBorrow:true}"/>
+ <property name="testOnReturn" value="${jpa.pool.testOnReturn:false}"/>
+ <property name="testWhileIdle" value="${jpa.pool.testWhileIdle:false}"/>
+ <property name="timeBetweenEvictionRunsMillis" value="${jpa.pool.timeBetweenEvictionRunsMillis:-1}"/>
+ <property name="numTestsPerEvictionRun" value="${jpa.pool.numTestsPerEvictionRun:3}"/>
+ <property name="minEvictableIdleTimeMillis" value="${jpa.pool.minEvictableIdleTimeMillis:1800000}"/>
+ <property name="removeAbandoned" value="${jpa.pool.removeAbandoned:false}"/>
+ <property name="removeAbandonedTimeout" value="${jpa.pool.removeAbandonedTimeout:300}"/>
+ <property name="logAbandoned" value="${jpa.pool.logAbandoned:false}"/>
</bean>
<bean id="entityManager" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
Modified: syncope/trunk/core/src/main/resources/schedulingContext.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/schedulingContext.xml?rev=1554832&r1=1554831&r2=1554832&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/schedulingContext.xml (original)
+++ syncope/trunk/core/src/main/resources/schedulingContext.xml Thu Jan 2 15:33:08 2014
@@ -35,6 +35,8 @@ under the License.
</property>
<property name="quartzProperties">
<props>
+ <prop key="org.quartz.scheduler.idleWaitTime">${quartz.scheduler.idleWaitTime:30000}</prop>
+
<prop key="org.quartz.jobStore.misfireThreshold">6000000</prop>
<prop key="org.quartz.jobStore.driverDelegateClass">${quartz.jobstore}</prop>
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java?rev=1554832&r1=1554831&r2=1554832&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java Thu Jan 2 15:33:08 2014
@@ -47,7 +47,7 @@ import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.JVM)
public class ReportTestITCase extends AbstractTest {
- public ReportTO createReport(final ReportTO report) {
+ private ReportTO createReport(final ReportTO report) {
Response response = reportService.create(report);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusInfo().getStatusCode());
return getObject(response.getLocation(), ReportService.class, ReportTO.class);
@@ -181,7 +181,8 @@ public class ReportTestITCase extends Ab
assertNotNull(reportTO.getExecutions());
i++;
- } while (!ReportExecStatus.SUCCESS.name().equals(reportTO.getExecutions().get(0).getStatus()) && i < maxit);
+ } while (reportTO.getExecutions().isEmpty()
+ || (!ReportExecStatus.SUCCESS.name().equals(reportTO.getExecutions().get(0).getStatus()) && i < maxit));
assertEquals(ReportExecStatus.SUCCESS.name(), reportTO.getExecutions().get(0).getStatus());
long execId = reportTO.getExecutions().get(0).getId();
Modified: syncope/trunk/core/src/test/resources/mysql/persistence.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/resources/mysql/persistence.properties?rev=1554832&r1=1554831&r2=1554832&view=diff
==============================================================================
--- syncope/trunk/core/src/test/resources/mysql/persistence.properties (original)
+++ syncope/trunk/core/src/test/resources/mysql/persistence.properties Thu Jan 2 15:33:08 2014
@@ -19,6 +19,9 @@ jpa.url=jdbc:mysql://localhost:3306/sync
jpa.username=syncope
jpa.password=syncope
jpa.dialect=org.apache.openjpa.jdbc.sql.MySQLDictionary
+jpa.pool.validationQuery=SELECT 1
+#note: other connection pool settings can also be configured here, see persistenceContext.xml
quartz.jobstore=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
+quartz.scheduler.idleWaitTime=5000
quartz.sql=tables_mysql.sql
audit.sql=audit.sql
Modified: syncope/trunk/core/src/test/resources/oracle/persistence.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/resources/oracle/persistence.properties?rev=1554832&r1=1554831&r2=1554832&view=diff
==============================================================================
--- syncope/trunk/core/src/test/resources/oracle/persistence.properties (original)
+++ syncope/trunk/core/src/test/resources/oracle/persistence.properties Thu Jan 2 15:33:08 2014
@@ -19,7 +19,10 @@ jpa.url=jdbc:oracle:thin:@pioppo:1521:or
jpa.username=syncope
jpa.password=syncope
jpa.dialect=org.apache.openjpa.jdbc.sql.OracleDictionary
+jpa.pool.validationQuery=SELECT 1 FROM DUAL
+#note: other connection pool settings can also be configured here, see persistenceContext.xml
quartz.jobstore=org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
+quartz.scheduler.idleWaitTime=5000
quartz.sql=tables_oracle.sql
audit.sql=audit_oracle.sql
database.schema=SYNCOPE
Modified: syncope/trunk/core/src/test/resources/persistence.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/resources/persistence.properties?rev=1554832&r1=1554831&r2=1554832&view=diff
==============================================================================
--- syncope/trunk/core/src/test/resources/persistence.properties (original)
+++ syncope/trunk/core/src/test/resources/persistence.properties Thu Jan 2 15:33:08 2014
@@ -19,6 +19,9 @@ jpa.url=jdbc:h2:mem:syncopedb;DB_CLOSE_D
jpa.username=sa
jpa.password=
jpa.dialect=org.apache.openjpa.jdbc.sql.H2Dictionary
+jpa.pool.validationQuery=SELECT 1
+#note: other connection pool settings can also be configured here, see persistenceContext.xml
quartz.jobstore=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
+quartz.scheduler.idleWaitTime=5000
quartz.sql=tables_h2.sql
audit.sql=audit.sql
Modified: syncope/trunk/core/src/test/resources/postgres/persistence.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/resources/postgres/persistence.properties?rev=1554832&r1=1554831&r2=1554832&view=diff
==============================================================================
--- syncope/trunk/core/src/test/resources/postgres/persistence.properties (original)
+++ syncope/trunk/core/src/test/resources/postgres/persistence.properties Thu Jan 2 15:33:08 2014
@@ -19,5 +19,9 @@ jpa.url=jdbc:postgresql://localhost:5432
jpa.username=syncope
jpa.password=syncope
jpa.dialect=org.apache.openjpa.jdbc.sql.PostgresDictionary
+jpa.pool.validationQuery=SELECT 1
+#note: other connection pool settings can also be configured here, see persistenceContext.xml
quartz.jobstore=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
+quartz.scheduler.idleWaitTime=5000
quartz.sql=tables_postgres.sql
+audit.sql=audit.sql
Modified: syncope/trunk/core/src/test/resources/sqlserver/persistence.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/resources/sqlserver/persistence.properties?rev=1554832&r1=1554831&r2=1554832&view=diff
==============================================================================
--- syncope/trunk/core/src/test/resources/sqlserver/persistence.properties (original)
+++ syncope/trunk/core/src/test/resources/sqlserver/persistence.properties Thu Jan 2 15:33:08 2014
@@ -19,6 +19,9 @@ jpa.url=jdbc:sqlserver://acacia:1433;dat
jpa.username=syncope
jpa.password=syncope
jpa.dialect=org.apache.openjpa.jdbc.sql.SQLServerDictionary
+jpa.pool.validationQuery=SELECT 1
+#note: other connection pool settings can also be configured here, see persistenceContext.xml
quartz.jobstore=org.quartz.impl.jdbcjobstore.MSSQLDelegate
+quartz.scheduler.idleWaitTime=5000
quartz.sql=tables_sqlServer.sql
audit.sql=audit_sqlserver.sql
Modified: syncope/trunk/pom.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/pom.xml?rev=1554832&r1=1554831&r2=1554832&view=diff
==============================================================================
--- syncope/trunk/pom.xml (original)
+++ syncope/trunk/pom.xml Thu Jan 2 15:33:08 2014
@@ -321,7 +321,8 @@ under the License.
<openjpa.version>2.3.0</openjpa.version>
<bval.version>0.5</bval.version>
-
+ <commons-dbcp.version>1.4</commons-dbcp.version>
+
<cocoon.version>3.0.0-alpha-3</cocoon.version>
<wicket.version>6.12.0</wicket.version>
@@ -504,6 +505,12 @@ under the License.
<artifactId>openjpa-persistence-jdbc</artifactId>
<version>${openjpa.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>${commons-dbcp.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>