Skip to content
This repository was archived by the owner on Apr 5, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ project('spring-xd-module') {
compile "org.codehaus.groovy:groovy-all"
compile "org.springframework.integration:spring-integration-core"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.springframework.boot:spring-boot-configuration-metadata"
compile "org.springframework.boot:spring-boot-loader"
compile "com.fasterxml.jackson.core:jackson-databind"
compile "org.slf4j:slf4j-api"
Expand Down
91 changes: 46 additions & 45 deletions dependencies.properties
Original file line number Diff line number Diff line change
Expand Up @@ -311,51 +311,52 @@ org.springframework\:spring-webmvc-portlet=4.2.0.RC2
org.springframework\:spring-websocket=4.2.0.RC2
org.springframework.amqp\:spring-amqp=1.5.0.M1
org.springframework.amqp\:spring-rabbit=1.5.0.M1
org.springframework.batch\:spring-batch-core=3.0.4.RELEASE
org.springframework.batch\:spring-batch-infrastructure=3.0.4.RELEASE
org.springframework.batch\:spring-batch-integration=3.0.4.RELEASE
org.springframework.batch\:spring-batch-test=3.0.4.RELEASE
org.springframework.boot\:spring-boot=1.2.3.RELEASE
org.springframework.boot\:spring-boot-actuator=1.2.3.RELEASE
org.springframework.boot\:spring-boot-autoconfigure=1.2.3.RELEASE
org.springframework.boot\:spring-boot-dependency-tools=1.2.3.RELEASE
org.springframework.boot\:spring-boot-gradle-plugin=1.2.3.RELEASE
org.springframework.boot\:spring-boot-loader=1.2.3.RELEASE
org.springframework.boot\:spring-boot-loader-tools=1.2.3.RELEASE
org.springframework.boot\:spring-boot-maven-plugin=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-actuator=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-amqp=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-aop=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-batch=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-data-elasticsearch=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-data-gemfire=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-data-jpa=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-data-mongodb=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-data-rest=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-data-solr=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-freemarker=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-groovy-templates=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-hornetq=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-integration=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-jdbc=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-jetty=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-log4j=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-logging=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-mobile=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-redis=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-remote-shell=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-security=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-social-facebook=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-social-linkedin=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-social-twitter=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-test=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-thymeleaf=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-tomcat=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-velocity=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-web=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-websocket=1.2.3.RELEASE
org.springframework.boot\:spring-boot-starter-ws=1.2.3.RELEASE
org.springframework.batch\:spring-batch-core=3.1.0.BUILD-SNAPSHOT
org.springframework.batch\:spring-batch-infrastructure=3.1.0.BUILD-SNAPSHOT
org.springframework.batch\:spring-batch-integration=3.1.0.BUILD-SNAPSHOT
org.springframework.batch\:spring-batch-test=3.1.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-actuator=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-autoconfigure=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-configuration-metadata=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-dependency-tools=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-gradle-plugin=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-loader=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-loader-tools=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-maven-plugin=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-actuator=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-amqp=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-aop=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-batch=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-data-elasticsearch=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-data-gemfire=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-data-jpa=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-data-mongodb=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-data-rest=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-data-solr=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-freemarker=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-groovy-templates=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-hornetq=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-integration=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-jdbc=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-jetty=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-log4j=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-logging=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-mobile=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-redis=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-remote-shell=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-security=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-social-facebook=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-social-linkedin=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-social-twitter=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-test=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-thymeleaf=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-tomcat=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-velocity=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-web=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-websocket=1.3.0.BUILD-SNAPSHOT
org.springframework.boot\:spring-boot-starter-ws=1.3.0.BUILD-SNAPSHOT
org.springframework.build.gradle\:propdeps-plugin=0.0.7
org.springframework.cloud\:spring-cloud-cloudfoundry-connector=1.1.1.RELEASE
org.springframework.cloud\:spring-cloud-core=1.1.1.RELEASE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@

package org.springframework.xd.dirt.server;


import javax.annotation.PostConstruct;

import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.actuate.autoconfigure.AuditAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration;
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
Expand All @@ -31,6 +38,9 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.jmx.support.MBeanServerFactoryBean;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.xd.dirt.util.ConfigLocations;

/**
Expand Down Expand Up @@ -63,4 +73,25 @@ public ApplicationHealthIndicator healthIndicator() {
return new ApplicationHealthIndicator();
}

/**
* Create a dedicated thread pool for "framework" tasks.
*/
@Bean
@Qualifier("framework")
public TaskScheduler frameworkTaskScheduler() {
return new ThreadPoolTaskScheduler();
}

@Autowired
private ScheduledAnnotationBeanPostProcessor postProcessor;

@Autowired
@Qualifier("framework")
private TaskScheduler frameworkTaskScheduler;

@PostConstruct
public void forceScheduledTaskExecutor() {
postProcessor.setScheduler(frameworkTaskScheduler);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
import java.io.IOException;
import java.net.ServerSocket;

import javax.annotation.PostConstruct;
import javax.servlet.Filter;

import org.apache.commons.lang.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.actuate.autoconfigure.AuditAutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration;
Expand All @@ -46,6 +49,8 @@
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.event.SourceFilteringListener;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor;
import org.springframework.web.filter.HttpPutFormContentFilter;
import org.springframework.xd.batch.XdBatchDatabaseInitializer;
import org.springframework.xd.dirt.rest.RestConfiguration;
Expand Down Expand Up @@ -189,4 +194,18 @@ public ApplicationListener<?> xdInitializer(ApplicationContext context) {
public BatchDatabaseInitializer batchDatabaseInitializer() {
return new XdBatchDatabaseInitializer();
}


@Autowired
private ScheduledAnnotationBeanPostProcessor postProcessor;

@Autowired
@Qualifier("framework")
private TaskScheduler frameworkTaskScheduler;

@PostConstruct
public void forceScheduledTaskExecutor() {
postProcessor.setScheduler(frameworkTaskScheduler);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting technique 😄

A couple of thoughts...

  • Perhaps we should open a JIRA against SF to fall back to some well-known bean name when there's more than one scheduler in the context?
  • We should probably document someplace how users can override this "framework" scheduler if they want multiple threads in the TPTS

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to Gary's comments, and...

I'm not a fan of the word "framework" here.

Also the thread prefix should be set.

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

package org.springframework.xd.dirt.server.container;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.actuate.autoconfigure.AuditAutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration;
Expand All @@ -28,6 +31,8 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.SourceFilteringListener;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor;
import org.springframework.xd.dirt.cluster.ContainerAttributes;
import org.springframework.xd.dirt.container.store.ContainerRepository;
import org.springframework.xd.dirt.job.JobFactory;
Expand Down Expand Up @@ -131,4 +136,18 @@ private void initializeZooKeeperConnection() {
}
}


@Autowired
private ScheduledAnnotationBeanPostProcessor postProcessor;

@Autowired
@Qualifier("framework")
private TaskScheduler frameworkTaskScheduler;

@PostConstruct
public void forceScheduledTaskExecutor() {
postProcessor.setScheduler(frameworkTaskScheduler);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ explicitly set as a module option.
<bean class="org.springframework.xd.module.options.DefaultModuleOptionsMetadataResolver">
<property name="compositeResolver" ref="moduleOptionsMetadataResolver" />
</bean>
<bean class="org.springframework.xd.module.options.BootModuleOptionsMetadataResolver" />
<bean class="org.springframework.xd.dirt.plugins.stream.ModuleTypeConversionPluginMetadataResolver" />
<bean class="org.springframework.xd.dirt.plugins.job.JobPluginMetadataResolver" />
</list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.springframework.xd.module.ModuleDescriptor;
import org.springframework.xd.module.SimpleModuleDefinition;
import org.springframework.xd.module.options.ModuleOptions;
import org.springframework.xd.module.options.ModuleUtils;
import org.springframework.xd.module.options.PassthruModuleOptionsMetadata;

/**
Expand Down Expand Up @@ -263,13 +264,7 @@ public void destroy() {
throw new IllegalStateException(e);
}
}
if (classLoader instanceof Closeable) {
try {
((Closeable) classLoader).close();
}
catch (IOException e) {
}
}
ModuleUtils.closeClassLoader(classLoader);
}

private static ModuleOptions defaultModuleOptions() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright 2015 the original author or authors.
*
* 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 org.springframework.xd.module.options;

import java.io.IOException;
import java.util.Map;

import org.springframework.boot.configurationmetadata.ConfigurationMetadataProperty;
import org.springframework.boot.configurationmetadata.ConfigurationMetadataRepository;
import org.springframework.boot.configurationmetadata.ConfigurationMetadataRepositoryJsonBuilder;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.xd.module.ModuleDefinition;
import org.springframework.xd.module.SimpleModuleDefinition;

/**
* A ModuleOptionsMetadataResolver that knows how to read Spring Boot metadata for configuration properties
* and exposes some of the properties as module options.
*
* @author Eric Bottard
*/
public class BootModuleOptionsMetadataResolver implements ModuleOptionsMetadataResolver {


private ResourcePatternResolver resourceLoader = new PathMatchingResourcePatternResolver();

/**
* The prefix with which configuration options must start to be considered module options.
*
* <p>The prefix-less form will be used for module options, while at runtime,
* the module may expect the long form.</p>
*/
private String prefix = "module.";


@Override
public ModuleOptionsMetadata resolve(ModuleDefinition moduleDefinition) {
if (moduleDefinition.isComposed()) {
return null;
}
SimpleModuleDefinition simpleModuleDefinition = (SimpleModuleDefinition) moduleDefinition;
Resource resource = resourceLoader.getResource(simpleModuleDefinition.getLocation());
ClassLoader moduleClassLoader = ModuleUtils.createModuleDiscoveryClassLoader(resource, BootModuleOptionsMetadataResolver.class.getClassLoader());

ResourcePatternResolver moduleResourceLoader = new PathMatchingResourcePatternResolver(moduleClassLoader);

ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder.create();

try {
for (Resource r : moduleResourceLoader.getResources("classpath*:/META-INF/*spring-configuration-metadata.json")) {
builder.withJsonResource(r.getInputStream());
}
}
catch (IOException e) {
throw new RuntimeException(e);
}
ModuleUtils.closeClassLoader(moduleClassLoader);

ConfigurationMetadataRepository repo = builder.build();
SimpleModuleOptionsMetadata result = new SimpleModuleOptionsMetadata();

for (Map.Entry<String, ConfigurationMetadataProperty> kv : repo.getAllProperties().entrySet()) {
String key = kv.getKey();
if (!key.startsWith(prefix)) {
continue;
}
ConfigurationMetadataProperty value = kv.getValue();
ModuleOption mo = new ModuleOption(key.substring(prefix.length()), value.getDescription())
.withDefaultValue(value.getDefaultValue())
.withType(value.getType());
result.add(mo);

}

return result;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.xd.module.options;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down
Loading