tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r419297 - in /incubator/tuscany/sandbox/jboynes/sca: core2/src/main/java/org/apache/tuscany/core/bootstrap/ core2/src/main/java/org/apache/tuscany/core/builder/ core2/src/main/java/org/apache/tuscany/core/component/scope/ core2/src/main/jav...
Date Wed, 05 Jul 2006 17:48:26 GMT
Author: jboynes
Date: Wed Jul  5 10:48:25 2006
New Revision: 419297

URL: http://svn.apache.org/viewvc?rev=419297&view=rev
Log:
Simpify property processors by providing common baseclass
Test loading of a more complex bootstrap file
Support sytem binding

Added:
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/AbstractPropertyProcessor.java   (with props)
    incubator/tuscany/sandbox/jboynes/sca/core2/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl
    incubator/tuscany/sandbox/jboynes/sca/runtime/standalone/src/main/scdl/
    incubator/tuscany/sandbox/jboynes/sca/runtime/standalone/src/main/scdl/client.scdl
Removed:
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/composite/builder/
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/composite/loader/
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/injection/MonitorObjectFactory.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/injection/MonitorObjectFactoryTestCase.java
Modified:
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/DestroyProcessor.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/InitProcessor.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/MonitorProcessor.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/PropertyProcessor.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilder.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemCompositeBuilder.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/processor/MonitorProcessorTestCase.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderWireTestCase.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java Wed Jul  5 10:48:25 2006
@@ -51,6 +51,7 @@
 import org.apache.tuscany.core.implementation.processor.ReferenceProcessor;
 import org.apache.tuscany.core.implementation.processor.ScopeProcessor;
 import org.apache.tuscany.core.implementation.processor.ServiceProcessor;
+import org.apache.tuscany.core.implementation.processor.MonitorProcessor;
 import org.apache.tuscany.core.implementation.system.builder.SystemBindingBuilder;
 import org.apache.tuscany.core.implementation.system.builder.SystemComponentBuilder;
 import org.apache.tuscany.core.implementation.system.builder.SystemCompositeBuilder;
@@ -219,10 +220,10 @@
         introspectionRegistry.registerProcessor(new InitProcessor());
         introspectionRegistry.registerProcessor(new ScopeProcessor());
         introspectionRegistry.registerProcessor(new PropertyProcessor());
-        introspectionRegistry.registerProcessor(new MonitorProcessor());
         introspectionRegistry.registerProcessor(new ReferenceProcessor());
         introspectionRegistry.registerProcessor(new ServiceProcessor());
         introspectionRegistry.registerProcessor(new HeuristicPojoProcessor());
+        introspectionRegistry.registerProcessor(new MonitorProcessor(monitorFactory));
         return introspectionRegistry;
     }
 

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java Wed Jul  5 10:48:25 2006
@@ -18,6 +18,7 @@
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.component.Reference;
 import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.Service;
 import org.apache.tuscany.spi.model.Scope;
 import org.apache.tuscany.spi.wire.InboundInvocationChain;
 import org.apache.tuscany.spi.wire.InboundWire;
@@ -58,6 +59,8 @@
             for (SCAObject<?> child : (List<SCAObject<?>>) composite.getChildren()) {
                 connect(child);
             }
