tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r399348 [2/2] - in /incubator/tuscany/sandbox/jboynes/sca: ./ core/src/main/java/org/apache/tuscany/core/async/builder/ core/src/main/java/org/apache/tuscany/core/builder/system/ core/src/main/java/org/apache/tuscany/core/config/impl/ core/...
Date Wed, 03 May 2006 16:33:31 GMT
Copied: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/system/loader/SystemImplementationLoader.java
(from r399282, incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/loader/system/SystemImplementationLoader.java)
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/system/loader/SystemImplementationLoader.java?p2=incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/system/loader/SystemImplementationLoader.java&p1=incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/loader/system/SystemImplementationLoader.java&r1=399282&r2=399348&rev=399348&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/loader/system/SystemImplementationLoader.java
(original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/system/loader/SystemImplementationLoader.java
Wed May  3 09:33:22 2006
@@ -14,53 +14,37 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.tuscany.core.loader.system;
-
-import org.apache.tuscany.core.config.ComponentTypeIntrospector;
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.loader.StAXUtil;
-import org.apache.tuscany.core.loader.LoaderContext;
-import org.apache.tuscany.core.loader.assembly.AbstractLoader;
-import org.apache.tuscany.core.system.annotation.Autowire;
-import org.apache.tuscany.core.system.assembly.SystemImplementation;
-import org.osoa.sca.annotations.Scope;
+package org.apache.tuscany.core.system.loader;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
+import org.apache.tuscany.core.loader.StAXUtil;
+import org.apache.tuscany.core.system.model.SystemImplementation;
+import org.apache.tuscany.spi.loader.LoaderContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderSupport;
+
 /**
  * @version $Rev$ $Date$
  */
-@Scope("MODULE")
-public class SystemImplementationLoader extends AbstractLoader {
-    public static final QName SYSTEM_IMPLEMENTATION = new QName("http://org.apache.tuscany/xmlns/system/0.9",
"implementation.system");
-
-    private ComponentTypeIntrospector introspector;
-
-    @Autowire
-    public void setIntrospector(ComponentTypeIntrospector introspector) {
-        this.introspector = introspector;
-    }
+public class SystemImplementationLoader extends LoaderSupport {
+    public static final QName SYSTEM_IMPLEMENTATION = new QName("http://tuscany.apache.org/xmlns/system/0.9",
"implementation.system");
 
     protected QName getXMLType() {
         return SYSTEM_IMPLEMENTATION;
     }
 
-    public SystemImplementation load(XMLStreamReader reader, LoaderContext loaderContext)
throws XMLStreamException, ConfigurationLoadException {
+    public SystemImplementation load(XMLStreamReader reader, LoaderContext loaderContext)
throws XMLStreamException, LoaderException {
         assert SYSTEM_IMPLEMENTATION.equals(reader.getName());
-        SystemImplementation implementation = factory.createSystemImplementation();
+        SystemImplementation implementation = new SystemImplementation();
         String implClass = reader.getAttributeValue(null, "class");
-        Class<?> implementationClass;
-        try {
-            implementationClass = loaderContext.getResourceLoader().loadClass(implClass);
-            implementation.setImplementationClass(implementationClass);
-        } catch (ClassNotFoundException e) {
-            throw new ConfigurationLoadException(e);
-        }
+        Class<?> implementationClass = StAXUtil.loadClass(implClass, loaderContext.getClassLoader());
+        implementation.setImplementationClass(implementationClass);
 
         // todo we should allow componentType sidefiles for system implementations
-        implementation.setComponentInfo(introspector.introspect(implementationClass));
+//        implementation.setComponentType(introspector.introspect(implementationClass));
 
         StAXUtil.skipToEndElement(reader);
         return implementation;

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/system/loader/SystemImplementationLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/system/loader/SystemImplementationLoader.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/system/model/SystemImplementation.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/system/model/SystemImplementation.java?rev=399348&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/system/model/SystemImplementation.java
(added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/system/model/SystemImplementation.java
Wed May  3 09:33:22 2006
@@ -0,0 +1,34 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.core.system.model;
+
+import org.apache.tuscany.model.AtomicImplementation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SystemImplementation extends AtomicImplementation {
+    private Class<?> implementationClass;
+
+    public Class<?> getImplementationClass() {
+        return implementationClass;
+    }
+
+    public void setImplementationClass(Class<?> implementationClass) {
+        this.implementationClass = implementationClass;
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/system/model/SystemImplementation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/system/model/SystemImplementation.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java?rev=399348&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java
(added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java
Wed May  3 09:33:22 2006
@@ -0,0 +1,72 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.core.loader;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.model.Service;
+import org.apache.tuscany.model.ServiceContract;
+import org.apache.tuscany.spi.loader.LoaderContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.StAXLoaderRegistry;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceLoaderTestCase extends MockObjectTestCase {
+    private ServiceLoader loader;
+    private LoaderContext loaderContext;
+    private Mock mockReader;
+    private Mock mockRegistry;
+
+    public void testWithNoInterface() throws LoaderException, XMLStreamException {
+        String name = "service";
+        mockReader.expects(once()).method("getName").will(returnValue(AssemblyConstants.SERVICE));
+        mockReader.expects(once()).method("getAttributeValue").with(NULL, eq("name")).will(returnValue(name));
+        mockReader.expects(once()).method("next").will(returnValue(END_ELEMENT));
+        Service service = loader.load((XMLStreamReader) mockReader.proxy(), null);
+        assertNotNull(service);
+        assertEquals(name, service.getName());
+    }
+
+    public void testWithInterface() throws LoaderException, XMLStreamException {
+        String name = "service";
+        ServiceContract sc = new ServiceContract(){};
+        mockReader.expects(once()).method("getName").will(returnValue(AssemblyConstants.SERVICE));
+        mockReader.expects(once()).method("getAttributeValue").with(NULL, eq("name")).will(returnValue(name));
+        mockReader.expects(atLeastOnce()).method("next").will(onConsecutiveCalls(returnValue(START_ELEMENT),
returnValue(END_ELEMENT)));
+        mockRegistry.expects(once()).method("load").with(eq(mockReader.proxy()), eq(loaderContext)).will(returnValue(sc));
+        Service service = loader.load((XMLStreamReader) mockReader.proxy(), loaderContext);
+        assertNotNull(service);
+        assertEquals(name, service.getName());
+        assertSame(sc, service.getServiceContract());
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        loader = new ServiceLoader();
+        mockReader = mock(XMLStreamReader.class);
+        mockRegistry = mock(StAXLoaderRegistry.class);
+        loader.setRegistry((StAXLoaderRegistry) mockRegistry.proxy());
+        loaderContext = new LoaderContext(null);
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/StAXLoaderRegistryImplTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/StAXLoaderRegistryImplTestCase.java?rev=399348&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/StAXLoaderRegistryImplTestCase.java
(added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/StAXLoaderRegistryImplTestCase.java
Wed May  3 09:33:22 2006
@@ -0,0 +1,89 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.core.loader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.loader.StAXElementLoader;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderContext;
+import org.apache.tuscany.spi.loader.UnrecognizedElementException;
+import org.apache.tuscany.model.ModelObject;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@SuppressWarnings({"CastToIncompatibleInterface"})
+public class StAXLoaderRegistryImplTestCase extends MockObjectTestCase {
+    private StAXLoaderRegistryImpl registry;
+    private QName name;
+    private Mock mockMonitor;
+    private Mock mockLoader;
+    private Mock mockReader;
+    private LoaderContext loaderContext;
+    private ModelObject modelObject;
+
+    public void testLoaderRegistration() {
+        mockMonitor.expects(once()).method("registeringLoader").with(eq(name));
+        registry.registerLoader(name, (StAXElementLoader<ModelObject>) mockLoader.proxy());
+    }
+
+    public void testLoaderUnregistration() {
+        mockMonitor.expects(once()).method("unregisteringLoader").with(eq(name));
+        registry.unregisterLoader(name, (StAXElementLoader<ModelObject>) mockLoader.proxy());
+    }
+
+    public void testSuccessfulDispatch() throws LoaderException, XMLStreamException {
+        mockReader.expects(once()).method("getName").will(returnValue(name));
+        mockMonitor.expects(once()).method("registeringLoader").with(eq(name));
+        mockMonitor.expects(once()).method("elementLoad").with(eq(name));
+        mockLoader.expects(once()).method("load").with(eq(mockReader.proxy()), eq(loaderContext)).will(returnValue(modelObject));
+
+        registry.registerLoader(name, (StAXElementLoader<ModelObject>) mockLoader.proxy());
+        assertSame(modelObject, registry.load((XMLStreamReader) mockReader.proxy(), loaderContext));
+    }
+
+    public void testUnsuccessfulDispatch() throws LoaderException, XMLStreamException {
+        mockReader.expects(once()).method("getName").will(returnValue(name));
+        mockMonitor.expects(once()).method("elementLoad").with(eq(name));
+
+        try {
+            registry.load((XMLStreamReader) mockReader.proxy(), loaderContext);
+            fail();
+        } catch (UnrecognizedElementException e) {
+            assertSame(name, e.getElement());
+        }
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        name = new QName("http://mock", "test");
+        loaderContext = new LoaderContext(null);
+        registry = new StAXLoaderRegistryImpl();
+        mockMonitor = mock(StAXLoaderRegistryImpl.Monitor.class);
+        registry.setMonitor((StAXLoaderRegistryImpl.Monitor) mockMonitor.proxy());
+
+        mockLoader = mock(StAXElementLoader.class);
+        mockReader = mock(XMLStreamReader.class);
+        modelObject = new ModelObject() {
+        };
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/StAXLoaderRegistryImplTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/StAXLoaderRegistryImplTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Modified: incubator/tuscany/sandbox/jboynes/sca/model/src/main/java/org/apache/tuscany/model/ComponentType.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/model/src/main/java/org/apache/tuscany/model/ComponentType.java?rev=399348&r1=399347&r2=399348&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/model/src/main/java/org/apache/tuscany/model/ComponentType.java
(original)
+++ incubator/tuscany/sandbox/jboynes/sca/model/src/main/java/org/apache/tuscany/model/ComponentType.java
Wed May  3 09:33:22 2006
@@ -25,7 +25,7 @@
 public class ComponentType extends ModelObject {
     private final Map<String, Service> services = new HashMap<String, Service>();
     private final Map<String, Reference> references = new HashMap<String, Reference>();
-    private final Map<String, Property> properties = new HashMap<String, Property>();
+    private final Map<String, Property<?>> properties = new HashMap<String,
Property<?>>();
 
     public Map<String, Service> getServices() {
         return services;
@@ -35,7 +35,19 @@
         return references;
     }
 
-    public Map<String, Property> getProperties() {
+    public Map<String, Property<?>> getProperties() {
         return properties;
+    }
+
+    public void add(Service service) {
+        services.put(service.getName(), service);
+    }
+
+    public void add(Reference reference) {
+        references.put(reference.getName(), reference);
+    }
+
+    public void add(Property<?> property) {
+        properties.put(property.getName(), property);
     }
 }

Modified: incubator/tuscany/sandbox/jboynes/sca/model/src/main/java/org/apache/tuscany/model/JavaServiceContract.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/model/src/main/java/org/apache/tuscany/model/JavaServiceContract.java?rev=399348&r1=399347&r2=399348&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/model/src/main/java/org/apache/tuscany/model/JavaServiceContract.java
(original)
+++ incubator/tuscany/sandbox/jboynes/sca/model/src/main/java/org/apache/tuscany/model/JavaServiceContract.java
Wed May  3 09:33:22 2006
@@ -20,4 +20,40 @@
  * @version $Rev$ $Date$
  */
 public class JavaServiceContract extends ServiceContract {
+    private String interfaceName;
+    private Class<?> interfaceClass;
+    private String callbackName;
+    private Class<?> callbackClass;
+
+    public String getInterfaceName() {
+        return interfaceName;
+    }
+
+    public void setInterfaceName(String interfaceName) {
+        this.interfaceName = interfaceName;
+    }
+
+    public Class<?> getInterfaceClass() {
+        return interfaceClass;
+    }
+
+    public void setInterfaceClass(Class<?> interfaceClass) {
+        this.interfaceClass = interfaceClass;
+    }
+
+    public String getCallbackName() {
+        return callbackName;
+    }
+
+    public void setCallbackName(String callbackName) {
+        this.callbackName = callbackName;
+    }
+
+    public Class<?> getCallbackClass() {
+        return callbackClass;
+    }
+
+    public void setCallbackClass(Class<?> callbackClass) {
+        this.callbackClass = callbackClass;
+    }
 }

Modified: incubator/tuscany/sandbox/jboynes/sca/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/pom.xml?rev=399348&r1=399347&r2=399348&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/pom.xml (original)
+++ incubator/tuscany/sandbox/jboynes/sca/pom.xml Wed May  3 09:33:22 2006
@@ -30,8 +30,8 @@
         <module>common</module>
         <module>model</module>
         <module>spi</module>
+        <module>core2</module>
 <!--
-        <module>core</module>
         <module>bindings</module>
         <module>databinding</module>
         <module>containers</module>
@@ -46,6 +46,7 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.1.3</version>
                 <configuration>
                     <includes>
                         <include>**/*TestCase.java</include>

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed May  3 09:33:22 2006
@@ -0,0 +1,13 @@
+target
+*.iws
+*.ipr
+*.iml
+.project
+.classpath
+maven.log
+velocity.log*
+junit*.properties
+.settings
+.deployables
+.wtpmodules
+

Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java?rev=399348&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java
(added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java
Wed May  3 09:33:22 2006
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.spi.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * A system annotation to inject an autowired instance
+ * 
+ * @version $Rev: 395110 $ $Date: 2006-04-18 19:32:30 -0700 (Tue, 18 Apr 2006) $
+ */
+@Target( { METHOD, FIELD })
+@Retention(RUNTIME)
+public @interface Autowire {
+
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Monitor.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Monitor.java?rev=399348&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Monitor.java
(added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Monitor.java
Wed May  3 09:33:22 2006
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.spi.annotation;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * A system annotation to inject a monitor
+ *
+ * @version $Rev: 392146 $ $Date: 2006-04-06 18:11:28 -0700 (Thu, 06 Apr 2006) $
+ */
+@Target( { ElementType.METHOD, ElementType.FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Monitor {
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Monitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/annotation/Monitor.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Modified: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java?rev=399348&r1=399347&r2=399348&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java
(original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java
Wed May  3 09:33:22 2006
@@ -22,6 +22,9 @@
  * @version $Rev$ $Date$
  */
 public class LoaderException extends TuscanyException {
+    private static final long serialVersionUID = -7459051598906813461L;
+    private String resourceURI;
+
     public LoaderException() {
     }
 
@@ -36,4 +39,23 @@
     public LoaderException(Throwable cause) {
         super(cause);
     }
+
+    /**
+     * Returns the location of the resource that was being loaded.
+     *
+     * @return the location of the resource that was being loaded
+     */
+    public String getResourceURI() {
+        return resourceURI;
+    }
+
+    /**
+     * Sets the location of the resource that was being loaded.
+     *
+     * @param resourceURI the location of the resource that was being loaded
+     */
+    public void setResourceURI(String resourceURI) {
+        this.resourceURI = resourceURI;
+    }
+
 }

Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderSupport.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderSupport.java?rev=399348&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderSupport.java
(added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderSupport.java
Wed May  3 09:33:22 2006
@@ -0,0 +1,55 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.spi.loader;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.model.ModelObject;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+/**
+ * Base class for loader implementations that handles registration.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class LoaderSupport<T extends ModelObject> implements StAXElementLoader<T>
{
+    protected StAXLoaderRegistry registry;
+
+    @Autowire
+    public void setRegistry(StAXLoaderRegistry registry) {
+        this.registry = registry;
+    }
+
+    @Init(eager = true)
+    public void start() {
+        registry.registerLoader(getXMLType(), this);
+    }
+
+    @Destroy
+    public void stop() {
+        registry.unregisterLoader(getXMLType(), this);
+    }
+
+    /**
+     * Returns the QName of the element that this implementation handles.
+     *
+     * @return the QName of the element that this implementation handles
+     */
+    protected abstract QName getXMLType();
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderSupport.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java?rev=399348&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java
(added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java
Wed May  3 09:33:22 2006
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.spi.loader;
+
+/**
+ * Exception that indicates an expected resource could not be found.
+ * The message should be set to the name of the resource.
+ *
+ * @version $Rev: 392764 $ $Date: 2006-04-09 09:13:55 -0700 (Sun, 09 Apr 2006) $
+ */
+public class MissingResourceException extends LoaderException {
+    private static final long serialVersionUID = 3775013318397916445L;
+
+    /**
+     * Constructor that indicates which resource could not be found.
+     * The supplied parameter is also returned as the message.
+     *
+     * @param resource the resource that could not be found
+     */
+    public MissingResourceException(String resource) {
+        super(resource);
+    }
+
+    /**
+     * Constructor that indicates which resource could not be found.
+     * The supplied parameter is also returned as the message.
+     *
+     * @param resource the resource that could not be found
+     */
+    public MissingResourceException(String resource, Throwable cause) {
+        super(resource, cause);
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java?rev=399348&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java
(added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java
Wed May  3 09:33:22 2006
@@ -0,0 +1,45 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.spi.loader;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Exception that indicates an element was encountered that could not be handled.
+ *
+ * @version $Rev: 392764 $ $Date: 2006-04-09 09:13:55 -0700 (Sun, 09 Apr 2006) $
+ */
+public class UnrecognizedElementException extends LoaderException {
+    private static final long serialVersionUID = 2549543622209829032L;
+    private final QName element;
+
+    /**
+     * Constructor that indicates which resource could not be found.
+     * The supplied parameter is also returned as the message.
+     *
+     * @param element the element that could not be handled
+     */
+    public UnrecognizedElementException(QName element) {
+        super(element.toString());
+        setIdentifier(getMessage());
+        this.element = element;
+    }
+
+    public QName getElement() {
+        return element;
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date



Mime
View raw message