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/06 08:51:40 UTC

svn commit: r526073 - in /incubator/tuscany/java/sca/modules: idl-java-xml/ idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/ idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/impl/ idl-java-xml/src/test/java/org/...

Author: rfeng
Date: Thu Apr  5 23:51:39 2007
New Revision: 526073

URL: http://svn.apache.org/viewvc?view=rev&rev=526073
Log:
Add java interface introspection

Added:
    incubator/tuscany/java/sca/modules/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/impl/
    incubator/tuscany/java/sca/modules/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/impl/JavaInterfaceProcessorRegistryImpl.java   (with props)
    incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/
    incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/
    incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/ConversationalIntrospectionTestCase.java   (with props)
    incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/JavaInterfaceProcessorRegistryImplTestCase.java   (with props)
    incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/InvalidCallbackException.java   (with props)
    incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/InvalidOperationException.java   (with props)
    incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/OverloadedOperationException.java   (with props)
    incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/util/JavaXMLMapper.java   (with props)
Modified:
    incubator/tuscany/java/sca/modules/idl-java-xml/pom.xml
    incubator/tuscany/java/sca/modules/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/JavaInterfaceIntrospector.java

Modified: incubator/tuscany/java/sca/modules/idl-java-xml/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/idl-java-xml/pom.xml?view=diff&rev=526073&r1=526072&r2=526073
==============================================================================
--- incubator/tuscany/java/sca/modules/idl-java-xml/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/idl-java-xml/pom.xml Thu Apr  5 23:51:39 2007
@@ -30,6 +30,13 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.osoa</groupId>
+            <artifactId>sca-api-r1.0</artifactId>
+            <version>1.0.1-incubating-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+            
+        <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-contribution</artifactId>
             <version>1.0-incubating-SNAPSHOT</version>

Modified: incubator/tuscany/java/sca/modules/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/JavaInterfaceIntrospector.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/JavaInterfaceIntrospector.java?view=diff&rev=526073&r1=526072&r2=526073
==============================================================================
--- incubator/tuscany/java/sca/modules/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/JavaInterfaceIntrospector.java (original)
+++ incubator/tuscany/java/sca/modules/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/JavaInterfaceIntrospector.java Thu Apr  5 23:51:39 2007
@@ -18,8 +18,8 @@
  */
 package org.apache.tuscany.idl.java.introspection;
 
+import org.apache.tuscany.assembly.Contract;
 import org.apache.tuscany.idl.InvalidInterfaceException;
-import org.apache.tuscany.idl.java.JavaInterface;
 
 /**
  * Processor for creating JavaServiceContract definitions from Java Classes.
@@ -34,6 +34,13 @@
      * @param type the interface to inspect
      * @return a JavaServiceContract corresponding to the Java interface
      */
-    <I> JavaInterface introspect(Class<I> type) throws InvalidInterfaceException;
+    void introspect(Contract contract, Class<?> type) throws InvalidInterfaceException;
+    /**
+     * @param contract
+     * @param type
+     * @param callback
+     * @throws InvalidInterfaceException
+     */
+    void introspect(Contract contract, Class<?> type, Class<?> callback) throws InvalidInterfaceException;
 
 }

