diff options
Diffstat (limited to '')
5 files changed, 0 insertions, 323 deletions
diff --git a/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/SCANamespaceHandlerResolver.java b/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/SCANamespaceHandlerResolver.java deleted file mode 100644 index 07c7c6a454..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/SCANamespaceHandlerResolver.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.tuscany.sca.implementation.spring.namespace.tie; - -import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver; -import org.springframework.beans.factory.xml.NamespaceHandler; - -/** - * Overrides the default Spring namespace resolver to automatically register - * {@link ScaNamespaceHandler} instead of requiring a value to be supplied in a - * Spring configuration - * - * @version $Rev$ $Date$ - */ -public class SCANamespaceHandlerResolver extends DefaultNamespaceHandlerResolver { - private static final String SCA_NAMESPACE = "http://www.springframework.org/schema/sca"; - - private ScaNamespaceHandler handler; - - public SCANamespaceHandlerResolver(ClassLoader classLoader) { - super(classLoader); - handler = new ScaNamespaceHandler(/*componentType*/); - } - - public SCANamespaceHandlerResolver(String handlerMappingsLocation, ClassLoader classLoader) { - super(classLoader, handlerMappingsLocation); - handler = new ScaNamespaceHandler(/*componentType*/); - } - - @Override - public NamespaceHandler resolve(String namespaceUri) { - if (SCA_NAMESPACE.equals(namespaceUri)) { - return handler; - } - return super.resolve(namespaceUri); - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaNamespaceHandler.java b/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaNamespaceHandler.java deleted file mode 100644 index 27b1811b86..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaNamespaceHandler.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2002-2006 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.apache.tuscany.sca.implementation.spring.namespace.tie; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import javax.xml.namespace.QName; - -import org.springframework.beans.factory.xml.NamespaceHandlerSupport; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * Handler for the <sca:> namespace in an application context - * - * @version $Rev$ $Date$ - */ -public class ScaNamespaceHandler extends NamespaceHandlerSupport { - - public ScaNamespaceHandler() { - } - - @Override - public void init() { - registerBeanDefinitionParser("reference", new ScaReferenceBeanDefinitionParser()); - registerBeanDefinitionParser("service", new ScaServiceBeanDefinitionParser()); - registerBeanDefinitionParser("property", new ScaPropertyBeanDefinitionParser()); - } - - private static String getNamespaceURI(Element element, String prefix) { - if (element == null) { - return null; - } - String name = ("".equals(prefix)) ? "xmlns" : "xmlns:" + prefix; - String ns = element.getAttribute(name); - if (ns != null && !"".equals(ns)) { - return ns; - } - Node parent = element.getParentNode(); - if (parent instanceof Element) { - return getNamespaceURI((Element)parent, prefix); - } else { - return null; - } - } - - public static List<QName> resolve(Element element, String listOfNames) { - List<QName> qnames = new ArrayList<QName>(); - StringTokenizer tokenizer = new StringTokenizer(listOfNames); - while (tokenizer.hasMoreTokens()) { - String qname = tokenizer.nextToken(); - String prefix = ""; - String local = qname; - int index = qname.indexOf(':'); - if (index != -1) { - local = qname.substring(index + 1); - prefix = qname.substring(0, index); - } - String ns = getNamespaceURI(element, prefix); - if (ns != null) { - qnames.add(new QName(ns, local, prefix)); - } else { - throw new IllegalArgumentException("Prefix " + prefix + "is not bound to a namespace"); - } - } - return qnames; - } - - public static String getAttribute(Element element, String name) { - String attr = element.getAttributeNS(null, name); - if ("".equals(attr)) { - return null; - } else { - return attr; - } - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaPropertyBeanDefinitionParser.java b/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaPropertyBeanDefinitionParser.java deleted file mode 100644 index ad11a300ae..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaPropertyBeanDefinitionParser.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2002-2006 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.apache.tuscany.sca.implementation.spring.namespace.tie; - -import org.apache.tuscany.sca.implementation.spring.context.tie.SCAGenericApplicationContext; -import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAPropertyElement; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.beans.factory.xml.BeanDefinitionParser; -import org.springframework.beans.factory.xml.ParserContext; -import org.w3c.dom.Element; - -/** - * Parser for the <sca:reference> element - * @version $Rev$ $Date$ - */ -public class ScaPropertyBeanDefinitionParser implements BeanDefinitionParser { - - public BeanDefinition parse(Element element, ParserContext parserContext) { - BeanDefinitionRegistry registry = parserContext.getRegistry(); - if (registry instanceof SCAGenericApplicationContext) { - SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry; - SpringSCAPropertyElement propertyElement = - new SpringSCAPropertyElement(element.getAttributeNS(null, "name"), element.getAttributeNS(null, "type")); - context.addSCAPropertyElement(propertyElement); - } - // do nothing, this is handled by Tuscany - return null; - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaReferenceBeanDefinitionParser.java b/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaReferenceBeanDefinitionParser.java deleted file mode 100644 index 8470d2ffd5..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaReferenceBeanDefinitionParser.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2002-2006 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.apache.tuscany.sca.implementation.spring.namespace.tie; - -import static org.apache.tuscany.sca.implementation.spring.namespace.tie.ScaNamespaceHandler.getAttribute; - -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.implementation.spring.context.tie.SCAGenericApplicationContext; -import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAReferenceElement; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.beans.factory.xml.BeanDefinitionParser; -import org.springframework.beans.factory.xml.ParserContext; -import org.w3c.dom.Element; - -/** - * Parser for the <sca:reference> element - * - * @version $Rev$ $Date$ - */ -public class ScaReferenceBeanDefinitionParser implements BeanDefinitionParser { - - public BeanDefinition parse(Element element, ParserContext parserContext) { - BeanDefinitionRegistry registry = parserContext.getRegistry(); - if (registry instanceof SCAGenericApplicationContext) { - SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry; - SpringSCAReferenceElement referenceElement = - new SpringSCAReferenceElement(getAttribute(element, "name"), getAttribute(element, "type")); - referenceElement.setDefaultBean(getAttribute(element, "default")); - - String requires = getAttribute(element, "requires"); - if (requires != null) { - List<QName> qnames = ScaNamespaceHandler.resolve(element, requires); - referenceElement.getIntentNames().addAll(qnames); - } - - String policySets = getAttribute(element, "policySets"); - if (policySets != null) { - List<QName> qnames = ScaNamespaceHandler.resolve(element, policySets); - referenceElement.getPolicySetNames().addAll(qnames); - } - - context.addSCAReferenceElement(referenceElement); - } - - // do nothing, this is handled by Tuscany - return null; - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaServiceBeanDefinitionParser.java b/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaServiceBeanDefinitionParser.java deleted file mode 100644 index 900356698d..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC2/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaServiceBeanDefinitionParser.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2002-2006 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.apache.tuscany.sca.implementation.spring.namespace.tie; - -import static org.apache.tuscany.sca.implementation.spring.namespace.tie.ScaNamespaceHandler.getAttribute; - -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.implementation.spring.context.tie.SCAGenericApplicationContext; -import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAServiceElement; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.beans.factory.xml.BeanDefinitionParser; -import org.springframework.beans.factory.xml.ParserContext; -import org.w3c.dom.Element; - -/** - * Parser for the <sca:service/> element - * - * @version $Rev$ $Date$ - */ -public class ScaServiceBeanDefinitionParser implements BeanDefinitionParser { - - public BeanDefinition parse(Element element, ParserContext parserContext) { - BeanDefinitionRegistry registry = parserContext.getRegistry(); - if (registry instanceof SCAGenericApplicationContext) { - SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry; - SpringSCAServiceElement serviceElement = - new SpringSCAServiceElement(getAttribute(element, "name"), getAttribute(element, "target")); - serviceElement.setType(getAttribute(element, "type")); - - String requires = getAttribute(element, "requires"); - if (requires != null) { - List<QName> qnames = ScaNamespaceHandler.resolve(element, requires); - serviceElement.getIntentNames().addAll(qnames); - } - - String policySets = getAttribute(element, "policySets"); - if (policySets != null) { - List<QName> qnames = ScaNamespaceHandler.resolve(element, policySets); - serviceElement.getPolicySetNames().addAll(qnames); - } - - context.addSCAServiceElement(serviceElement); - } - // do nothing, handled by Tuscany - return null; - } - -} |