From 0daa6e66908eb59332ee38b5bd2193ba40a7eb55 Mon Sep 17 00:00:00 2001 From: antelder Date: Mon, 23 Mar 2009 08:34:33 +0000 Subject: Delete test trunk in sandbox git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@757347 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/interfacedef/java/xml/JavaConstants.java | 35 ---- .../java/xml/JavaInterfaceProcessor.java | 191 --------------------- 2 files changed, 226 deletions(-) delete mode 100644 sandbox/ant/sca/trunk/modules/interface-java-xml/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java delete mode 100644 sandbox/ant/sca/trunk/modules/interface-java-xml/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java (limited to 'sandbox/ant/sca/trunk/modules/interface-java-xml/src/main/java/org') diff --git a/sandbox/ant/sca/trunk/modules/interface-java-xml/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java b/sandbox/ant/sca/trunk/modules/interface-java-xml/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java deleted file mode 100644 index 5e8cf6a433..0000000000 --- a/sandbox/ant/sca/trunk/modules/interface-java-xml/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.interfacedef.java.xml; - -import javax.xml.namespace.QName; - -/** - * Interface Java XML Constants. - * - * @version $Rev$ $Date$ - */ -public interface JavaConstants { - String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903"; - String INTERFACE_JAVA = "interface.java"; - QName INTERFACE_JAVA_QNAME = new QName(SCA11_NS, "interface.java"); - String INTERFACE = "interface"; - String CALLBACK_INTERFACE = "callbackInterface"; - -} diff --git a/sandbox/ant/sca/trunk/modules/interface-java-xml/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java b/sandbox/ant/sca/trunk/modules/interface-java-xml/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java deleted file mode 100644 index 35bc5e8f57..0000000000 --- a/sandbox/ant/sca/trunk/modules/interface-java-xml/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.interfacedef.java.xml; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ClassReference; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; - -/** - * - * @version $Rev$ $Date$ - */ -public class JavaInterfaceProcessor implements StAXArtifactProcessor, JavaConstants { - private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903"; - private JavaInterfaceFactory javaFactory; - private Monitor monitor; - - public JavaInterfaceProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { - this.javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class); - this.monitor = monitor; - } - - /** - * Report a exception. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Exception ex) { - if (monitor != null) { - Problem problem = monitor.createProblem(this.getClass().getName(), "interface-javaxml-validation-messages", Severity.ERROR, model, message, ex); - monitor.problem(problem); - } - } - - /** - * Report a error. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = monitor.createProblem(this.getClass().getName(), "interface-javaxml-validation-messages", Severity.ERROR, model, message,(Object[])messageParameters); - monitor.problem(problem); - } - } - - private JavaInterface createJavaInterface(String interfaceName) { - JavaInterface javaInterface = javaFactory.createJavaInterface(); - javaInterface.setUnresolved(true); - javaInterface.setName(interfaceName); - return javaInterface; - } - - public JavaInterfaceContract read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - - // Read an - JavaInterfaceContract javaInterfaceContract = javaFactory.createJavaInterfaceContract(); - String interfaceName = reader.getAttributeValue(null, INTERFACE); - if (interfaceName != null) { - JavaInterface javaInterface = createJavaInterface(interfaceName); - javaInterfaceContract.setInterface(javaInterface); - } - - String callbackInterfaceName = reader.getAttributeValue(null, CALLBACK_INTERFACE); - if (callbackInterfaceName != null) { - JavaInterface javaCallbackInterface = createJavaInterface(callbackInterfaceName); - javaInterfaceContract.setCallbackInterface(javaCallbackInterface); - } - - // Skip to end element - while (reader.hasNext()) { - if (reader.next() == END_ELEMENT && INTERFACE_JAVA_QNAME.equals(reader.getName())) { - break; - } - } - return javaInterfaceContract; - } - - public void write(JavaInterfaceContract javaInterfaceContract, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - - // Write an - writer.writeStartElement(SCA11_NS, INTERFACE_JAVA); - JavaInterface javaInterface = (JavaInterface)javaInterfaceContract.getInterface(); - - if (javaInterface != null && javaInterface.getName() != null) { - writer.writeAttribute(INTERFACE, javaInterface.getName()); - } - - JavaInterface javaCallbackInterface = (JavaInterface)javaInterfaceContract.getCallbackInterface(); - if (javaCallbackInterface != null && javaCallbackInterface.getName() != null) { - writer.writeAttribute(CALLBACK_INTERFACE, javaCallbackInterface.getName()); - } - - writer.writeEndElement(); - } - - private JavaInterface resolveJavaInterface(JavaInterface javaInterface, ModelResolver resolver) throws ContributionResolveException { - - if (javaInterface != null && javaInterface.isUnresolved()) { - - // Resolve the Java interface - javaInterface = resolver.resolveModel(JavaInterface.class, javaInterface); - if (javaInterface.isUnresolved()) { - - // If the Java interface has never been resolved yet, do it now - ClassReference classReference = new ClassReference(javaInterface.getName()); - classReference = resolver.resolveModel(ClassReference.class, classReference); - Class javaClass = classReference.getJavaClass(); - if (javaClass == null) { - error("ClassNotFoundException", resolver, javaInterface.getName()); - return javaInterface; - //throw new ContributionResolveException(new ClassNotFoundException(javaInterface.getName())); - } - - try { - // Introspect the Java interface and populate the interface and - // operations - javaFactory.createJavaInterface(javaInterface, javaClass); - - } catch (InvalidInterfaceException e) { - ContributionResolveException ce = new ContributionResolveException(e); - error("ContributionResolveException", javaFactory, ce); - return javaInterface; - //throw ce; - } - - // Cache the resolved interface - javaInterface.setUnresolved(false); - resolver.addModel(javaInterface); - } - } - return javaInterface; - } - - public void resolve(JavaInterfaceContract javaInterfaceContract, ModelResolver resolver) throws ContributionResolveException { - - // Resolve the interface and callback interface - JavaInterface javaInterface = resolveJavaInterface((JavaInterface)javaInterfaceContract.getInterface(), resolver); - javaInterfaceContract.setInterface(javaInterface); - - JavaInterface javaCallbackInterface = resolveJavaInterface((JavaInterface)javaInterfaceContract.getCallbackInterface(), resolver); - javaInterfaceContract.setCallbackInterface(javaCallbackInterface); - } - - public QName getArtifactType() { - return INTERFACE_JAVA_QNAME; - } - - public Class getModelType() { - return JavaInterfaceContract.class; - } -} -- cgit v1.2.3