Survive by day and develop by night.
talk for import biz , show your perfect code,full busy,skip hardness,make a better result,wait for change,challenge Survive.
happy for hardess to solve denpendies.
activiti-spring
public class ApplicationContextElResolver extends ELResolver {
protected ApplicationContext applicationContext;
public ApplicationContextElResolver(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
public Object getValue(ELContext context, Object base, Object property) {
if (base == null) {
// according to javadoc, can only be a String
String key = (String) property;
if (applicationContext.containsBean(key)) {
context.setPropertyResolved(true);
return applicationContext.getBean(key);
}
}
return null;
}
protected ProcessEngineConfigurationImpl processEngineConfiguration;
protected ApplicationContext applicationContext;
protected ProcessEngine processEngine;
public void destroy() throws Exception {
if (processEngine != null) {
processEngine.close();
}
}
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
public ProcessEngine getObject() throws Exception {
configureExpressionManager();
configureExternallyManagedTransactions();
if (processEngineConfiguration.getBeans() == null) {
processEngineConfiguration.setBeans(new SpringBeanFactoryProxyMap(applicationContext));
}
this.processEngine = processEngineConfiguration.buildProcessEngine();
return this.processEngine;
}
爬虫调度器就是可以利用多线程机制,进行调度似的更快的进行网页爬取。
public class SpringAdvancedBusinessCalendarManagerFactory {
private Integer defaultScheduleVersion;
private Clock clock;
public Integer getDefaultScheduleVersion() {
return defaultScheduleVersion;
}
public void setDefaultScheduleVersion(Integer defaultScheduleVersion) {
this.defaultScheduleVersion = defaultScheduleVersion;
}
public class SpringAsyncExecutor extends DefaultAsyncJobExecutor {
protected TaskExecutor taskExecutor;
protected SpringRejectedJobsHandler rejectedJobsHandler;
public SpringAsyncExecutor() {
}
public SpringAsyncExecutor(TaskExecutor taskExecutor, SpringRejectedJobsHandler rejectedJobsHandler) {
this.taskExecutor = taskExecutor;
this.rejectedJobsHandler = rejectedJobsHandler;
}
public TaskExecutor getTaskExecutor() {
return taskExecutor;
}
/**
* Required spring injected {@link TaskExecutor} implementation that will be used to execute runnable jobs.
*
* @param taskExecutor
*/
public void setTaskExecutor(TaskExecutor taskExecutor) {
this.taskExecutor = taskExecutor;
}
public SpringRejectedJobsHandler getRejectedJobsHandler() {
return rejectedJobsHandler;
}
/**
* Required spring injected {@link SpringRejectedJobsHandler} implementation that will be used when jobs were rejected by the task executor.
*
* @param rejectedJobsHandler
*/
public void setRejectedJobsHandler(SpringRejectedJobsHandler rejectedJobsHandler) {
this.rejectedJobsHandler = rejectedJobsHandler;
}
public class SpringEntityManagerSessionFactory implements SessionFactory {
protected EntityManagerFactory entityManagerFactory;
protected boolean handleTransactions;
protected boolean closeEntityManager;
public SpringEntityManagerSessionFactory(Object entityManagerFactory, boolean handleTransactions, boolean closeEntityManager) {
this.entityManagerFactory = (EntityManagerFactory) entityManagerFactory;
this.handleTransactions = handleTransactions;
this.closeEntityManager = closeEntityManager;
}
public Class<?> getSessionType() {
return EntityManagerFactory.class;
}
public Session openSession(CommandContext commandContext) {
EntityManager entityManager = EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory);
if (entityManager == null) {
return new EntityManagerSessionImpl(entityManagerFactory, handleTransactions, closeEntityManager);
}
return new EntityManagerSessionImpl(entityManagerFactory, entityManager, false, false);
}
}
public class SpringExpressionManager extends ExpressionManager {
protected ApplicationContext applicationContext;
/**
* @param applicationContext
* the applicationContext to use. Ignored when 'beans' parameter is not null.
* @param beans
* a map of custom beans to expose. If null, all beans in the application-context will be exposed.
*/
public SpringExpressionManager(ApplicationContext applicationContext, Map<Object, Object> beans) {
super(beans);
this.applicationContext = applicationContext;
}
@Override
protected void addBeansResolver(CompositeELResolver elResolver) {
if (beans != null) {
// Only expose limited set of beans in expressions
elResolver.add(new ReadOnlyMapELResolver(beans));
} else {
// Expose full application-context in expressions
elResolver.add(new ApplicationContextElResolver(applicationContext));
}
}
}
public class SpringTransactionContext implements TransactionContext {
protected PlatformTransactionManager transactionManager;
protected CommandContext commandContext;
protected Integer transactionSynchronizationAdapterOrder;
public SpringTransactionContext(PlatformTransactionManager transactionManager, CommandContext commandContext) {
this(transactionManager, commandContext, null);
}
public SpringTransactionContext(PlatformTransactionManager transactionManager, CommandContext commandContext, Integer transactionSynchronizationAdapterOrder) {
this.transactionManager = transactionManager;
this.commandContext = commandContext;
if (transactionSynchronizationAdapterOrder != null) {
this.transactionSynchronizationAdapterOrder = transactionSynchronizationAdapterOrder;
} else {
// Revert to default, which is a high number as the behaviour prior
// to adding the order would
// case the TransactionSynchronizationAdapter to be called AFTER all
// Adapters that implement Ordered
this.transactionSynchronizationAdapterOrder = Integer.MAX_VALUE;
}
}
欢迎阅读,各位老铁,如果对你有帮助,点个赞加个关注呗!~