Added: incubator/tuscany/java/sca/modules/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/impl/JavaInterfaceProcessorRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/impl/JavaInterfaceProcessorRegistryImpl.java?view=auto&rev=526073
==============================================================================
--- incubator/tuscany/java/sca/modules/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/impl/JavaInterfaceProcessorRegistryImpl.java (added)
+++ incubator/tuscany/java/sca/modules/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/impl/JavaInterfaceProcessorRegistryImpl.java Thu Apr  5 23:51:39 2007
@@ -0,0 +1,154 @@
+/*
+ * 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.idl.java.introspection.impl;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.assembly.Contract;
+import org.apache.tuscany.idl.DataType;
+import org.apache.tuscany.idl.InvalidCallbackException;
+import org.apache.tuscany.idl.InvalidInterfaceException;
+import org.apache.tuscany.idl.InvalidOperationException;
+import org.apache.tuscany.idl.Operation;
+import org.apache.tuscany.idl.OverloadedOperationException;
+import org.apache.tuscany.idl.impl.DataTypeImpl;
+import org.apache.tuscany.idl.impl.OperationImpl;
+import org.apache.tuscany.idl.java.JavaFactory;
+import org.apache.tuscany.idl.java.JavaInterface;
+import org.apache.tuscany.idl.java.impl.DefaultJavaFactory;
+import org.apache.tuscany.idl.java.introspection.JavaInterfaceProcessor;
+import org.apache.tuscany.idl.java.introspection.JavaInterfaceProcessorRegistry;
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
+import org.osoa.sca.annotations.OneWay;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Default implementation of an InterfaceJavaIntrospector.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class JavaInterfaceProcessorRegistryImpl implements JavaInterfaceProcessorRegistry {
+    public static final String IDL_INPUT = "idl:input";
+
+    private static final String UNKNOWN_DATABINDING = null;
+
+    private JavaFactory javaFactory;
+    private List<JavaInterfaceProcessor> processors = new ArrayList<JavaInterfaceProcessor>();
+
+    public JavaInterfaceProcessorRegistryImpl() {
+        this.javaFactory = new DefaultJavaFactory();
+    }
+
+    public void registerProcessor(JavaInterfaceProcessor processor) {
+        processors.add(processor);
+    }
+
+    public void unregisterProcessor(JavaInterfaceProcessor processor) {
+        processors.remove(processor);
+    }
+
+    public void introspect(Contract contract, Class<?> type) throws InvalidInterfaceException {
+        Class<?> callbackClass = null;
+        org.osoa.sca.annotations.Callback callback = type.getAnnotation(org.osoa.sca.annotations.Callback.class);
+        if (callback != null && !Void.class.equals(callback.value())) {
+            callbackClass = callback.value();
+        } else if (callback != null && Void.class.equals(callback.value())) {
+            throw new InvalidCallbackException("No callback interface specified on annotation");
+        }
+        introspect(contract, type, callbackClass);
+    }
+
+    public void introspect(Contract contract, Class<?> type, Class<?> callback) throws InvalidInterfaceException {
+        JavaInterface javaInterface = javaFactory.createJavaInterface();
+        javaInterface.setJavaClass(type);
+        boolean remotable = type.isAnnotationPresent(Remotable.class);
+        javaInterface.setRemotable(remotable);
+        // Scope interactionScope = type.getAnnotation(Scope.class);
+        boolean conversational = type.isAnnotationPresent(Conversational.class);
+        javaInterface.setConversational(conversational);
+        contract.setInterface(javaInterface);
+        javaInterface.getOperations().addAll(getOperations(type, remotable, conversational).values());
+
+        if (callback != null) {
+            JavaInterface callbackInterface = javaFactory.createJavaInterface();
+            callbackInterface.setJavaClass(callback);
+            contract.setCallbackInterface(callbackInterface);
+            callbackInterface.getOperations().addAll(getOperations(callback, remotable, conversational).values());
+        }
+
+        for (JavaInterfaceProcessor processor : processors) {
+            processor.visitInterface(type, callback, contract);
+        }
+    }
+
+    private <T> Map<String, Operation> getOperations(Class<T> type, boolean remotable, boolean conversational)
+        throws InvalidInterfaceException {
+        Method[] methods = type.getMethods();
+        Map<String, Operation> operations = new HashMap<String, Operation>(methods.length);
+        for (Method method : methods) {
+            String name = method.getName();
+            if (remotable && operations.containsKey(name)) {
+                throw new OverloadedOperationException(method);
+            }
+
+            Class returnType = method.getReturnType();
+            Class[] paramTypes = method.getParameterTypes();
+            Class[] faultTypes = method.getExceptionTypes();
+            boolean nonBlocking = method.isAnnotationPresent(OneWay.class);
+            Operation.ConversationSequence conversationSequence = Operation.ConversationSequence.NO_CONVERSATION;
+            if (method.isAnnotationPresent(EndsConversation.class)) {
+                if (!conversational) {
+                    throw new InvalidOperationException(
+                                                        "Method is marked as end conversation but contract is not conversational",
+                                                        method);
+                }
+                conversationSequence = Operation.ConversationSequence.CONVERSATION_END;
+            } else if (conversational) {
+                conversationSequence = Operation.ConversationSequence.CONVERSATION_CONTINUE;
+            }
+
+            DataType<Class> returnDataType = new DataTypeImpl<Class>(UNKNOWN_DATABINDING, returnType, returnType);
+            List<DataType> paramDataTypes = new ArrayList<DataType>(paramTypes.length);
+            for (Class paramType : paramTypes) {
+                paramDataTypes.add(new DataTypeImpl<Class>(UNKNOWN_DATABINDING, paramType, paramType));
+            }
+            List<DataType> faultDataTypes = new ArrayList<DataType>(faultTypes.length);
+            for (Class faultType : faultTypes) {
+                faultDataTypes.add(new DataTypeImpl<Class>(UNKNOWN_DATABINDING, faultType, faultType));
+            }
+
+            DataType<List<DataType>> inputType = new DataTypeImpl<List<DataType>>(IDL_INPUT, Object[].class,
+                                                                                  paramDataTypes);
+            Operation operation = new OperationImpl(name);
+            operation.setInputType(inputType);
+            operation.setOutputType(returnDataType);
+            operation.setFaultTypes(faultDataTypes);
+            operation.setConversationSequence(conversationSequence);
+            operation.setNonBlocking(nonBlocking);
+            operations.put(name, operation);
+        }
+        return operations;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/impl/JavaInterfaceProcessorRegistryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/introspection/impl/JavaInterfaceProcessorRegistryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/ConversationalIntrospectionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/ConversationalIntrospectionTestCase.java?view=auto&rev=526073
==============================================================================
--- incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/ConversationalIntrospectionTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/ConversationalIntrospectionTestCase.java Thu Apr  5 23:51:39 2007
@@ -0,0 +1,98 @@
+/*
+ * 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.idl.java.introspection.impl;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.AssemblyFactory;
+import org.apache.tuscany.assembly.Contract;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.idl.Interface;
+import org.apache.tuscany.idl.InvalidOperationException;
+import org.apache.tuscany.idl.Operation;
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConversationalIntrospectionTestCase extends TestCase {
+    private AssemblyFactory factory = new DefaultAssemblyFactory();
+    private JavaInterfaceProcessorRegistryImpl registry = new JavaInterfaceProcessorRegistryImpl();
+
+    private Operation getOperation(Interface i, String name) {
+        for (Operation op : i.getOperations()) {
+            if (op.getName().equals(name)) {
+                return op;
+            }
+        }
+        return null;
+    }
+
+    public void testServiceContractConversationalInformationIntrospection() throws Exception {
+        Contract contract = factory.createComponentService();
+        registry.introspect(contract, Foo.class);
+        Interface i = contract.getInterface();
+        assertNotNull(i);
+        assertTrue(i.isConversational());
+        Operation.ConversationSequence seq = getOperation(i, "operation").getConversationSequence();
+        assertEquals(Operation.ConversationSequence.CONVERSATION_CONTINUE, seq);
+        seq = getOperation(i, "endOperation").getConversationSequence();
+        assertEquals(Operation.ConversationSequence.CONVERSATION_END, seq);
+    }
+
+    public void testBadServiceContract() throws Exception {
+        try {
+            Contract contract = factory.createComponentService();
+            registry.introspect(contract, BadFoo.class);
+            fail();
+        } catch (InvalidOperationException e) {
+            // expected
+        }
+    }
+
+    public void testNonConversationalInformationIntrospection() throws Exception {
+        Contract contract = factory.createComponentService();
+        registry.introspect(contract, NonConversationalFoo.class);
+        assertFalse(contract.getInterface().isConversational());
+        Operation.ConversationSequence seq = getOperation(contract.getInterface(), "operation")
+            .getConversationSequence();
+        assertEquals(Operation.ConversationSequence.NO_CONVERSATION, seq);
+    }
+
+    @Conversational
+    private interface Foo {
+        void operation();
+
+        @EndsConversation
+        void endOperation();
+    }
+
+    private interface BadFoo {
+        void operation();
+
+        @EndsConversation
+        void endOperation();
+    }
+
+    private interface NonConversationalFoo {
+        void operation();
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/ConversationalIntrospectionTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/ConversationalIntrospectionTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/JavaInterfaceProcessorRegistryImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/JavaInterfaceProcessorRegistryImplTestCase.java?view=auto&rev=526073
==============================================================================
--- incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/JavaInterfaceProcessorRegistryImplTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/JavaInterfaceProcessorRegistryImplTestCase.java Thu Apr  5 23:51:39 2007
@@ -0,0 +1,104 @@
+/*
+ * 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.idl.java.introspection.impl;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+import java.lang.reflect.Type;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.AssemblyFactory;
+import org.apache.tuscany.assembly.Contract;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.idl.DataType;
+import org.apache.tuscany.idl.InvalidInterfaceException;
+import org.apache.tuscany.idl.Operation;
+import org.apache.tuscany.idl.java.JavaInterface;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaInterfaceProcessorRegistryImplTestCase extends TestCase {
+    private JavaInterfaceProcessorRegistryImpl impl;
+    private AssemblyFactory factory = new DefaultAssemblyFactory();
+
+    public void testSimpleInterface() throws InvalidInterfaceException {
+        Contract contract = factory.createComponentService();
+        impl.introspect(contract, Simple.class);
+
+        JavaInterface intf = (JavaInterface)contract.getInterface();
+
+        assertEquals(Simple.class, intf.getJavaClass());
+        List<Operation> operations = intf.getOperations();
+        assertEquals(1, operations.size());
+        Operation baseInt = operations.get(0);
+        assertEquals("baseInt", baseInt.getName());
+
+        DataType<Type> returnType = baseInt.getOutputType();
+        assertEquals(Integer.TYPE, returnType.getPhysical());
+        assertEquals(Integer.TYPE, returnType.getLogical());
+
+        List<DataType> parameterTypes = baseInt.getInputType().getLogical();
+        assertEquals(1, parameterTypes.size());
+        DataType<Type> arg0 = parameterTypes.get(0);
+        assertEquals(Integer.TYPE, arg0.getPhysical());
+        assertEquals(Integer.TYPE, arg0.getLogical());
+
+        List<DataType> faultTypes = baseInt.getFaultTypes();
+        assertEquals(1, faultTypes.size());
+        DataType<Type> fault0 = faultTypes.get(0);
+        assertEquals(IllegalArgumentException.class, fault0.getPhysical());
+        assertEquals(IllegalArgumentException.class, fault0.getLogical());
+    }
+
+    public void testUnregister() throws Exception {
+        org.apache.tuscany.idl.java.introspection.JavaInterfaceProcessor processor = createMock(org.apache.tuscany.idl.java.introspection.JavaInterfaceProcessor.class);
+        processor.visitInterface(eq(Base.class), EasyMock.same((Class)null), isA(Contract.class));
+        expectLastCall().once();
+        replay(processor);
+        Contract contract = factory.createComponentService();
+        impl.registerProcessor(processor);
+        impl.introspect(contract, Base.class);
+        impl.unregisterProcessor(processor);
+        impl.introspect(contract, Base.class);
+        verify(processor);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        impl = new JavaInterfaceProcessorRegistryImpl();
+
+    }
+
+    private static interface Base {
+        int baseInt(int param) throws IllegalArgumentException;
+    }
+
+    private static interface Simple extends Base {
+
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/JavaInterfaceProcessorRegistryImplTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/introspection/impl/JavaInterfaceProcessorRegistryImplTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/InvalidCallbackException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/InvalidCallbackException.java?view=auto&rev=526073
==============================================================================
--- incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/InvalidCallbackException.java (added)
+++ incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/InvalidCallbackException.java Thu Apr  5 23:51:39 2007
@@ -0,0 +1,34 @@
+/*
+ * 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.idl;
+
+
+/**
+ * Denotes an illegal callback interface
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class InvalidCallbackException extends InvalidInterfaceException {
+    private static final long serialVersionUID = 2727755895702116397L;
+
+    public InvalidCallbackException(String message) {
+        super(message);
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/InvalidCallbackException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/InvalidCallbackException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/InvalidOperationException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/InvalidOperationException.java?view=auto&rev=526073
==============================================================================
--- incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/InvalidOperationException.java (added)
+++ incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/InvalidOperationException.java Thu Apr  5 23:51:39 2007
@@ -0,0 +1,42 @@
+/*
+ * 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.idl;
+
+import java.lang.reflect.Method;
+
+/**
+ * Denotes an invalid conversational interface definition
+ * 
+ * @version $Rev$ $Date$
+ */
+public class InvalidOperationException extends InvalidInterfaceException {
+
+    private static final long serialVersionUID = -1797615361821517091L;
+    private final Method operation;
+
+    public InvalidOperationException(String message, Method operation) {
+        super(message);
+        this.operation = operation;
+    }
+
+    public Method getOperation() {
+        return operation;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/InvalidOperationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/InvalidOperationException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/OverloadedOperationException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/OverloadedOperationException.java?view=auto&rev=526073
==============================================================================
--- incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/OverloadedOperationException.java (added)
+++ incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/OverloadedOperationException.java Thu Apr  5 23:51:39 2007
@@ -0,0 +1,42 @@
+/*
+ * 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.idl;
+
+import java.lang.reflect.Method;
+
+/**
+ * Exception thrown to indicate that a service contract specification contains
+ * an overloaded method.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class OverloadedOperationException extends InvalidInterfaceException {
+    private static final long serialVersionUID = -4658711318608885638L;
+    private final Method operation;
+
+    public OverloadedOperationException(Method operation) {
+        super();
+        this.operation = operation;
+    }
+
+    public Method getOperation() {
+        return operation;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/OverloadedOperationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/OverloadedOperationException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/util/JavaXMLMapper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/util/JavaXMLMapper.java?view=auto&rev=526073
==============================================================================
--- incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/util/JavaXMLMapper.java (added)
+++ incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/util/JavaXMLMapper.java Thu Apr  5 23:51:39 2007
@@ -0,0 +1,117 @@
+/*
+ * 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.idl.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+public final class JavaXMLMapper {
+    private static final Map<Class, QName> JAVA2XML = new HashMap<Class, QName>();
+
+    private static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema";
+
+    private static final Map<String, Class> XML2JAVA = new HashMap<String, Class>();
+
+    private JavaXMLMapper() {
+    }
+
+    static {
+        JAVA2XML.put(boolean.class, getTypeName("boolean"));
+        JAVA2XML.put(byte.class, getTypeName("byte"));
+        JAVA2XML.put(short.class, getTypeName("short"));
+        JAVA2XML.put(int.class, getTypeName("int"));
+        JAVA2XML.put(long.class, getTypeName("long"));
+        JAVA2XML.put(float.class, getTypeName("float"));
+        JAVA2XML.put(double.class, getTypeName("double"));
+        JAVA2XML.put(Boolean.class, getTypeName("boolean"));
+        JAVA2XML.put(Byte.class, getTypeName("byte"));
+        JAVA2XML.put(Short.class, getTypeName("short"));
+        JAVA2XML.put(Integer.class, getTypeName("int"));
+        JAVA2XML.put(Long.class, getTypeName("long"));
+        JAVA2XML.put(Float.class, getTypeName("float"));
+        JAVA2XML.put(Double.class, getTypeName("double"));
+        JAVA2XML.put(java.lang.String.class, getTypeName("string"));
+        JAVA2XML.put(java.math.BigInteger.class, getTypeName("integer"));
+        JAVA2XML.put(java.math.BigDecimal.class, getTypeName("decimal"));
+        JAVA2XML.put(java.util.Calendar.class, getTypeName("dateTime"));
+        JAVA2XML.put(java.util.Date.class, getTypeName("dateTime"));
+        JAVA2XML.put(javax.xml.namespace.QName.class, getTypeName("QName"));
+        JAVA2XML.put(java.net.URI.class, getTypeName("string"));
+        JAVA2XML.put(javax.xml.datatype.XMLGregorianCalendar.class, getTypeName("anySimpleType"));
+        JAVA2XML.put(javax.xml.datatype.Duration.class, getTypeName("duration"));
+        JAVA2XML.put(java.lang.Object.class, getTypeName("anyType"));
+        JAVA2XML.put(java.awt.Image.class, getTypeName("base64Binary"));
+        JAVA2XML.put(byte[].class, getTypeName("base64Binary"));
+        // java2XSD.put(javax.activation.DataHandler.class, getTypeName("base64Binary"));
+        JAVA2XML.put(javax.xml.transform.Source.class, getTypeName("base64Binary"));
+        JAVA2XML.put(java.util.UUID.class, getTypeName("string"));
+    }
+
+    static {
+        XML2JAVA.put("string", java.lang.String.class);
+        XML2JAVA.put("integer", java.math.BigInteger.class);
+        XML2JAVA.put("int", int.class);
+        XML2JAVA.put("long", long.class);
+        XML2JAVA.put("short", short.class);
+        XML2JAVA.put("decimal", java.math.BigDecimal.class);
+        XML2JAVA.put("float", float.class);
+        XML2JAVA.put("double", double.class);
+        XML2JAVA.put("boolean", boolean.class);
+        XML2JAVA.put("byte", byte.class);
+        XML2JAVA.put("QName", javax.xml.namespace.QName.class);
+        XML2JAVA.put("dateTime", javax.xml.datatype.XMLGregorianCalendar.class);
+        XML2JAVA.put("base64Binary", byte[].class);
+        XML2JAVA.put("hexBinary", byte[].class);
+        XML2JAVA.put("unsignedInt", long.class);
+        XML2JAVA.put("unsignedShort", int.class);
+        XML2JAVA.put("unsignedByte", short.class);
+        XML2JAVA.put("time", javax.xml.datatype.XMLGregorianCalendar.class);
+        XML2JAVA.put("date", javax.xml.datatype.XMLGregorianCalendar.class);
+        XML2JAVA.put("gDay", javax.xml.datatype.XMLGregorianCalendar.class);
+        XML2JAVA.put("gMonth", javax.xml.datatype.XMLGregorianCalendar.class);
+        XML2JAVA.put("gYear", javax.xml.datatype.XMLGregorianCalendar.class);
+        XML2JAVA.put("gYearMonth", javax.xml.datatype.XMLGregorianCalendar.class);
+        XML2JAVA.put("gMonthDay", javax.xml.datatype.XMLGregorianCalendar.class);
+        XML2JAVA.put("anySimpleType", java.lang.Object.class); // For elements
+        // XML2JAVA.put("anySimpleType", java.lang.String.class); // For
+        // attributes
+        XML2JAVA.put("duration", javax.xml.datatype.Duration.class);
+        XML2JAVA.put("NOTATION", javax.xml.namespace.QName.class);
+    }
+
+    public static Class getJavaType(QName xmlType) {
+        if (URI_2001_SCHEMA_XSD.equals(xmlType.getNamespaceURI())) {
+            return XML2JAVA.get(xmlType.getLocalPart());
+        } else {
+            return null;
+        }
+    }
+
+    private static QName getTypeName(String name) {
+        return new QName(URI_2001_SCHEMA_XSD, name);
+    }
+
+    public static QName getXMLType(Class javaType) {
+        return JAVA2XML.get(javaType);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/util/JavaXMLMapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/idl/src/main/java/org/apache/tuscany/idl/util/JavaXMLMapper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org