org.activiti.spring.SpringAdvancedBusinessCalendarManagerFactory Maven / Gradle / Ivy
package org.activiti.spring;
import org.activiti.engine.impl.calendar.*;
import org.activiti.engine.impl.util.DefaultClockImpl;
import org.activiti.engine.runtime.Clock;
/**
* Creates an advanced cycle business calendar manager (ACBCM). The ACBCM can handle daylight
* savings changes when the scheduled time zone is different than the server time zone.
*
* Create a factory bean
*
* <bean id="businessCalendarManagerFactory" class="org.activiti.spring.SpringAdvancedBusinessCalendarManagerFactory" />
*
* Add the manager to your org.activiti.spring.SpringProcessEngineConfiguration bean
*
* <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
* ...
* <property name="businessCalendarManager">
* <bean id="advancedBusinessCalendarManager" factory-bean="businessCalendarManagerFactory" factory-method="getBusinessCalendarManager" />
* </property>
* ...
* </bean>
*
*
* @author mseiden
* @see AdvancedCycleBusinessCalendar
*/
public class SpringAdvancedBusinessCalendarManagerFactory {
private Integer defaultScheduleVersion;
private Clock clock;
public Integer getDefaultScheduleVersion() {
return defaultScheduleVersion;
}
public void setDefaultScheduleVersion(Integer defaultScheduleVersion) {
this.defaultScheduleVersion = defaultScheduleVersion;
}
public Clock getClock() {
if (clock == null) {
clock = new DefaultClockImpl();
}
return clock;
}
public void setClock(Clock clock) {
this.clock = clock;
}
public BusinessCalendarManager getBusinessCalendarManager() {
MapBusinessCalendarManager mapBusinessCalendarManager = new MapBusinessCalendarManager();
mapBusinessCalendarManager.addBusinessCalendar(DurationBusinessCalendar.NAME, new DurationBusinessCalendar(getClock()));
mapBusinessCalendarManager.addBusinessCalendar(DueDateBusinessCalendar.NAME, new DueDateBusinessCalendar(getClock()));
mapBusinessCalendarManager.addBusinessCalendar(AdvancedCycleBusinessCalendar.NAME, new AdvancedCycleBusinessCalendar(getClock(), defaultScheduleVersion));
return mapBusinessCalendarManager;
}
}