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
This commit is contained in:
parent
a84ffb3382
commit
8d2678027f
6 changed files with 78 additions and 10 deletions
|
@ -46,6 +46,16 @@ public interface Interface extends Cloneable, PolicySubject {
|
||||||
*/
|
*/
|
||||||
void setRemotable(boolean remotable);
|
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
|
// FIXME: [rfeng] We need to re-consider the conversational as an intent
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,7 +39,7 @@ import org.apache.tuscany.sca.policy.PolicySet;
|
||||||
*/
|
*/
|
||||||
public class InterfaceImpl implements Interface {
|
public class InterfaceImpl implements Interface {
|
||||||
|
|
||||||
private boolean remotable;
|
private Boolean remotable;
|
||||||
private boolean conversational;
|
private boolean conversational;
|
||||||
private OperationList operations = new OperationList();
|
private OperationList operations = new OperationList();
|
||||||
private boolean unresolved;
|
private boolean unresolved;
|
||||||
|
@ -50,11 +50,19 @@ public class InterfaceImpl implements Interface {
|
||||||
private Map<Object, Object> attributes = new ConcurrentHashMap<Object, Object>();
|
private Map<Object, Object> attributes = new ConcurrentHashMap<Object, Object>();
|
||||||
|
|
||||||
public boolean isRemotable() {
|
public boolean isRemotable() {
|
||||||
return remotable;
|
boolean value = false;
|
||||||
|
if (remotable != null && remotable.booleanValue()) {
|
||||||
|
value = true;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRemotable(boolean local) {
|
public void setRemotable(boolean remotable) {
|
||||||
this.remotable = local;
|
this.remotable = Boolean.valueOf(remotable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRemotableSet() {
|
||||||
|
return remotable == null ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Operation> getOperations() {
|
public List<Operation> getOperations() {
|
||||||
|
|
|
@ -35,6 +35,7 @@ import java.util.Set;
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import org.apache.tuscany.sca.interfacedef.DataType;
|
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.InvalidCallbackException;
|
||||||
import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
|
import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
|
||||||
import org.apache.tuscany.sca.interfacedef.InvalidOperationException;
|
import org.apache.tuscany.sca.interfacedef.InvalidOperationException;
|
||||||
|
@ -72,6 +73,12 @@ public class JavaInterfaceIntrospectorImpl {
|
||||||
|
|
||||||
boolean remotable = clazz.isAnnotationPresent(Remotable.class);
|
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
|
// Consider @javax.ejb.Remote, java.rmi.Remote and javax.ejb.EJBObject
|
||||||
// equivalent to @Remotable
|
// equivalent to @Remotable
|
||||||
if (!remotable) {
|
if (!remotable) {
|
||||||
|
|
|
@ -31,5 +31,6 @@ public interface JavaConstants {
|
||||||
QName INTERFACE_JAVA_QNAME = new QName(SCA11_NS, "interface.java");
|
QName INTERFACE_JAVA_QNAME = new QName(SCA11_NS, "interface.java");
|
||||||
String INTERFACE = "interface";
|
String INTERFACE = "interface";
|
||||||
String CALLBACK_INTERFACE = "callbackInterface";
|
String CALLBACK_INTERFACE = "callbackInterface";
|
||||||
|
String REMOTABLE = "remotable";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,11 +63,11 @@ public class JavaInterfaceProcessor implements StAXArtifactProcessor<JavaInterfa
|
||||||
* @param model
|
* @param model
|
||||||
*/
|
*/
|
||||||
private void error(String message, Object model, Exception ex) {
|
private void error(String message, Object model, Exception ex) {
|
||||||
if (monitor != null) {
|
if (monitor != null) {
|
||||||
Problem problem = monitor.createProblem(this.getClass().getName(), "interface-javaxml-validation-messages", Severity.ERROR, model, message, ex);
|
Problem problem = monitor.createProblem(this.getClass().getName(), "interface-javaxml-validation-messages", Severity.ERROR, model, message, ex);
|
||||||
monitor.problem(problem);
|
monitor.problem(problem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report a error.
|
* Report a error.
|
||||||
|
@ -106,6 +106,12 @@ public class JavaInterfaceProcessor implements StAXArtifactProcessor<JavaInterfa
|
||||||
javaInterfaceContract.setCallbackInterface(javaCallbackInterface);
|
javaInterfaceContract.setCallbackInterface(javaCallbackInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String remotable = reader.getAttributeValue(null, REMOTABLE);
|
||||||
|
if (remotable != null) {
|
||||||
|
javaInterfaceContract.getInterface().setRemotable(Boolean.parseBoolean(remotable));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Skip to end element
|
// Skip to end element
|
||||||
while (reader.hasNext()) {
|
while (reader.hasNext()) {
|
||||||
if (reader.next() == END_ELEMENT && INTERFACE_JAVA_QNAME.equals(reader.getName())) {
|
if (reader.next() == END_ELEMENT && INTERFACE_JAVA_QNAME.equals(reader.getName())) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue