Add support for direct binding

and refactor channel proxy behaviour

- Remove DirectChannelProxyFactory;
- Proxies create channels as necessary, including support for PollableChannels;
- Channel beans are using the bean factory methods for the proxies;
- Coordinate bind/unbind across a context through the internal Bindable interface;
- Add support for embedding modules as independent child contexts of the main module, wrapped in a Bindable interface;
- Add support for channel name namespacing;
- Use a shared channel registry (consulted by the proxies) to create direct bindings;

Restrict the use of SharedChannelRegistry to aggregation

Fixed copyrights

Polishing based on comments from the previous branch

Tweaks

- namespacing takes into account module index, so multiple modules with the same class can partiticipate
- fix how properties are passes to parent/child
- Split ChannelBindingLifecycle from ChannelBindingAdapter and register it with each child;

Javadoc updates

Pass only  prefixed properties

Actually use the filtering method

Lifecycle simplifications

- Removing BindableChannelWrapper and UnbindOnCloseApplicationListener and relying on ChannelBindingListener solely;
- Some code cleanup

Further simplifications

More cleanup

Remove BindableUtils, rename ChannelBindingAdapter

Minor improvements

Addressing some comments, renaming, etc

More polishing
This commit is contained in:
Marius Bogoevici
2015-08-06 09:04:57 -04:00
committed by Mark Fisher
parent 80391fa876
commit bd47560bd5
55 changed files with 1368 additions and 1451 deletions

View File

@@ -0,0 +1,26 @@
/*
* 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 config.sink;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author Marius Bogoevici
*/
@SpringBootApplication
public class SinkApplication {
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package config;
package config.sink;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@@ -0,0 +1,26 @@
/*
* 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 config.source;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author Marius Bogoevici
*/
@SpringBootApplication
public class SourceApplication {
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package config;
package config.source;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -35,11 +35,10 @@ import org.springframework.messaging.support.GenericMessage;
@EnableModule(Source.class)
public class SourceModuleDefinition {
@Value("${format:YYYY/MM/dd hh:mm:ss}")
private String format;
private String format = "yyyy-MM-dd HH:mm:ss";
@Bean
@InboundChannelAdapter(value = Source.OUTPUT, autoStartup = "false", poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
@InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
public MessageSource<String> timerMessageSource() {
return () -> new GenericMessage<>(new SimpleDateFormat(this.format).format(new Date()));
}

View File

@@ -16,25 +16,17 @@
package demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.aggregate.AggregateBuilder;
import org.springframework.cloud.stream.aggregate.AggregateConfigurer;
import org.springframework.cloud.stream.aggregate.AggregateApplication;
import config.SinkModuleDefinition;
import config.SourceModuleDefinition;
import config.sink.SinkApplication;
import config.source.SourceApplication;
@SpringBootApplication
public class DoubleApplication implements AggregateConfigurer {
@Override
public void configure(AggregateBuilder builder) {
builder.from(SourceModuleDefinition.class).as("source")
.to(SinkModuleDefinition.class).as("sink");
}
public class DoubleApplication {
public static void main(String[] args) {
SpringApplication.run(DoubleApplication.class, args);
AggregateApplication.run(SourceApplication.class, SinkApplication.class);
}
}