Author: veithen Date: Mon Mar 29 11:44:48 2010 New Revision: 928727 URL: http://svn.apache.org/viewvc?rev=928727&view=rev Log: AXIS2-4662: Added some Spring related PoC code to my scratch area.
Added: axis/axis2/java/core/scratch/java/veithen/spring/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/pom.xml (with props) axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationBeanFactoryPostProcessor.java (with props) axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationFactory.java (with props) axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationParser.java (with props) axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/Constants.java (with props) axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/NamespaceHandler.java (with props) axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/TransportInDescriptionFactory.java (with props) axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/TransportReceiverParser.java (with props) axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/META-INF/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/META-INF/spring.handlers axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/META-INF/spring.schemas axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/schemas/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/schemas/spring-axis2.xsd axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/axis2/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/axis2/spring/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/axis2/spring/DummyTransportListener.java (with props) axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/axis2/spring/MultiConfigurationTest.java (with props) axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/resources/ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/resources/multi_configuration.xml (with props) Added: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/pom.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/pom.xml?rev=928727&view=auto ============================================================================== --- axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/pom.xml (added) +++ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/pom.xml Mon Mar 29 11:44:48 2010 @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-parent</artifactId> + <version>SNAPSHOT</version> + <!-- relativePath>../parent/pom.xml</relativePath --> + </parent> + <artifactId>axis2-spring-core</artifactId> + <name>Apache Axis2 - Spring - Core</name> + <description>Spring support for Axis2</description> + <dependencies> + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-kernel</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-aop</artifactId> + <version>2.5.1</version> + </dependency> + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-transport-http</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <artifactId>maven-remote-resources-plugin</artifactId> + <executions> + <execution> + <id>legal-files</id> + <goals> + <goal>process</goal> + </goals> + <configuration> + <resourceBundles> + <resourceBundle>org.apache.axis2:axis2-resource-bundle:${project.version}</resourceBundle> + </resourceBundles> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> Propchange: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationBeanFactoryPostProcessor.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationBeanFactoryPostProcessor.java?rev=928727&view=auto ============================================================================== --- axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationBeanFactoryPostProcessor.java (added) +++ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationBeanFactoryPostProcessor.java Mon Mar 29 11:44:48 2010 @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.axis2.spring; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.apache.axis2.description.TransportInDescription; +import org.apache.axis2.engine.AxisConfiguration; +import org.springframework.beans.BeansException; +import org.springframework.beans.PropertyValue; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.beans.factory.config.RuntimeBeanReference; +import org.springframework.beans.factory.support.ManagedList; + +public class AxisConfigurationBeanFactoryPostProcessor implements BeanFactoryPostProcessor { + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { + Map<String,BeanDefinition> axisConfigurations = new HashMap<String,BeanDefinition>(); + for (String name : beanFactory.getBeanNamesForType(AxisConfiguration.class)) { + axisConfigurations.put(name, beanFactory.getBeanDefinition(name)); + } + processItems(beanFactory, axisConfigurations, TransportInDescription.class, "transportInDescriptions"); + } + + private void processItems(ConfigurableListableBeanFactory beanFactory, + Map<String,BeanDefinition> axisConfigurationMap, + Class<?> type, + String propertyName) { + for (String name : beanFactory.getBeanNamesForType(type)) { + BeanDefinition item = beanFactory.getBeanDefinition(name); + String axisConfigurationName = (String)item.getPropertyValues().getPropertyValue(Constants.AXIS_CONFIGURATION_PROPERTY_NAME).getValue(); + Collection<BeanDefinition> axisConfigurations; + if (axisConfigurationName.length() == 0) { + axisConfigurations = axisConfigurationMap.values(); + } else { + BeanDefinition axisConfiguration = axisConfigurationMap.get(axisConfigurationName); + if (axisConfiguration == null) { + throw new RuntimeException(); // TODO + } else { + axisConfigurations = Collections.singleton(axisConfiguration); + } + } + for (BeanDefinition axisConfiguration : axisConfigurations) { + PropertyValue propertyValue = axisConfiguration.getPropertyValues().getPropertyValue(propertyName); + ManagedList list; + if (propertyValue == null) { + list = new ManagedList(); + axisConfiguration.getPropertyValues().addPropertyValue(propertyName, list); + } else { + list = (ManagedList)propertyValue.getValue(); + } + list.add(new RuntimeBeanReference(name)); + } + item.getPropertyValues().removePropertyValue(Constants.AXIS_CONFIGURATION_PROPERTY_NAME); + } + } +} Propchange: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationBeanFactoryPostProcessor.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationFactory.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationFactory.java?rev=928727&view=auto ============================================================================== --- axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationFactory.java (added) +++ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationFactory.java Mon Mar 29 11:44:48 2010 @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.axis2.spring; + +import org.apache.axis2.description.TransportInDescription; +import org.apache.axis2.engine.AxisConfiguration; +import org.springframework.beans.factory.FactoryBean; + +public class AxisConfigurationFactory implements FactoryBean { + private TransportInDescription[] transportInDescriptions; + + public void setTransportInDescriptions(TransportInDescription[] transportInDescriptions) { + this.transportInDescriptions = transportInDescriptions; + } + + public Class getObjectType() { + return AxisConfiguration.class; + } + + public boolean isSingleton() { + return false; + } + + public Object getObject() throws Exception { + AxisConfiguration config = new AxisConfiguration(); + if (transportInDescriptions != null) { + for (TransportInDescription description : transportInDescriptions) { + config.addTransportIn(description); + } + } + return config; + } +} Propchange: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationParser.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationParser.java?rev=928727&view=auto ============================================================================== --- axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationParser.java (added) +++ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationParser.java Mon Mar 29 11:44:48 2010 @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.axis2.spring; + +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; +import org.springframework.beans.factory.xml.ParserContext; +import org.w3c.dom.Element; + +public class AxisConfigurationParser extends AbstractSingleBeanDefinitionParser { + private static final String BEAN_FACTORY_POST_PROCESSOR_BEAN_NAME = AxisConfigurationBeanFactoryPostProcessor.class.getName(); + + @Override + protected Class getBeanClass(Element element) { + return AxisConfigurationFactory.class; + } + + @Override + protected boolean shouldGenerateIdAsFallback() { + return true; + } + + @Override + protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { + registerBeanFactoryPostProcessorIfNecessary(parserContext.getRegistry()); + } + + private static void registerBeanFactoryPostProcessorIfNecessary(BeanDefinitionRegistry registry) { + if (!registry.containsBeanDefinition(BEAN_FACTORY_POST_PROCESSOR_BEAN_NAME)) { + BeanDefinition beanDefinition = new RootBeanDefinition(AxisConfigurationBeanFactoryPostProcessor.class); + registry.registerBeanDefinition(BEAN_FACTORY_POST_PROCESSOR_BEAN_NAME, beanDefinition); + } + } +} Propchange: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/AxisConfigurationParser.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/Constants.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/Constants.java?rev=928727&view=auto ============================================================================== --- axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/Constants.java (added) +++ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/Constants.java Mon Mar 29 11:44:48 2010 @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.axis2.spring; + +public class Constants { + private Constants() {} + + public static final String AXIS_CONFIGURATION_PROPERTY_NAME = "__axisConfiguration__"; +} Propchange: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/Constants.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/NamespaceHandler.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/NamespaceHandler.java?rev=928727&view=auto ============================================================================== --- axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/NamespaceHandler.java (added) +++ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/NamespaceHandler.java Mon Mar 29 11:44:48 2010 @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.axis2.spring; + +import org.springframework.beans.factory.xml.NamespaceHandlerSupport; + +public class NamespaceHandler extends NamespaceHandlerSupport { + public void init() { + registerBeanDefinitionParser("axisConfiguration", new AxisConfigurationParser()); + registerBeanDefinitionParser("transportReceiver", new TransportReceiverParser()); + } +} Propchange: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/NamespaceHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/TransportInDescriptionFactory.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/TransportInDescriptionFactory.java?rev=928727&view=auto ============================================================================== --- axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/TransportInDescriptionFactory.java (added) +++ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/TransportInDescriptionFactory.java Mon Mar 29 11:44:48 2010 @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.axis2.spring; + +import org.apache.axis2.description.TransportInDescription; +import org.apache.axis2.transport.TransportListener; +import org.springframework.beans.factory.FactoryBean; + +public class TransportInDescriptionFactory implements FactoryBean { + private String name; + private TransportListener receiver; + + public void setName(String name) { + this.name = name; + } + + public void setReceiver(TransportListener receiver) { + this.receiver = receiver; + } + + public Class getObjectType() { + return TransportInDescription.class; + } + + public boolean isSingleton() { + return false; + } + + public Object getObject() throws Exception { + TransportInDescription description = new TransportInDescription(name); + description.setReceiver(receiver); + return description; + } +} + Propchange: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/TransportInDescriptionFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/TransportReceiverParser.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/TransportReceiverParser.java?rev=928727&view=auto ============================================================================== --- axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/TransportReceiverParser.java (added) +++ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/TransportReceiverParser.java Mon Mar 29 11:44:48 2010 @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.axis2.spring; + +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; +import org.springframework.beans.factory.xml.ParserContext; +import org.w3c.dom.Element; + +public class TransportReceiverParser extends AbstractSingleBeanDefinitionParser { + @Override + protected Class getBeanClass(Element element) { + return TransportInDescriptionFactory.class; + } + + @Override + protected boolean shouldGenerateId() { + return true; + } + + @Override + protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { + builder.setScope(BeanDefinition.SCOPE_PROTOTYPE); + builder.addPropertyValue(Constants.AXIS_CONFIGURATION_PROPERTY_NAME, element.getAttribute("axisConfiguration")); + builder.addPropertyValue("name", element.getAttribute("name")); + BeanDefinitionBuilder receiver = BeanDefinitionBuilder.rootBeanDefinition(element.getAttribute("class")); + receiver.setSource(parserContext.extractSource(element)); + builder.addPropertyValue("receiver", receiver.getBeanDefinition()); + } +} Propchange: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/java/org/apache/axis2/spring/TransportReceiverParser.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/META-INF/spring.handlers URL: http://svn.apache.org/viewvc/axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/META-INF/spring.handlers?rev=928727&view=auto ============================================================================== --- axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/META-INF/spring.handlers (added) +++ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/META-INF/spring.handlers Mon Mar 29 11:44:48 2010 @@ -0,0 +1,19 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# +http\://axis.apache.org/spring-axis2=org.apache.axis2.spring.NamespaceHandler Added: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/META-INF/spring.schemas URL: http://svn.apache.org/viewvc/axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/META-INF/spring.schemas?rev=928727&view=auto ============================================================================== --- axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/META-INF/spring.schemas (added) +++ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/META-INF/spring.schemas Mon Mar 29 11:44:48 2010 @@ -0,0 +1,19 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# +http\://axis.apache.org/schema/spring-axis2.xsd=schemas/spring-axis2.xsd Added: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/schemas/spring-axis2.xsd URL: http://svn.apache.org/viewvc/axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/schemas/spring-axis2.xsd?rev=928727&view=auto ============================================================================== --- axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/schemas/spring-axis2.xsd (added) +++ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/main/resources/schemas/spring-axis2.xsd Mon Mar 29 11:44:48 2010 @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you 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. + --> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:beans="http://www.springframework.org/schema/beans" + targetNamespace="http://axis.apache.org/spring-axis2" + xmlns:tns="http://axis.apache.org/spring-axis2" elementFormDefault="qualified"> + <import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"/> + <complexType name="parameter"> + <!-- TODO: a parameter can either be a string or an element! --> + <simpleContent> + <extension base="string"> + <attribute name="name" type="string" use="required"/> + <attribute name="locked" type="boolean" use="optional"/> + </extension> + </simpleContent> + </complexType> + <element name="axisConfiguration"> + <complexType> + <complexContent> + <extension base="beans:identifiedType"/> + </complexContent> + </complexType> + </element> + <complexType name="transportDescription"> + <sequence> + <element name="parameter" type="tns:parameter" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="string" use="required"/> + <attribute name="class" type="string" use="required"/> + <attribute name="axisConfiguration" type="string" use="optional"/> + </complexType> + <element name="transportReceiver" type="tns:transportDescription"/> + <element name="transportSender" type="tns:transportDescription"/> +</schema> \ No newline at end of file Added: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/axis2/spring/DummyTransportListener.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/axis2/spring/DummyTransportListener.java?rev=928727&view=auto ============================================================================== --- axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/axis2/spring/DummyTransportListener.java (added) +++ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/axis2/spring/DummyTransportListener.java Mon Mar 29 11:44:48 2010 @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.axis2.spring; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.context.SessionContext; +import org.apache.axis2.description.TransportInDescription; +import org.apache.axis2.transport.TransportListener; + +public class DummyTransportListener implements TransportListener { + public void destroy() { + } + + public EndpointReference getEPRForService(String serviceName, String ip) throws AxisFault { + return null; + } + + public EndpointReference[] getEPRsForService(String serviceName, String ip) throws AxisFault { + return null; + } + + public SessionContext getSessionContext(MessageContext messageContext) { + return null; + } + + public void init(ConfigurationContext axisConf, TransportInDescription transprtIn) throws AxisFault { + } + + public void start() throws AxisFault { + } + + public void stop() throws AxisFault { + } +} Propchange: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/axis2/spring/DummyTransportListener.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/axis2/spring/MultiConfigurationTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/axis2/spring/MultiConfigurationTest.java?rev=928727&view=auto ============================================================================== --- axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/axis2/spring/MultiConfigurationTest.java (added) +++ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/axis2/spring/MultiConfigurationTest.java Mon Mar 29 11:44:48 2010 @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.axis2.spring; + +import java.util.Map; + +import org.apache.axis2.description.TransportInDescription; +import org.apache.axis2.engine.AxisConfiguration; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import junit.framework.TestCase; + +public class MultiConfigurationTest extends TestCase { + public void test() { + ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext("multi_configuration.xml"); + AxisConfiguration config1 = (AxisConfiguration)appContext.getBean("config1"); + AxisConfiguration config2 = (AxisConfiguration)appContext.getBean("config2"); + Map<String,TransportInDescription> transports1 = config1.getTransportsIn(); + Map<String,TransportInDescription> transports2 = config2.getTransportsIn(); + assertEquals(2, transports1.size()); + assertEquals(2, transports2.size()); + assertTrue(transports1.containsKey("dummy1")); + assertTrue(transports1.containsKey("dummy2")); + assertTrue(transports2.containsKey("dummy1")); + assertTrue(transports2.containsKey("dummy3")); + assertNotSame(transports1.get("dummy1").getReceiver(), transports2.get("dummy1").getReceiver()); + } +} Propchange: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/java/org/apache/axis2/spring/MultiConfigurationTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/resources/multi_configuration.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/resources/multi_configuration.xml?rev=928727&view=auto ============================================================================== --- axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/resources/multi_configuration.xml (added) +++ axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/resources/multi_configuration.xml Mon Mar 29 11:44:48 2010 @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you 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. + --> +<beans:beans xmlns:beans="http://www.springframework.org/schema/beans" + xmlns="http://axis.apache.org/spring-axis2" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://axis.apache.org/spring-axis2 http://axis.apache.org/schema/spring-axis2.xsd"> + <axisConfiguration id="config1"/> + <axisConfiguration id="config2"/> + <transportReceiver name="dummy1" class="org.apache.axis2.spring.DummyTransportListener"/> + <transportReceiver name="dummy2" class="org.apache.axis2.spring.DummyTransportListener" axisConfiguration="config1"/> + <transportReceiver name="dummy3" class="org.apache.axis2.spring.DummyTransportListener" axisConfiguration="config2"/> +</beans:beans> Propchange: axis/axis2/java/core/scratch/java/veithen/spring/axis2-spring-core/src/test/resources/multi_configuration.xml ------------------------------------------------------------------------------ svn:eol-style = native