You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/03/23 16:57:09 UTC
svn commit: r521781 [2/3] - in
/incubator/tuscany/sandbox/sebastien/java/sca/modules: ./ assembly/
assembly/src/main/java/org/apache/tuscany/assembly/model/
assembly/src/main/java/org/apache/tuscany/assembly/model/impl/
assembly/src/main/java/org/apach...
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/java-scdl/src/test/resources/CalculatorImpl.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/java-scdl/src/test/resources/CalculatorImpl.componentType?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/java-scdl/src/test/resources/CalculatorImpl.componentType (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/java-scdl/src/test/resources/CalculatorImpl.componentType Fri Mar 23 08:57:03 2007
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * 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.
+-->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
+
+ <service name="CalculatorService">
+ <interface.java class="calculator.CalculatorService" />
+ </service>
+
+ <reference name="divideService">
+ <interface.java class="calculator.DivideService" />
+ </reference>
+
+</componentType>
+
\ No newline at end of file
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/java-scdl/src/test/resources/CalculatorImpl.componentType
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/java-scdl/src/test/resources/CalculatorImpl.componentType
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/sandbox/sebastien/java/sca/modules/java/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/java/pom.xml?view=diff&rev=521781&r1=521780&r2=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/java/pom.xml (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/java/pom.xml Fri Mar 23 08:57:03 2007
@@ -22,9 +22,10 @@
<groupId>org.apache.tuscany.sca.modules</groupId>
<artifactId>parent</artifactId>
<version>0.1-sandbox-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>tuscany-assembly-java</artifactId>
+ <artifactId>tuscany-java</artifactId>
<packaging>jar</packaging>
<name>Apache Tuscany Java Interface Model</name>
<description>Apache Tuscany Java Interface Model.</description>
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/JavaFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/JavaFactory.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/JavaFactory.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/JavaFactory.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,40 @@
+/*
+ * 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.java.model;
+
+/**
+ * Factory for the Java model
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaFactory {
+
+ /**
+ * Creates a new Java implementation.
+ * @return
+ */
+ JavaImplementation createJavaImplementation();
+
+ /**
+ * Creates a new Java interface.
+ * @return
+ */
+ JavaInterface createJavaInterface();
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/JavaFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/JavaFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/JavaInterface.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/JavaInterface.java?view=diff&rev=521781&r1=521780&r2=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/JavaInterface.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/JavaInterface.java Fri Mar 23 08:57:03 2007
@@ -25,7 +25,7 @@
*
* @version $Rev$ $Date$
*/
-public interface JavaInterface extends Interface{
+public interface JavaInterface extends Interface {
/**
* Returns the name of the Java interface class.
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/JavaFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/JavaFactoryImpl.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/JavaFactoryImpl.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/JavaFactoryImpl.java Fri Mar 23 08:57:03 2007
@@ -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.java.model.impl;
+
+/**
+ * A factory for the Java model.
+ */
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.Service;
+import org.apache.tuscany.java.model.JavaFactory;
+import org.apache.tuscany.java.model.JavaImplementation;
+import org.apache.tuscany.java.model.JavaInterface;
+
+public class JavaFactoryImpl implements JavaFactory {
+
+ private AssemblyFactory assemblyFactory;
+
+ public JavaFactoryImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public JavaImplementation createJavaImplementation() {
+ JavaImplementation javaImplementation = new JavaImplementationImpl();
+
+ //TODO temporary, services should be created by introspecting
+ // the implementation
+ Service service = assemblyFactory.createService();
+ service.setName("default");
+ javaImplementation.getServices().add(service);
+ return javaImplementation;
+ }
+
+ public JavaInterface createJavaInterface() {
+ return new JavaInterfaceImpl();
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/JavaFactoryImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/JavaFactoryImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/JavaImplementationImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/JavaImplementationImpl.java?view=diff&rev=521781&r1=521780&r2=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/JavaImplementationImpl.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/JavaImplementationImpl.java Fri Mar 23 08:57:03 2007
@@ -32,14 +32,14 @@
private Class<?> javaClass;
public String getName() {
- if (isUndefined())
+ if (isUnresolved())
return className;
else
return javaClass.getName();
}
public void setName(String className) {
- if (!isUndefined())
+ if (!isUnresolved())
throw new IllegalStateException();
this.className = className;
}
Modified: incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/JavaInterfaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/JavaInterfaceImpl.java?view=diff&rev=521781&r1=521780&r2=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/JavaInterfaceImpl.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/JavaInterfaceImpl.java Fri Mar 23 08:57:03 2007
@@ -32,14 +32,14 @@
private Class<?> javaClass;
public String getName() {
- if (isUndefined())
+ if (isUnresolved())
return className;
else
return javaClass.getName();
}
public void setName(String className) {
- if (!isUndefined())
+ if (!isUnresolved())
throw new IllegalStateException();
this.className = className;
}
Modified: incubator/tuscany/sandbox/sebastien/java/sca/modules/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/pom.xml?view=diff&rev=521781&r1=521780&r2=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/pom.xml (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/pom.xml Fri Mar 23 08:57:03 2007
@@ -39,9 +39,11 @@
<modules>
<module>policy</module>
<module>assembly</module>
+ <module>scdl</module>
<module>java</module>
+ <module>java-scdl</module>
<module>wsdl</module>
- <module>scdl</module>
+ <module>wsdl-scdl</module>
<module>builder</module>
<module>impl-crud</module>
<module>http</module>
@@ -55,9 +57,11 @@
<modules>
<module>policy</module>
<module>assembly</module>
+ <module>scdl</module>
<module>java</module>
+ <module>java-scdl</module>
<module>wsdl</module>
- <module>scdl</module>
+ <module>wsdl-scdl</module>
<module>builder</module>
<module>impl-crud</module>
<module>http</module>
@@ -71,9 +75,11 @@
<modules>
<module>policy</module>
<module>assembly</module>
+ <module>scdl</module>
<module>java</module>
+ <module>java-scdl</module>
<module>wsdl</module>
- <module>scdl</module>
+ <module>wsdl-scdl</module>
<module>builder</module>
<module>impl-crud</module>
<module>http</module>
Modified: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/pom.xml?view=diff&rev=521781&r1=521780&r2=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/pom.xml (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/pom.xml Fri Mar 23 08:57:03 2007
@@ -22,6 +22,7 @@
<groupId>org.apache.tuscany.sca.modules</groupId>
<artifactId>parent</artifactId>
<version>0.1-sandbox-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>tuscany-assembly-scdl</artifactId>
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/AnyHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/AnyHandler.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/AnyHandler.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/AnyHandler.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,36 @@
+/*
+ * 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.scdl;
+
+import org.xml.sax.ContentHandler;
+
+/**
+ * A content handler for xsd:any extension elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AnyHandler extends ContentHandler {
+
+ /**
+ * Returns the parsed model object.
+ * @return
+ */
+ Object getAny();
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/AnyHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/AnyHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/BindingHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/BindingHandler.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/BindingHandler.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/BindingHandler.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,37 @@
+/*
+ * 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.scdl;
+
+import org.apache.tuscany.assembly.model.Binding;
+import org.xml.sax.ContentHandler;
+
+/**
+ * A content handler for SCDL binding elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BindingHandler extends ContentHandler {
+
+ /**
+ * Returns the parsed binding model object.
+ * @return
+ */
+ Binding getBinding();
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/BindingHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/BindingHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/ContentHandlerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/ContentHandlerRegistry.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/ContentHandlerRegistry.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/ContentHandlerRegistry.java Fri Mar 23 08:57:03 2007
@@ -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.tuscany.scdl;
+
+import org.xml.sax.ContentHandler;
+
+/**
+ * A registry for SCDL content handlers.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ContentHandlerRegistry<H extends ContentHandler> {
+
+ /**
+ * Registers a content handler with an XML element qname.
+ * @param qname
+ * @param handler
+ */
+ void addHandler(String uri, String name, H handler);
+
+ /**
+ * Returns the handler registered with the given XML element qname.
+ * @param qname
+ * @return
+ */
+ H getHandler(String uri, String name);
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/ContentHandlerRegistry.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/ContentHandlerRegistry.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/ImplementationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/ImplementationHandler.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/ImplementationHandler.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/ImplementationHandler.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,37 @@
+/*
+ * 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.scdl;
+
+import org.apache.tuscany.assembly.model.Implementation;
+import org.xml.sax.ContentHandler;
+
+/**
+ * A content handler for SCDL implementation elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ImplementationHandler extends ContentHandler {
+
+ /**
+ * Returns the implementation model object.
+ * @return
+ */
+ Implementation getImplementation();
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/ImplementationHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/ImplementationHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/InterfaceHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/InterfaceHandler.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/InterfaceHandler.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/InterfaceHandler.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,37 @@
+/*
+ * 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.scdl;
+
+import org.apache.tuscany.assembly.model.Interface;
+import org.xml.sax.ContentHandler;
+
+/**
+ * A content handler for Java interface elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface InterfaceHandler extends ContentHandler {
+
+ /**
+ * Returns the parsed interface model object.
+ * @return
+ */
+ Interface getInterface();
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/InterfaceHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/InterfaceHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeHandler.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeHandler.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeHandler.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,138 @@
+/*
+ * 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.scdl.impl;
+
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.Callback;
+import org.apache.tuscany.assembly.model.ComponentService;
+import org.apache.tuscany.assembly.model.ComponentType;
+import org.apache.tuscany.assembly.model.Contract;
+import org.apache.tuscany.assembly.model.Property;
+import org.apache.tuscany.assembly.model.Reference;
+import org.apache.tuscany.assembly.model.Service;
+import org.apache.tuscany.scdl.Constants;
+import org.apache.tuscany.scdl.ContentHandlerRegistry;
+import org.apache.tuscany.scdl.InterfaceHandler;
+import org.apache.tuscany.scdl.util.BaseHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ A componentType content handler.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeHandler extends BaseHandler implements ContentHandler {
+
+ private ComponentType componentType;
+ private Service service;
+ private Reference reference;
+ private Contract contract;
+ private Property property;
+ private Callback callback;
+ private InterfaceHandler interfaceHandler;
+ private AssemblyFactory factory;
+
+ public ComponentTypeHandler(AssemblyFactory factory, ContentHandlerRegistry<InterfaceHandler> interfaceHandlers) {
+ super(factory, interfaceHandlers, null, null);
+ this.factory = factory;
+ }
+
+ public void startDocument() throws SAXException {
+ componentType = null;
+ }
+
+ public void startElement(String uri, String name, String qname, Attributes attr) throws SAXException {
+ if (Constants.SCA10_NS.equals(uri)) {
+
+ if (Constants.COMPONENT_TYPE.equals(name)) {
+ componentType = factory.createComponentType();
+ componentType.setConstrainingType(getConstrainingType(attr));
+ return;
+
+ } else if (Constants.SERVICE.equals(name)) {
+ service = factory.createService();
+ contract = service;
+ componentType.getServices().add(service);
+ service.setName(getString(attr, Constants.NAME));
+ return;
+
+ } else if (Constants.REFERENCE.equals(name)) {
+ reference = factory.createReference();
+ contract = reference;
+ componentType.getReferences().add(reference);
+ reference.setName(getString(attr, Constants.NAME));
+
+ //TODO support multivalued attribute
+ ComponentService target = factory.createComponentService();
+ target.setUnresolved(true);
+ target.setName(getString(attr, Constants.TARGET));
+ reference.getTargets().add(target);
+ return;
+
+ } else if (Constants.PROPERTY.equals(name)) {
+ property = factory.createProperty();
+ readProperty(property, attr);
+ return;
+
+ } else if (Constants.CALLBACK.equals(name)) {
+ callback = factory.createCallback();
+ contract.setCallback(callback);
+ return;
+ }
+ }
+
+ // Handle interface elements
+ if (contract != null) {
+ interfaceHandler = startInterfaceElement(uri, name, qname, attr);
+ }
+ }
+
+ public void endElement(String uri, String name, String qname) throws SAXException {
+
+ // Handle interface elements
+ if (contract != null) {
+ if (endInterfaceElement(uri, name, qname)) {
+ contract.setInterface(interfaceHandler.getInterface());
+ interfaceHandler = null;
+ return;
+ }
+ }
+
+ if (Constants.SCA10_NS.equals(uri)) {
+ if (Constants.SERVICE.equals(name)) {
+ service = null;
+ contract = null;
+ } else if (Constants.REFERENCE.equals(name)) {
+ reference = null;
+ contract = null;
+ } else if (Constants.PROPERTY.equals(name)) {
+ property = null;
+ } else if (Constants.CALLBACK.equals(name))
+ callback = null;
+ }
+ }
+
+ public ComponentType getComponentType() {
+ return componentType;
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeWriter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeWriter.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeWriter.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeWriter.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,78 @@
+/*
+ * 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.scdl.impl;
+
+import org.apache.tuscany.assembly.model.ComponentType;
+import org.apache.tuscany.assembly.model.Property;
+import org.apache.tuscany.assembly.model.Reference;
+import org.apache.tuscany.assembly.model.Service;
+import org.apache.tuscany.scdl.Constants;
+import org.apache.tuscany.scdl.util.Attr;
+import org.apache.tuscany.scdl.util.BaseWriter;
+import org.xml.sax.SAXException;
+
+/**
+ * A test handler to test the usability of the assembly model API when writing SCDL
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeWriter extends BaseWriter {
+
+ private ComponentType componentType;
+
+ public ComponentTypeWriter(ComponentType componentType) {
+ this.componentType = componentType;
+ }
+
+ protected void write() throws SAXException {
+
+ start(Constants.COMPONENT_TYPE, new Attr(Constants.CONSTRAINING_TYPE, getConstrainingType(componentType)));
+
+ for (Service service: componentType.getServices()) {
+ start(Constants.SERVICE, new Attr(Constants.NAME, service.getName()));
+ if (service.getCallback() != null) {
+ start(Constants.CALLBACK);
+ end(Constants.CALLBACK);
+ }
+ end(Constants.SERVICE);
+ }
+
+ for (Reference reference: componentType.getReferences()) {
+ //TODO handle multivalued target attribute
+ String target = reference.getTargets().isEmpty()? null: reference.getTargets().get(0).getName();
+ start(Constants.REFERENCE,
+ new Attr(Constants.NAME, reference.getName()),
+ new Attr(Constants.TARGET, target));
+ if (reference.getCallback() != null) {
+ start(Constants.CALLBACK);
+ end(Constants.CALLBACK);
+ }
+ end(Constants.REFERENCE);
+ }
+
+ for (Property property: componentType.getProperties()) {
+ start(Constants.PROPERTY, new Attr(Constants.NAME, property.getName()));
+ end(Constants.PROPERTY);
+ }
+
+ end(Constants.COMPONENT_TYPE);
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeWriter.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/CompositeHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/CompositeHandler.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/CompositeHandler.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/CompositeHandler.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,239 @@
+/*
+ * 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.scdl.impl;
+
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.Callback;
+import org.apache.tuscany.assembly.model.Component;
+import org.apache.tuscany.assembly.model.ComponentProperty;
+import org.apache.tuscany.assembly.model.ComponentReference;
+import org.apache.tuscany.assembly.model.ComponentService;
+import org.apache.tuscany.assembly.model.Composite;
+import org.apache.tuscany.assembly.model.CompositeReference;
+import org.apache.tuscany.assembly.model.CompositeService;
+import org.apache.tuscany.assembly.model.Contract;
+import org.apache.tuscany.assembly.model.Property;
+import org.apache.tuscany.assembly.model.Wire;
+import org.apache.tuscany.scdl.BindingHandler;
+import org.apache.tuscany.scdl.Constants;
+import org.apache.tuscany.scdl.ContentHandlerRegistry;
+import org.apache.tuscany.scdl.ImplementationHandler;
+import org.apache.tuscany.scdl.InterfaceHandler;
+import org.apache.tuscany.scdl.util.BaseHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * A composite content handler.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeHandler extends BaseHandler implements ContentHandler {
+
+ private Composite composite;
+ private Component component;
+ private Property property;
+ private ComponentService componentService;
+ private ComponentReference componentReference;
+ private ComponentProperty componentProperty;
+ private CompositeService compositeService;
+ private CompositeReference compositeReference;
+ private Contract contract;
+ private Wire wire;
+ private Callback callback;
+ private AssemblyFactory factory;
+ private InterfaceHandler interfaceHandler;
+ private ImplementationHandler implementationHandler;
+ private BindingHandler bindingHandler;
+
+ public CompositeHandler(AssemblyFactory factory,
+ ContentHandlerRegistry<InterfaceHandler> interfaceHandlers,
+ ContentHandlerRegistry<ImplementationHandler> implementationHandlers,
+ ContentHandlerRegistry<BindingHandler> bindingHandlers) {
+ super(factory, interfaceHandlers, implementationHandlers, bindingHandlers);
+ this.factory = factory;
+ }
+
+ public void startDocument() throws SAXException {
+ composite = null;
+ }
+
+ public void startElement(String uri, String name, String qname, Attributes attr) throws SAXException {
+ if (Constants.SCA10_NS.equals(uri)) {
+
+ if (Constants.COMPOSITE.equals(name)) {
+ composite = factory.createComposite();
+ composite.setName(getQName(attr, Constants.NAME));
+ composite.setAutowire(getBoolean(attr, Constants.AUTOWIRE));
+ composite.setLocal(getBoolean(attr, Constants.LOCAL));
+ composite.setConstrainingType(getConstrainingType(attr));
+ return;
+
+ } else if (Constants.SERVICE.equals(name)) {
+ if (component != null) {
+ componentService = factory.createComponentService();
+ contract = componentService;
+ component.getServices().add(componentService);
+ componentService.setName(getString(attr, Constants.NAME));
+ } else {
+ compositeService = factory.createCompositeService();
+ contract = compositeService;
+ composite.getServices().add(compositeService);
+ compositeService.setName(getString(attr, Constants.NAME));
+
+ ComponentService promoted = factory.createComponentService();
+ promoted.setUnresolved(true);
+ promoted.setName(getString(attr, Constants.PROMOTE));
+ compositeService.setPromotedService(promoted);
+ }
+ return;
+
+ } else if (Constants.REFERENCE.equals(name)) {
+ if (component != null) {
+ componentReference = factory.createComponentReference();
+ contract = componentReference;
+ component.getReferences().add(componentReference);
+ componentReference.setName(getString(attr, Constants.NAME));
+
+ //TODO support multivalued attribute
+ ComponentService target = factory.createComponentService();
+ target.setUnresolved(true);
+ target.setName(getString(attr, Constants.TARGET));
+ componentReference.getTargets().add(target);
+
+ } else {
+ compositeReference = factory.createCompositeReference();
+ contract = compositeReference;
+ composite.getReferences().add(compositeReference);
+ compositeReference.setName(getString(attr, Constants.NAME));
+
+ //TODO support multivalued attribute
+ ComponentReference promoted = factory.createComponentReference();
+ promoted.setUnresolved(true);
+ promoted.setName(getString(attr, Constants.PROMOTE));
+ compositeReference.getPromotedReferences().add(promoted);
+ }
+ return;
+
+ } else if (Constants.PROPERTY.equals(name)) {
+ if (component != null) {
+ componentProperty = factory.createComponentProperty();
+ component.getProperties().add(componentProperty);
+ readProperty(componentProperty, attr);
+ } else {
+ property = factory.createProperty();
+ composite.getProperties().add(property);
+ readProperty(property, attr);
+ }
+ return;
+
+ } else if (Constants.COMPONENT.equals(name)) {
+ component = factory.createComponent();
+ composite.getComponents().add(component);
+ component.setName(getString(attr, Constants.NAME));
+ component.setConstrainingType(getConstrainingType(attr));
+ return;
+
+ } else if (Constants.WIRE.equals(name)) {
+ wire = factory.createWire();
+ composite.getWires().add(wire);
+
+ ComponentReference source = factory.createComponentReference();
+ source.setUnresolved(true);
+ source.setName(getString(attr, Constants.SOURCE));
+ wire.setSource(source);
+
+ ComponentService target = factory.createComponentService();
+ target.setUnresolved(true);
+ target.setName(getString(attr, Constants.TARGET));
+ wire.setTarget(target);
+ return;
+
+ } else if (Constants.CALLBACK.equals(name)) {
+ callback = factory.createCallback();
+ contract.setCallback(callback);
+ return;
+ }
+ }
+
+ // Handle interface elements
+ if (contract != null) {
+ interfaceHandler = startInterfaceElement(uri, name, qname, attr);
+ if (interfaceHandler == null) {
+ bindingHandler = startBindingElement(uri, name, qname, attr);
+ }
+
+ } else if (component != null) {
+
+ // Handle implementation elements
+ implementationHandler = startImplementationElement(uri, name, qname, attr);
+ }
+ }
+
+ public void endElement(String uri, String name, String qname) throws SAXException {
+
+ // Handle interface elements
+ if (contract != null) {
+ if (endInterfaceElement(uri, name, qname)) {
+ contract.setInterface(interfaceHandler.getInterface());
+ interfaceHandler = null;
+ return;
+
+ } else if (endBindingElement(uri, name, qname)) {
+ contract.getBindings().add(bindingHandler.getBinding());
+ bindingHandler = null;
+ return;
+ }
+ } else if (component != null) {
+
+ // Handle implementation elements
+ if (endImplementationElement(uri, name, qname)) {
+ component.setImplementation(implementationHandler.getImplementation());
+ implementationHandler = null;
+ return;
+ }
+ }
+
+ if (Constants.SERVICE.equals(name)) {
+ componentService = null;
+ compositeService = null;
+ contract = null;
+ } else if (Constants.REFERENCE.equals(name)) {
+ componentReference = null;
+ compositeReference = null;
+ contract = null;
+ } else if (Constants.PROPERTY.equals(name)) {
+ componentProperty = null;
+ property = null;
+ } else if (Constants.COMPONENT.equals(name)) {
+ component = null;
+ } else if (Constants.WIRE.equals(name)) {
+ wire= null;
+ } else if (Constants.CALLBACK.equals(name)) {
+ callback = null;
+ }
+ }
+
+ public Composite getComposite() {
+ return composite;
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/CompositeHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/CompositeHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/CompositeWriter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/CompositeWriter.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/CompositeWriter.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/CompositeWriter.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,129 @@
+/*
+ * 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.scdl.impl;
+
+import org.apache.tuscany.assembly.model.Component;
+import org.apache.tuscany.assembly.model.ComponentProperty;
+import org.apache.tuscany.assembly.model.ComponentReference;
+import org.apache.tuscany.assembly.model.ComponentService;
+import org.apache.tuscany.assembly.model.Composite;
+import org.apache.tuscany.assembly.model.CompositeReference;
+import org.apache.tuscany.assembly.model.CompositeService;
+import org.apache.tuscany.assembly.model.Property;
+import org.apache.tuscany.assembly.model.Reference;
+import org.apache.tuscany.assembly.model.Service;
+import org.apache.tuscany.scdl.Constants;
+import org.apache.tuscany.scdl.util.Attr;
+import org.apache.tuscany.scdl.util.BaseWriter;
+import org.xml.sax.SAXException;
+
+/**
+ * A test handler to test the usability of the assembly model API when writing SCDL
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeWriter extends BaseWriter {
+
+ private Composite composite;
+
+ public CompositeWriter(Composite composite) {
+ this.composite = composite;
+ }
+
+ protected void write() throws SAXException {
+
+ start(Constants.COMPOSITE, new Attr(Constants.CONSTRAINING_TYPE, getConstrainingType(composite)));
+
+ for (Service service: composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+ ComponentService promotedService = compositeService.getPromotedService();
+ String promote = promotedService != null? promotedService.getName():null;
+ start(Constants.SERVICE,
+ new Attr(Constants.NAME, service.getName()),
+ new Attr(Constants.PROMOTE, promote));
+ if (service.getCallback() != null) {
+ start(Constants.CALLBACK);
+ end(Constants.CALLBACK);
+ }
+ end(Constants.SERVICE);
+ }
+
+ for (Component component: composite.getComponents()) {
+ start(Constants.COMPONENT,
+ new Attr(Constants.NAME, component.getName()));
+
+ for (ComponentService service: component.getServices()) {
+ start(Constants.SERVICE,
+ new Attr(Constants.NAME, service.getName()));
+ end(Constants.SERVICE);
+ if (service.getCallback() != null) {
+ start(Constants.CALLBACK);
+ end(Constants.CALLBACK);
+ }
+ }
+
+ for (ComponentReference reference: component.getReferences()) {
+ //TODO handle multivalued target attribute
+ String target = reference.getTargets().isEmpty()? null: reference.getTargets().get(0).getName();
+ start(Constants.REFERENCE,
+ new Attr(Constants.NAME, reference.getName()),
+ new Attr(Constants.TARGET, target));
+ if (reference.getCallback() != null) {
+ start(Constants.CALLBACK);
+ end(Constants.CALLBACK);
+ }
+ end(Constants.REFERENCE);
+ }
+
+ for (ComponentProperty property: component.getProperties()) {
+ start(Constants.PROPERTY, new Attr(Constants.NAME, property.getName()));
+ end(Constants.PROPERTY);
+ }
+
+ end(Constants.COMPONENT);
+ }
+
+ for (Reference reference: composite.getReferences()) {
+ //TODO handle multivalued promote attribute
+ CompositeReference compositeReference = (CompositeReference)reference;
+ String promote;
+ if (!compositeReference.getPromotedReferences().isEmpty())
+ promote = compositeReference.getPromotedReferences().get(0).getName();
+ else
+ promote = null;
+ start(Constants.REFERENCE,
+ new Attr(Constants.NAME, reference.getName()),
+ new Attr(Constants.PROMOTE, promote));
+ if (reference.getCallback() != null) {
+ start(Constants.CALLBACK);
+ end(Constants.CALLBACK);
+ }
+ end(Constants.REFERENCE);
+ }
+
+ for (Property property: composite.getProperties()) {
+ start(Constants.PROPERTY, new Attr(Constants.NAME, property.getName()));
+ end(Constants.PROPERTY);
+ }
+
+ end(Constants.COMPOSITE);
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/CompositeWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/CompositeWriter.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeHandler.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeHandler.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeHandler.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,127 @@
+/*
+ * 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.scdl.impl;
+
+import org.apache.tuscany.assembly.model.AbstractContract;
+import org.apache.tuscany.assembly.model.AbstractProperty;
+import org.apache.tuscany.assembly.model.AbstractReference;
+import org.apache.tuscany.assembly.model.AbstractService;
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.ConstrainingType;
+import org.apache.tuscany.scdl.Constants;
+import org.apache.tuscany.scdl.ContentHandlerRegistry;
+import org.apache.tuscany.scdl.InterfaceHandler;
+import org.apache.tuscany.scdl.util.BaseHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * A contrainingType content handler.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConstrainingTypeHandler extends BaseHandler implements ContentHandler {
+
+ private ConstrainingType constrainingType;
+ private AbstractService abstractService;
+ private AbstractReference abstractReference;
+ private AbstractProperty abstractProperty;
+ private AbstractContract abstractContract;
+ private AssemblyFactory factory;
+ private InterfaceHandler interfaceHandler;
+
+ public ConstrainingTypeHandler(AssemblyFactory factory, ContentHandlerRegistry<InterfaceHandler> interfaceHandlers) {
+ super(factory, interfaceHandlers, null, null);
+ this.factory = factory;
+ }
+
+ public void startDocument() throws SAXException {
+ constrainingType = null;
+ }
+
+ public void startElement(String uri, String name, String qname, Attributes attr) throws SAXException {
+ if (Constants.SCA10_NS.equals(uri)) {
+
+ if (Constants.CONSTRAINING_TYPE.equals(name)) {
+ constrainingType = factory.createConstrainingType();
+ constrainingType.setName(getQName(attr, Constants.NAME));
+ return;
+
+ } else if (Constants.SERVICE.equals(name)) {
+ abstractService = factory.createAbstractService();
+ abstractContract = abstractService;
+ constrainingType.getServices().add(abstractService);
+ abstractService.setName(getString(attr, Constants.NAME));
+ return;
+
+ } else if (Constants.REFERENCE.equals(name)) {
+ abstractReference = factory.createAbstractReference();
+ abstractContract = abstractReference;
+ constrainingType.getReferences().add(abstractReference);
+ abstractReference.setName(getString(attr, Constants.NAME));
+ return;
+
+ } else if (Constants.PROPERTY.equals(name)) {
+ abstractProperty = factory.createAbstractProperty();
+ constrainingType.getProperties().add(abstractProperty);
+ readAbstractProperty(abstractProperty, attr);
+ return;
+ }
+ }
+
+ // Handle interface elements
+ if (abstractContract !=null) {
+ interfaceHandler = startInterfaceElement(uri, name, qname, attr);
+ }
+
+ }
+
+ public void endElement(String uri, String name, String qname) throws SAXException {
+
+ // Handle interface elements
+ if (abstractContract !=null) {
+ if (endInterfaceElement(uri, name, qname)) {
+ abstractContract.setInterface(interfaceHandler.getInterface());
+ interfaceHandler = null;
+ return;
+ }
+ }
+
+ if (Constants.SCA10_NS.equals(uri)) {
+ if (Constants.SERVICE.equals(name)) {
+ abstractService = null;
+ abstractContract = null;
+
+ } else if (Constants.REFERENCE.equals(name)) {
+ abstractReference = null;
+ abstractContract = null;
+
+ } else if (Constants.PROPERTY.equals(name)) {
+ abstractProperty = null;
+ }
+ }
+ }
+
+ public ConstrainingType getConstrainingType() {
+ return constrainingType;
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeWriter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeWriter.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeWriter.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeWriter.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,67 @@
+/*
+ * 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.scdl.impl;
+
+import org.apache.tuscany.assembly.model.AbstractProperty;
+import org.apache.tuscany.assembly.model.AbstractReference;
+import org.apache.tuscany.assembly.model.AbstractService;
+import org.apache.tuscany.assembly.model.ConstrainingType;
+import org.apache.tuscany.scdl.Constants;
+import org.apache.tuscany.scdl.util.Attr;
+import org.apache.tuscany.scdl.util.BaseWriter;
+import org.xml.sax.SAXException;
+
+/**
+ * A test handler to test the usability of the assembly model API when writing SCDL
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConstrainingTypeWriter extends BaseWriter {
+
+ private ConstrainingType constrainingType;
+
+ public ConstrainingTypeWriter(ConstrainingType constrainingType) {
+ this.constrainingType = constrainingType;
+ }
+
+ protected void write() throws SAXException {
+
+ start(Constants.CONSTRAINING_TYPE);
+
+ for (AbstractService service: constrainingType.getServices()) {
+ start(Constants.SERVICE, new Attr(Constants.NAME, service.getName()));
+ end(Constants.SERVICE);
+ }
+
+ for (AbstractReference reference: constrainingType.getReferences()) {
+ //TODO handle multivalued target attribute
+ start(Constants.REFERENCE, new Attr(Constants.NAME, reference.getName()));
+ end(Constants.REFERENCE);
+ }
+
+ for (AbstractProperty property: constrainingType.getProperties()) {
+ start(Constants.PROPERTY, new Attr(Constants.NAME, property.getName()));
+ end(Constants.PROPERTY);
+ }
+
+ end(Constants.CONSTRAINING_TYPE);
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeWriter.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/DefaultContentHandlerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/DefaultContentHandlerRegistry.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/DefaultContentHandlerRegistry.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/DefaultContentHandlerRegistry.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,41 @@
+/*
+ * 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.scdl.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.scdl.ContentHandlerRegistry;
+import org.xml.sax.ContentHandler;
+
+public class DefaultContentHandlerRegistry<H extends ContentHandler> implements ContentHandlerRegistry<H> {
+
+ private Map<QName, H> map = new HashMap<QName, H>();
+
+ public void addHandler(String uri, String name, H handler) {
+ map.put(new QName(uri, name), handler);
+ }
+
+ public H getHandler(String uri, String name) {
+ return map.get(new QName(uri, name));
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/DefaultContentHandlerRegistry.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/impl/DefaultContentHandlerRegistry.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/Attr.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/Attr.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/Attr.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/Attr.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,71 @@
+/*
+ * 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.scdl.util;
+
+import javax.xml.namespace.QName;
+
+import org.xml.sax.helpers.AttributesImpl;
+
+public class Attr {
+
+ String uri;
+ String name;
+ Object value;
+
+ public Attr(String uri, String name, String value) {
+ this.uri = uri;
+ this.name = name;
+ this.value = value;
+ }
+
+ public Attr(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public Attr(String uri, String name, boolean value) {
+ this.uri = uri;
+ this.name = name;
+ this.value = value;
+ }
+
+ public Attr(String name, boolean value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public Attr(String uri, String name, QName value) {
+ this.uri = uri;
+ this.name = name;
+ this.value = value;
+ }
+
+ public Attr(String name, QName value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ void write(AttributesImpl attrs) {
+ if (value != null) {
+ attrs.addAttribute(uri, name, name, "CDATA", String.valueOf(value));
+ }
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/Attr.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/Attr.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/BaseHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/BaseHandler.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/BaseHandler.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/BaseHandler.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,196 @@
+/*
+ * 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.scdl.util;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.assembly.model.AbstractProperty;
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.ConstrainingType;
+import org.apache.tuscany.assembly.model.Property;
+import org.apache.tuscany.scdl.BindingHandler;
+import org.apache.tuscany.scdl.ContentHandlerRegistry;
+import org.apache.tuscany.scdl.ImplementationHandler;
+import org.apache.tuscany.scdl.InterfaceHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * A test handler to test the usability of the assembly model API when loading SCDL
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseHandler extends DefaultHandler implements ContentHandler {
+
+ protected final static String sca10 = "http://www.osoa.org/xmlns/sca/1.0";
+
+ private AssemblyFactory factory;
+ private ContentHandlerRegistry<InterfaceHandler> interfaceHandlers;
+ private ContentHandlerRegistry<ImplementationHandler> implementationHandlers;
+ private ContentHandlerRegistry<BindingHandler> bindingHandlers;
+ private NamespaceStack nsStack = new NamespaceStack();
+ private InterfaceHandler interfaceHandler;
+ private ImplementationHandler implementationHandler;
+ private BindingHandler bindingHandler;
+ private int elementCount;
+
+ public BaseHandler(AssemblyFactory factory,
+ ContentHandlerRegistry<InterfaceHandler> interfaceHandlers,
+ ContentHandlerRegistry<ImplementationHandler> implementationHandlers,
+ ContentHandlerRegistry<BindingHandler> bindingHandlers) {
+
+ this.factory = factory;
+ this.interfaceHandlers = interfaceHandlers;
+ this.implementationHandlers = implementationHandlers;
+ this.bindingHandlers = bindingHandlers;
+ }
+
+ protected String getString(Attributes attr, String name) {
+ return attr.getValue(name);
+ }
+
+ protected QName getQName(Attributes attr, String name) {
+ String qName = attr.getValue(name);
+ int index = qName.indexOf(':');
+ String prefix = index == -1 ? "" : qName.substring(0, index);
+ String localName = index == -1 ? qName : qName.substring(index);
+ String ns = nsStack.getNamespaceURI(prefix);
+ if (ns == null) {
+ ns = "";
+ }
+ return new QName(ns, localName, prefix);
+ }
+
+ protected boolean getBoolean(Attributes attr, String name) {
+ return Boolean.valueOf(attr.getValue(name));
+ }
+
+ protected ConstrainingType getConstrainingType(Attributes attr) {
+ String constrainingTypeName = attr.getValue(sca10, "constrainingType");
+ if (constrainingTypeName != null) {
+ ConstrainingType constrainingType = factory.createConstrainingType();
+ constrainingType.setName(new QName(constrainingTypeName));
+ constrainingType.setUnresolved(true);
+ return constrainingType;
+ } else {
+ return null;
+ }
+ }
+
+ protected void readAbstractProperty(AbstractProperty prop, Attributes attr) {
+ prop.setName(getString(attr, "name"));
+ prop.setMany(getBoolean(attr, "many"));
+ prop.setMustSupply(getBoolean(attr, "mustSupply"));
+ String xsdElement = getString(attr, "element");
+ if (xsdElement != null) {
+ prop.setXSDElement(new QName(xsdElement));
+ }
+ String xsdType = getString(attr, "type");
+ if (xsdType != null) {
+ prop.setXSDType(new QName(xsdType));
+ }
+ // TODO handle default value
+ }
+
+ protected void readProperty(Property prop, Attributes attr) {
+ readAbstractProperty(prop, attr);
+ // TODO handle property value
+ }
+
+ protected InterfaceHandler startInterfaceElement(String uri, String name, String qname, Attributes attr) throws SAXException {
+ if (interfaceHandler == null && interfaceHandlers != null) {
+ interfaceHandler = interfaceHandlers.getHandler(uri, name);
+ }
+ if (interfaceHandler != null) {
+ interfaceHandler.startElement(uri, name, qname, attr);
+ elementCount++;
+ }
+ return interfaceHandler;
+ }
+
+ protected boolean endInterfaceElement(String uri, String name, String qname) throws SAXException {
+ if (interfaceHandler != null) {
+ interfaceHandler.endElement(uri, name, qname);
+ elementCount--;
+ if (elementCount == 0) {
+ interfaceHandler = null;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected ImplementationHandler startImplementationElement(String uri, String name, String qname, Attributes attr) throws SAXException {
+ if (implementationHandler == null && implementationHandlers != null) {
+ implementationHandler = implementationHandlers.getHandler(uri, name);
+ }
+ if (implementationHandler != null) {
+ implementationHandler.startElement(uri, name, qname, attr);
+ elementCount++;
+ }
+ return implementationHandler;
+ }
+
+ protected boolean endImplementationElement(String uri, String name, String qname) throws SAXException {
+ if (implementationHandler != null) {
+ implementationHandler.endElement(uri, name, qname);
+ elementCount--;
+ if (elementCount == 0) {
+ implementationHandler = null;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected BindingHandler startBindingElement(String uri, String name, String qname, Attributes attr) throws SAXException {
+ if (bindingHandler == null && bindingHandlers != null) {
+ bindingHandler = bindingHandlers.getHandler(uri, name);
+ }
+ if (bindingHandler != null) {
+ bindingHandler.startElement(uri, name, qname, attr);
+ elementCount++;
+ }
+ return bindingHandler;
+ }
+
+ protected boolean endBindingElement(String uri, String name, String qname) throws SAXException {
+ if (bindingHandler != null) {
+ bindingHandler.endElement(uri, name, qname);
+ elementCount--;
+ if (elementCount == 0) {
+ bindingHandler = null;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void endPrefixMapping(String prefix) throws SAXException {
+ nsStack.endPrefixMapping(prefix);
+ }
+
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {
+ nsStack.startPrefixMapping(prefix, uri);
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/BaseHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/BaseHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/BaseWriter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/BaseWriter.java?view=auto&rev=521781
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/BaseWriter.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/BaseWriter.java Fri Mar 23 08:57:03 2007
@@ -0,0 +1,113 @@
+/*
+ * 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.scdl.util;
+
+import java.io.IOException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.assembly.model.AbstractProperty;
+import org.apache.tuscany.assembly.model.ComponentType;
+import org.apache.tuscany.assembly.model.ConstrainingType;
+import org.apache.tuscany.assembly.model.Property;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+/**
+ * A test writer to test the usability of the assembly model API when writing SCDL
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseWriter extends XMLFilterImpl {
+
+ protected final static String sca10 = "http://www.osoa.org/xmlns/sca/1.0";
+ protected ContentHandler out;
+
+ /**
+ * This is where you write the logic to produce SCDL.
+ * @throws SAXException
+ */
+ abstract protected void write() throws SAXException;
+
+ public void parse(InputSource input) throws SAXException, IOException {
+ out.startDocument();
+ write();
+ out.endDocument();
+ }
+
+ public void setContentHandler(ContentHandler handler) {
+ super.setContentHandler(handler);
+ out = handler;
+ }
+
+ protected void start(String uri, String name, Attr... attrs) throws SAXException {
+ out.startElement(uri, null, name, attributes(attrs));
+ }
+
+ protected void start(String name, Attr... attrs) throws SAXException {
+ out.startElement(sca10, null, name, attributes(attrs));
+ }
+
+ protected void end(String uri, String name) throws SAXException {
+ out.endElement(uri, null, name);
+ }
+
+ protected void end(String name) throws SAXException {
+ out.endElement(sca10, null, name);
+ }
+
+ protected Attributes attributes(Attr... attrs) {
+ AttributesImpl attributes = new AttributesImpl();
+ for (Attr attr: attrs) {
+ if (attr != null)
+ attr.write(attributes);
+ }
+ return attributes;
+ }
+
+ protected QName getConstrainingType(ComponentType componentType) {
+ ConstrainingType constrainingType = componentType.getConstrainingType();
+ if (constrainingType!=null)
+ return constrainingType.getName();
+ else
+ return null;
+ }
+
+ protected Attributes abstractPropertyAttributes(AbstractProperty prop) {
+ Attributes attributes = attributes(
+ new Attr("name", prop.getName()),
+ new Attr("many", prop.isMany()),
+ new Attr("mustSupply", prop.isMustSupply()),
+ new Attr("element", prop.getXSDElement()),
+ new Attr("type", prop.getXSDType())
+ );
+ // TODO handle default value
+ return attributes;
+ }
+
+ protected Attributes propertyAttributes(Property prop) {
+ // TODO handle property value
+ return abstractPropertyAttributes(prop);
+ }
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/BaseWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/scdl/src/main/java/org/apache/tuscany/scdl/util/BaseWriter.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org