diff --git a/org.springframework.integration.osgi/.classpath b/org.springframework.integration.osgi/.classpath
deleted file mode 100644
index 3864c75089..0000000000
--- a/org.springframework.integration.osgi/.classpath
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/.project b/org.springframework.integration.osgi/.project
deleted file mode 100644
index 30de144f70..0000000000
--- a/org.springframework.integration.osgi/.project
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
- org.springframework.integration.osgi
-
-
-
-
-
- org.eclipse.wst.common.project.facet.core.builder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.springframework.ide.eclipse.core.springbuilder
-
-
-
-
-
- org.springframework.ide.eclipse.core.springnature
- org.eclipse.jdt.core.javanature
- org.eclipse.wst.common.project.facet.core.nature
-
-
diff --git a/org.springframework.integration.osgi/build.xml b/org.springframework.integration.osgi/build.xml
deleted file mode 100644
index afbe9fa38c..0000000000
--- a/org.springframework.integration.osgi/build.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/ivy.xml b/org.springframework.integration.osgi/ivy.xml
deleted file mode 100644
index 8a871cd273..0000000000
--- a/org.springframework.integration.osgi/ivy.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/org.springframework.integration.osgi/pom.xml b/org.springframework.integration.osgi/pom.xml
deleted file mode 100644
index 0bb49c23ce..0000000000
--- a/org.springframework.integration.osgi/pom.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
- 4.0.0
- org.springframework.integration
- spring-integration-osgi
- jar
- Spring Integration OSGi Extender
-
- org.springframework.integration
- spring-integration-parent
- 2.0.0.BUILD-SNAPSHOT
- ../spring-integration-parent
-
-
-
- cglib
- cglib-nodep
- 2.1_3
- test
-
-
- junit
- junit
- ${junit.version}
- test
-
-
- org.springframework
- spring-context
- ${spring.version}
- compile
-
-
- org.springframework
- spring-test
- ${spring.version}
- test
-
-
- org.springframework.integration
- spring-integration-core
- ${project.version}
- compile
-
-
- org.mockito
- mockito-all
- 1.8.0
- test
-
-
-
diff --git a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/IntegrationOSGiConstants.java b/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/IntegrationOSGiConstants.java
deleted file mode 100644
index 6977cccb4c..0000000000
--- a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/IntegrationOSGiConstants.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi;
-
-/**
- * Constants used by OSGi Service Extender
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public interface IntegrationOSGiConstants {
- public final String OSGI_BEAN_NAME = "org.springframework.osgi.bean.name";
- public final String INTEGRATION_EVENT_TYPE = "INTEGRATION_EVENT_TYPE";
- public final String REGISTRATION = "REGISTRATION";
- public final String UNREGISTRATION = "UNREGISTRATION";
- public final String BINDING = "BINDING";
- public final String UNBINDING= "UNBINDING";
-}
diff --git a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/OSGiIntegrationControlBus.java b/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/OSGiIntegrationControlBus.java
deleted file mode 100644
index 26509ab5eb..0000000000
--- a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/OSGiIntegrationControlBus.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi;
-
-import org.springframework.integration.channel.SubscribableChannel;
-import org.springframework.integration.controlbus.ControlBus;
-import org.springframework.integration.core.Message;
-import org.springframework.integration.message.MessageHandler;
-
-/**
- * Implementation of the {@link ControlBus} interface.
- * Control Bus itself wrapper over {@link SubscribableChannel},
- * which represents the entry point to Control Bus infrastructure.
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class OSGiIntegrationControlBus implements ControlBus {
- private SubscribableChannel channel;
- private String busName;
-
- public OSGiIntegrationControlBus(SubscribableChannel channel, String busName){
- this.channel = channel;
- this.busName = busName;
- }
-
- public boolean subscribe(MessageHandler handler) {
- return channel.subscribe(handler);
- }
-
-
- public boolean unsubscribe(MessageHandler handler) {
- return channel.unsubscribe(handler);
- }
-
- public String getName() {
- return channel.getName();
- }
-
-
- public boolean send(Message> message) {
- return channel.send(message);
- }
-
-
- public boolean send(Message> message, long timeout) {
- return channel.send(message, timeout);
- }
- /*
- * (non-Javadoc)
- * @see org.springframework.integration.controlbus.ControlBus#isBusAvailable()
- */
- public boolean isBusAvailable() {
- return true;
- }
-}
diff --git a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/BusConfigParser.java b/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/BusConfigParser.java
deleted file mode 100644
index b7354af466..0000000000
--- a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/BusConfigParser.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.config.xml;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.BeanDefinitionStoreException;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
-import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.integration.controlbus.ControlBus;
-import org.springframework.integration.osgi.OSGiIntegrationControlBus;
-import org.springframework.util.Assert;
-import org.springframework.util.StringUtils;
-import org.w3c.dom.Element;
-
-/**
- * Parser to handle 'bus-config' element.
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class BusConfigParser extends AbstractBeanDefinitionParser {
- private static final Log log = LogFactory.getLog(BusConfigParser.class);
-
- private String beanName;
- /**
- *
- */
- protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
- throws BeanDefinitionStoreException {
- return beanName;
- }
- /**
- *
- */
- protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
- String busGroupName = element.getAttribute("group-name");
- Assert.isTrue(StringUtils.hasText(busGroupName), "bus-config 'group-name' attribute must be provided");
- beanName = busGroupName;
- if (parserContext.getRegistry().containsBeanDefinition(beanName)){
- throw new BeanDefinitionStoreException("You atempted to register a second instance of the Control Bus with the same 'group-name' " +
- "in the single Application Context which is not allowed.");
- }
-
- BeanDefinitionBuilder rootBuilder = BeanDefinitionBuilder.rootBeanDefinition(OSGiIntegrationControlBus.class);
- rootBuilder.addConstructorArgReference(ControlBusOSGiConfigUtils.DEFAULT_CONTROL_DIST_CHANNEL);
- rootBuilder.addConstructorArgValue(beanName);
-
- BeanDefinitionBuilder osgiServiceDefinition =
- ControlBusOSGiConfigUtils.defineServiceExporterFor(beanName, parserContext.getRegistry(), ControlBus.class);
- BeanDefinitionReaderUtils.registerWithGeneratedName(osgiServiceDefinition.getBeanDefinition(), parserContext.getRegistry());
-
- // NOTE add listeners
- log.trace("Control Bus " + beanName + " was parsed successfully");
- return rootBuilder.getBeanDefinition();
- }
-}
diff --git a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/ConfigParser.java b/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/ConfigParser.java
deleted file mode 100644
index 45c0399fa1..0000000000
--- a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/ConfigParser.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.config.xml;
-
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.xml.BeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.integration.osgi.extender.ControlBusRegistrationMessageDistributionListener;
-import org.springframework.integration.osgi.extender.LifecycleServiceManagingListener;
-import org.springframework.util.Assert;
-import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
-
-/**
- * Parser to process 'config' element of SI Service Extender
- * and its sub-elements
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class ConfigParser implements BeanDefinitionParser {
- private static final Log log = LogFactory.getLog(ConfigParser.class);
- private static final String TYPE = "si-type";
- private static final String REF = "ref";
- private static final String NAME = "name";
- private static final String CONTROL_BUS = "control-bus";
- private static final String EXPORTER_SUFFIX = "-Service";
- private static final int EXPORT = 1;
- private static final int IMPORT = 2;
- /**
- * Will parse 'config' element of "integration-service-extender' namespace and its sub-elements
- */
- public BeanDefinition parse(Element element, ParserContext parserContext) {
- List elements = DomUtils.getChildElementsByTagName(element, "export");
- for (Element exportElements : elements) {
- this.processExportElement(exportElements, parserContext, EXPORT);
- }
- elements = DomUtils.getChildElementsByTagName(element, "import");
- for (Element exportElements : elements) {
- this.processImportElement(exportElements, parserContext, IMPORT);
- }
- return null;
- }
- /**
- */
- private void processExportElement(Element element, ParserContext parserContext, int configType){
- BeanDefinitionRegistry registry = parserContext.getRegistry();
- String includeType = this.getIncludeType(element);
- Assert.notNull(includeType, "You must prvide one of the following: 'type' or 'ref' attribute wihin the 'include' element");
- if (includeType.equals(TYPE)){
- this.processTypeAttribute(element, registry, configType);
- } else if (includeType.equals(REF)){
- this.processRefAttribute(element, registry, configType);
- }
- }
- /**
- */
- private void processImportElement(Element element, ParserContext parserContext, int configType){
- BeanDefinitionRegistry registry = parserContext.getRegistry();
- String serviceName = element.getAttribute(NAME);
- Assert.hasText(serviceName, "you must enter a valid value in the " + NAME + " attribute");
- Class[] interfaces = this.discoverInterfaces(serviceName, element);
- BeanDefinitionBuilder importerBuilder =
- ControlBusOSGiConfigUtils.defineServiceImporterFor(serviceName, null, registry, interfaces);
- // define binding listeners
- ManagedList listenerDefinitions = new ManagedList();
- if (element.hasAttribute(CONTROL_BUS)){
- String busBeanName = element.getAttribute(CONTROL_BUS);
- BeanDefinition busBindingListener =
- ControlBusOSGiConfigUtils.defineBindingMessageDistributor(registry, importerBuilder, busBeanName);
- listenerDefinitions.add(busBindingListener);
- }
- List dependentSources = ControlBusOSGiConfigUtils.discoverDependentElements(element, serviceName);
- // add binding listener that will execute start/stop on dependent lifecycle beans
- if (dependentSources.size() > 0){
- log.debug("Candidate beans dependent on '" + serviceName +
- "' and to be managed by IntegrationServiceBindingListener: " + dependentSources);
- BeanDefinitionBuilder lifecycleBindingManagerBuilder =
- BeanDefinitionBuilder.genericBeanDefinition(LifecycleServiceManagingListener.class);
- lifecycleBindingManagerBuilder.addPropertyValue("dependentSources", dependentSources);
- listenerDefinitions.add(lifecycleBindingManagerBuilder.getBeanDefinition());
- }
-
- if (listenerDefinitions.size() > 0){
- importerBuilder.addPropertyValue("listeners", listenerDefinitions);
- }
-
- registry.registerBeanDefinition(serviceName, importerBuilder.getBeanDefinition());
- }
- /**
- */
- private void processRefAttribute(Element element, BeanDefinitionRegistry registry, int configType) {
- if (configType == EXPORT){
- String beanName = element.getAttribute(REF);
- this.generateServiceExorterDefinition(beanName, element, registry);
- } else if (configType == IMPORT){
-
- }
- }
- /**
- */
- private void processTypeAttribute(Element element, BeanDefinitionRegistry registry, int configType) {
- String exportedTypes = element.getAttribute(TYPE);
- if (configType == EXPORT){
- Element rootDocumentElement = element.getOwnerDocument().getDocumentElement();
- List elementsToExport = DomUtils.getChildElementsByTagName(rootDocumentElement, exportedTypes);
- for (Element elementToExport : elementsToExport) {
- String beanName = elementToExport.getAttribute("id");
- this.generateServiceExorterDefinition(beanName, element, registry);
- }
- }
- }
- /*
- *
- */
- private void generateServiceExorterDefinition(String beanName, Element element, BeanDefinitionRegistry registry){
- BeanDefinitionBuilder exportedElementBuilder =
- ControlBusOSGiConfigUtils.defineServiceExporterFor(beanName, registry);
- ManagedList listenerDefinitions = new ManagedList();
- if (element.hasAttribute(CONTROL_BUS)){
- BeanDefinition controlBusMessageDistributorDefinition =
- this.defineControlBusMessageDistributor(element, exportedElementBuilder, registry, beanName);
- listenerDefinitions.add(controlBusMessageDistributorDefinition);
- }
- // NOTE: add more listeners here if needed
- if (listenerDefinitions.size() > 0){
- exportedElementBuilder.addPropertyValue("listeners", listenerDefinitions);
- }
- registry.registerBeanDefinition(beanName+EXPORTER_SUFFIX, exportedElementBuilder.getBeanDefinition());
- }
- /**
- * If element specifies 'control-bus' attribute, this method will register
- * {@link ControlBusRegistrationMessageDistributionListener}
- * which will send registration messages to the ControlBus
- */
- private BeanDefinition defineControlBusMessageDistributor(Element originalElement,
- BeanDefinitionBuilder exportedElementBuilder,
- BeanDefinitionRegistry registry,
- String componentName) {
- AbstractBeanDefinition listenerDefinition = null;
- if (originalElement.hasAttribute(CONTROL_BUS)){
- String controlBusAttributeValue = originalElement.getAttribute(CONTROL_BUS);
- Assert.hasText(controlBusAttributeValue, "You must provide control bus name when defining 'control-bus' attribute");
- log.trace("Adding registration listener for exported OSGi service for:" + componentName);
-
- listenerDefinition =
- ControlBusOSGiConfigUtils.defineRegistrationMessageDistributor(registry, exportedElementBuilder, controlBusAttributeValue);
- BeanDefinitionReaderUtils.registerWithGeneratedName(listenerDefinition, registry);
- }
- return listenerDefinition;
- }
- /**
- */
- private String getIncludeType(Element element){
- if (element.hasAttribute(REF)){
- return REF;
- } else if (element.hasAttribute(TYPE)){
- return TYPE;
- }
- return null;
- }
- /**
- */
- private Class[] discoverInterfaces(String name, Element element){
- if (element.hasAttribute(TYPE)){
- return SiTypeToJavaTypeMaper.mapSiType(element.getAttribute(TYPE));
- }
- return null;
- }
-}
diff --git a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/ControlBusOSGiConfigUtils.java b/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/ControlBusOSGiConfigUtils.java
deleted file mode 100644
index dbd8f305e0..0000000000
--- a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/ControlBusOSGiConfigUtils.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.config.xml;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.integration.controlbus.ControlBus;
-import org.springframework.integration.osgi.IntegrationOSGiConstants;
-import org.springframework.integration.osgi.extender.ControlBusBindingMessageDistributionListener;
-import org.springframework.integration.osgi.extender.ControlBusListeningDecorator;
-import org.springframework.integration.osgi.extender.ControlBusRegistrationMessageDistributionListener;
-import org.springframework.osgi.service.exporter.support.AutoExport;
-import org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean;
-import org.springframework.osgi.service.importer.support.Cardinality;
-import org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean;
-import org.springframework.util.Assert;
-import org.springframework.util.StringUtils;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Helper class used by varilus bean parsers to create OSGi Factory bean definitions
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-class ControlBusOSGiConfigUtils {
- public final static String DEFAULT_BUS_GROUP_NAME = "DEFAULT_CONTROL_GROUP";
- public final static String DEFAULT_CONTROL_DIST_CHANNEL = "DEFAULT_CONTROL_DIST_CHANNEL";
- /**
- * Will define a service importer (equivalent to ) for the ControlBus service.
- * It will also register binding listener for this 'controlbus' reference which could be used
- * to react to the life-cycle events of this 'controlbus' reference.
- * For example: Individual service reference listeners coiuld use it to determine when the bus went away and
- * no control events need to be dispatched to the bus.
- */
- public static BeanDefinition registerImporterForControlBus(BeanDefinitionRegistry registry, String busGroupName){
- String filter = "(&(" + IntegrationOSGiConstants.OSGI_BEAN_NAME + "=" + busGroupName + "))";
- BeanDefinitionBuilder controlBusImporterBuilder =
- defineServiceImporterFor(busGroupName, filter, registry, ControlBus.class);
-
- BeanDefinitionBuilder busListenerBuilder =
- BeanDefinitionBuilder.genericBeanDefinition(ControlBusListeningDecorator.class);
- AbstractBeanDefinition busListenerDefinition = busListenerBuilder.getBeanDefinition();
- //String listenerName = IntegrationOSGiConstants.BUS_LISTENER_PREFIX + busGroupName;
- String listenerName = busGroupName;
- registry.registerBeanDefinition(listenerName, busListenerDefinition);
- controlBusImporterBuilder.addPropertyReference("listeners", listenerName);
- BeanDefinition controlBusImporterDefinition = controlBusImporterBuilder.getBeanDefinition();
- BeanDefinitionReaderUtils.registerWithGeneratedName(controlBusImporterBuilder.getBeanDefinition(), registry);
- return controlBusImporterDefinition;
- }
- /**
- * Will define OSGi Service exporter BeanDefinitionBuilder for a bean identified by the 'beanName'
- * parameter as an OSGi Service. If 'publishInterfaces' parameter is not provided this exporter will
- * use all interfaces implemented by this service class hierarchy. Otherwise you can provide an array of
- * specific interfaces to be published under this service.
- *
- * @param beanName
- * @param registry
- * @param publishedIntefaces
- * @return
- */
- @SuppressWarnings("unchecked")
- public static BeanDefinitionBuilder defineServiceExporterFor(String beanName,
- BeanDefinitionRegistry registry,
- Class... publishedIntefaces){
- BeanDefinitionBuilder serviceBuilder = BeanDefinitionBuilder.genericBeanDefinition(OsgiServiceFactoryBean.class);
- serviceBuilder.addPropertyValue("targetBeanName", beanName);
- if (publishedIntefaces != null && publishedIntefaces.length > 0){
- serviceBuilder.addPropertyValue("interfaces", publishedIntefaces);
- } else {
- serviceBuilder.addPropertyValue("autoExport", AutoExport.INTERFACES);
- }
- serviceBuilder.addPropertyValue("registerService", true);
- return serviceBuilder;
- }
- /**
- *
- * @param beanName
- * @param filter
- * @param registry
- * @param publishedIntefaces
- * @return
- */
- @SuppressWarnings("unchecked")
- public static BeanDefinitionBuilder defineServiceImporterFor(String beanName, String filter,
- BeanDefinitionRegistry registry, Class... publishedIntefaces){
- Assert.notEmpty(publishedIntefaces, "At least one interface must be provided");
- BeanDefinitionBuilder serviceBuilder = BeanDefinitionBuilder.genericBeanDefinition(OsgiServiceProxyFactoryBean.class);
- serviceBuilder.addPropertyValue("cardinality", Cardinality.C_0__1);
- if (StringUtils.hasText(filter)){
- serviceBuilder.addPropertyValue("filter", filter);
- }
- if (publishedIntefaces != null && publishedIntefaces.length > 0){
- serviceBuilder.addPropertyValue("interfaces", publishedIntefaces);
- }
- // will make sure it uses exporter's bean name when building a relationship with importer
- serviceBuilder.addPropertyValue("serviceBeanName", beanName);
-
- //TODO: pf.setTimeout(timeoutInMillis)
-
- return serviceBuilder;
- }
- /**
- * Will define a registration listener bean definition for the exported service adding reference to the
- * to the ControlBusListeninigDecorator to it.
- *
- * @param registry
- * @param exporterBuilder
- * @param busBeanName
- * @return
- */
- public static AbstractBeanDefinition defineRegistrationMessageDistributor(BeanDefinitionRegistry registry,
- BeanDefinitionBuilder exporterBuilder,
- String busBeanName){
- // create listener builder
- BeanDefinitionBuilder listenerBuilder =
- BeanDefinitionBuilder.genericBeanDefinition(ControlBusRegistrationMessageDistributionListener.class);
- String busGroupName = busBeanName;
- // if reference to the bus doesn't exist yet, create one
- // corresponding bean is not the actual bus but a ControlBusListentingDecorator
- if (!registry.containsBeanDefinition(busGroupName)){
- ControlBusOSGiConfigUtils.registerImporterForControlBus(registry, busGroupName);
- }
- listenerBuilder.addConstructorArgReference(busGroupName);
- AbstractBeanDefinition listenerDefinition = listenerBuilder.getBeanDefinition();
- //exporterBuilder.addPropertyValue("listeners", listenerDefinition);
- return listenerDefinition;
- }
- /**
- *
- * @param registry
- * @param exporterBuilder
- * @param busBeanName
- * @return
- */
- public static AbstractBeanDefinition defineBindingMessageDistributor(BeanDefinitionRegistry registry,
- BeanDefinitionBuilder exporterBuilder,
- String busBeanName){
- // create listener builder
- BeanDefinitionBuilder listenerBuilder =
- BeanDefinitionBuilder.genericBeanDefinition(ControlBusBindingMessageDistributionListener.class);
- String busGroupName = busBeanName;
- // if reference to the bus doesn't exist yet, create one
- // corresponding bean is not the actual bus but a ControlBusListentingDecorator
- if (!registry.containsBeanDefinition(busGroupName)){
- ControlBusOSGiConfigUtils.registerImporterForControlBus(registry, busGroupName);
- }
- listenerBuilder.addConstructorArgReference(busGroupName);
- AbstractBeanDefinition listenerDefinition = listenerBuilder.getBeanDefinition();
- return listenerDefinition;
- }
-
- public static List discoverDependentElements(Element element, String attributeValue){
- List dependentSources = new ArrayList();
- Element documentElement = element.getOwnerDocument().getDocumentElement();
- NodeList nodes = documentElement.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE){
- Element elementNode = (Element) node;
- String elementName = isDependent(elementNode, attributeValue);
- if (StringUtils.hasText(elementName)){
- dependentSources.add(elementName);
- }
- }
- }
- return dependentSources;
- }
- //
- private static String isDependent(Element element, String attributeValue){
- String[] monitoredAttributes = new String[]{"input-channel",
- "output-channel",
- "default-request-channel",
- "default-reply-channel",
- "channel"};
- for (String monitoredAttribute : monitoredAttributes) {
- if (element.hasAttribute(monitoredAttribute) &&
- element.getAttribute(monitoredAttribute).equals(attributeValue) ){
- if (!element.hasAttribute("name") && !element.hasAttribute("id")){
- // need to generate id for elements that do not have one
- // so they can be included in the listener dependentSource list
- element.setAttribute("id", element.getTagName() + "-" + attributeValue + "-" + element.hashCode());
- element.setIdAttribute("id", true);
- }
- String elementName = StringUtils.hasText(element.getAttribute("id")) ?
- element.getAttribute("id") : element.getAttribute("name");
- return elementName;
- }
- }
- return null;
- }
-}
diff --git a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/IntegrationOSGiControlBusNamespaceHandler.java b/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/IntegrationOSGiControlBusNamespaceHandler.java
deleted file mode 100644
index ef91ee98d0..0000000000
--- a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/IntegrationOSGiControlBusNamespaceHandler.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.config.xml;
-
-import org.springframework.integration.config.xml.AbstractIntegrationNamespaceHandler;
-
-/**
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class IntegrationOSGiControlBusNamespaceHandler extends AbstractIntegrationNamespaceHandler {
-
- /**
- * Will register the required parsers
- */
- public void init() {
- registerBeanDefinitionParser("bus-config", new BusConfigParser());
- }
-
-}
diff --git a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/IntegrationOSGiServiceExtenderNamespaceHandler.java b/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/IntegrationOSGiServiceExtenderNamespaceHandler.java
deleted file mode 100644
index bd154f027c..0000000000
--- a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/IntegrationOSGiServiceExtenderNamespaceHandler.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.config.xml;
-
-import org.springframework.integration.config.xml.AbstractIntegrationNamespaceHandler;
-
-/**
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class IntegrationOSGiServiceExtenderNamespaceHandler extends AbstractIntegrationNamespaceHandler {
-
- /**
- * Will register the required parsers
- */
- public void init() {
- registerBeanDefinitionParser("config", new ConfigParser());
- }
-
-}
diff --git a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/SiTypeToJavaTypeMaper.java b/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/SiTypeToJavaTypeMaper.java
deleted file mode 100644
index bd2ee3b821..0000000000
--- a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/config/xml/SiTypeToJavaTypeMaper.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.config.xml;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.springframework.integration.channel.SubscribableChannel;
-import org.springframework.util.Assert;
-
-/**
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-@SuppressWarnings("unchecked")
-class SiTypeToJavaTypeMaper {
- public static final String PUB_SUB_CHANNEL = "publish-subscribe-channel";
- private static Map siTypeMappings = new HashMap();
-
- static {
- siTypeMappings.put(PUB_SUB_CHANNEL, new Class[]{SubscribableChannel.class});
- }
-
- public static Class[] mapSiType(String siType){
- Assert.isTrue(siTypeMappings.containsKey(siType), "Can not map SI-Type '" + siType + "' to Java Type. Not supported.");
- return siTypeMappings.get(siType);
- }
-}
diff --git a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/extender/ControlBusBindingMessageDistributionListener.java b/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/extender/ControlBusBindingMessageDistributionListener.java
deleted file mode 100644
index 5840965e3a..0000000000
--- a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/extender/ControlBusBindingMessageDistributionListener.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.extender;
-
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.integration.controlbus.ControlBus;
-import org.springframework.integration.message.MessageBuilder;
-import org.springframework.integration.osgi.IntegrationOSGiConstants;
-import org.springframework.osgi.service.importer.OsgiServiceLifecycleListener;
-
-/**
- * Will send control messages to the ControlBus when OSGi references are bound to the backing services.
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class ControlBusBindingMessageDistributionListener implements
- OsgiServiceLifecycleListener {
- private static final Log log = LogFactory.getLog(ControlBusBindingMessageDistributionListener.class);
- private ControlBus controlBus;
-
- public ControlBusBindingMessageDistributionListener(ControlBus controlBus){
- this.controlBus = controlBus;
- }
-
- /* (non-Javadoc)
- * @see org.springframework.osgi.service.importer.OsgiServiceLifecycleListener#bind(java.lang.Object, java.util.Map)
- */
- @SuppressWarnings("unchecked")
- public void bind(Object service, Map properties) throws Exception {
- if (controlBus.isBusAvailable()){
- log.info("Dispatching BINDING Message for: " + properties.get(IntegrationOSGiConstants.OSGI_BEAN_NAME) +
- "- " + properties + " to: " +
- controlBus.getName());
- MessageBuilder builder = MessageBuilder.withPayload(properties.get(IntegrationOSGiConstants.OSGI_BEAN_NAME));
- builder.copyHeaders(properties);
- builder.setHeader(IntegrationOSGiConstants.INTEGRATION_EVENT_TYPE, IntegrationOSGiConstants.BINDING);
- controlBus.send(builder.build());
- }
- }
-
- /* (non-Javadoc)
- * @see org.springframework.osgi.service.importer.OsgiServiceLifecycleListener#unbind(java.lang.Object, java.util.Map)
- */
- @SuppressWarnings("unchecked")
- public void unbind(Object service, Map properties) throws Exception {
- if (controlBus.isBusAvailable()){
- log.info("Dispatching UNBINDING Message for: " + properties.get(IntegrationOSGiConstants.OSGI_BEAN_NAME) +
- "- " + properties + " to: " +
- controlBus.getName());
- MessageBuilder builder = MessageBuilder.withPayload(properties.get(IntegrationOSGiConstants.OSGI_BEAN_NAME));
- builder.copyHeaders(properties);
- builder.setHeader(IntegrationOSGiConstants.INTEGRATION_EVENT_TYPE, IntegrationOSGiConstants.UNBINDING);
- controlBus.send(builder.build());
- }
- }
-
-}
diff --git a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/extender/ControlBusListeningDecorator.java b/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/extender/ControlBusListeningDecorator.java
deleted file mode 100644
index 38de5a6e1a..0000000000
--- a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/extender/ControlBusListeningDecorator.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.extender;
-
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.integration.controlbus.ControlBus;
-import org.springframework.integration.core.Message;
-import org.springframework.integration.message.MessageHandler;
-import org.springframework.osgi.service.importer.OsgiServiceLifecycleListener;
-
-/**
- * Wraps OSGi Service Reference representing a {@link ControlBus} to provide several simplification
- * around life-cycle of the underlying reference.
- *
- * First, this wrapper implements {@link OsgiServiceLifecycleListener} which will listen for
- * bind/unbind events of the service reference representing a particular instance of the {@link ControlBus} service.
- * Calls to bind/unbind methods will set busAvailable attribute to 'true'/'false' respectively.
- * sparing you from dealing with the internals of the service reference proxy, which might be at the state where
- * it is not backed up by a concrete instance of the {@link ControlBus} service (e.g., when such service is unregistered).
- * This class also implements {@link ControlBus} interface delegating all method calls to the actual instance of the ControlBus
- * with one exception. Call to {@link ControlBus#isBusAvailable()} will return the value of the busAvailable
- * attribute which is set by the calls to bind/unbind methods.
- * This way you can interact with the ControlBus as if it was a real instance of the ControlBus service when it is
- * available, but it also give you a quick and convenient way to know when bus goes away.
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-@SuppressWarnings("unchecked")
-public class ControlBusListeningDecorator implements OsgiServiceLifecycleListener, ControlBus {
-
- private static final Log log = LogFactory.getLog(ControlBusListeningDecorator.class);
- private boolean busAvailable;
- private ControlBus controlBus;
- private String name;
- /*
- * (non-Javadoc)
- * @see org.springframework.osgi.service.importer.OsgiServiceLifecycleListener#bind(java.lang.Object, java.util.Map)
- */
- public void bind(Object service, Map properties) throws Exception {
- controlBus = (ControlBus) service;
- name = controlBus.getName();
- log.debug("Binding to the Control Bus: " + name);
- busAvailable = true;
- }
- /*
- * (non-Javadoc)
- * @see org.springframework.osgi.service.importer.OsgiServiceLifecycleListener#unbind(java.lang.Object, java.util.Map)
- */
- public void unbind(Object service, Map properties) throws Exception {
- log.debug("un-Binding from the Control Bus: " + name);
- busAvailable = false;
- controlBus = null;
- }
- /*
- */
- public void setControlBus(ControlBus controlBus) {
- this.controlBus = controlBus;
- }
- /*
- * (non-Javadoc)
- * @see org.springframework.integration.controlbus.ControlBus#isBusAvailable()
- */
- public boolean isBusAvailable() {
- return busAvailable;
- }
- /*
- */
- public void setBusAvailable(boolean busAvailable) {
- this.busAvailable = busAvailable;
- }
- /*
- * (non-Javadoc)
- * @see org.springframework.integration.channel.SubscribableChannel#subscribe(org.springframework.integration.message.MessageHandler)
- */
- public boolean subscribe(MessageHandler handler) {
- if (isBusAvailable()){
- return controlBus.subscribe(handler);
- } else {
- log.debug("Can not subscribe to the Control Bus: " + name + ". Control Bus is not availabel");
- return false;
- }
- }
- /*
- * (non-Javadoc)
- * @see org.springframework.integration.channel.SubscribableChannel#unsubscribe(org.springframework.integration.message.MessageHandler)
- */
- public boolean unsubscribe(MessageHandler handler) {
- if (isBusAvailable()){
- return controlBus.unsubscribe(handler);
- } else {
- log.debug("Can not unsubscribe from the Control Bus: " + name + ". Control Bus is not availabel");
- return false;
- }
- }
- /*
- * (non-Javadoc)
- * @see org.springframework.integration.core.MessageChannel#getName()
- */
- public String getName() {
- return name;
- }
- /*
- * (non-Javadoc)
- * @see org.springframework.integration.core.MessageChannel#send(org.springframework.integration.core.Message)
- */
- public boolean send(Message> message) {
- if (isBusAvailable()){
- return controlBus.send(message);
- } else {
- log.debug("Can not send message to the Control Bus: " + name + ". Control Bus is not availabel");
- return false;
- }
- }
- /*
- * (non-Javadoc)
- * @see org.springframework.integration.core.MessageChannel#send(org.springframework.integration.core.Message, long)
- */
- public boolean send(Message> message, long timeout) {
- if (isBusAvailable()){
- return controlBus.send(message, timeout);
- } else {
- log.debug("Can not send message to the Control Bus: " + name + ". Control Bus is not availabel");
- return false;
- }
- }
-}
diff --git a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/extender/ControlBusRegistrationMessageDistributionListener.java b/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/extender/ControlBusRegistrationMessageDistributionListener.java
deleted file mode 100644
index 1bfd42810d..0000000000
--- a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/extender/ControlBusRegistrationMessageDistributionListener.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.extender;
-
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.integration.controlbus.ControlBus;
-import org.springframework.integration.message.MessageBuilder;
-import org.springframework.integration.osgi.IntegrationOSGiConstants;
-import org.springframework.osgi.service.exporter.OsgiServiceRegistrationListener;
-
-/**
- * Will send control messages to the ControlBus when OSGi services are registered.
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class ControlBusRegistrationMessageDistributionListener implements OsgiServiceRegistrationListener {
- private static final Log log = LogFactory.getLog(ControlBusRegistrationMessageDistributionListener.class);
- private ControlBus controlBus;
-
- public ControlBusRegistrationMessageDistributionListener(ControlBus controlBus){
- this.controlBus = controlBus;
- }
- /**
- * Will send a notification message to the named {@link ControlBus} notifying that service
- * for an SI component was registered and is ready to be used.
- */
- @SuppressWarnings("unchecked")
- public void registered(Object service, Map properties){
- if (controlBus.isBusAvailable()){
- log.info("Dispatching REGISTRATION Message for: " + service + "- " + properties + " to: " +
- controlBus.getName());
- MessageBuilder builder = MessageBuilder.withPayload(service);
- builder.copyHeaders(properties);
- builder.setHeader(IntegrationOSGiConstants.INTEGRATION_EVENT_TYPE, IntegrationOSGiConstants.REGISTRATION);
- controlBus.send(builder.build());
- }
- }
- /**
- * Will send a notification message to the named {@link ControlBus} notifying that service
- * for an SI component was un-registered and can no longet be used.
- */
- @SuppressWarnings("unchecked")
- public void unregistered(Object service, Map properties){
- if (controlBus.isBusAvailable()){
- log.info("Dispatching UN-REGISTRATION Message for: " + service + "- " + properties + " to: " +
- controlBus.getName());
- MessageBuilder builder = MessageBuilder.withPayload(service);
- builder.copyHeaders(properties);
- builder.setHeader(IntegrationOSGiConstants.INTEGRATION_EVENT_TYPE, IntegrationOSGiConstants.UNREGISTRATION);
- controlBus.send(builder.build());
- }
- }
-}
diff --git a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/extender/LifecycleServiceManagingListener.java b/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/extender/LifecycleServiceManagingListener.java
deleted file mode 100644
index 107c1f8171..0000000000
--- a/org.springframework.integration.osgi/src/main/java/org/springframework/integration/osgi/extender/LifecycleServiceManagingListener.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.extender;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.DirectFieldAccessor;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.context.Lifecycle;
-import org.springframework.osgi.service.importer.OsgiServiceLifecycleListener;
-
-/**
- * Will start/stop {@link Lifecycle} beans that are dependent on OSGi Service references that are being bound/unbound
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class LifecycleServiceManagingListener implements OsgiServiceLifecycleListener, BeanFactoryAware {
- private static final Log log = LogFactory.getLog(LifecycleServiceManagingListener.class);
- private List dependentSources;
- private BeanFactory beanFactory;
-
- /* (non-Javadoc)
- * @see org.springframework.osgi.service.importer.OsgiServiceLifecycleListener#bind(java.lang.Object, java.util.Map)
- */
- public void bind(Object service, Map properties) throws Exception {
- for (String dependentSource : dependentSources) {
- Object bean = beanFactory.getBean(dependentSource);
- if (bean instanceof Lifecycle){
- Lifecycle lifecycle = (Lifecycle) bean;
- if (!lifecycle.isRunning()){
- log.debug("Staring: " + lifecycle);
- lifecycle.start();
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.springframework.osgi.service.importer.OsgiServiceLifecycleListener#unbind(java.lang.Object, java.util.Map)
- */
- public void unbind(Object service, Map properties) throws Exception {
- for (String dependentSource : dependentSources) {
- Object bean = beanFactory.getBean(dependentSource);
- if (bean instanceof Lifecycle){
- Lifecycle lifecycle = (Lifecycle) bean;
- if (lifecycle.isRunning()){
- log.debug("Stopping: " + lifecycle);
- //lifecycle.stop();
- DirectFieldAccessor lifecycleAccessor = new DirectFieldAccessor(lifecycle);
- lifecycleAccessor.setPropertyValue("running", false);
- }
- }
- }
- }
- public List getDependentSources() {
- return dependentSources;
- }
-
- public void setDependentSources(List dependentSources) {
- this.dependentSources = dependentSources;
- }
-
-
- public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
- this.beanFactory = beanFactory;
- }
-}
diff --git a/org.springframework.integration.osgi/src/main/resources/META-INF/spring.handlers b/org.springframework.integration.osgi/src/main/resources/META-INF/spring.handlers
deleted file mode 100644
index 1ddd8fe6db..0000000000
--- a/org.springframework.integration.osgi/src/main/resources/META-INF/spring.handlers
+++ /dev/null
@@ -1,2 +0,0 @@
-http\://www.springframework.org/schema/integration/integration-control-bus=org.springframework.integration.osgi.config.xml.IntegrationOSGiControlBusNamespaceHandler
-http\://www.springframework.org/schema/integration/integration-service-extender=org.springframework.integration.osgi.config.xml.IntegrationOSGiServiceExtenderNamespaceHandler
\ No newline at end of file
diff --git a/org.springframework.integration.osgi/src/main/resources/META-INF/spring.schemas b/org.springframework.integration.osgi/src/main/resources/META-INF/spring.schemas
deleted file mode 100644
index 0475b358bf..0000000000
--- a/org.springframework.integration.osgi/src/main/resources/META-INF/spring.schemas
+++ /dev/null
@@ -1,3 +0,0 @@
-http\://www.springframework.org/schema/integration/integration-control-bus/spring-integration-bus-1.0.xsd=org/springframework/integration/osgi/config/xml/spring-integration-bus-1.0.xsd
-http\://www.springframework.org/schema/integration/integration-service-extender/spring-integration-service-extender-1.0.xsd=org/springframework/integration/osgi/config/xml/spring-integration-service-extender-1.0.xsd
-
diff --git a/org.springframework.integration.osgi/src/main/resources/META-INF/spring/integration-control-bus.xml b/org.springframework.integration.osgi/src/main/resources/META-INF/spring/integration-control-bus.xml
deleted file mode 100644
index 55aeb6149c..0000000000
--- a/org.springframework.integration.osgi/src/main/resources/META-INF/spring/integration-control-bus.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/src/main/resources/org/springframework/integration/osgi/config/xml/spring-integration-bus-1.0.xsd b/org.springframework.integration.osgi/src/main/resources/org/springframework/integration/osgi/config/xml/spring-integration-bus-1.0.xsd
deleted file mode 100644
index ed207e7133..0000000000
--- a/org.springframework.integration.osgi/src/main/resources/org/springframework/integration/osgi/config/xml/spring-integration-bus-1.0.xsd
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
- Configures all required components for a named Control Bus configuration
-
-
-
-
-
- Identifies group-name of a Control Bus this configuration defines
-
-
-
-
-
-
- Identifies the 'task-executor' for this bus's instance
-
-
-
-
-
-
\ No newline at end of file
diff --git a/org.springframework.integration.osgi/src/main/resources/org/springframework/integration/osgi/config/xml/spring-integration-service-extender-1.0.xsd b/org.springframework.integration.osgi/src/main/resources/org/springframework/integration/osgi/config/xml/spring-integration-service-extender-1.0.xsd
deleted file mode 100644
index eb815230eb..0000000000
--- a/org.springframework.integration.osgi/src/main/resources/org/springframework/integration/osgi/config/xml/spring-integration-service-extender-1.0.xsd
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
-
-
-
-
- Configures SI Service Extender, which configures
- existing beans as SI Services.
-
-
-
-
-
-
-
-
-
-
- Identifies the name of the 'bean' to be
- exported as an SI Service. Framework will find bean matching
- this name and export it as an SI Service.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Identifies the name of the 'bean' to be
- imported as an SI Service.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Identifies the supported type of Spring
- Integration components to be
- exported as SI Services. Framework
- will find all components of matching type and export them as
- SI
- Services.
-
-
-
-
-
-
- Will export all components of type
- <publish-subscribe-channel> as SI Services
-
-
-
-
-
-
-
-
- Identifies the name of the 'control-bus'
- which
- will manage this component. This
- means that framework will
- dispatch
- control events to the identified
- 'control-bus'.
- (OPTIONAL if no
- control is necessary)
-
-
-
-
-
\ No newline at end of file
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/AbstractSIConfigBundleTestDeployer.java b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/AbstractSIConfigBundleTestDeployer.java
deleted file mode 100644
index 54b073a1e5..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/AbstractSIConfigBundleTestDeployer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-
-import org.osgi.framework.BundleContext;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.integration.osgi.stubs.SIBundleContextStub;
-import org.springframework.osgi.context.ConfigurableOsgiBundleApplicationContext;
-import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
-import org.springframework.osgi.mock.ArrayEnumerator;
-import org.springframework.osgi.mock.MockBundle;
-
-/**
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public abstract class AbstractSIConfigBundleTestDeployer {
- protected OsgiBundleXmlApplicationContext applicationContext;
-
- @SuppressWarnings("unchecked")
- public ConfigurableOsgiBundleApplicationContext deploySIConfig(BundleContext bundleContext, String configPackage, String... configFiles) throws Exception {
- applicationContext = new OsgiBundleXmlApplicationContext(configFiles);
- final ArrayList tempConfigurations = new ArrayList();
- for (String configFile : configFiles) {
- tempConfigurations.add(new ClassPathResource(configPackage + configFile).getURL());
- }
- ((SIBundleContextStub)bundleContext).setBundle(new MockBundle() {
- public Enumeration findEntries(String path, String filePattern, boolean recurse) {
- return new ArrayEnumerator(tempConfigurations.toArray());
- }
- });
- ((OsgiBundleXmlApplicationContext)applicationContext).setBundleContext(bundleContext);
- ((OsgiBundleXmlApplicationContext)applicationContext).refresh();
- return applicationContext;
- }
-}
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusConfigParserTests-default.xml b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusConfigParserTests-default.xml
deleted file mode 100644
index dc50cfdfc3..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusConfigParserTests-default.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusConfigParserTests-overrideGroupName.xml b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusConfigParserTests-overrideGroupName.xml
deleted file mode 100644
index 394b7fd93f..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusConfigParserTests-overrideGroupName.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusConfigParserTests.java b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusConfigParserTests.java
deleted file mode 100644
index 1b94c0113a..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusConfigParserTests.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.config.xml;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.springframework.context.ApplicationContext;
-import org.springframework.integration.controlbus.ControlBus;
-import org.springframework.integration.osgi.AbstractSIConfigBundleTestDeployer;
-import org.springframework.integration.osgi.IntegrationOSGiConstants;
-import org.springframework.integration.osgi.stubs.SIBundleContextStub;
-
-
-/**
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class BusConfigParserTests extends AbstractSIConfigBundleTestDeployer {
-
- @Test
- public void testDefaultControlBusConfig() throws Exception {
- BundleContext bundleContext = SIBundleContextStub.getInstance();
- ApplicationContext ac = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "BusConfigParserTests-default.xml");
- ControlBus controlBus = (ControlBus) ac.getBean(ControlBusOSGiConfigUtils.DEFAULT_BUS_GROUP_NAME);
- assertNotNull(controlBus);
- ServiceReference[] sr = bundleContext.getServiceReferences(ControlBus.class.getName(),
- "(&(" + IntegrationOSGiConstants.OSGI_BEAN_NAME + "=" +
- ControlBusOSGiConfigUtils.DEFAULT_BUS_GROUP_NAME + "))");
- assertNotNull(sr);
- assertTrue(sr.length == 1);
- controlBus = (ControlBus) bundleContext.getService(sr[0]);
- }
-
- @Test
- public void testNamededControlBusConfig() throws Exception {
- BundleContext bundleContext = SIBundleContextStub.getInstance();
- ApplicationContext ac = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "BusConfigParserTests-overrideGroupName.xml");
- ControlBus controlBus = (ControlBus) ac.getBean("FOO");
- assertNotNull(controlBus);
- ServiceReference sr = bundleContext.getServiceReference(ControlBus.class.getName());
- assertNotNull(sr);
- controlBus = (ControlBus) bundleContext.getService(sr);
- }
-}
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusUsageFailoverReferenceTests-context.xml b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusUsageFailoverReferenceTests-context.xml
deleted file mode 100644
index 19482fdcca..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusUsageFailoverReferenceTests-context.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusUsageFailoverTests-context-primary.xml b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusUsageFailoverTests-context-primary.xml
deleted file mode 100644
index 5a7a111150..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusUsageFailoverTests-context-primary.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusUsageFailoverTests-context-secondary.xml b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusUsageFailoverTests-context-secondary.xml
deleted file mode 100644
index 5a7a111150..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusUsageFailoverTests-context-secondary.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusUsageFailoverTests.java b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusUsageFailoverTests.java
deleted file mode 100644
index b2ca4a7a38..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/BusUsageFailoverTests.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.config.xml;
-
-import java.util.Map;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.osgi.framework.BundleContext;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.integration.controlbus.ControlBus;
-import org.springframework.integration.message.MessageHandler;
-import org.springframework.integration.message.StringMessage;
-import org.springframework.integration.osgi.AbstractSIConfigBundleTestDeployer;
-import org.springframework.integration.osgi.stubs.SIBundleContextStub;
-
-/**
- * This test bootstraps two instances of the Control Bus, then shuts down one demonstrating and testing
- * transparent fail-over to another instance of the Control Bus
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class BusUsageFailoverTests extends AbstractSIConfigBundleTestDeployer {
- static MessageHandler handler = Mockito.mock(MessageHandler.class);
-
-
- @Test
- public void testControlBusFailover() throws Exception {
- BundleContext bundleContext = SIBundleContextStub.getInstance();
-
- ConfigurableApplicationContext primaryAc = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "BusUsageFailoverTests-context-primary.xml");
-
- this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "BusUsageFailoverTests-context-secondary.xml");
-
- ApplicationContext userAC = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "BusUsageFailoverReferenceTests-context.xml");
-
- ControlBus bus = (ControlBus) userAC.getBean("bus");
- StringMessage message = new StringMessage("hello");
-
- bus.send(message);
- Thread.sleep(200);
- Mockito.verify(handler, Mockito.times(1)).handleMessage(message);
- primaryAc.close(); // shut down primary Bus
-
- Mockito.reset(handler);
- bus.send(message);
- Thread.sleep(200);
- Mockito.verify(handler, Mockito.times(1)).handleMessage(message);
- }
-
- public static class BusListener{
- public void bind(ControlBus bus, Map properties){
- bus.subscribe(handler);
- }
- public void unBind(ControlBus bus, Map properties){
- }
- }
-}
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserExporterTests-default.xml b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserExporterTests-default.xml
deleted file mode 100644
index 9309342d35..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserExporterTests-default.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserExporterTests-withbus-attribute.xml b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserExporterTests-withbus-attribute.xml
deleted file mode 100644
index 7068a5e6c2..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserExporterTests-withbus-attribute.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserExporterTests.java b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserExporterTests.java
deleted file mode 100644
index f4875e7d05..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserExporterTests.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.config.xml;
-
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.osgi.framework.BundleContext;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.integration.channel.SubscribableChannel;
-import org.springframework.integration.controlbus.ControlBus;
-import org.springframework.integration.core.Message;
-import org.springframework.integration.message.MessageHandler;
-import org.springframework.integration.message.StringMessage;
-import org.springframework.integration.osgi.AbstractSIConfigBundleTestDeployer;
-import org.springframework.integration.osgi.stubs.SIBundleContextStub;
-
-/**
- * Tests 'config' element.
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class ConfigParserExporterTests extends AbstractSIConfigBundleTestDeployer {
-
- @Test
- public void testBasicSIServiceConfig() throws Exception {
- BundleContext bundleContext = SIBundleContextStub.getNewInstance();
- ApplicationContext ac = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "ConfigParserExporterTests-default.xml");
- assertNotNull(ac.getBean("channelA-Service"));
- assertNotNull(ac.getBean("channelB-Service"));
- assertNotNull(ac.getBean("channelC-Service"));
-
- SubscribableChannel channel = (SubscribableChannel) ac.getBean("channelA");
- SubscribableChannel channel_reference = ac.getBean("channelA-reference", SubscribableChannel.class);
- // verify that standar OSGi configuration can still bind to this service
- MessageHandler handler = Mockito.mock(MessageHandler.class);
- channel_reference.subscribe(handler);
- Message message = new StringMessage("hello");
- channel.send(message);
- Mockito.verify(handler, Mockito.times(1)).handleMessage(message);
- }
- @Test
- public void testControlBusAttributeWithBusPresent() throws Exception {
- BundleContext bundleContext = SIBundleContextStub.getNewInstance();
- ConfigurableApplicationContext busAC = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "BusConfigParserTests-default.xml");
- ConfigurableApplicationContext ac = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "ConfigParserExporterTests-withbus-attribute.xml");
- assertNotNull(ac.getBean("channelA-Service"));
- assertNotNull(ac.getBean("channelB-Service"));
- assertNotNull(ac.getBean("channelC-Service"));
- ControlBus bus = (ControlBus) ac.getBean("DEFAULT_CONTROL_GROUP");
- assertNotNull(bus);
- MessageHandler handler = Mockito.mock(MessageHandler.class);
- bus.subscribe(handler);
- ac.close();
- // should be 3 notification messages sent to the bus
- Mockito.verify(handler, Mockito.times(3)).handleMessage((Message>) Mockito.any());
- }
-}
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserImporterTests-default.xml b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserImporterTests-default.xml
deleted file mode 100644
index 0cf2195d81..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserImporterTests-default.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserImporterTests-exporter.xml b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserImporterTests-exporter.xml
deleted file mode 100644
index c4f141e3a5..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserImporterTests-exporter.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserImporterTests.java b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserImporterTests.java
deleted file mode 100644
index 567691ae64..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/ConfigParserImporterTests.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.config.xml;
-
-import static org.junit.Assert.assertNotNull;
-import junit.framework.Assert;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.osgi.framework.BundleContext;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.Lifecycle;
-import org.springframework.integration.channel.SubscribableChannel;
-import org.springframework.integration.controlbus.ControlBus;
-import org.springframework.integration.core.Message;
-import org.springframework.integration.message.MessageHandler;
-import org.springframework.integration.message.StringMessage;
-import org.springframework.integration.osgi.AbstractSIConfigBundleTestDeployer;
-import org.springframework.integration.osgi.stubs.SIBundleContextStub;
-import org.springframework.osgi.service.ServiceUnavailableException;
-
-/**
- * Tests 'config' element.
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class ConfigParserImporterTests extends AbstractSIConfigBundleTestDeployer {
-
- @Test
- public void testBasicSIServiceConfigNoBackingService() throws Exception {
- BundleContext bundleContext = SIBundleContextStub.getNewInstance();
- ApplicationContext ac = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "ConfigParserImporterTests-default.xml");
- SubscribableChannel channel = ac.getBean("channelA", SubscribableChannel.class);
- assertNotNull(channel);
- }
-
- @Test(expected=ServiceUnavailableException.class)
- public void testBasicSIServiceConfigNoBackingServiceError() throws Exception {
- BundleContext bundleContext = SIBundleContextStub.getNewInstance();
- ApplicationContext ac = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "ConfigParserImporterTests-default.xml");
- SubscribableChannel channel = ac.getBean("channelA", SubscribableChannel.class);
- assertNotNull(channel);
- // try to use it and see error
- channel.send(null);
- }
- /**
- * Will register AC with service importer, then it will register another AC with service exporter
- *
- * @throws Exception
- */
- @Test
- public void testBasicSIServiceConfigWithBackingService() throws Exception {
- BundleContext bundleContext = SIBundleContextStub.getNewInstance();
- ApplicationContext ac = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "ConfigParserImporterTests-default.xml");
- SubscribableChannel channel = ac.getBean("channelA", SubscribableChannel.class);
- assertNotNull(channel);
- this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "ConfigParserImporterTests-exporter.xml");
- MessageHandler handler = Mockito.mock(MessageHandler.class);
- Message message = new StringMessage("hello");
- channel.subscribe(handler);
- channel.send(message);
- Mockito.verify(handler, Mockito.times(1)).handleMessage(message);
- }
- @Test
- public void testBasicSIServiceConfigWithBackingServiceLate() throws Exception {
- BundleContext bundleContext = SIBundleContextStub.getNewInstance();
- ApplicationContext ac = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "ConfigParserImporterTests-default.xml");
- SubscribableChannel channel = ac.getBean("channelA", SubscribableChannel.class);
- assertNotNull(channel);
- Lifecycle sampleActivator = (Lifecycle) ac.getBean("sampleActivator");
- Assert.assertTrue(!sampleActivator.isRunning());
- try {
- channel.send(new StringMessage("hello"));
- Assert.fail("Should have failed with ServiceUnavailableException");
- } catch (ServiceUnavailableException e) {}
-
-
- ConfigurableApplicationContext exporterAC = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "ConfigParserImporterTests-exporter.xml");
- Assert.assertTrue(sampleActivator.isRunning());
- try {
- channel.send(new StringMessage("hello"));
- } catch (Exception e) {
- Assert.fail("Should not have failed");
- }
- exporterAC.close();
- Assert.assertTrue(!sampleActivator.isRunning());
- exporterAC = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "ConfigParserImporterTests-exporter.xml");
- Assert.assertTrue(sampleActivator.isRunning());
- }
-
- @Test
- public void testControlBusAttributeWithBusPresent() throws Exception {
- BundleContext bundleContext = SIBundleContextStub.getNewInstance();
- ConfigurableApplicationContext busAC = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "BusConfigParserTests-default.xml");
- ConfigurableApplicationContext exporterAC = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "ConfigParserImporterTests-exporter.xml");
- ConfigurableApplicationContext ac = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "ConfigParserImporterTests-default.xml");
- assertNotNull(ac.getBean("channelA"));
-
- ControlBus bus = (ControlBus) ac.getBean("DEFAULT_CONTROL_GROUP");
- assertNotNull(bus);
- MessageHandler handler = Mockito.mock(MessageHandler.class);
- bus.subscribe(handler);
- exporterAC.close();
- // should be 1 notification message sent to the bus
- Mockito.verify(handler, Mockito.times(1)).handleMessage((Message>) Mockito.any());
- }
-
- public static class TestBean{
- public void foo(Message> message){}
- }
-}
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/MultiBusDefinitionInSingleApplicationContextTests-context.xml b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/MultiBusDefinitionInSingleApplicationContextTests-context.xml
deleted file mode 100644
index 677be9d45d..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/MultiBusDefinitionInSingleApplicationContextTests-context.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/MultiBusDefinitionInSingleApplicationContextTests.java b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/MultiBusDefinitionInSingleApplicationContextTests.java
deleted file mode 100644
index 1132a0721a..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/MultiBusDefinitionInSingleApplicationContextTests.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.config.xml;
-
-import org.junit.Test;
-import org.osgi.framework.BundleContext;
-import org.springframework.beans.factory.BeanDefinitionStoreException;
-import org.springframework.integration.osgi.AbstractSIConfigBundleTestDeployer;
-import org.springframework.integration.osgi.stubs.SIBundleContextStub;
-
-/**
- * Will make sure only one instance of the Control Bus can exist per single Application Context
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class MultiBusDefinitionInSingleApplicationContextTests extends AbstractSIConfigBundleTestDeployer{
- @Test(expected=BeanDefinitionStoreException.class)
- public void testMultiBusDefinitionConfig() throws Exception {
- BundleContext bundleContext = SIBundleContextStub.getInstance();
- this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/config/xml/",
- "MultiBusDefinitionInSingleApplicationContextTests-context.xml");
- }
-}
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/base-bus-config.xml b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/base-bus-config.xml
deleted file mode 100644
index b172a63904..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/config/xml/base-bus-config.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/demo/SampleActivator.java b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/demo/SampleActivator.java
deleted file mode 100644
index d743e52332..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/demo/SampleActivator.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.springframework.integration.osgi.demo;
-
-import org.springframework.integration.core.Message;
-
-public class SampleActivator {
-
- public void handle(Message> message){
- System.out.println("Message: " + message);
- }
-}
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/demo/SpringDMnoOSGiDemo.java b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/demo/SpringDMnoOSGiDemo.java
deleted file mode 100644
index 3c819e0a6e..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/demo/SpringDMnoOSGiDemo.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.demo;
-
-import org.junit.Test;
-import org.osgi.framework.BundleContext;
-import org.springframework.context.ApplicationContext;
-import org.springframework.integration.channel.SubscribableChannel;
-import org.springframework.integration.message.StringMessage;
-import org.springframework.integration.osgi.AbstractSIConfigBundleTestDeployer;
-import org.springframework.integration.osgi.stubs.SIBundleContextStub;
-import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
-
-/**
- * Simple demo shows how Spring-DM namespace support could be applied without using
- * real OSGi runtime, by simply stubbing out OSGi BundleContext and passing it to
- * OsgiBundleXmlApplicationContext
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class SpringDMnoOSGiDemo extends AbstractSIConfigBundleTestDeployer {
-
- public static void main(String[] args) throws Exception {
- new SpringDMnoOSGiDemo().runDemo();
- }
- /**
- *
- */
- public void runDemo() throws Exception {
- BundleContext bundleContext = SIBundleContextStub.getNewInstance();
- ApplicationContext serviceExporterAC = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/extender/",
- "ac-service-exporter.xml");
- ApplicationContext serviceImporterAC = this.deploySIConfig(bundleContext,
- "org/springframework/integration/osgi/extender/",
- "ac-service-importer.xml");
- // get channel from the exporter AC and send message
- SubscribableChannel channel = serviceExporterAC.getBean("input", SubscribableChannel.class);
- channel.send(new StringMessage("Hello String-DM without OSGi"));
- // the output coming out of Service Activator defined in importer AC should display the message
- }
-
-}
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/demo/ac-service-exporter.xml b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/demo/ac-service-exporter.xml
deleted file mode 100644
index 1ab7f93f89..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/demo/ac-service-exporter.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/demo/ac-service-importer.xml b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/demo/ac-service-importer.xml
deleted file mode 100644
index 1c1740ad8f..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/demo/ac-service-importer.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/stubs/OSGiMockUtils.java b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/stubs/OSGiMockUtils.java
deleted file mode 100644
index 99b53da463..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/stubs/OSGiMockUtils.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.stubs;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.osgi.framework.ServiceReference;
-import org.springframework.osgi.util.internal.MapBasedDictionary;
-import org.springframework.util.StringUtils;
-
-/**
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class OSGiMockUtils {
-
- public static Dictionary parseFilterIntoDictionary(String filter){
- Dictionary properties = new MapBasedDictionary();
- String filterToEvaluate = null;
- if (filter != null){
- StringTokenizer tokenizer = new StringTokenizer(filter, "()&!");
- while(tokenizer.hasMoreTokens()){
- String nextToken = tokenizer.nextToken();
- String name = nextToken.substring(0, nextToken.indexOf("="));
- String value = nextToken.substring(nextToken.indexOf("=")+1);
- properties.put(name, value);
- }
- }
- return properties;
- }
- /**
- *
- * @param originalFilter
- * @param valueToAdd
- */
- public static String addToFilter(String originalFilter, String valueToAdd) {
- MapBasedDictionary original = new MapBasedDictionary(OSGiMockUtils.parseFilterIntoDictionary(originalFilter));
- Dictionary added = OSGiMockUtils.parseFilterIntoDictionary(valueToAdd);
- original.putAll(added);
- StringBuffer newFilter = new StringBuffer("(&");
- Enumeration emum = original.keys();
- while (emum.hasMoreElements()) {
- Object key = (Object) emum.nextElement();
- Object value = original.get(key);
- newFilter.append("(");
- newFilter.append(key);
- newFilter.append("=");
- newFilter.append(value);
- newFilter.append(")");
- }
- newFilter.append(")");
- return newFilter.toString();
- }
- /**
- *
- * @param allServiceReferences
- * @param filter
- * @return
- */
- public static ServiceReference[] buildFilteredServiceReferences(Set allServiceReferences, String filter){
- Dictionary properties = OSGiMockUtils.parseFilterIntoDictionary(filter);
- ArrayList filteredReferences = new ArrayList();
-
- for (ServiceReference sr : allServiceReferences) {
- Enumeration keys = properties.keys();
- boolean match = true;
- inner:
- while (keys.hasMoreElements()) {
- String key = (String) keys.nextElement();
- Object value = properties.get(key);
- Object compareToValue = sr.getProperty(key);
- if (compareToValue != null && compareToValue instanceof String[] && key.equals("objectClass")){
- List srImplementedClasses = Arrays.asList((String[])compareToValue);
- List filteredClasses = Arrays.asList(StringUtils.commaDelimitedListToStringArray((String)value));
- match = srImplementedClasses.containsAll(filteredClasses);
- if (!match){
- break inner;
- }
- } else if (!value.equals(compareToValue)){
- match = false;
- break inner;
- }
- }
- if (match){
- filteredReferences.add(sr);
- }
- }
- ServiceReference[] references = null;
- if (filteredReferences.size() > 0){
- references = new ServiceReference[filteredReferences.size()];
- for (int i = 0; i < filteredReferences.size(); i++) {
- references[i] = filteredReferences.get(i);
- }
- }
- return references;
- }
-
-}
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/stubs/SIBundleContextStub.java b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/stubs/SIBundleContextStub.java
deleted file mode 100644
index 716d7fe82a..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/stubs/SIBundleContextStub.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.stubs;
-
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.mockito.Mockito;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.springframework.osgi.mock.MockBundleContext;
-import org.springframework.osgi.mock.MockServiceReference;
-import org.springframework.osgi.util.internal.MapBasedDictionary;
-
-/**
- * Mock BundleContext to be used for testing
- *
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class SIBundleContextStub extends MockBundleContext {
- private static final Log log = LogFactory.getLog(SIBundleContextStub.class);
- private static SIBundleContextStub bundleContext = new SIBundleContextStub();
-
- private Map services = new HashMap();
-
-
- private Set serviceReferences = new HashSet();
- private Map serviceListenerMap =
- new HashMap();
-
-
- /**
- *
- * @return
- */
- public static SIBundleContextStub getInstance(){
- log.debug("Returning Stubed BundleContext");
- return bundleContext;
- }
- /**
- *
- * @return
- */
- public static SIBundleContextStub getNewInstance(){
- log.debug("Returning newly created Stubed BundleContext");
- return new SIBundleContextStub();
- }
- /**
- *
- */
- @SuppressWarnings("unchecked")
- public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
- if (properties instanceof Hashtable){
- properties = new MapBasedDictionary(properties);
- }
- log.info("Registering SERVICE: " + service);
- SIServiceRegistrationStub reg = new SIServiceRegistrationStub(clazzes, properties);
- reg.setBundleContext(this);
-
- MockServiceReference ref = new MockServiceReference(this.getBundle(), properties, reg, clazzes);
- for (int i = 0; i < clazzes.length; i++) {
- serviceReferences.add(ref);
- }
- if (service instanceof ServiceFactory){
- service = ((ServiceFactory)service).getService(this.getBundle(), reg);
- }
- reg.setReference(ref);
- services.put(ref, service);
- final ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, ref);
- final Set listeners = this.getFilteredListeners(properties);
- for (final ServiceListener listener : listeners) {
-// Thread t = new Thread(new Runnable() {
-// public void run() {
- listener.serviceChanged(event);
-// }
-// });
-// t.start();
- }
- log.info("Registered SERVICE: " + ref);
- return reg;
- }
- /**
- *
- */
- public Object getService(ServiceReference sr){
- return services.get(sr);
- }
- /**
- *
- */
- public ServiceReference getServiceReference(String serviceName){
- String filter = "(&(objectClass=" + serviceName + "))";
- ServiceReference[] references = OSGiMockUtils.buildFilteredServiceReferences(serviceReferences, filter);
- return references == null ? null : references[0];
- }
- /**
- *
- */
- public ServiceReference[] getServiceReferences(String serviceName, String filter) throws InvalidSyntaxException {
- if (serviceName != null){
- String classFilter = "(&(objectClass=" + serviceName + "))";
- filter = OSGiMockUtils.addToFilter(filter, classFilter);
- }
- ServiceReference[] references = OSGiMockUtils.buildFilteredServiceReferences(serviceReferences, filter);
- return references;
- }
- /**
- *
- */
- public void addServiceListener(ServiceListener listener) {
- MapBasedDictionary properties = new MapBasedDictionary();
- serviceListenerMap.put(properties, listener);
- }
- /**
- *
- */
- public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException {
- MapBasedDictionary properties = (MapBasedDictionary) OSGiMockUtils.parseFilterIntoDictionary(filter);
- serviceListenerMap.put(properties, listener);
- }
- @SuppressWarnings("unchecked")
- public Set getFilteredListeners(Dictionary properties){
- Set filteredListeners = new HashSet();
- if (properties != null && properties.size() > 0){
- for (Dictionary filter : serviceListenerMap.keySet()) {
- MapBasedDictionary listenerFilter = new MapBasedDictionary(filter);
-
- log.trace("Trying to match filter properties: " + listenerFilter);
- MapBasedDictionary inFilter = new MapBasedDictionary(properties);
- log.trace("Current filter entry: " + inFilter);
- boolean objecClassMatch = true;
- if (listenerFilter.containsKey("objectClass")){
- objecClassMatch = this.matchObjectClass(listenerFilter, inFilter);
- }
- listenerFilter.remove("objectClass");
- inFilter.remove("objectClass");
- if (inFilter.keySet().containsAll(listenerFilter.keySet()) &&
- inFilter.values().containsAll(listenerFilter.values()) && objecClassMatch){
- filteredListeners.add(serviceListenerMap.get(filter));
- log.debug("Found listener for properties: " + listenerFilter + " - " + serviceListenerMap.get(filter));
- }
- }
- }
- return filteredListeners;
- }
-
- public boolean matchObjectClass(MapBasedDictionary listenerFilter, MapBasedDictionary inFilter){
- String interfaze = (String) listenerFilter.get("objectClass");
- String[] interfaces = (String[]) inFilter.get("objectClass");
-
- return Arrays.binarySearch(interfaces, interfaze) >=0;
- }
- public Map getServiceListenerMap() {
- return serviceListenerMap;
- }
- public Map getServices() {
- return services;
- }
-
- public void remove(ServiceReference sr){
- services.remove(sr);
- serviceReferences.remove(sr);
- }
-}
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/stubs/SIBundleContextStubTest.java b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/stubs/SIBundleContextStubTest.java
deleted file mode 100644
index 31fea698ff..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/stubs/SIBundleContextStubTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.stubs;
-
-import java.io.Serializable;
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class SIBundleContextStubTest {
-
- @Test
- public void validateServiceRegistrationWithNoFilters(){
- BundleContext context = SIBundleContextStub.getInstance();
- context.registerService(Serializable.class.getName(), new Serializable(){}, null);
-
- ServiceReference sr = context.getServiceReference(Serializable.class.getName());
- Assert.assertNotNull(sr);
- Serializable service = (Serializable) context.getService(sr);
- Assert.assertNotNull(service);
- }
- @Test
- public void validateServiceRegistrationWithFiltersNegativeReturn() throws Exception {
- BundleContext context = SIBundleContextStub.getInstance();
- Dictionary properties = new Hashtable();
- properties.put("name", "foo");
- context.registerService(Serializable.class.getName(), new Serializable(){}, properties);
-
- ServiceReference[] srs = context.getServiceReferences(Serializable.class.getName(), "(&(name=bar))");
- Assert.assertTrue("Expected no ServiceReferences", srs == null);
- }
- @Test
- public void validateServiceRegistrationWithFiltersPositiveReturn() throws Exception {
- BundleContext context = SIBundleContextStub.getInstance();
- Dictionary properties = new Hashtable();
- properties.put("name", "foo");
- context.registerService(Serializable.class.getName(), new Serializable(){}, properties);
-
- properties = new Hashtable();
- properties.put("name", "bar");
- context.registerService(Serializable.class.getName(), new Serializable(){}, properties);
-
- ServiceReference[] srs = context.getServiceReferences(Serializable.class.getName(), "(&(name=bar))");
- Assert.assertNotNull(srs);
- }
- @Test
- public void validateServiceListenerRegistrationWithFilter() throws Exception{
- BundleContext context = SIBundleContextStub.getInstance();
- ServiceListener sl = Mockito.mock(ServiceListener.class);
- context.addServiceListener(sl, "(&(name=foo))");
- Dictionary properties = new Hashtable();
- properties.put("name", "foo");
- ServiceRegistration sr =
- context.registerService(Serializable.class.getName(), new Serializable(){}, properties);
- Mockito.verify(sl, Mockito.times(1)).serviceChanged((ServiceEvent) Mockito.anyObject());
- }
-}
diff --git a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/stubs/SIServiceRegistrationStub.java b/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/stubs/SIServiceRegistrationStub.java
deleted file mode 100644
index 0a438fbec2..0000000000
--- a/org.springframework.integration.osgi/src/test/java/org/springframework/integration/osgi/stubs/SIServiceRegistrationStub.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2002-2008 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.integration.osgi.stubs;
-
-import java.util.Dictionary;
-import java.util.Set;
-
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.springframework.beans.DirectFieldAccessor;
-import org.springframework.osgi.mock.MockServiceRegistration;
-
-/**
- * TODO - insert COMMENT
- * @author Oleg Zhurakousky
- * @since 2.0
- */
-public class SIServiceRegistrationStub extends MockServiceRegistration {
- private SIBundleContextStub context;
-
- public SIServiceRegistrationStub(String[] clazz, Dictionary props) {
- super(clazz, props);
- }
- public void setBundleContext(SIBundleContextStub context){
- this.context = context;
- }
- public void unregister() {
- ServiceReference ref = this.getReference();
- DirectFieldAccessor refAccessor = new DirectFieldAccessor(ref);
- Dictionary properties = (Dictionary) refAccessor.getPropertyValue("properties");
-
- context.remove(this.getReference());
- Set listeners = context.getFilteredListeners(properties);
- for (ServiceListener serviceListener : listeners) {
- serviceListener.serviceChanged(new ServiceEvent(ServiceEvent.UNREGISTERING, ref));
- }
- }
-}
diff --git a/org.springframework.integration.osgi/src/test/resources/log4j.xml b/org.springframework.integration.osgi/src/test/resources/log4j.xml
deleted file mode 100644
index d48f36a320..0000000000
--- a/org.springframework.integration.osgi/src/test/resources/log4j.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/org.springframework.integration.osgi/template.mf b/org.springframework.integration.osgi/template.mf
deleted file mode 100644
index 24fcdf40e7..0000000000
--- a/org.springframework.integration.osgi/template.mf
+++ /dev/null
@@ -1,16 +0,0 @@
-Bundle-SymbolicName: org.springframework.integration.osgi
-Bundle-Name: Spring Integration OSGi Extender
-Bundle-Vendor: SpringSource
-Bundle-ManifestVersion: 2
-Import-Package: org.springframework.integration.handler;version="[2.0.0, 2.0.1)",
- org.springframework.integration.config;version="[2.0.0, 2.0.1)",
- org.springframework.integration.router;version="[2.0.0, 2.0.1)",
- org.springframework.integration.endpoint;version="[2.0.0, 2.0.1)",
- org.springframework.scheduling.concurrent;version="[3.0.0, 4.0.0)"
-Import-Template: org.springframework.integration.*;version="[2.0.0, 2.0.1)",
- org.springframework.osgi.*;version="[1.2.0, 2.0.1)",
- org.springframework.*;version="[3.0.0, 4.0.0)",
- org.apache.commons.logging.*;version="[1.1.1,1.1.1]",
- org.w3c.dom;version="0"
-
-
\ No newline at end of file