+        } else if (source instanceof Service) {
+            Service<T> service = (Service<T>) source;
         } else {
             BuilderConfigException e = new BuilderConfigException("Invalid source context type");
             e.setIdentifier(source.getName());

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java Wed Jul  5 10:48:25 2006
@@ -4,6 +4,7 @@
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.annotation.Autowire;
 import org.apache.tuscany.spi.component.ScopeContainer;
 import org.apache.tuscany.spi.component.ScopeNotFoundException;
 import org.apache.tuscany.spi.component.ScopeRegistry;
@@ -13,18 +14,27 @@
 /**
  * The default implementation of a scope registry
  *
- * @version $$Rev: 415032 $$ $$Date: 2006-06-17 10:28:07 -0700 (Sat, 17 Jun 2006) $$
+ * @version $Rev: 415032 $ $Date: 2006-06-17 10:28:07 -0700 (Sat, 17 Jun 2006) $
  */
 public class ScopeRegistryImpl implements ScopeRegistry {
 
-    private final Map<Scope, ScopeContainer> scopeCache;
-    private final Map<Scope, ObjectFactory<? extends ScopeContainer>> factoryCache;
-    private final WorkContext workContext;
+    private final Map<Scope, ScopeContainer> scopeCache =
+            new ConcurrentHashMap<Scope, ScopeContainer>();
+    private final Map<Scope, ObjectFactory<? extends ScopeContainer>> factoryCache =
+            new ConcurrentHashMap<Scope, ObjectFactory<? extends ScopeContainer>>();
+    private WorkContext workContext;
 
     public ScopeRegistryImpl(WorkContext workContext) {
         assert workContext != null;
-        scopeCache = new ConcurrentHashMap<Scope, ScopeContainer>();
-        factoryCache = new ConcurrentHashMap<Scope, ObjectFactory<? extends ScopeContainer>>();
+        this.workContext = workContext;
+    }
+
+    // TODO remove and replace with CDI
+    public ScopeRegistryImpl() {
+    }
+
+    @Autowire
+    public void setWorkContext(WorkContext workContext) {
         this.workContext = workContext;
     }
 

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/AbstractPropertyProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/AbstractPropertyProcessor.java?rev=419297&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/AbstractPropertyProcessor.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/AbstractPropertyProcessor.java Wed Jul  5 10:48:25 2006
@@ -0,0 +1,124 @@
+/**
+ *
+ * Copyright 2006 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.core.implementation.processor;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.annotation.Annotation;
+import java.util.Map;
+
+import org.apache.tuscany.core.implementation.ImplementationProcessorSupport;
+import org.apache.tuscany.core.implementation.JavaMappedService;
+import org.apache.tuscany.core.implementation.JavaMappedReference;
+import org.apache.tuscany.core.implementation.JavaMappedProperty;
+import org.apache.tuscany.core.implementation.PojoComponentType;
+import org.apache.tuscany.core.implementation.ProcessingException;
+import org.apache.tuscany.core.util.JavaIntrospectionHelper;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * Base class for ImplementationProcessors that handle annotations that add Property's.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractPropertyProcessor<A extends Annotation> extends ImplementationProcessorSupport {
+    private final Class<A> annotationClass;
+
+    protected AbstractPropertyProcessor(Class<A> annotationClass) {
+        this.annotationClass = annotationClass;
+    }
+
+    public void visitMethod(CompositeComponent<?> parent,
+                            Method method,
+                            PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+                            DeploymentContext context) throws ProcessingException {
+        A annotation = method.getAnnotation(annotationClass);
+        if (annotation == null) {
+            return;
+        }
+
+        if (!Void.TYPE.equals(method.getReturnType())) {
+            IllegalPropertyException ipe = new IllegalPropertyException("Method does not have void return type");
+            ipe.setIdentifier(method.toString());
+            throw ipe;
+        }
+        Class[] paramTypes = method.getParameterTypes();
+        if (paramTypes.length != 1) {
+            IllegalPropertyException ipe = new IllegalPropertyException("Method must have 1 parameter");
+            ipe.setIdentifier(method.toString());
+            throw ipe;
+        }
+        Class<?> javaType = paramTypes[0];
+
+        String name = getName(annotation);
+        if (name == null || name.length() == 0) {
+            name = method.getName();
+            if (name.startsWith("set")) {
+                name = JavaIntrospectionHelper.toPropertyName(method.getName());
+            }
+        }
+
+        Map<String, JavaMappedProperty<?>> properties = type.getProperties();
+        if (properties.containsKey(name)) {
+            throw new DuplicatePropertyException(name);
+        }
+
+        JavaMappedProperty<?> property = createProperty(name, javaType, method);
+        initProperty(property, annotation, parent, context);
+        properties.put(name, property);
+    }
+
+    public void visitField(CompositeComponent<?> parent,
+                           Field field,
+                           PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+                           DeploymentContext context) throws ProcessingException {
+        A annotation = field.getAnnotation(annotationClass);
+        if (annotation == null) {
+            return;
+        }
+
+        Class<?> javaType = field.getType();
+
+        String name = getName(annotation);
+        if (name == null || name.length() == 0) {
+            name = field.getName();
+        }
+
+        Map<String, JavaMappedProperty<?>> properties = type.getProperties();
+        if (properties.containsKey(name)) {
+            throw new DuplicatePropertyException(name);
+        }
+
+        JavaMappedProperty<?> property = createProperty(name, javaType, field);
+        initProperty(property, annotation, parent, context);
+        properties.put(name, property);
+    }
+
+    protected abstract String getName(A annotation);
+
+    protected <T> void initProperty(JavaMappedProperty<T> property, 
+                                A annotation,
+                                CompositeComponent<?> parent,
+                                DeploymentContext context) {
+    }
+
+    protected <T> JavaMappedProperty<T> createProperty(String name, Class<T> javaType, Member member) {
+        return new JavaMappedProperty<T>(name, null, javaType, member);
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/AbstractPropertyProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/AbstractPropertyProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/DestroyProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/DestroyProcessor.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/DestroyProcessor.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/DestroyProcessor.java Wed Jul  5 10:48:25 2006
@@ -14,6 +14,7 @@
 package org.apache.tuscany.core.implementation.processor;
 
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 
 import org.osoa.sca.annotations.Destroy;
 
@@ -51,7 +52,9 @@
         if (type.getDestroyMethod() != null) {
             throw new DuplicateDestructorException("More than one destructor found on implementation");
         }
-        method.setAccessible(true);
+        if (Modifier.isProtected(method.getModifiers())) {
+            method.setAccessible(true);
+        }
         type.setDestroyMethod(method);
     }
 }

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/InitProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/InitProcessor.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/InitProcessor.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/InitProcessor.java Wed Jul  5 10:48:25 2006
@@ -14,6 +14,7 @@
 package org.apache.tuscany.core.implementation.processor;
 
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 
 import org.osoa.sca.annotations.Init;
 
@@ -51,7 +52,9 @@
         if (type.getInitMethod() != null) {
             throw new DuplicateInitException("More than one initializer found on implementaton");
         }
-        method.setAccessible(true);
+        if (Modifier.isProtected(method.getModifiers())) {
+            method.setAccessible(true);
+        }
         type.setEagerInit(annotation.eager());
         type.setInitMethod(method);
     }

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/MonitorProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/MonitorProcessor.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/MonitorProcessor.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/MonitorProcessor.java Wed Jul  5 10:48:25 2006
@@ -1,84 +1,62 @@
 /**
  *
- * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ * Copyright 2006 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
+ *  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
+ *     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.
+ *  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.implementation.processor;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
+import org.apache.tuscany.core.implementation.JavaMappedProperty;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
 import org.apache.tuscany.spi.annotation.Monitor;
+import org.apache.tuscany.spi.annotation.Autowire;
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
-
-import org.apache.tuscany.core.component.AutowireComponent;
-import org.apache.tuscany.core.implementation.ImplementationProcessorSupport;
-import org.apache.tuscany.core.implementation.JavaMappedProperty;
-import org.apache.tuscany.core.implementation.JavaMappedReference;
-import org.apache.tuscany.core.implementation.JavaMappedService;
-import org.apache.tuscany.core.implementation.PojoComponentType;
-import org.apache.tuscany.core.implementation.ProcessingException;
-import org.apache.tuscany.core.injection.MonitorObjectFactory;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName;
+import org.apache.tuscany.spi.monitor.MonitorFactory;
 
 /**
- * Processes the {@link Monitor} annotation, creating a property on the component type
+ * Processes an {@link @Monitor} annotation, updating the component type with corresponding
+ * {@link org.apache.tuscany.core.implementation.JavaMappedProperty}
  *
  * @version $Rev$ $Date$
  */
-public class MonitorProcessor extends ImplementationProcessorSupport {
+public class MonitorProcessor extends AbstractPropertyProcessor<Monitor>{
+    private MonitorFactory monitorFactory;
+
+    public MonitorProcessor(MonitorFactory monitorFactory) {
+        super(Monitor.class);
+        this.monitorFactory = monitorFactory;
+    }
+
+    // TODO replace with CDI
+    public MonitorProcessor() {
+        super(Monitor.class);
+    }
+
+    @Autowire
+    public void setMonitorFactory(MonitorFactory monitorFactory) {
+        this.monitorFactory = monitorFactory;
+    }
 
-    public void visitMethod(CompositeComponent<?> parent, Method method,
-                            PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
-                            DeploymentContext context) throws IllegalPropertyException {
-        Monitor annotation = method.getAnnotation(Monitor.class);
-        if (annotation == null) {
-            return;
-        }
-        assert parent instanceof AutowireComponent;
-        if (method.getParameterTypes().length != 1) {
-            IllegalPropertyException e =
-                new IllegalPropertyException("Monitor setters must take exactly one parameter");
-            e.setIdentifier(method.getName());
-            throw e;
-        }
-        AutowireComponent autowireComponent = (AutowireComponent) parent;
-        String name = toPropertyName(method.getName());
-        Class<?> monitorType = method.getParameterTypes()[0];
-        JavaMappedProperty property = new JavaMappedProperty();
-        property.setName(name);
-        property.setMember(method);
-        property.setJavaType(monitorType);
-        property.setDefaultValueFactory(new MonitorObjectFactory(autowireComponent, monitorType));
-        type.getProperties().put(name, property);
+    protected String getName(Monitor annotation) {
+        return null;
     }
 
-    public void visitField(CompositeComponent<?> parent, Field field,
-                           PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
-                           DeploymentContext context) throws ProcessingException {
-
-        Monitor annotation = field.getAnnotation(Monitor.class);
-        if (annotation == null) {
-            return;
-        }
-        assert parent instanceof AutowireComponent;
-        AutowireComponent autowireComponent = (AutowireComponent) parent;
-        String name = field.getName();
-        Class<?> monitorType = field.getType();
-        JavaMappedProperty property = new JavaMappedProperty();
-        property.setName(name);
-        property.setMember(field);
-        property.setJavaType(monitorType);
-        property.setDefaultValueFactory(new MonitorObjectFactory(autowireComponent, monitorType));
-        type.getProperties().put(name, property);
+    protected <T> void initProperty(JavaMappedProperty<T> property,
+                                    Monitor annotation,
+                                    CompositeComponent<?> parent,
+                                    DeploymentContext context) {
+        Class<T> javaType = property.getJavaType();
+        property.setDefaultValueFactory(new SingletonObjectFactory<T>(monitorFactory.getMonitor(javaType)));
     }
 }

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/PropertyProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/PropertyProcessor.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/PropertyProcessor.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/processor/PropertyProcessor.java Wed Jul  5 10:48:25 2006
@@ -1,79 +1,30 @@
 package org.apache.tuscany.core.implementation.processor;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
 import org.osoa.sca.annotations.Property;
 
-import org.apache.tuscany.spi.deployer.DeploymentContext;
-import org.apache.tuscany.spi.component.CompositeComponent;
-
-import org.apache.tuscany.core.implementation.ImplementationProcessorSupport;
 import org.apache.tuscany.core.implementation.JavaMappedProperty;
-import org.apache.tuscany.core.implementation.JavaMappedReference;
-import org.apache.tuscany.core.implementation.JavaMappedService;
-import org.apache.tuscany.core.implementation.PojoComponentType;
-import org.apache.tuscany.core.implementation.ProcessingException;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
 
 /**
  * Processes an {@link @Property} annotation, updating the component type with corresponding {@link JavaMappedProperty}
  *
  * @version $Rev$ $Date$
  */
-public class PropertyProcessor extends ImplementationProcessorSupport {
+public class PropertyProcessor extends AbstractPropertyProcessor<Property> {
 
-    public void visitMethod(CompositeComponent<?> parent, Method method,
-                            PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
-                            DeploymentContext context)
-        throws ProcessingException {
-        Property annotation = method.getAnnotation(Property.class);
-        if (annotation == null) {
-            return;
-        }
-        if (method.getParameterTypes().length != 1) {
-            IllegalPropertyException e = new IllegalPropertyException("Setter must have one parameter");
-            e.setIdentifier(method.getName());
-            throw e;
-        }
-        String name = annotation.name();
-        if (name.length() == 0) {
-            if (method.getName().startsWith("set")) {
-                name = toPropertyName(method.getName());
-            } else {
-                name = method.getName();
-            }
-        }
-        if (type.getProperties().get(name) != null) {
-            throw new DuplicatePropertyException(name);
-        }
-        JavaMappedProperty property = new JavaMappedProperty();
-        property.setName(name);
-        property.setMember(method);
-        property.setRequired(annotation.required());
-        property.setJavaType(method.getParameterTypes()[0]);
-        type.getProperties().put(name, property);
+    public PropertyProcessor() {
+        super(Property.class);
     }
 
-    public void visitField(CompositeComponent<?> parent, Field field,
-                           PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
-                           DeploymentContext context) throws ProcessingException {
-        Property annotation = field.getAnnotation(Property.class);
-        if (annotation == null) {
-            return;
-        }
-        String name = annotation.name();
-        if (name.length() == 0) {
-            name = field.getName();
-        }
-        if (type.getProperties().get(name) != null) {
-            throw new DuplicatePropertyException(name);
-        }
-        JavaMappedProperty property = new JavaMappedProperty();
-        property.setMember(field);
-        property.setRequired(annotation.required());
-        property.setJavaType(field.getType());
-        type.getProperties().put(name, property);
+    protected String getName(Property annotation) {
+        return annotation.name();
     }
 
+    protected <T> void initProperty(JavaMappedProperty<T> property,
+                                    Property annotation,
+                                    CompositeComponent<?> parent,
+                                    DeploymentContext context) {
+        property.setRequired(annotation.required());
+    }
 }

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilder.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilder.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilder.java Wed Jul  5 10:48:25 2006
@@ -1,14 +1,5 @@
 package org.apache.tuscany.core.implementation.system.builder;
 
-import org.apache.tuscany.spi.QualifiedName;
-import org.apache.tuscany.spi.builder.BindingBuilder;
-import org.apache.tuscany.spi.component.Component;
-import org.apache.tuscany.spi.component.CompositeComponent;
-import org.apache.tuscany.spi.deployer.DeploymentContext;
-import org.apache.tuscany.spi.model.BoundReferenceDefinition;
-import org.apache.tuscany.spi.model.BoundServiceDefinition;
-import org.apache.tuscany.spi.wire.OutboundWire;
-
 import org.apache.tuscany.core.component.AutowireComponent;
 import org.apache.tuscany.core.implementation.system.component.SystemReference;
 import org.apache.tuscany.core.implementation.system.component.SystemReferenceImpl;
@@ -20,6 +11,15 @@
 import org.apache.tuscany.core.implementation.system.wire.SystemOutboundAutowire;
 import org.apache.tuscany.core.implementation.system.wire.SystemOutboundWire;
 import org.apache.tuscany.core.implementation.system.wire.SystemOutboundWireImpl;
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.builder.BindingBuilder;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.wire.OutboundWire;
 
 /**
  * Creates {@link SystemService}s and {@link SystemReference}s by evaluating an assembly definition
@@ -34,6 +34,9 @@
         Class<?> interfaze = boundServiceDefinition.getServiceContract().getInterfaceClass();
         QualifiedName targetName = new QualifiedName(boundServiceDefinition.getTarget().getPath());
         Component target = (Component) parent.getChild(targetName.getPartName());
+        if (target == null) {
+            throw new BuilderConfigException("Target not found: [" + targetName + ']');
+        }
         SystemInboundWire<?> inboundWire =
             new SystemInboundWireImpl(boundServiceDefinition.getName(), interfaze, target);
         SystemOutboundWire<?> outboundWire =

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemCompositeBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemCompositeBuilder.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemCompositeBuilder.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemCompositeBuilder.java Wed Jul  5 10:48:25 2006
@@ -66,16 +66,16 @@
         CompositeComponentType<?, ?, ?> componentType = impl.getComponentType();
         SystemCompositeComponent<?> context =
             new SystemCompositeComponentImpl(componentDefinition.getName(), parent, getAutowireContext(parent));
+        for (ComponentDefinition<? extends Implementation> childComponentDefinition
+            : componentType.getComponents().values()) {
+            context.register(builderRegistry.build(context, childComponentDefinition, deploymentContext));
+        }
         for (ServiceDefinition serviceDefinition : componentType.getServices().values()) {
             if (serviceDefinition instanceof BoundServiceDefinition) {
                 context.register(builderRegistry.build(context,
                     (BoundServiceDefinition<? extends Binding>) serviceDefinition,
                     deploymentContext));
             }
-        }
-        for (ComponentDefinition<? extends Implementation> childComponentDefinition
-            : componentType.getComponents().values()) {
-            context.register(builderRegistry.build(context, childComponentDefinition, deploymentContext));
         }
         return context;
     }

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java Wed Jul  5 10:48:25 2006
@@ -16,6 +16,8 @@
  */
 package org.apache.tuscany.core.loader;
 
+import java.net.URI;
+import java.net.URISyntaxException;
 import javax.xml.namespace.QName;
 import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
 import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
@@ -26,6 +28,7 @@
 import org.apache.tuscany.spi.extension.LoaderExtension;
 import org.apache.tuscany.spi.loader.LoaderException;
 import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.InvalidReferenceException;
 import org.apache.tuscany.spi.model.Binding;
 import org.apache.tuscany.spi.model.BoundServiceDefinition;
 import org.apache.tuscany.spi.model.ModelObject;
@@ -57,6 +60,7 @@
         throws XMLStreamException, LoaderException {
         assert AssemblyConstants.SERVICE.equals(reader.getName());
         String name = reader.getAttributeValue(null, "name");
+        String target = reader.getAttributeValue(null, "target");
         Binding binding = null;
         ServiceContract serviceContract = null;
         while (true) {
@@ -72,8 +76,22 @@
                     break;
                 case END_ELEMENT:
                     if (binding != null) {
+                        if (target == null) {
+                            InvalidReferenceException e = new InvalidReferenceException("No target for service ");
+                            e.setIdentifier(name);
+                            throw e;
+                        }
+                        URI targetURI;
+                        try {
+                            targetURI = new URI(target);
+                        } catch (URISyntaxException e) {
+                            InvalidReferenceException ire = new InvalidReferenceException(target);
+                            ire.setIdentifier(name);
+                            throw ire;
+                        }
+
                         //FIXME need a way to specify "remotable" on a service
-                        return new BoundServiceDefinition<Binding>(name, serviceContract, false, binding, null);
+                        return new BoundServiceDefinition<Binding>(name, serviceContract, false, binding, targetURI);
                     } else {
                         //FIXME need a way to specify "remotable" on a service
                         return new ServiceDefinition(name, serviceContract, false);

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java Wed Jul  5 10:48:25 2006
@@ -245,7 +245,7 @@
     }
 
     public static <T> Constructor<T> getDefaultConstructor(Class<T> clazz) throws NoSuchMethodException {
-        return clazz.getConstructor((Class[]) null);
+        return clazz.getConstructor(null);
     }
 
     /**

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java Wed Jul  5 10:48:25 2006
@@ -20,8 +20,19 @@
 import java.util.Map;
 import javax.xml.stream.XMLInputFactory;
 
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+import org.apache.tuscany.core.bootstrap.Bootstrapper;
+import org.apache.tuscany.core.bootstrap.DefaultBootstrapper;
+import org.apache.tuscany.core.implementation.system.model.SystemBinding;
+import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation;
+import org.apache.tuscany.core.mock.component.BasicInterface;
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
+import org.apache.tuscany.spi.component.Component;
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.deployer.Deployer;
 import org.apache.tuscany.spi.loader.LoaderException;
 import org.apache.tuscany.spi.model.BoundServiceDefinition;
 import org.apache.tuscany.spi.model.ComponentDefinition;
@@ -31,15 +42,6 @@
 import org.apache.tuscany.spi.model.PropertyValue;
 import org.apache.tuscany.spi.model.ServiceDefinition;
 
-import org.apache.tuscany.core.bootstrap.Bootstrapper;
-import org.apache.tuscany.core.bootstrap.DefaultBootstrapper;
-import org.apache.tuscany.core.implementation.system.model.SystemBinding;
-import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation;
-import org.apache.tuscany.core.mock.component.BasicInterface;
-import org.apache.tuscany.core.monitor.NullMonitorFactory;
-import org.jmock.Mock;
-import org.jmock.MockObjectTestCase;
-
 /**
  * Verifies the default boostrap deployer
  *
@@ -50,6 +52,7 @@
     private DeploymentContext deploymentContext;
     private ComponentDefinition<SystemCompositeImplementation> componentDefinition;
     private SystemCompositeImplementation implementation;
+    private Mock parent;
 
     public void testBoot1Load() throws LoaderException {
         Mock mock = mock(CompositeComponent.class);
@@ -83,6 +86,34 @@
         assertNotNull(componentType); // details checked in SystemComponentTypeLoaderTestCase
     }
 
+    public void testBoot2Deployment() throws LoaderException {
+        URL scdl = BootstrapDeployerTestCase.class.getResource("boot2.scdl");
+        implementation.setScdlLocation(scdl);
+        parent.expects(once()).method("register").withAnyArguments();
+
+        // load the boot2 file using the bootstrap deployer
+        componentDefinition.setName("newDeployer");
+        Component<?> component = deployer.deploy((CompositeComponent<?>) parent.proxy(), componentDefinition);
+        assertNotNull(component);
+        parent.verify();
+        component.start();
+        Deployer newDeployer = (Deployer) component.getServiceInstance("deployer");
+        assertNotNull(newDeployer);
+
+/*      // FIXME
+        // load the boot2 file using the newly loaded deployer
+        parent.reset();
+        parent.expects(once()).method("register").withAnyArguments();
+        componentDefinition.setName("newDeployer2");
+        component = newDeployer.deploy((CompositeComponent<?>) parent.proxy(), componentDefinition);
+        assertNotNull(component);
+        parent.verify();
+        component.start();
+        Deployer newDeployer2 = (Deployer) component.getServiceInstance("deployer");
+        assertNotNull(newDeployer2);
+*/
+    }
+
     protected void setUp() throws Exception {
         super.setUp();
         XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
@@ -92,5 +123,6 @@
         implementation = new SystemCompositeImplementation();
         implementation.setClassLoader(getClass().getClassLoader());
         componentDefinition = new ComponentDefinition<SystemCompositeImplementation>(implementation);
+        parent = mock(CompositeComponent.class);
     }
 }

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/processor/MonitorProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/processor/MonitorProcessorTestCase.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/processor/MonitorProcessorTestCase.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/processor/MonitorProcessorTestCase.java Wed Jul  5 10:48:25 2006
@@ -18,13 +18,15 @@
 import java.util.Map;
 
 import org.apache.tuscany.spi.annotation.Monitor;
+import org.apache.tuscany.spi.monitor.MonitorFactory;
 
 import org.apache.tuscany.core.component.AutowireComponent;
 import org.apache.tuscany.core.implementation.JavaMappedProperty;
 import org.apache.tuscany.core.implementation.JavaMappedReference;
 import org.apache.tuscany.core.implementation.JavaMappedService;
 import org.apache.tuscany.core.implementation.PojoComponentType;
-import org.apache.tuscany.core.injection.MonitorObjectFactory;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+
 import org.jmock.Mock;
 import org.jmock.MockObjectTestCase;
 
@@ -33,26 +35,26 @@
  */
 public class MonitorProcessorTestCase extends MockObjectTestCase {
 
-    private AutowireComponent parent;
+    private MonitorProcessor processor;
+    private Mock monitorFactory;
 
     public void testSetter() throws Exception {
-        MonitorProcessor processor = new MonitorProcessor();
         PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Method method = Foo.class.getMethod("setMonitor", Foo.class);
-        processor.visitMethod(parent, method, type, null);
+        monitorFactory.expects(once()).method("getMonitor").with(eq(Foo.class)).will(returnValue(null));
+        processor.visitMethod(null, method, type, null);
         Map<String, JavaMappedProperty<?>> properties = type.getProperties();
-        assertTrue(properties.get("monitor").getDefaultValueFactory() instanceof MonitorObjectFactory);
+        assertTrue(properties.get("monitor").getDefaultValueFactory() instanceof SingletonObjectFactory);
     }
 
 
     public void testBadSetter() throws Exception {
-        MonitorProcessor processor = new MonitorProcessor();
         PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Method method = BadMonitor.class.getMethod("setMonitor");
         try {
-            processor.visitMethod(parent, method, type, null);
+            processor.visitMethod(null, method, type, null);
             fail();
         } catch (IllegalPropertyException e) {
             // expected
@@ -60,19 +62,19 @@
     }
 
     public void testField() throws Exception {
-        MonitorProcessor processor = new MonitorProcessor();
         PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Field field = Foo.class.getDeclaredField("bar");
-        processor.visitField(parent, field, type, null);
+        monitorFactory.expects(once()).method("getMonitor").with(eq(Foo.class)).will(returnValue(null));
+        processor.visitField(null, field, type, null);
         Map<String, JavaMappedProperty<?>> properties = type.getProperties();
-        assertTrue(properties.get("bar").getDefaultValueFactory() instanceof MonitorObjectFactory);
+        assertTrue(properties.get("bar").getDefaultValueFactory() instanceof SingletonObjectFactory);
     }
 
     protected void setUp() throws Exception {
         super.setUp();
-        Mock mock = mock(AutowireComponent.class);
-        parent = (AutowireComponent) mock.proxy();
+        monitorFactory = mock(MonitorFactory.class);
+        processor = new MonitorProcessor((MonitorFactory) monitorFactory.proxy());
     }
 
     private class Foo {

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderWireTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderWireTestCase.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderWireTestCase.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderWireTestCase.java Wed Jul  5 10:48:25 2006
@@ -136,11 +136,12 @@
         ComponentDefinition<SystemImplementation> componentDefinition = MockComponentFactory.createTarget();
 
         AtomicComponent sourceComponent = builder.build(parent, componentDefinition, deploymentContext);
+        parent.register(sourceComponent);
+
         Service service = bindingBuilder.build(parent, serviceDefinition, deploymentContext);
+        parent.register(service);
 
         connector.connect(service.getInboundWire(), service.getOutboundWire(), true);
-        parent.register(sourceComponent);
-        parent.register(service);
 
         connector.connect(sourceComponent);
         String serviceName = service.getOutboundWire().getTargetName().getPortName();

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java Wed Jul  5 10:48:25 2006
@@ -16,20 +16,21 @@
  */
 package org.apache.tuscany.core.loader;
 
+import java.net.URI;
 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.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
 import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.loader.LoaderException;
 import org.apache.tuscany.spi.loader.LoaderRegistry;
 import org.apache.tuscany.spi.model.ServiceContract;
 import org.apache.tuscany.spi.model.ServiceDefinition;
 
-import org.jmock.Mock;
-import org.jmock.MockObjectTestCase;
-
 /**
  * Verifies loading of a service definition from an XML-based assembly
  *
@@ -43,8 +44,12 @@
 
     public void testWithNoInterface() throws LoaderException, XMLStreamException {
         String name = "serviceDefinition";
+        String target = "target";
         mockReader.expects(once()).method("getName").will(returnValue(AssemblyConstants.SERVICE));
-        mockReader.expects(once()).method("getAttributeValue").with(NULL, eq("name")).will(returnValue(name));
+        // todo figure out how to check ordering
+        mockReader.expects(atLeastOnce()).method("getAttributeValue")
+                .with(ANYTHING, ANYTHING)
+                .will(onConsecutiveCalls(returnValue(name), returnValue(target)));
         mockReader.expects(once()).method("next").will(returnValue(END_ELEMENT));
         ServiceDefinition serviceDefinition = loader.load(null, (XMLStreamReader) mockReader.proxy(), null);
         assertNotNull(serviceDefinition);
@@ -53,10 +58,14 @@
 
     public void testWithInterface() throws LoaderException, XMLStreamException {
         String name = "serviceDefinition";
+        String target = "target";
         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));
+        // todo figure out how to check ordering
+        mockReader.expects(atLeastOnce()).method("getAttributeValue")
+                .with(ANYTHING, ANYTHING)
+                .will(onConsecutiveCalls(returnValue(name), returnValue(target)));
         mockReader.expects(atLeastOnce()).method("next")
             .will(onConsecutiveCalls(returnValue(START_ELEMENT), returnValue(END_ELEMENT)));
         mockRegistry.expects(once()).method("load").with(eq(null), eq(mockReader.proxy()), eq(deploymentContext))

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl?rev=419297&r1=419296&r2=419297&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl Wed Jul  5 10:48:25 2006
@@ -17,7 +17,7 @@
 <composite xmlns="http://www.osoa.org/xmlns/sca/0.9"
            xmlns:system="http://tuscany.apache.org/xmlns/system/0.9"
            name="simple">
-    <service name="service">
+    <service name="service" target="component">
         <interface.java interface="org.apache.tuscany.core.mock.component.BasicInterface"/>
         <system:binding.system/>
     </service>

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl?rev=419297&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl Wed Jul  5 10:48:25 2006
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ *  Copyright (c) 2006 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.
+ -->
+<!--
+    A more complex example closer to a typical bootstrap configuration
+    $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/0.9"
+           xmlns:system="http://tuscany.apache.org/xmlns/system/0.9"
+           name="boot2">
+
+    <!-- expose Deployer API as a service -->
+    <service name="deployer" target="deployerImpl">
+        <interface.java interface="org.apache.tuscany.spi.deployer.Deployer"/>
+        <system:binding.system/>
+    </service>
+
+    <!-- Component that provides the Deployer service -->
+    <component name="deployerImpl">
+        <system:implementation.system class="org.apache.tuscany.core.deployer.DeployerImpl"/>
+    </component>
+
+    <!-- Work management -->
+    <component name="workContext">
+        <system:implementation.system class="org.apache.tuscany.core.component.WorkContextImpl"/>
+    </component>
+
+    <!-- Scope infrastructure -->
+    <component name="scopeRegistry">
+        <system:implementation.system class="org.apache.tuscany.core.component.scope.ScopeRegistryImpl"/>
+    </component>
+
+    <!-- Builder and BuilderRegistry -->
+    <component name="builder">
+        <system:implementation.system class="org.apache.tuscany.core.builder.BuilderRegistryImpl"/>
+    </component>
+
+    <!-- Loader and LoaderRegistry -->
+    <component name="loader">
+        <system:implementation.system class="org.apache.tuscany.core.loader.LoaderRegistryImpl"/>
+    </component>
+
+    <!-- Introspector and IntrospectionRegistry -->
+    <component name="introspector">
+        <system:implementation.system class="org.apache.tuscany.core.implementation.IntrospectionRegistryImpl"/>
+    </component>
+
+    <!-- Connector infrastructure -->
+    <component name="connector">
+        <system:implementation.system class="org.apache.tuscany.core.builder.ConnectorImpl"/>
+    </component>
+
+    <!-- Foundcation element loader implementations -->
+    <component name="elementLoader.component">
+        <system:implementation.system class="org.apache.tuscany.core.loader.ComponentLoader"/>
+    </component>
+    <component name="elementLoader.componentType">
+        <system:implementation.system class="org.apache.tuscany.core.loader.ComponentTypeElementLoader"/>
+    </component>
+    <component name="elementLoader.interface.java">
+        <system:implementation.system class="org.apache.tuscany.core.loader.InterfaceJavaLoader"/>
+    </component>
+    <component name="elementLoader.property">
+        <system:implementation.system class="org.apache.tuscany.core.loader.PropertyLoader"/>
+    </component>
+    <component name="elementLoader.reference">
+        <system:implementation.system class="org.apache.tuscany.core.loader.ReferenceLoader"/>
+    </component>
+    <component name="elementLoader.service">
+        <system:implementation.system class="org.apache.tuscany.core.loader.ServiceLoader"/>
+    </component>
+
+    <!-- Composite implementation type -->
+    <component name="composite.loader">
+        <system:implementation.system class="org.apache.tuscany.core.implementation.composite.CompositeLoader"/>
+    </component>
+</composite>
\ No newline at end of file

Added: incubator/tuscany/sandbox/jboynes/sca/runtime/standalone/src/main/scdl/client.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/runtime/standalone/src/main/scdl/client.scdl?rev=419297&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/runtime/standalone/src/main/scdl/client.scdl (added)
+++ incubator/tuscany/sandbox/jboynes/sca/runtime/standalone/src/main/scdl/client.scdl Wed Jul  5 10:48:25 2006
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ *  Copyright (c) 2006 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.
+ -->
+<!--
+    A more complex example closer to a typical bootstrap configuration
+    $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/0.9"
+           xmlns:system="http://tuscany.apache.org/xmlns/system/0.9"
+           name="boot2">
+
+    <!-- expose Deployer API as a service -->
+    <service name="deployer">
+        <interface.java interface="org.apache.tuscany.spi.deployer.Deployer"/>
+        <reference target="deployer"/>
+    </service>
+
+    <!-- Component that provides the Deployer service -->
+    <component name="deployer">
+        <system:implementation.system class="org.apache.tuscany.core.deployer.DeployerImpl"/>
+    </component>
+
+    <!-- Work management -->
+    <component name="workContext">
+        <system:implementation.system class="org.apache.tuscany.core.component.WorkContextImpl"/>
+    </component>
+
+    <!-- Scope infrastructure -->
+    <component name="scopeRegistry">
+        <system:implementation.system class="org.apache.tuscany.core.component.scope.ScopeRegistryImpl"/>
+    </component>
+
+    <!-- Builder and BuilderRegistry -->
+    <component name="builder">
+        <system:implementation.system class="org.apache.tuscany.core.builder.BuilderRegistryImpl"/>
+    </component>
+
+    <!-- Loader and LoaderRegistry -->
+    <component name="loader">
+        <system:implementation.system class="org.apache.tuscany.core.loader.LoaderRegistryImpl"/>
+    </component>
+
+    <!-- Introspector and IntrospectionRegistry -->
+    <component name="introspector">
+        <system:implementation.system class="org.apache.tuscany.core.implementation.IntrospectionRegistryImpl"/>
+    </component>
+
+    <!-- Connector infrastructure -->
+    <component name="connector">
+        <system:implementation.system class="org.apache.tuscany.core.builder.ConnectorImpl"/>
+    </component>
+
+    <!-- Foundcation element loader implementations -->
+    <component name="elementLoader.component">
+        <system:implementation.system class="org.apache.tuscany.core.loader.ComponentLoader"/>
+    </component>
+    <component name="elementLoader.componentType">
+        <system:implementation.system class="org.apache.tuscany.core.loader.ComponentTypeElementLoader"/>
+    </component>
+    <component name="elementLoader.interface.java">
+        <system:implementation.system class="org.apache.tuscany.core.loader.InterfaceJavaLoader"/>
+    </component>
+    <component name="elementLoader.property">
+        <system:implementation.system class="org.apache.tuscany.core.loader.PropertyLoader"/>
+    </component>
+    <component name="elementLoader.reference">
+        <system:implementation.system class="org.apache.tuscany.core.loader.ReferenceLoader"/>
+    </component>
+    <component name="elementLoader.service">
+        <system:implementation.system class="org.apache.tuscany.core.loader.ServiceLoader"/>
+    </component>
+
+    <!-- Composite implementation type -->
+    <component name="composite.loader">
+        <system:implementation.system class="org.apache.tuscany.core.implementation.composite.CompositeLoader"/>
+    </component>
+</composite>
\ No newline at end of file



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


Mime
View raw message