/*
 * 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.cloud.stream.config;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.binding.BindingBeanDefinitionRegistryUtils;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.util.ClassUtils;

/**
 * @author Marius Bogoevici
 * @author Dave Syer
 */

public class BindingBeansRegistrar implements ImportBeanDefinitionRegistrar {

	@Override
	public void registerBeanDefinitions(AnnotationMetadata metadata,
			BeanDefinitionRegistry registry) {
		AnnotationAttributes attrs = AnnotatedElementUtils.getMergedAnnotationAttributes(
				ClassUtils.resolveClassName(metadata.getClassName(), null),
				EnableBinding.class);
		for (Class<?> type : collectClasses(attrs.get("value"))) {
			BindingBeanDefinitionRegistryUtils.registerChannelBeanDefinitions(type,
					type.getName(), registry);
			BindingBeanDefinitionRegistryUtils.registerChannelsQualifiedBeanDefinitions(
					ClassUtils.resolveClassName(metadata.getClassName(), null), type,
					registry);
		}
	}

	private List<Class<?>> collectClasses(Object object) {
		ArrayList<Class<?>> result = new ArrayList<Class<?>>();
		for (Object value : (Object[]) object) {
			if (value instanceof Class && void.class != value) {
				result.add((Class<?>) value);
			}
		}
		return result;
	}

}

@@ -664,60 +664,8 @@
 g;%0A%0A
-import java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 impo
@@ -733,16 +733,16 @@
 gistry;%0A
+
 import o
@@ -1091,16 +1091,76 @@
 ibutes;%0A
+import org.springframework.core.annotation.AnnotationUtils;%0A
 import o
@@ -1726,20 +1726,32 @@
 ttrs
-.get(%22value%22
+, metadata.getClassName(
 ))) 
@@ -2043,29 +2043,24 @@
 private 
-List%3C
 Class%3C?%3E
 %3E collec
@@ -2051,17 +2051,18 @@
 Class%3C?%3E
-%3E
+%5B%5D
  collect
@@ -2073,240 +2073,234 @@
 ses(
-Object object) %7B%0A%09%09ArrayList%3CClass%3C?%3E%3E result = new ArrayList%3CClass%3C?%3E%3E();%0A%09%09for (Object value : (Object%5B%5D) object) %7B%0A%09%09%09if (value instanceof Class && void.class != value) %7B%0A%09%09%09%09result.add((Class%3C?%3E) value);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return result
+AnnotationAttributes attrs, String className) %7B%0A%09%09EnableBinding enableBinding = AnnotationUtils.synthesizeAnnotation(attrs,%0A%09%09%09%09EnableBinding.class, ClassUtils.resolveClassName(className, null));%0A%09%09return enableBinding.value()
 ;%0A%09%7D

Use AnnotationUtils to synthesise annotation