From 558e63a849e90059c16a8834f87b8c39b629b237 Mon Sep 17 00:00:00 2001 From: lresende Date: Sat, 17 Jan 2009 01:27:23 +0000 Subject: TUSCANY-2463 - Storing extended attributes in a second list, wrapped into a extension class that stores the attribute QName, it's value git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@735197 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/assembly/DefaultExtensionFactory.java | 36 ++++++++++++ .../apache/tuscany/sca/assembly/Extensible.java | 7 +++ .../org/apache/tuscany/sca/assembly/Extension.java | 65 ++++++++++++++++++++++ .../tuscany/sca/assembly/ExtensionFactory.java | 28 ++++++++++ .../tuscany/sca/assembly/impl/ExtensibleImpl.java | 6 ++ .../tuscany/sca/assembly/impl/ExtensionImpl.java | 63 +++++++++++++++++++++ ...rg.apache.tuscany.sca.assembly.ExtensionFactory | 18 ++++++ 7 files changed, 223 insertions(+) create mode 100644 branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultExtensionFactory.java create mode 100644 branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java create mode 100644 branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ExtensionFactory.java create mode 100644 branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java create mode 100644 branches/sca-java-1.x/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.ExtensionFactory (limited to 'branches/sca-java-1.x/modules/assembly/src') diff --git a/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultExtensionFactory.java b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultExtensionFactory.java new file mode 100644 index 0000000000..2ed02e214b --- /dev/null +++ b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultExtensionFactory.java @@ -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.sca.assembly; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.impl.ExtensionImpl; + +public class DefaultExtensionFactory implements ExtensionFactory { + + public Extension createExtension() { + return new ExtensionImpl(); + } + + public Extension createExtension(QName name, Object value, boolean isAttribute) { + return new ExtensionImpl(name, value, isAttribute); + } + +} diff --git a/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java index 3577a94d1e..593b7de88b 100644 --- a/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java +++ b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java @@ -33,5 +33,12 @@ public interface Extensible { * @return a list of extension objects container in this model object */ List getExtensions(); + + /** + * Returns a list of attribute extensions contained in this model object + * + * @return a list of attribute extensions contained in this model object + */ + List getAttributeExtensions(); } diff --git a/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java new file mode 100644 index 0000000000..499c97c278 --- /dev/null +++ b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java @@ -0,0 +1,65 @@ +/* + * 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.assembly; + +import javax.xml.namespace.QName; + +/** + * Base interface for storing contents of extensible assembly model objects. + * + * @version $Rev$ $Date$ + */ +public interface Extension { + + /** + * Return QName for the extension + * @return the extension QName + */ + QName getQName(); + + /** + * Set QName for the extension + * @param qName the extension QName + */ + void setQName(QName qName); + + /** + * Return the original extension value + * @return the extension value + */ + Object getValue(); + + /** + * Set the original extension value + * @param value the extension value + */ + void setValue(Object value); + + /** + * Return whether or not the extension is an attribute + * @return + */ + boolean isAttribute(); + + /** + * Set whether or not the extension is an attribute + * @param value + */ + void setIsAttribute(boolean isAttribute); +} diff --git a/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ExtensionFactory.java b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ExtensionFactory.java new file mode 100644 index 0000000000..214cf59748 --- /dev/null +++ b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ExtensionFactory.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.assembly; + +import javax.xml.namespace.QName; + +public interface ExtensionFactory { + + Extension createExtension(); + + Extension createExtension(QName qName, Object value, boolean isAttribute); +} diff --git a/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java index 9a7ca09e43..0a2e25aa43 100644 --- a/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java +++ b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.tuscany.sca.assembly.Extensible; +import org.apache.tuscany.sca.assembly.Extension; /** * Convenience base class for extensible assembly model objects. @@ -30,6 +31,7 @@ import org.apache.tuscany.sca.assembly.Extensible; */ public abstract class ExtensibleImpl extends BaseImpl implements Extensible { private List extensions = new ArrayList(); + private List attributeExtensions = new ArrayList(); /** * Constructs a new base model object. @@ -40,5 +42,9 @@ public abstract class ExtensibleImpl extends BaseImpl implements Extensible { public List getExtensions() { return extensions; } + + public List getAttributeExtensions() { + return attributeExtensions; + } } diff --git a/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java new file mode 100644 index 0000000000..2753bcc091 --- /dev/null +++ b/branches/sca-java-1.x/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java @@ -0,0 +1,63 @@ +/* + * 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.assembly.impl; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.Extension; + +public class ExtensionImpl implements Extension { + private QName qName; + private Object value; + boolean isAttribute = false; + + public ExtensionImpl() { + + } + + public ExtensionImpl(QName qName, Object value, boolean isAttribute) { + this.qName = qName; + this.value = value; + this.isAttribute = isAttribute; + } + + public QName getQName() { + return qName; + } + + public void setQName(QName qName) { + this.qName = qName; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public boolean isAttribute() { + return isAttribute; + } + + public void setIsAttribute(boolean isAttribute) { + this.isAttribute = isAttribute; + } +} diff --git a/branches/sca-java-1.x/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.ExtensionFactory b/branches/sca-java-1.x/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.ExtensionFactory new file mode 100644 index 0000000000..bea25da958 --- /dev/null +++ b/branches/sca-java-1.x/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.ExtensionFactory @@ -0,0 +1,18 @@ +# 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. + +org.apache.tuscany.sca.assembly.DefaultExtensionFactory \ No newline at end of file -- cgit v1.2.3