提交 5beba0ff 编写于 作者: J jbarrez

UI: adding demo data

上级 dc21ccc9
......@@ -32,7 +32,7 @@ public class MailScanSchedulerThread extends Thread {
private static Logger log = Logger.getLogger(MailScanSchedulerThread.class.getName());
protected boolean isActive = false;
protected int idleWaitInMillis = 2000;
protected int idleWaitInMillis = 10000;
protected MailScanner mailScanner;
protected CommandExecutor commandExecutor;
protected Map<String, MailScanCmd> allMailScansCmds = Collections.synchronizedMap(new HashMap<String, MailScanCmd>());
......@@ -58,15 +58,17 @@ public class MailScanSchedulerThread extends Thread {
public void run() {
isActive = true;
log.fine(getClass().getName()+" is started");
while (mailScanner.isActive()) {
while (isActive) {
MailScanCmd mailScanCmd = getNextMailScanCmd();
try {
commandExecutor.execute(mailScanCmd);
} catch (Exception e) {
// users need to logout and login if they want to re-enable mail scanning after a failure
String userId = mailScanCmd.getUserId();
allMailScansCmds.remove(userId);
log.log(Level.SEVERE, "couldn't check todo mail for "+userId+": "+e.getMessage(), e);
if (mailScanCmd != null) {
try {
commandExecutor.execute(mailScanCmd);
} catch (Exception e) {
// users need to logout and login if they want to re-enable mail scanning after a failure
String userId = mailScanCmd.getUserId();
allMailScansCmds.remove(userId);
log.log(Level.SEVERE, "couldn't check todo mail for "+userId+": "+e.getMessage(), e);
}
}
}
log.fine(getClass().getName()+" is stopping");
......@@ -81,6 +83,7 @@ public class MailScanSchedulerThread extends Thread {
Thread.sleep(idleWaitInMillis);
} catch (InterruptedException e) {
log.fine("sleep got interrupted");
return null;
}
}
if (nextMailScanCmds.isEmpty()) {
......
/* 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 demo;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.impl.ProcessEngineImpl;
import org.activiti.engine.impl.mail.MailScanner;
import org.springframework.beans.factory.InitializingBean;
/**
* @author Joram Barrez
*/
public class DemoMailScanner implements InitializingBean {
protected ProcessEngine processEngine;
protected MailScanner mailScanner;
public void afterPropertiesSet() throws Exception {
mailScanner = ((ProcessEngineImpl) processEngine)
.getProcessEngineConfiguration()
.getMailScanner();
mailScanner.start();
mailScanner.addUser("tom", null);
}
public void shutdown() {
mailScanner.shutdown();
}
public ProcessEngine getProcessEngine() {
return processEngine;
}
public void setProcessEngine(ProcessEngine processEngine) {
this.processEngine = processEngine;
}
}
......@@ -13,6 +13,8 @@
package org.activiti.explorer.demo;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import org.activiti.engine.IdentityService;
......@@ -144,13 +146,26 @@ public class DemoDataGenerator {
createUser(identityService, "julie", "Julie", "Hall", "julie", "julie.hall@alfresco.com", "org/activiti/explorer/images/julie.jpg");
createUser(identityService, "erik", "Erik", "Winlof", "erik", "erik.witloof@alfresco.com", "org/activiti/explorer/images/erik.jpg");
// Additional info
// Joram
identityService.setUserInfo("joram", "birthDate", "10-10-1985");
identityService.setUserInfo("joram", "jobTitle", "Activiti core developer");
identityService.setUserInfo("joram", "location", "Welle, Belgium");
identityService.setUserInfo("joram", "phone", "+32485869655");
identityService.setUserInfo("joram", "twitterName", "jbarrez");
identityService.setUserInfo("joram", "skype", "joram.barrez");
// Tim
String accountUsername = System.getProperty("user");
String accountPassword = System.getProperty("pwd");
if (accountUsername == null || accountPassword == null) {
throw new RuntimeException("'user' and 'pwd' system property must be set");
}
Map<String, String> accountDetails = new HashMap<String, String>();
accountDetails.put("toDoFolderName", "Cases");
accountDetails.put("toDoInActivitiFolderName", "CasesInActiviti");
accountDetails.put("imapHost", "imap.gmail.com");
accountDetails.put("imapProtocol", "imaps");
identityService.setUserAccount("tom", null, "mailscan", accountUsername, accountPassword, accountDetails);
}
protected void createUser(IdentityService identityService, String userId, String firstName, String lastName,
......
......@@ -10,6 +10,10 @@
<bean id="demoDataGenerator" class="org.activiti.explorer.demo.DemoDataGenerator">
<property name="processEngine" ref="processEngine" />
</bean>
<bean id="demoMailScanner" class="demo.DemoMailScanner" destroy-method="shutdown">
<property name="processEngine" ref="processEngine" />
</bean>
<context:component-scan base-package="org.activiti.explorer" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册