You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/04/01 06:10:59 UTC
svn commit: r524526 - in /incubator/tuscany/java/sca/scdl4j:
stax/src/test/java/org/apache/tuscany/scdl/stax/impl/
xml/src/main/java/org/apache/tuscany/scdl/
xml/src/main/java/org/apache/tuscany/scdl/impl/
xml/src/main/java/org/apache/tuscany/scdl/util/
Author: rfeng
Date: Sat Mar 31 21:10:58 2007
New Revision: 524526
URL: http://svn.apache.org/viewvc?view=rev&rev=524526
Log:
Format the code based on the tuscany template for eclipse code formatter
Modified:
incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/StAXPerfTest.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/AnyHandler.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/BindingHandler.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/Constants.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/HandlerRegistry.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/ImplementationHandler.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/InterfaceHandler.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/BindingHandlerRegistry.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeHandler.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeWriter.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/CompositeHandler.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/CompositeWriter.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeHandler.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeWriter.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ImplementationHandlerRegistry.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/InterfaceHandlerRegistry.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/Attr.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/BaseHandler.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/BaseWriter.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/DefaultHandlerRegistry.java
incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/NamespaceStack.java
Modified: incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/StAXPerfTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/StAXPerfTest.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/StAXPerfTest.java (original)
+++ incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/StAXPerfTest.java Sat Mar 31 21:10:58 2007
@@ -37,34 +37,34 @@
* @version $Rev$ $Date$
*/
public class StAXPerfTest {
-
+
private XMLInputFactory inputFactory;
private AssemblyFactory assemblyFactory;
private PolicyFactory policyFactory;
private LoaderRegistry loaderRegistry;
- public static void main(String[] args) throws Exception {
-
- StAXPerfTest perfTest = new StAXPerfTest();
- perfTest.setUp();
-
- // Warm up
- for (long i = 0; i<500; i++) {
- perfTest.testReadComposite();
- }
-
- long begin = System.currentTimeMillis();
- long iter = 50000;
- for (long i = 0; i<iter; i++) {
- perfTest.testReadComposite();
- }
- long end = System.currentTimeMillis();
- System.out.println("Iterations: "+ iter);
- double time = ((double)(end - begin)) / ((double)iter);
- System.out.println("Time: "+ time);
- System.out.println("Memory: "+Runtime.getRuntime().totalMemory()/1024);
-
- }
+ public static void main(String[] args) throws Exception {
+
+ StAXPerfTest perfTest = new StAXPerfTest();
+ perfTest.setUp();
+
+ // Warm up
+ for (long i = 0; i < 500; i++) {
+ perfTest.testReadComposite();
+ }
+
+ long begin = System.currentTimeMillis();
+ long iter = 50000;
+ for (long i = 0; i < iter; i++) {
+ perfTest.testReadComposite();
+ }
+ long end = System.currentTimeMillis();
+ System.out.println("Iterations: " + iter);
+ double time = ((double)(end - begin)) / ((double)iter);
+ System.out.println("Time: " + time);
+ System.out.println("Memory: " + Runtime.getRuntime().totalMemory() / 1024);
+
+ }
public void setUp() throws Exception {
inputFactory = XMLInputFactory.newInstance();
@@ -88,8 +88,9 @@
Composite composite = loader.load(reader);
is.close();
- if (composite == null)
- throw new IllegalStateException("Null composite");
+ if (composite == null) {
+ throw new IllegalStateException("Null composite");
+ }
}
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/AnyHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/AnyHandler.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/AnyHandler.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/AnyHandler.java Sat Mar 31 21:10:58 2007
@@ -22,15 +22,16 @@
/**
* A content handler for xsd:any extension elements.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public interface AnyHandler extends ContentHandler {
-
- /**
- * Returns the parsed model object.
- * @return
- */
- Object getAny();
+
+ /**
+ * Returns the parsed model object.
+ *
+ * @return
+ */
+ Object getAny();
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/BindingHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/BindingHandler.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/BindingHandler.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/BindingHandler.java Sat Mar 31 21:10:58 2007
@@ -23,15 +23,16 @@
/**
* A content handler for SCDL binding elements.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public interface BindingHandler extends ContentHandler {
- /**
- * Returns the parsed binding model object.
- * @return
- */
- Binding getBinding();
+ /**
+ * Returns the parsed binding model object.
+ *
+ * @return
+ */
+ Binding getBinding();
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/Constants.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/Constants.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/Constants.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/Constants.java Sat Mar 31 21:10:58 2007
@@ -20,39 +20,39 @@
package org.apache.tuscany.scdl;
public interface Constants {
-
- public final static String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
- public final static String COMPONENT_TYPE = "componentType";
- public final static String SERVICE = "service";
- public final static String REFERENCE = "reference";
- public final static String PROPERTY = "property";
- public final static String CONSTRAINING_TYPE = "constrainingType";
- public final static String COMPOSITE = "composite";
- public final static String INCLUDE = "include";
- public final static String COMPONENT = "component";
- public final static String WIRE = "wire";
- public final static String NAME = "name";
- public final static String TARGET_NAMESPACE = "targetNamespace";
- public final static String LOCAL = "local";
- public final static String AUTOWIRE = "autowire";
- public final static String REQUIRES = "requires";
- public final static String POLICY_SETS = "policySets";
- public final static String OPERATION = "operation";
- public final static String CALLBACK = "callback";
- public final static String PROMOTE = "promote";
- public final static String TARGET = "target";
- public final static String WIRED_BY_IMPL = "wiredByImpl";
- public final static String MULTIPLICITY = "multiplicity";
- public final static String TYPE = "type";
- public final static String ELEMENT = "element";
- public final static String MANY = "many";
- public final static String MUST_SUPPLY = "mustSupply";
- public final static String SOURCE = "source";
- public final static String FILE = "file";
- public final static String URI = "uri";
- public final static String ZERO_ONE = "0..1";
- public final static String ZERO_N = "0..n";
- public final static String ONE_ONE = "1..1";
- public final static String ONE_N = "1..n";
+
+ public final static String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
+ public final static String COMPONENT_TYPE = "componentType";
+ public final static String SERVICE = "service";
+ public final static String REFERENCE = "reference";
+ public final static String PROPERTY = "property";
+ public final static String CONSTRAINING_TYPE = "constrainingType";
+ public final static String COMPOSITE = "composite";
+ public final static String INCLUDE = "include";
+ public final static String COMPONENT = "component";
+ public final static String WIRE = "wire";
+ public final static String NAME = "name";
+ public final static String TARGET_NAMESPACE = "targetNamespace";
+ public final static String LOCAL = "local";
+ public final static String AUTOWIRE = "autowire";
+ public final static String REQUIRES = "requires";
+ public final static String POLICY_SETS = "policySets";
+ public final static String OPERATION = "operation";
+ public final static String CALLBACK = "callback";
+ public final static String PROMOTE = "promote";
+ public final static String TARGET = "target";
+ public final static String WIRED_BY_IMPL = "wiredByImpl";
+ public final static String MULTIPLICITY = "multiplicity";
+ public final static String TYPE = "type";
+ public final static String ELEMENT = "element";
+ public final static String MANY = "many";
+ public final static String MUST_SUPPLY = "mustSupply";
+ public final static String SOURCE = "source";
+ public final static String FILE = "file";
+ public final static String URI = "uri";
+ public final static String ZERO_ONE = "0..1";
+ public final static String ZERO_N = "0..n";
+ public final static String ONE_ONE = "1..1";
+ public final static String ONE_N = "1..n";
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/HandlerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/HandlerRegistry.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/HandlerRegistry.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/HandlerRegistry.java Sat Mar 31 21:10:58 2007
@@ -22,23 +22,25 @@
/**
* A registry for SCDL content handlers.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public interface HandlerRegistry<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);
+ /**
+ * 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);
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/ImplementationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/ImplementationHandler.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/ImplementationHandler.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/ImplementationHandler.java Sat Mar 31 21:10:58 2007
@@ -23,15 +23,16 @@
/**
* A content handler for SCDL implementation elements.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public interface ImplementationHandler extends ContentHandler {
- /**
- * Returns the implementation model object.
- * @return
- */
- Implementation getImplementation();
+ /**
+ * Returns the implementation model object.
+ *
+ * @return
+ */
+ Implementation getImplementation();
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/InterfaceHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/InterfaceHandler.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/InterfaceHandler.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/InterfaceHandler.java Sat Mar 31 21:10:58 2007
@@ -23,15 +23,16 @@
/**
* A content handler for Java interface elements.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public interface InterfaceHandler extends ContentHandler {
- /**
- * Returns the parsed interface model object.
- * @return
- */
- Interface getInterface();
-
+ /**
+ * Returns the parsed interface model object.
+ *
+ * @return
+ */
+ Interface getInterface();
+
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/BindingHandlerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/BindingHandlerRegistry.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/BindingHandlerRegistry.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/BindingHandlerRegistry.java Sat Mar 31 21:10:58 2007
@@ -23,8 +23,8 @@
/**
* A registry for implementation handlers.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class BindingHandlerRegistry extends DefaultHandlerRegistry<BindingHandler> {
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeHandler.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeHandler.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeHandler.java Sat Mar 31 21:10:58 2007
@@ -39,7 +39,7 @@
import org.xml.sax.SAXException;
/**
- A componentType content handler.
+ * A componentType content handler.
*
* @version $Rev$ $Date$
*/
@@ -52,17 +52,18 @@
private Property property;
private Callback callback;
private InterfaceHandler interfaceHandler;
- private BindingHandler bindingHandler;
- private AssemblyFactory factory;
+ private BindingHandler bindingHandler;
+ private AssemblyFactory factory;
- public ComponentTypeHandler(AssemblyFactory factory, PolicyFactory policyFactory,
- HandlerRegistry<InterfaceHandler> interfaceHandlers) {
+ public ComponentTypeHandler(AssemblyFactory factory,
+ PolicyFactory policyFactory,
+ HandlerRegistry<InterfaceHandler> interfaceHandlers) {
super(factory, policyFactory, interfaceHandlers, null, null);
this.factory = factory;
}
-
+
public void startDocument() throws SAXException {
- componentType = null;
+ componentType = null;
}
public void startElement(String uri, String name, String qname, Attributes attr) throws SAXException {
@@ -87,16 +88,16 @@
contract = 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);
+ // TODO support multivalued attribute
+ ComponentService target = factory.createComponentService();
+ target.setUnresolved(true);
+ target.setName(getString(attr, Constants.TARGET));
+ reference.getTargets().add(target);
- componentType.getReferences().add(reference);
+ componentType.getReferences().add(reference);
readPolicies(reference, attr);
- return;
-
+ return;
+
} else if (Constants.PROPERTY.equals(name)) {
property = factory.createProperty();
readProperty(property, attr);
@@ -105,47 +106,47 @@
return;
} else if (Constants.CALLBACK.equals(name)) {
- callback = factory.createCallback();
- contract.setCallback(callback);
+ callback = factory.createCallback();
+ contract.setCallback(callback);
readPolicies(callback, attr);
- return;
+ return;
} else if (Constants.OPERATION.equals(name)) {
- Operation operation = factory.createOperation();
- operation.setName(getString(attr, Constants.NAME));
- operation.setUnresolved(true);
- if (callback != null) {
- readPolicies(callback, operation, attr);
- } else {
- readPolicies(contract, operation, attr);
- }
- }
+ Operation operation = factory.createOperation();
+ operation.setName(getString(attr, Constants.NAME));
+ operation.setUnresolved(true);
+ if (callback != null) {
+ readPolicies(callback, operation, attr);
+ } else {
+ readPolicies(contract, operation, attr);
+ }
+ }
}
-
+
// Handle interface elements
if (contract != null) {
- interfaceHandler = startInterfaceElement(uri, name, qname, attr);
- if (interfaceHandler == null) {
- bindingHandler = startBindingElement(uri, name, qname, attr);
- }
+ interfaceHandler = startInterfaceElement(uri, name, qname, attr);
+ if (interfaceHandler == null) {
+ bindingHandler = startBindingElement(uri, name, qname, attr);
+ }
}
}
public void endElement(String uri, String name, String qname) throws SAXException {
-
- // Handle interface elements
+
+ // 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;
- }
+ 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;
+ }
}
-
+
if (Constants.SCA10_NS.equals(uri)) {
if (Constants.SERVICE.equals(name)) {
service = null;
@@ -156,12 +157,12 @@
} else if (Constants.PROPERTY.equals(name)) {
property = null;
} else if (Constants.CALLBACK.equals(name))
- callback = null;
+ callback = null;
}
}
- public ComponentType getComponentType() {
- return componentType;
- }
+ public ComponentType getComponentType() {
+ return componentType;
+ }
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeWriter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeWriter.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeWriter.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ComponentTypeWriter.java Sat Mar 31 21:10:58 2007
@@ -29,7 +29,8 @@
import org.xml.sax.SAXException;
/**
- * A test handler to test the usability of the assembly model API when writing SCDL
+ * A test handler to test the usability of the assembly model API when writing
+ * SCDL
*
* @version $Rev$ $Date$
*/
@@ -40,39 +41,39 @@
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);
+
+ 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);
}
-
+
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/CompositeHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/CompositeHandler.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/CompositeHandler.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/CompositeHandler.java Sat Mar 31 21:10:58 2007
@@ -62,21 +62,22 @@
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, PolicyFactory policyFactory,
- HandlerRegistry<InterfaceHandler> interfaceHandlers,
- HandlerRegistry<ImplementationHandler> implementationHandlers,
- HandlerRegistry<BindingHandler> bindingHandlers) {
+ private AssemblyFactory factory;
+ private InterfaceHandler interfaceHandler;
+ private ImplementationHandler implementationHandler;
+ private BindingHandler bindingHandler;
+
+ public CompositeHandler(AssemblyFactory factory,
+ PolicyFactory policyFactory,
+ HandlerRegistry<InterfaceHandler> interfaceHandlers,
+ HandlerRegistry<ImplementationHandler> implementationHandlers,
+ HandlerRegistry<BindingHandler> bindingHandlers) {
super(factory, policyFactory, interfaceHandlers, implementationHandlers, bindingHandlers);
this.factory = factory;
}
-
+
public void startDocument() throws SAXException {
- composite = null;
+ composite = null;
}
public void startElement(String uri, String name, String qname, Attributes attr) throws SAXException {
@@ -92,11 +93,11 @@
return;
} else if (Constants.INCLUDE.equals(name)) {
- include = factory.createComposite();
- include.setUnresolved(true);
- composite.getIncludes().add(include);
- return;
-
+ include = factory.createComposite();
+ include.setUnresolved(true);
+ composite.getIncludes().add(include);
+ return;
+
} else if (Constants.SERVICE.equals(name)) {
if (component != null) {
componentService = factory.createComponentService();
@@ -110,11 +111,11 @@
compositeService.setName(getString(attr, Constants.NAME));
ComponentService promoted = factory.createComponentService();
- promoted.setUnresolved(true);
- promoted.setName(getString(attr, Constants.PROMOTE));
- compositeService.setPromotedService(promoted);
+ promoted.setUnresolved(true);
+ promoted.setName(getString(attr, Constants.PROMOTE));
+ compositeService.setPromotedService(promoted);
- composite.getServices().add(compositeService);
+ composite.getServices().add(compositeService);
}
readPolicies(contract, attr);
return;
@@ -125,25 +126,25 @@
contract = 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);
-
+ // TODO support multivalued attribute
+ ComponentService target = factory.createComponentService();
+ target.setUnresolved(true);
+ target.setName(getString(attr, Constants.TARGET));
+ componentReference.getTargets().add(target);
+
component.getReferences().add(componentReference);
} else {
compositeReference = factory.createCompositeReference();
contract = compositeReference;
compositeReference.setName(getString(attr, Constants.NAME));
- //TODO support multivalued attribute
+ // TODO support multivalued attribute
ComponentReference promoted = factory.createComponentReference();
- promoted.setUnresolved(true);
- promoted.setName(getString(attr, Constants.PROMOTE));
- compositeReference.getPromotedReferences().add(promoted);
+ promoted.setUnresolved(true);
+ promoted.setName(getString(attr, Constants.PROMOTE));
+ compositeReference.getPromotedReferences().add(promoted);
- composite.getReferences().add(compositeReference);
+ composite.getReferences().add(compositeReference);
}
readPolicies(contract, attr);
return;
@@ -169,94 +170,94 @@
composite.getComponents().add(component);
readPolicies(component, attr);
return;
-
+
} else if (Constants.WIRE.equals(name)) {
- wire = factory.createWire();
- 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);
-
+ wire = factory.createWire();
+ 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);
+
composite.getWires().add(wire);
readPolicies(wire, attr);
return;
-
- } else if (Constants.CALLBACK.equals(name)) {
+
+ } else if (Constants.CALLBACK.equals(name)) {
callback = factory.createCallback();
contract.setCallback(callback);
readPolicies(callback, attr);
return;
-
- } else if (Constants.OPERATION.equals(name)) {
- Operation operation = factory.createOperation();
- operation.setName(getString(attr, Constants.NAME));
- operation.setUnresolved(true);
- if (callback != null) {
- readPolicies(callback, operation, attr);
- } else {
- readPolicies(contract, operation, attr);
- }
- }
+
+ } else if (Constants.OPERATION.equals(name)) {
+ Operation operation = factory.createOperation();
+ operation.setName(getString(attr, Constants.NAME));
+ operation.setUnresolved(true);
+ if (callback != null) {
+ readPolicies(callback, operation, attr);
+ } else {
+ readPolicies(contract, operation, attr);
+ }
+ }
}
// Handle interface elements
if (contract != null) {
- interfaceHandler = startInterfaceElement(uri, name, qname, attr);
- if (interfaceHandler == null) {
- bindingHandler = startBindingElement(uri, name, qname, attr);
- }
-
+ 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);
+
+ // Handle implementation elements
+ implementationHandler = startImplementationElement(uri, name, qname, attr);
}
}
-
+
public void characters(char[] ch, int start, int length) throws SAXException {
-
- // Handle property value
- if (property != null) {
- property.setDefaultValue(new String(ch, start, length));
- } else if (include != null) {
- include.setName(getQName(new String(ch, start, length)));
- }
+
+ // Handle property value
+ if (property != null) {
+ property.setDefaultValue(new String(ch, start, length));
+ } else if (include != null) {
+ include.setName(getQName(new String(ch, start, length)));
+ }
}
public void endElement(String uri, String name, String qname) throws SAXException {
-
- // Handle interface elements
+
+ // 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;
- }
+ 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;
- }
+
+ // 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.INCLUDE.equals(name)) {
- include = null;
+ include = null;
} else if (Constants.REFERENCE.equals(name)) {
componentReference = null;
compositeReference = null;
@@ -267,14 +268,14 @@
} else if (Constants.COMPONENT.equals(name)) {
component = null;
} else if (Constants.WIRE.equals(name)) {
- wire= null;
+ wire = null;
} else if (Constants.CALLBACK.equals(name)) {
- callback = null;
+ callback = null;
}
}
- public Composite getComposite() {
- return composite;
- }
+ public Composite getComposite() {
+ return composite;
+ }
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/CompositeWriter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/CompositeWriter.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/CompositeWriter.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/CompositeWriter.java Sat Mar 31 21:10:58 2007
@@ -35,7 +35,8 @@
import org.xml.sax.SAXException;
/**
- * A test handler to test the usability of the assembly model API when writing SCDL
+ * A test handler to test the usability of the assembly model API when writing
+ * SCDL
*
* @version $Rev$ $Date$
*/
@@ -46,84 +47,78 @@
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);
+
+ 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);
}
-
+
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeHandler.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeHandler.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeHandler.java Sat Mar 31 21:10:58 2007
@@ -46,17 +46,18 @@
private AbstractReference abstractReference;
private AbstractProperty abstractProperty;
private AbstractContract abstractContract;
- private AssemblyFactory factory;
- private InterfaceHandler interfaceHandler;
+ private AssemblyFactory factory;
+ private InterfaceHandler interfaceHandler;
- public ConstrainingTypeHandler(AssemblyFactory factory, PolicyFactory policyFactory,
- HandlerRegistry<InterfaceHandler> interfaceHandlers) {
+ public ConstrainingTypeHandler(AssemblyFactory factory,
+ PolicyFactory policyFactory,
+ HandlerRegistry<InterfaceHandler> interfaceHandlers) {
super(factory, policyFactory, interfaceHandlers, null, null);
this.factory = factory;
}
-
+
public void startDocument() throws SAXException {
- constrainingType = null;
+ constrainingType = null;
}
public void startElement(String uri, String name, String qname, Attributes attr) throws SAXException {
@@ -92,25 +93,25 @@
return;
}
}
-
+
// Handle interface elements
- if (abstractContract !=null) {
- interfaceHandler = startInterfaceElement(uri, name, qname, attr);
+ 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;
- }
+
+ // 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;
@@ -126,8 +127,8 @@
}
}
- public ConstrainingType getConstrainingType() {
- return constrainingType;
- }
+ public ConstrainingType getConstrainingType() {
+ return constrainingType;
+ }
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeWriter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeWriter.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeWriter.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ConstrainingTypeWriter.java Sat Mar 31 21:10:58 2007
@@ -29,7 +29,8 @@
import org.xml.sax.SAXException;
/**
- * A test handler to test the usability of the assembly model API when writing SCDL
+ * A test handler to test the usability of the assembly model API when writing
+ * SCDL
*
* @version $Rev$ $Date$
*/
@@ -40,28 +41,28 @@
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);
+
+ 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);
}
-
+
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ImplementationHandlerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ImplementationHandlerRegistry.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ImplementationHandlerRegistry.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/ImplementationHandlerRegistry.java Sat Mar 31 21:10:58 2007
@@ -23,8 +23,8 @@
/**
* A registry for implementation handlers.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class ImplementationHandlerRegistry extends DefaultHandlerRegistry<ImplementationHandler> {
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/InterfaceHandlerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/InterfaceHandlerRegistry.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/InterfaceHandlerRegistry.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/impl/InterfaceHandlerRegistry.java Sat Mar 31 21:10:58 2007
@@ -23,8 +23,8 @@
/**
* A registry for interface handlers.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class InterfaceHandlerRegistry extends DefaultHandlerRegistry<InterfaceHandler> {
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/Attr.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/Attr.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/Attr.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/Attr.java Sat Mar 31 21:10:58 2007
@@ -24,48 +24,48 @@
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));
- }
- }
-
+
+ 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));
+ }
+ }
+
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/BaseHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/BaseHandler.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/BaseHandler.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/BaseHandler.java Sat Mar 31 21:10:58 2007
@@ -47,7 +47,8 @@
import org.xml.sax.helpers.DefaultHandler;
/**
- * A test handler to test the usability of the assembly model API when loading SCDL
+ * A test handler to test the usability of the assembly model API when loading
+ * SCDL
*
* @version $Rev$ $Date$
*/
@@ -66,34 +67,35 @@
private BindingHandler bindingHandler;
private int elementCount;
- public BaseHandler(AssemblyFactory factory, PolicyFactory policyFactory,
- HandlerRegistry<InterfaceHandler> interfaceHandlers,
- HandlerRegistry<ImplementationHandler> implementationHandlers,
- HandlerRegistry<BindingHandler> bindingHandlers) {
-
- this.factory = factory;
- this.policyFactory = policyFactory;
- this.interfaceHandlers = interfaceHandlers;
- this.implementationHandlers = implementationHandlers;
- this.bindingHandlers = bindingHandlers;
+ public BaseHandler(AssemblyFactory factory,
+ PolicyFactory policyFactory,
+ HandlerRegistry<InterfaceHandler> interfaceHandlers,
+ HandlerRegistry<ImplementationHandler> implementationHandlers,
+ HandlerRegistry<BindingHandler> bindingHandlers) {
+
+ this.factory = factory;
+ this.policyFactory = policyFactory;
+ this.interfaceHandlers = interfaceHandlers;
+ this.implementationHandlers = implementationHandlers;
+ this.bindingHandlers = bindingHandlers;
}
protected String getString(Attributes attr, String name) {
return attr.getValue(name);
}
-
+
protected QName getQName(String qname) {
if (qname != null) {
- int index = qname.indexOf(':');
- String prefix = index == -1 ? "" : qname.substring(0, index);
- String localName = index == -1 ? qname : qname.substring(index+1);
- String ns = nsStack.getNamespaceURI(prefix);
- if (ns == null) {
- ns = "";
- }
- return new QName(ns, localName, prefix);
+ int index = qname.indexOf(':');
+ String prefix = index == -1 ? "" : qname.substring(0, index);
+ String localName = index == -1 ? qname : qname.substring(index + 1);
+ String ns = nsStack.getNamespaceURI(prefix);
+ if (ns == null) {
+ ns = "";
+ }
+ return new QName(ns, localName, prefix);
} else {
- return null;
+ return null;
}
}
@@ -104,60 +106,60 @@
protected boolean getBoolean(Attributes attr, String name) {
return Boolean.valueOf(attr.getValue(name));
}
-
+
protected List<QName> getQNames(Attributes attr, String name) {
- String value = attr.getValue(name);
- if (value != null) {
- List<QName> qnames = new ArrayList<QName>();
- for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens(); ) {
- qnames.add(getQName(tokens.nextToken()));
- }
- return qnames;
- } else {
- return Collections.emptyList();
- }
+ String value = attr.getValue(name);
+ if (value != null) {
+ List<QName> qnames = new ArrayList<QName>();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ qnames.add(getQName(tokens.nextToken()));
+ }
+ return qnames;
+ } else {
+ return Collections.emptyList();
+ }
}
-
+
protected void readIntents(IntentAttachPoint attachPoint, Attributes attr) {
- readIntents(attachPoint, null, attr);
+ readIntents(attachPoint, null, attr);
}
-
+
protected void readIntents(IntentAttachPoint attachPoint, Operation operation, Attributes attr) {
- String value = attr.getValue(Constants.REQUIRES);
- if (value != null) {
- List<Intent> requiredIntents = attachPoint.getRequiredIntents();
- for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens(); ) {
- QName qname = getQName(tokens.nextToken());
- Intent intent = policyFactory.createIntent();
- intent.setName(qname);
- if (operation != null) {
- intent.getOperations().add(operation);
- }
- requiredIntents.add(intent);
- }
- }
+ String value = attr.getValue(Constants.REQUIRES);
+ if (value != null) {
+ List<Intent> requiredIntents = attachPoint.getRequiredIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQName(tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ if (operation != null) {
+ intent.getOperations().add(operation);
+ }
+ requiredIntents.add(intent);
+ }
+ }
}
-
+
protected void readPolicies(PolicySetAttachPoint attachPoint, Attributes attr) {
- readPolicies(attachPoint, null, attr);
+ readPolicies(attachPoint, null, attr);
}
- protected void readPolicies(PolicySetAttachPoint attachPoint, Operation operation, Attributes attr) {
- readIntents(attachPoint, operation, attr);
-
- String value = attr.getValue(Constants.POLICY_SETS);
- if (value != null) {
- List<PolicySet> policySets = attachPoint.getPolicySets();
- for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens(); ) {
- QName qname = getQName(tokens.nextToken());
- PolicySet policySet = policyFactory.createPolicySet();
- policySet.setName(qname);
- if (operation != null) {
- policySet.getOperations().add(operation);
- }
- policySets.add(policySet);
- }
- }
+ protected void readPolicies(PolicySetAttachPoint attachPoint, Operation operation, Attributes attr) {
+ readIntents(attachPoint, operation, attr);
+
+ String value = attr.getValue(Constants.POLICY_SETS);
+ if (value != null) {
+ List<PolicySet> policySets = attachPoint.getPolicySets();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQName(tokens.nextToken());
+ PolicySet policySet = policyFactory.createPolicySet();
+ policySet.setName(qname);
+ if (operation != null) {
+ policySet.getOperations().add(operation);
+ }
+ policySets.add(policySet);
+ }
+ }
}
protected ConstrainingType getConstrainingType(Attributes attr) {
@@ -183,74 +185,77 @@
protected void readProperty(Property prop, Attributes attr) {
readAbstractProperty(prop, attr);
}
-
- 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 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;
+ 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;
+ 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;
+ 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 {
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/BaseWriter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/BaseWriter.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/BaseWriter.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/BaseWriter.java Sat Mar 31 21:10:58 2007
@@ -35,7 +35,8 @@
import org.xml.sax.helpers.XMLFilterImpl;
/**
- * A test writer to test the usability of the assembly model API when writing SCDL
+ * A test writer to test the usability of the assembly model API when writing
+ * SCDL
*
* @version $Rev$ $Date$
*/
@@ -46,64 +47,63 @@
/**
* 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();
+ out.startDocument();
+ write();
+ out.endDocument();
}
-
+
public void setContentHandler(ContentHandler handler) {
- super.setContentHandler(handler);
- out = handler;
+ super.setContentHandler(handler);
+ out = handler;
}
-
+
protected void start(String uri, String name, Attr... attrs) throws SAXException {
- out.startElement(uri, null, name, attributes(attrs));
+ out.startElement(uri, null, name, attributes(attrs));
}
protected void start(String name, Attr... attrs) throws SAXException {
- out.startElement(sca10, null, name, attributes(attrs));
+ out.startElement(sca10, null, name, attributes(attrs));
}
-
+
protected void end(String uri, String name) throws SAXException {
- out.endElement(uri, null, name);
+ out.endElement(uri, null, name);
}
protected void end(String name) throws SAXException {
- out.endElement(sca10, null, name);
+ 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;
+ 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;
+ 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())
- );
+ 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;
+ return attributes;
}
protected Attributes propertyAttributes(Property prop) {
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/DefaultHandlerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/DefaultHandlerRegistry.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/DefaultHandlerRegistry.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/DefaultHandlerRegistry.java Sat Mar 31 21:10:58 2007
@@ -27,15 +27,15 @@
import org.xml.sax.ContentHandler;
public class DefaultHandlerRegistry<H extends ContentHandler> implements HandlerRegistry<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);
- }
+ private Map<QName, H> map = new HashMap<QName, H>();
- public H getHandler(String uri, String name) {
- return map.get(new QName(uri, name));
- }
+ 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));
+ }
}
Modified: incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/NamespaceStack.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/NamespaceStack.java?view=diff&rev=524526&r1=524525&r2=524526
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/NamespaceStack.java (original)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/main/java/org/apache/tuscany/scdl/util/NamespaceStack.java Sat Mar 31 21:10:58 2007
@@ -68,15 +68,20 @@
}
/**
- * An implementation of the {@link java.util.Stack} API that is based on an <code>ArrayList</code> instead of a
- * <code>Vector</code>, so it is not synchronized to protect against multi-threaded access. The implementation is
- * therefore operates faster in environments where you do not need to worry about multiple thread contention.
+ * An implementation of the {@link java.util.Stack} API that is based on an
+ * <code>ArrayList</code> instead of a <code>Vector</code>, so it is
+ * not synchronized to protect against multi-threaded access. The
+ * implementation is therefore operates faster in environments where you do
+ * not need to worry about multiple thread contention.
* <p>
- * The removal order of an <code>ArrayStack</code> is based on insertion order: The most recently added element is
- * removed first. The iteration order is <i>not</i> the same as the removal order. The iterator returns elements
- * from the bottom up, whereas the {@link #remove()} method removes them from the top down.
+ * The removal order of an <code>ArrayStack</code> is based on insertion
+ * order: The most recently added element is removed first. The iteration
+ * order is <i>not</i> the same as the removal order. The iterator returns
+ * elements from the bottom up, whereas the {@link #remove()} method removes
+ * them from the top down.
* <p>
- * Unlike <code>Stack</code>, <code>ArrayStack</code> accepts null entries.
+ * Unlike <code>Stack</code>, <code>ArrayStack</code> accepts null
+ * entries.
*/
private static class FastStack<T> extends ArrayList<T> {
@@ -84,18 +89,20 @@
private static final long serialVersionUID = 2130079159931574599L;
/**
- * Constructs a new empty <code>ArrayStack</code>. The initial size is controlled by <code>ArrayList</code>
- * and is currently 10.
+ * Constructs a new empty <code>ArrayStack</code>. The initial size
+ * is controlled by <code>ArrayList</code> and is currently 10.
*/
public FastStack() {
super();
}
/**
- * Constructs a new empty <code>ArrayStack</code> with an initial size.
+ * Constructs a new empty <code>ArrayStack</code> with an initial
+ * size.
*
* @param initialSize the initial size to use
- * @throws IllegalArgumentException if the specified initial size is negative
+ * @throws IllegalArgumentException if the specified initial size is
+ * negative
*/
public FastStack(int initialSize) {
super(initialSize);
@@ -104,7 +111,8 @@
/**
* Return <code>true</code> if this stack is currently empty.
* <p>
- * This method exists for compatibility with <code>java.util.Stack</code>. New users of this class should use
+ * This method exists for compatibility with
+ * <code>java.util.Stack</code>. New users of this class should use
* <code>isEmpty</code> instead.
*
* @return true if the stack is currently empty
@@ -129,11 +137,13 @@
}
/**
- * Returns the n'th item down (zero-relative) from the top of this stack without removing it.
+ * Returns the n'th item down (zero-relative) from the top of this stack
+ * without removing it.
*
* @param n the number of items down to go
* @return the n'th item on the stack, zero relative
- * @throws EmptyStackException if there are not enough items on the stack to satisfy this request
+ * @throws EmptyStackException if there are not enough items on the
+ * stack to satisfy this request
*/
public T peek(int n) throws EmptyStackException {
int m = (size() - n) - 1;
@@ -160,8 +170,8 @@
}
/**
- * Pushes a new item onto the top of this stack. The pushed item is also returned. This is equivalent to calling
- * <code>add</code>.
+ * Pushes a new item onto the top of this stack. The pushed item is also
+ * returned. This is equivalent to calling <code>add</code>.
*
* @param item the item to be added
* @return the item just pushed
@@ -172,10 +182,12 @@
}
/**
- * Returns the one-based position of the distance from the top that the specified object exists on this stack,
- * where the top-most element is considered to be at distance <code>1</code>. If the object is not present on
- * the stack, return <code>-1</code> instead. The <code>equals()</code> method is used to compare to the
- * items in this stack.
+ * Returns the one-based position of the distance from the top that the
+ * specified object exists on this stack, where the top-most element is
+ * considered to be at distance <code>1</code>. If the object is not
+ * present on the stack, return <code>-1</code> instead. The
+ * <code>equals()</code> method is used to compare to the items in
+ * this stack.
*
* @param object the object to be searched for
* @return index of the stack for the object, or -1 if not found
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org