diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-03 16:45:57 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-03 16:45:57 +0000 |
commit | 8d2678027fa767584fc1b618115933fb0314694b (patch) | |
tree | abfa2e50b2b673b28cca6017c0c1182045e63807 /java/sca | |
parent | a84ffb33828cd6e74a3d1b03b6e831fb85a93e13 (diff) |
TUSCANY-3290 - Adding support for @Remote attribute in <interface.java>
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@821362 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
6 files changed, 78 insertions, 10 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java index b72cade0cc..cab7057b57 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java @@ -45,7 +45,17 @@ public interface Interface extends Cloneable, PolicySubject { * @param remotable indicates whether the interface is remotable or local */ void setRemotable(boolean remotable); - + + /** + * Returns true if the interface remotable property is set.. + * + * This is used to verify if a @remotable attribute is used in the + * <interface.java> SCDL element. If true, use isRemotable to verify the + * current value + * + * @return + */ + boolean isRemotableSet(); // FIXME: [rfeng] We need to re-consider the conversational as an intent /** diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java new file mode 100644 index 0000000000..b24872bf96 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.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.interfacedef; + + +public class InvalidAnnotationException extends InvalidInterfaceException { + + private static final long serialVersionUID = 4923028138353415223L; + private final Class<?> clazz; + + public InvalidAnnotationException(String message, Class<?> clazz) { + super(message); + this.clazz = clazz; + } + + public Class<?> getAnnotation() { + return clazz; + } +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java index 37929c3242..08f859fc8a 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java @@ -39,7 +39,7 @@ import org.apache.tuscany.sca.policy.PolicySet; */ public class InterfaceImpl implements Interface { - private boolean remotable; + private Boolean remotable; private boolean conversational; private OperationList operations = new OperationList(); private boolean unresolved; @@ -50,11 +50,19 @@ public class InterfaceImpl implements Interface { private Map<Object, Object> attributes = new ConcurrentHashMap<Object, Object>(); public boolean isRemotable() { - return remotable; + boolean value = false; + if (remotable != null && remotable.booleanValue()) { + value = true; + } + return value; } - public void setRemotable(boolean local) { - this.remotable = local; + public void setRemotable(boolean remotable) { + this.remotable = Boolean.valueOf(remotable); + } + + public boolean isRemotableSet() { + return remotable == null ? false : true; } public List<Operation> getOperations() { diff --git a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java index 894b2f705c..e659d3a658 100644 --- a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java +++ b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java @@ -35,6 +35,7 @@ import java.util.Set; import javax.xml.namespace.QName; import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.InvalidAnnotationException; import org.apache.tuscany.sca.interfacedef.InvalidCallbackException; import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; import org.apache.tuscany.sca.interfacedef.InvalidOperationException; @@ -71,6 +72,12 @@ public class JavaInterfaceIntrospectorImpl { javaInterface.setJavaClass(clazz); boolean remotable = clazz.isAnnotationPresent(Remotable.class); + + if (remotable) { + if (javaInterface.isRemotableSet() && javaInterface.isRemotable() == false) { + throw new InvalidAnnotationException("@Remotable annotation present in a interface marked as not remotable in the SCDL", Remotable.class); + } + } // Consider @javax.ejb.Remote, java.rmi.Remote and javax.ejb.EJBObject // equivalent to @Remotable diff --git a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java index 5e8cf6a433..75816b1d36 100644 --- a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java +++ b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java @@ -31,5 +31,6 @@ public interface JavaConstants { QName INTERFACE_JAVA_QNAME = new QName(SCA11_NS, "interface.java"); String INTERFACE = "interface"; String CALLBACK_INTERFACE = "callbackInterface"; + String REMOTABLE = "remotable"; } diff --git a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java index 1eb38592b7..b7c953813a 100644 --- a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java +++ b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java @@ -63,11 +63,11 @@ public class JavaInterfaceProcessor implements StAXArtifactProcessor<JavaInterfa * @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); - } - } + 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. @@ -106,6 +106,12 @@ public class JavaInterfaceProcessor implements StAXArtifactProcessor<JavaInterfa javaInterfaceContract.setCallbackInterface(javaCallbackInterface); } + String remotable = reader.getAttributeValue(null, REMOTABLE); + if (remotable != null) { + javaInterfaceContract.getInterface().setRemotable(Boolean.parseBoolean(remotable)); + } + + // Skip to end element while (reader.hasNext()) { if (reader.next() == END_ELEMENT && INTERFACE_JAVA_QNAME.equals(reader.getName())) { |