summaryrefslogtreecommitdiffstats
path: root/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace')
-rw-r--r--tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java53
-rw-r--r--tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java38
-rw-r--r--tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java35
-rw-r--r--tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java36
-rw-r--r--tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java36
5 files changed, 198 insertions, 0 deletions
diff --git a/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java b/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java
new file mode 100644
index 0000000000..75e00007f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java
@@ -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.tuscany.sca.implementation.spring.namespace;
+
+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/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java b/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java
new file mode 100644
index 0000000000..f136e45b87
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+/**
+ * Handler for the <sca:> namespace in an application context
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaNamespaceHandler extends NamespaceHandlerSupport {
+
+ public ScaNamespaceHandler() {
+ init();
+ }
+
+ public final void init() {
+ registerBeanDefinitionParser("reference", new ScaReferenceBeanDefinitionParser());
+ registerBeanDefinitionParser("service", new ScaServiceBeanDefinitionParser());
+ registerBeanDefinitionParser("property", new ScaPropertyBeanDefinitionParser());
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java b/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java
new file mode 100644
index 0000000000..5b1064d8d8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java
@@ -0,0 +1,35 @@
+/*
+ * 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;
+
+import org.springframework.beans.factory.config.BeanDefinition;
+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) {
+ // do nothing, this is handled by Tuscany
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java b/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java
new file mode 100644
index 0000000000..fac02760c9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+import org.springframework.beans.factory.config.BeanDefinition;
+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) {
+ // do nothing, this is handled by Tuscany
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java b/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java
new file mode 100644
index 0000000000..3020dca8bc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC3/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+import org.springframework.beans.factory.config.BeanDefinition;
+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) {
+ // do nothing, handled by Tuscany
+ return null;
+ }
+
+}