You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2007/07/02 14:16:40 UTC

svn commit: r552481 [2/7] - in /incubator/tuscany/java/sca/itest/osgi-implementation: ./ src/ src/main/ src/main/java/ src/main/java/helloworld/ src/main/java/helloworld/ws/ src/main/java/stockquote/ src/main/java/supplychain/ src/main/java/supplychain...

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/JavaGreetingsComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/JavaGreetingsComponent.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/JavaGreetingsComponent.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/JavaGreetingsComponent.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package helloworld;
+
+import org.osoa.sca.annotations.AllowsPassByReference;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(Greetings.class)
+@Scope("COMPOSITE")
+public class JavaGreetingsComponent implements Greetings {
+
+    private Greetings greetingsService;
+    
+    @Reference
+    public void setGreetingsService(Greetings greetingsService) {
+    	this.greetingsService = greetingsService;
+    }
+    
+   
+    public String[] getGreetingsFromJava(String s[]) {
+        for (int i = 0; i < s.length; i++) {
+            s[i] = "Hello " + s[i] + "(From Java)";
+        }
+            
+        return greetingsService.getGreetingsFromJava(s);
+    }
+    
+    public String[] getGreetingsFromOSGi(String s[]) {
+        for (int i = 0; i < s.length; i++) {
+            s[i] = s[i] + "(From Java)";
+        }
+            
+        return s;
+    }
+    
+    @AllowsPassByReference
+    public String[] getModifiedGreetingsFromJava(String s[]) {
+        for (int i = 0; i < s.length; i++) {
+            s[i] = "Hello " + s[i] + "(From Java)";
+        }
+            
+        return greetingsService.getModifiedGreetingsFromJava(s);
+    }
+    
+    @AllowsPassByReference
+    public String[] getModifiedGreetingsFromOSGi(String s[]) {
+        for (int i = 0; i < s.length; i++) {
+            s[i] = s[i] + "(From Java)";
+        }
+            
+        return s;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/JavaGreetingsComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/JavaGreetingsComponent.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/JavaHelloWorldComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/JavaHelloWorldComponent.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/JavaHelloWorldComponent.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/JavaHelloWorldComponent.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package helloworld;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("COMPOSITE")
+public class JavaHelloWorldComponent implements HelloWorld {
+
+    public helloworld.ws.HelloWorld helloWorldWS;
+    
+    @Reference
+    public void setHelloWorldWS(helloworld.ws.HelloWorld helloWorldWS) {
+    	this.helloWorldWS = helloWorldWS;
+    }
+    
+    public String getGreetings(String s) {
+        return helloWorldWS.getGreetings(s);
+    }
+    
+   
+
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/JavaHelloWorldComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/JavaHelloWorldComponent.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/OSGiGreetingsImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/OSGiGreetingsImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/OSGiGreetingsImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/OSGiGreetingsImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package helloworld;
+
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.BundleActivator;
+
+
+public class OSGiGreetingsImpl implements Greetings, ServiceListener, BundleActivator {
+
+    private Greetings greetingsService;
+    
+    private BundleContext bundleContext;
+    
+    public String[] getGreetingsFromOSGi(String s[]) {
+        for (int i = 0; i < s.length; i++) {
+            s[i] = "Hello " + s[i] + "(From OSGi)";
+        }
+            
+        return greetingsService.getGreetingsFromOSGi(s);
+    }
+    
+    public String[] getGreetingsFromJava(String s[]) {
+        for (int i = 0; i < s.length; i++) {
+            s[i] = s[i] + "(From OSGi)";
+        }
+            
+        return s;
+    }
+    
+    public String[] getModifiedGreetingsFromOSGi(String s[]) {
+        for (int i = 0; i < s.length; i++) {
+            s[i] = "Hello " + s[i] + "(From OSGi)";
+        }
+            
+        return greetingsService.getModifiedGreetingsFromOSGi(s);
+    }
+    
+    public String[] getModifiedGreetingsFromJava(String s[]) {
+        for (int i = 0; i < s.length; i++) {
+            s[i] = s[i] + "(From OSGi)";
+        }
+            
+        return s;
+    }
+
+    public void start(BundleContext bc) {
+    	
+    	System.out.println("Started OsgiGreetingsImpl bundle ");
+    	
+    	this.bundleContext = bc;
+    	
+        Hashtable<String, Object> serviceProps = new Hashtable<String, Object>();
+        serviceProps.put("component.service.name", "OSGiGreetingsComponent/Greetings");
+        bundleContext.registerService("helloworld.Greetings", this, serviceProps);
+        
+        
+        ServiceReference ref = bundleContext.getServiceReference("helloworld.Greetings");
+        if (ref != null)
+            greetingsService = (helloworld.Greetings)bundleContext.getService(ref);
+        else {
+            try {
+                String filter = "(objectclass=helloworld.Greetings)";
+                this.bundleContext.addServiceListener(this, filter);                
+
+            } catch (InvalidSyntaxException e) {
+                e.printStackTrace();
+            }
+        }
+      
+    }
+    
+    public void stop(BundleContext bc)  {
+    }
+    
+	public void serviceChanged(ServiceEvent event) {
+		try {
+			if (event.getType() == ServiceEvent.REGISTERED) {
+			    ServiceReference ref = event.getServiceReference();
+			    greetingsService =  (helloworld.Greetings) bundleContext.getService(ref);
+			}
+		} catch (Throwable e) {
+			e.printStackTrace();
+		}
+	}
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/OSGiGreetingsImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/OSGiGreetingsImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/OSGiHelloWorldImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/OSGiHelloWorldImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/OSGiHelloWorldImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/OSGiHelloWorldImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package helloworld;
+
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.BundleActivator;
+
+
+public class OSGiHelloWorldImpl implements HelloWorld, ServiceListener, BundleActivator {
+
+    public helloworld.ws.HelloWorld helloWorldWS;
+    
+    private BundleContext bundleContext;
+    
+    public String getGreetings(String s) {
+        return helloWorldWS.getGreetings(s);
+    }
+    
+
+    public void start(BundleContext bc) {
+    	
+    	System.out.println("Started OsgiHelloWorldImpl bundle ");
+    	
+    	this.bundleContext = bc;
+    	
+        Hashtable<String, Object> serviceProps = new Hashtable<String, Object>();
+        serviceProps.put("component.name", "HelloWorldComponent");
+        bundleContext.registerService("helloworld.HelloWorld", this, serviceProps);
+        
+        ServiceReference ref = bundleContext.getServiceReference("helloworld.ws.HelloWorld");
+        if (ref != null)
+            helloWorldWS = (helloworld.ws.HelloWorld)bundleContext.getService(ref);
+        else {
+            try {
+            	String filter = "(objectclass=helloworld.ws.HelloWorld)";
+            	this.bundleContext.addServiceListener(this, filter);				
+
+            } catch (InvalidSyntaxException e) {
+            	e.printStackTrace();
+            }
+        }
+        
+    }
+    
+    public void stop(BundleContext bc)  {
+    }
+    
+	public void serviceChanged(ServiceEvent event) {
+		try {
+			if (event.getType() == ServiceEvent.REGISTERED) {
+			    ServiceReference ref = event.getServiceReference();
+			    helloWorldWS =  (helloworld.ws.HelloWorld) bundleContext.getService(ref);
+			}
+		} catch (Throwable e) {
+			e.printStackTrace();
+		}
+	}
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/OSGiHelloWorldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/OSGiHelloWorldImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/ws/HelloWorld.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/ws/HelloWorld.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/ws/HelloWorld.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/ws/HelloWorld.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package helloworld.ws;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface HelloWorld {
+    
+    public String getGreetings(String s);
+
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/ws/HelloWorld.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/ws/HelloWorld.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/ws/HelloWorldService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/ws/HelloWorldService.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/ws/HelloWorldService.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/ws/HelloWorldService.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package helloworld.ws;
+
+public class HelloWorldService implements HelloWorld {
+
+    public String getGreetings(String s) {
+        return "Hello " + s;
+    }
+    
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/ws/HelloWorldService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/helloworld/ws/HelloWorldService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteComponentImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteComponentImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteComponentImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package stockquote;
+
+import java.util.Dictionary;
+
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * Declarative Stock quote with configurable properties.
+ */
+public class OSGiStockQuoteComponentImpl implements StockQuote {
+    
+    public double exchangeRate;
+    
+    private String currency;
+    
+    
+    public double configExchangeRate;
+    public String configCurrency;
+    
+    public void setCurrency(String currency) {
+        this.currency = currency;
+    }
+    
+    public double getQuote(String ticker) throws Exception {
+        
+        if (exchangeRate == 2.0 && !"USD".equals(currency)) {
+            throw new RuntimeException("Property exchangeRate not set correctly, exchangeRate= " + 
+                    exchangeRate + " currency=" + currency);
+        }
+        if (exchangeRate == 1.48 && !"EURO".equals(currency)) {
+            throw new RuntimeException("Property exchangeRate not set correctly, exchangeRate= " + 
+                    exchangeRate + " currency=" + currency);
+        }
+        
+        if (configExchangeRate == 2.0 && !"USD".equals(configCurrency)) {
+            throw new RuntimeException("ConfigAdmin Property exchangeRate not set correctly, exchangeRate= " + 
+                    configExchangeRate + " currency=" + configCurrency);
+        }
+        if (configExchangeRate == 1.48 && !"EURO".equals(configCurrency)) {
+            throw new RuntimeException("Property configExchangeRate not set correctly, exchangeRate= " + 
+                    configExchangeRate + " currency=" + configCurrency);
+        }
+        
+        return 52.81 * exchangeRate;
+        
+    }
+    
+    protected void activate(ComponentContext context){
+        System.out.println("Activated OSGiStockQuoteComponentImpl bundle ");
+        Dictionary props = context.getProperties();
+        Object prop = props.get("currency");
+        if (prop instanceof String[]&& ((String [])prop).length > 0)
+            configCurrency = ((String [])prop)[0];
+        prop = props.get("exchangeRate");
+        if (prop instanceof Double[]&& ((Double [])prop).length > 0)
+            configExchangeRate = (double)((Double [])prop)[0];
+    }
+
+    protected void deactivate(ComponentContext context){
+        System.out.println("Deactivated OSGiStockQuoteComponentImpl bundle ");
+    }
+
+    
+
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteComponentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteComponentImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteFactoryImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteFactoryImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteFactoryImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package stockquote;
+
+import java.util.Hashtable;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * 
+ * OSGi service factory where service has configurable properties
+ * Only property injection is tested. ConfigurationAdmin is not used.
+ *
+ */
+public class OSGiStockQuoteFactoryImpl implements BundleActivator, ServiceFactory {
+    
+   
+    private BundleContext bundleContext;
+    
+
+    public void start(BundleContext bc) throws Exception {
+        
+        bundleContext = bc;
+        
+        Hashtable<String, Object> props = new Hashtable<String, Object>();
+        bc.registerService(StockQuote.class.getName(), this, props);
+        
+    }
+
+    public void stop(BundleContext bc) throws Exception {
+    }
+
+
+    public Object getService(Bundle bundle, ServiceRegistration registration) {
+        return new OSGiStockQuoteImpl(bundleContext);
+    }
+
+
+    public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
+        
+    }
+
+    
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteFactoryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package stockquote;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+/**
+ * 
+ * Stock quote with configurable properties.
+ *
+ */
+public class OSGiStockQuoteImpl implements StockQuote, BundleActivator {
+    
+    public String pid;
+    
+    public double exchangeRate;
+    
+    private String currency;
+    
+    private BundleContext bundleContext;
+    
+    public OSGiStockQuoteImpl() {     
+        this.pid = "stockQuote";
+    }
+    
+    protected OSGiStockQuoteImpl(BundleContext bc) {
+        this.bundleContext = bc;
+    }
+    
+    public void setCurrency(String currency) {
+        this.currency = currency;
+    }
+    
+     
+    private void checkProperties() throws Exception {
+               
+        if (exchangeRate == 2.0 && !"USD".equals(currency)) {
+            throw new RuntimeException("Property exchangeRate not set correctly, exchangeRate= " + 
+                    exchangeRate + " currency=" + currency);
+        }
+        
+        if (exchangeRate == 1.48 && !"EURO".equals(currency)) {
+            throw new RuntimeException("Property exchangeRate not set correctly, exchangeRate= " + 
+                    exchangeRate + " currency=" + currency);
+        }
+        
+        ServiceReference configAdminReference = bundleContext.getServiceReference("org.osgi.service.cm.ConfigurationAdmin");
+        if (configAdminReference != null && pid != null ) {
+            
+            ConfigurationAdmin cm = (ConfigurationAdmin)bundleContext.getService(configAdminReference);
+            
+            Configuration config = cm.getConfiguration("stockQuote", null);
+            
+            Dictionary props = config.getProperties();
+            
+            if (exchangeRate != (double)(Double)props.get("exchangeRate")) {
+                throw new Exception("Config Property exchangeRate not set correctly, expected " 
+                        + props.get("exchangeRate") + " got " + exchangeRate);
+            }
+            
+            if (!currency.equals(props.get("currency"))) {
+                throw new Exception("Config Property currency not set correctly, expected " 
+                        + props.get("currency") + " got " + currency);
+            }
+        }
+        
+    }
+    
+    public double getQuote(String ticker) throws Exception {
+        
+        checkProperties();
+       
+        return 52.81 * exchangeRate;
+        
+    }
+
+    public void start(BundleContext bc) throws Exception {
+        
+        bundleContext = bc;
+        
+        Hashtable<String, Object> props = new Hashtable<String, Object>();
+        props.put("service.pid", "stockQuote");
+        
+        bc.registerService(StockQuote.class.getName(), this, props);
+        
+    }
+
+    public void stop(BundleContext bc) throws Exception {
+    }
+
+    
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/OSGiStockQuoteImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/StockQuote.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/StockQuote.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/StockQuote.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/StockQuote.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package stockquote;
+
+/**
+ * 
+ * Stock Quote interface
+ *
+ */
+public interface StockQuote {
+    
+    public double getQuote(String ticker) throws Exception ;
+
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/StockQuote.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/stockquote/StockQuote.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/OSGiBundleImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/OSGiBundleImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/OSGiBundleImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/OSGiBundleImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package supplychain;
+
+
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+
+
+/**
+ * This class implements the Customer service component.
+ */
+public  class OSGiBundleImpl implements ServiceListener, BundleActivator {
+    
+
+    String name;
+    
+    String[] references;
+    Class<?>[] referenceClasses;
+    Field[] referenceFields;
+    String[] referenceFilters;
+    
+    Class myClass;
+    ArrayList<String> serviceNames = new ArrayList<String>();
+    ArrayList<Object> serviceObjs = new ArrayList<Object>();
+    ArrayList<Hashtable<String, Object>> serviceProperties = new ArrayList<Hashtable<String, Object>>();
+    
+    
+	private BundleContext bundleContext;
+    
+    public OSGiBundleImpl() {}
+    
+    public OSGiBundleImpl(String[] references, String[] filters) {
+        
+        myClass = this.getClass();
+        this.name = this.getClass().getSimpleName();
+        this.references = references == null?new String[0] : references;
+        
+       
+        try {
+            referenceClasses = new Class[references.length];
+            referenceFields = new Field[references.length];
+            referenceFilters = new String[references.length];
+            for (int i = 0; i < references.length; i++) {
+                referenceFields[i] = this.getClass().getDeclaredField(references[i]);
+                referenceFields[i].setAccessible(true);
+                referenceClasses[i] = referenceFields[i].getType();
+                
+                if (filters != null && filters.length > i)
+                    referenceFilters[i] = filters[i];
+            }
+            
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        
+    }
+    
+    public void start(BundleContext bc) {
+    	
+    	System.out.println("Started bundle " + name);
+    	
+    	this.bundleContext = bc;
+        
+        boolean useSingleRegisterService = serviceNames.size() > 1;
+        for (int i = 1; i < serviceNames.size(); i++) {
+            if (serviceObjs.get(i) != serviceObjs.get(0) || 
+                    serviceProperties.get(i) != serviceProperties.get(0)) {
+                useSingleRegisterService = false;
+                break;
+            }
+        }
+        if (useSingleRegisterService) {
+            bundleContext.registerService(serviceNames.toArray(new String[serviceNames.size()]), 
+                    serviceObjs.get(0), serviceProperties.get(0));
+        }
+        else {
+            for (int i = 0; i < serviceNames.size(); i++) {
+                bundleContext.registerService(serviceNames.get(i), serviceObjs.get(i), serviceProperties.get(i));
+            }
+        }
+        
+        started(bc);
+    	
+        for (int i = 0; i < references.length; i++) {
+
+            try {
+                if (referenceFields[i].get(this) != null)
+                    continue;
+                
+    	        ServiceReference[] refs = bundleContext.getServiceReferences(referenceClasses[i].getName(), referenceFilters[i]);
+	            if (refs != null && refs.length > 0) {
+                    Object obj = bundleContext.getService(refs[0]);
+                    referenceFields[i].set(this, referenceClasses[i].cast(obj));
+                } else {
+				    String filter = "(objectclass=" + referenceClasses[i].getName() + ")";
+				    this.bundleContext.addServiceListener(this, filter);				
+	            }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+    
+    public void stop(BundleContext bc)  {
+        System.out.println("Stop bundle " + name);
+
+    }
+    
+    protected void started(BundleContext bc)  {
+        
+    }
+
+	public void serviceChanged(ServiceEvent event) {
+		try {
+			if (event.getType() == ServiceEvent.REGISTERED) {
+                
+                ServiceReference ref = event.getServiceReference();
+                Object obj = bundleContext.getService(ref);
+                for (int i = 0; i < references.length; i++) {
+                    if (referenceClasses[i].isAssignableFrom(obj.getClass())) {
+                        referenceFields[i].set(this, referenceClasses[i].cast(obj));
+                    }
+                }
+			}
+		} catch (Throwable e) {
+			e.printStackTrace();
+		}
+	}
+    
+
+    public void registerService(Object serviceObject, String serviceName, Hashtable<String, Object> props) {
+        serviceObjs.add(serviceObject);
+        serviceNames.add(serviceName);
+        serviceProperties.add(props == null? new Hashtable<String, Object>() : props);
+    }
+}
+ 
\ No newline at end of file

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/OSGiBundleImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/OSGiBundleImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/Customer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/Customer.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/Customer.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/Customer.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package supplychain.customer;
+
+import org.osoa.sca.annotations.OneWay;
+
+/**
+ * This is the business interface of the Customer service component.
+ */
+public interface Customer {
+    
+    public void purchaseBooks();
+    
+    public void purchaseGames();
+    
+    public void purchaseGoods();
+    
+    @OneWay
+    public void notifyShipment(String order);
+    
+    public boolean hasOutstandingOrders();
+
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/Customer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/Customer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package supplychain.customer;
+
+import java.util.ArrayList;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+import supplychain.retailer.Retailer;
+
+/**
+ * This class implements the Customer service component.
+ */
+@Service(Customer.class)
+@Scope("COMPOSITE")
+public class JavaCustomerComponentImpl implements Customer {
+    
+    private Retailer retailer1;
+	
+    private Retailer retailer2;
+    
+    private Retailer retailer3;
+    
+    private static ArrayList<String> outstandingOrders = new ArrayList<String>();
+    
+    @Reference
+    public void setRetailer1(Retailer retailer1) {
+        this.retailer1 = retailer1;
+    }
+    
+    @Reference
+    public void setRetailer2(Retailer retailer2) {
+        this.retailer2 = retailer2;
+    }
+    
+    @Reference
+    public void setRetailer3(Retailer retailer3) {
+        this.retailer3 = retailer3;
+    }
+    
+    public void purchaseBooks() {
+    	System.out.println("JavaCustomerComponentImpl.purchaseBooks");
+        outstandingOrders.add("Order, submitted (amazon.com), fulfilled, shipped (ParcelForce)");
+        retailer1.submitOrder("Order");
+    }
+    
+    public void purchaseGames() {
+        System.out.println("JavaCustomerComponentImpl.purchaseGames");
+        outstandingOrders.add("Order, submitted (play.com), fulfilled, shipped (ParcelForce)");
+        
+        retailer2.submitOrder("Order");
+    }
+    
+    public void purchaseGoods() {
+        retailer3.submitOrder("Order");
+    }
+    
+    public void notifyShipment(String order) {
+        outstandingOrders.remove(order);
+        System.out.print("Work thread " + Thread.currentThread() + " - ");
+        System.out.println(order);       
+    }
+
+    public boolean hasOutstandingOrders() {
+        return outstandingOrders.size() != 0;
+    }
+    
+    
+
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package supplychain.customer;
+
+
+import java.util.ArrayList;
+
+import org.osgi.service.component.ComponentContext;
+
+
+import supplychain.retailer.Retailer;
+
+/**
+ * This class implements the Customer service component.
+ */
+public class OSGiCustomerComponentImpl implements Customer {
+    
+
+    private Retailer retailer1;
+    private Retailer retailer2;
+    private Retailer retailer3;
+    
+    private ArrayList<String> outstandingOrders = new ArrayList<String>();
+    
+    public OSGiCustomerComponentImpl() {
+        System.out.println("Created OSGiCustomerComponentImpl " + this);
+    }
+    
+    protected void setRetailer1(Retailer retailer1) {
+    	this.retailer1 = retailer1;
+    }
+    
+    protected void unsetRetailer1(Retailer retailer1) {
+    	this.retailer1 = null;
+    }
+    
+    
+    protected void setRetailer2(Retailer retailer2) {
+    	this.retailer2 = retailer2;
+    }
+    
+    protected void unsetRetailer2(Retailer retailer2) {
+    	this.retailer2 = null;
+    }
+    
+    protected void setRetailer3(Retailer retailer2) {
+        this.retailer3 = retailer2;
+    }
+    
+    protected void unsetRetailer3(Retailer retailer2) {
+        this.retailer3 = null;
+    }
+   
+    public void purchaseBooks() {
+    	System.out.println("OSGiCustomerComponentImpl.purchaseBooks");
+        outstandingOrders.add("Order, submitted (amazon.com), fulfilled, shipped (ParcelForce)");
+        retailer1.submitOrder("Order");
+    }
+    
+    public void purchaseGames() {
+        System.out.println("OSGiCustomerComponentImpl.purchaseGames");
+        outstandingOrders.add("Order, submitted (play.com), fulfilled, shipped (ParcelForce)");
+        
+        retailer2.submitOrder("Order");
+    }
+    
+    public void purchaseGoods() {
+        retailer3.submitOrder("Order");
+    }
+    
+    public void notifyShipment(String order) {
+        outstandingOrders.remove(order);
+        System.out.print("Work thread " + Thread.currentThread() + " - ");
+        System.out.println(order);
+    }
+    
+    protected void activate(ComponentContext context){
+        System.out.println("Activated OSGiCustomerComponentImpl bundle ");
+    }
+
+    protected void deactivate(ComponentContext context){
+        System.out.println("Deactivated OSGiCustomerComponentImpl bundle ");
+    }
+
+    public boolean hasOutstandingOrders() {
+        return outstandingOrders.size() != 0;
+    }
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerFactoryImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerFactoryImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerFactoryImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package supplychain.customer;
+
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * This class implements the Customer service component.
+ */
+public class OSGiCustomerFactoryImpl implements BundleActivator, ServiceFactory {
+    
+    private BundleContext bundleContext;
+    
+    public OSGiCustomerFactoryImpl() {
+    }
+    
+    
+    public void start(BundleContext bc)  {
+        
+        this.bundleContext = bc;
+        bc.registerService(Customer.class.getName(), this, null);
+    }
+    
+    
+    
+   
+    public void stop(BundleContext context) throws Exception {
+        
+    }
+
+
+    public Object getService(Bundle bundle, ServiceRegistration registration) {
+        
+        OSGiCustomerImpl customer = new OSGiCustomerImpl(false);
+        customer.start(bundleContext);
+        return customer;
+        
+    }
+
+    public void ungetService(Bundle bundle, ServiceRegistration registration, Object obj) {       
+    }
+    
+    
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerFactoryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package supplychain.customer;
+
+
+import java.util.ArrayList;
+
+import supplychain.OSGiBundleImpl;
+import supplychain.retailer.Retailer;
+
+/**
+ * This class implements the Customer service component.
+ */
+public class OSGiCustomerImpl extends OSGiBundleImpl implements Customer {
+    
+    private ArrayList<String> outstandingOrders = new ArrayList<String>();
+    
+    private Retailer retailer1;
+    private Retailer retailer2;
+    private Retailer retailer3;
+    
+    public OSGiCustomerImpl() {
+        super(  new String[]{"retailer1", "retailer2", "retailer3"},
+                new String[]{"(retailerName=amazon.com)", 
+                             "(retailerName=play.com)",
+                             "(retailerName=ebay.com)"
+                             });
+        registerService(this, "supplychain.customer.Customer", null);
+                
+    }
+    
+    public OSGiCustomerImpl(boolean ignore) { // Used only to test service factories
+        super(  new String[]{"retailer1", "retailer2", "retailer3"},
+                new String[]{"(retailerName=amazon.com)", 
+                             "(retailerName=play.com)",
+                             "(retailerName=ebay.com)"
+                             });
+               
+    }
+   
+    public void purchaseBooks() {
+    	System.out.println("OSGiCustomerImpl.purchaseBooks, retailer is " + retailer1);
+        outstandingOrders.add("Order, submitted (amazon.com), fulfilled, shipped (ParcelForce)");
+        
+        retailer1.submitOrder("Order");
+        
+    }
+    
+    public void purchaseGames() {
+        System.out.println("OSGiCustomerImpl.purchaseGames, retailer is " + retailer2);
+        outstandingOrders.add("Order, submitted (play.com), fulfilled, shipped (ParcelForce)");
+        
+        retailer2.submitOrder("Order");
+        
+    }
+    
+    public void purchaseGoods() {
+        retailer3.submitOrder("Order");
+    }
+    
+    public void notifyShipment(String order) {
+        
+        outstandingOrders.remove(order);
+        
+        System.out.print("Work thread " + Thread.currentThread() + " - ");
+        System.out.println(order);
+    }
+    
+    public boolean hasOutstandingOrders() {
+        return outstandingOrders.size() != 0;
+    }
+    
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryComponentImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryComponentImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryComponentImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package supplychain.customer;
+
+
+import java.util.ArrayList;
+
+import org.osgi.service.component.ComponentContext;
+
+
+import supplychain.retailer.Retailer;
+import supplychain.retailer.RetailerQuery;
+
+/**
+ * This class implements the Customer service component.
+ */
+public class OSGiCustomerWithQueryComponentImpl implements Customer {
+    
+
+    private Retailer retailer;
+    private RetailerQuery retailerQuery;
+    
+    private static ArrayList<String> outstandingOrders = new ArrayList<String>();
+    
+    public OSGiCustomerWithQueryComponentImpl() {
+        System.out.println("Created OSGiCustomerWithQueryComponentImpl " + this);
+    }
+    
+    protected void setRetailer(Retailer retailer) {
+    	this.retailer = retailer;
+    }
+    
+    protected void unsetRetailer(Retailer retailer) {
+    	this.retailer = null;
+    }
+    
+    
+    protected void setRetailerQuery(RetailerQuery retailerQuery) {
+        this.retailerQuery = retailerQuery;
+    }
+    
+    protected void unsetRetailerQuery(RetailerQuery retailerQuery) {
+        this.retailerQuery = null;
+    }
+    
+    public void purchaseBooks() {
+    	System.out.println("OSGiCustomerWithQueryComponentImpl.purchaseBooks");
+        outstandingOrders.add("Order, submitted (amazon.com), fulfilled, shipped (RoyalMail)");
+        
+        if (retailerQuery.isAvailable("Order"))
+            retailer.submitOrder("Order");
+    }
+    
+    public void purchaseGames() {
+        System.out.println("OSGiCustomerWithQueryComponentImpl.purchaseGames");
+        outstandingOrders.add("Order, submitted (amazon.com), fulfilled, shipped (RoyalMail)");
+        
+        if (retailerQuery.isAvailable("Order"))
+            retailer.submitOrder("Order");
+    }
+    
+    public void purchaseGoods() {
+        if (retailerQuery.isAvailable("Order"))
+            retailer.submitOrder("Order");
+    }
+    
+    public void notifyShipment(String order) {
+        outstandingOrders.remove(order);
+        System.out.print("Work thread " + Thread.currentThread() + " - ");
+        System.out.println(order);
+    }
+    
+    protected void activate(ComponentContext context){
+        System.out.println("Activated OSGiCustomerWithQueryComponentImpl bundle ");
+    }
+
+    protected void deactivate(ComponentContext context){
+        System.out.println("Deactivated OSGiCustomerWithQueryComponentImpl bundle ");
+    }
+
+    public boolean hasOutstandingOrders() {
+        return outstandingOrders.size() != 0;
+    }
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryComponentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryComponentImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package supplychain.customer;
+
+
+import java.util.ArrayList;
+
+import supplychain.OSGiBundleImpl;
+import supplychain.retailer.Retailer;
+import supplychain.retailer.RetailerQuery;
+
+/**
+ * This class implements the Customer service component.
+ */
+public class OSGiCustomerWithQueryImpl extends OSGiBundleImpl implements Customer {
+    
+    private static ArrayList<String> outstandingOrders = new ArrayList<String>();
+    
+    private Retailer retailer;
+    private RetailerQuery retailerQuery;
+    
+    public OSGiCustomerWithQueryImpl() {
+        super(  new String[]{"retailer", "retailerQuery"},
+                new String[]{"(retailerName=amazon.com)",
+                             "(retailerName=amazon.com)"
+                });
+        registerService(this, "supplychain.customer.Customer", null);
+                
+    }
+   
+    public void purchaseBooks() {
+    	System.out.println("OSGiCustomerWithQueryImpl.purchaseBooks");
+        outstandingOrders.add("Order, submitted (amazon.com), fulfilled, shipped (RoyalMail)");
+        
+        if (retailerQuery.isAvailable("Order"))
+            retailer.submitOrder("Order");
+        
+    }
+    
+    public void purchaseGames() {
+        System.out.println("OSGiCustomerWithQueryImpl.purchaseGames");
+        outstandingOrders.add("Order, submitted (amazon.com), fulfilled, shipped (RoyalMail)");
+        
+        if (retailerQuery.isAvailable("Order"))
+            retailer.submitOrder("Order");
+        
+    }
+    
+    public void purchaseGoods() {
+        if (retailerQuery.isAvailable("Order"))
+            retailer.submitOrder("Order");
+    }
+    
+    public void notifyShipment(String order) {
+        
+        outstandingOrders.remove(order);
+        
+        System.out.print("Work thread " + Thread.currentThread() + " - ");
+        System.out.println(order);
+    }
+    
+    public boolean hasOutstandingOrders() {
+        return outstandingOrders.size() != 0;
+    }
+    
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiVersionedCustomerImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiVersionedCustomerImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiVersionedCustomerImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiVersionedCustomerImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package supplychain.customer;
+
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleContext;
+
+import supplychain.OSGiBundleImpl;
+import supplychain.retailer.Retailer;
+
+/**
+ * This class implements the Customer service component.
+ */
+public class OSGiVersionedCustomerImpl extends OSGiBundleImpl implements Customer {
+    
+    private static ArrayList<String> outstandingOrders = new ArrayList<String>();
+    
+    private Retailer retailer1;
+    private Retailer retailer2;
+    private Retailer retailer3;
+    private int version;
+    
+    public OSGiVersionedCustomerImpl() {
+        super(  new String[]{"retailer1", "retailer2", "retailer3"},
+                new String[]{"(retailerName=amazon.com)", 
+                             "(retailerName=play.com)",
+                             "(retailerName=ebay.com)"
+                             });
+               
+    }
+    
+    protected void started(BundleContext bc)  {
+        
+        String jarFile = bc.getBundle().getLocation();
+        if (jarFile.endsWith("1.jar")) version = 1;
+        else if (jarFile.endsWith("2.jar")) version = 2;
+        else version = 3;
+        
+        Hashtable<String, Object> props1 = new Hashtable<String, Object>();
+        props1.put("component.name", "CustomerComponent" + version);
+        bc.registerService("supplychain.customer.Customer", this, props1);
+               
+    }
+   
+    public void purchaseBooks() {
+    	System.out.println("OSGiVersionedCustomerImpl.purchaseBooks , retailer is " + retailer1);
+        outstandingOrders.add("Order, submitted (amazon.com v" + version + 
+                "), fulfilled, shipped (ParcelForce)");
+        
+        retailer1.submitOrder("Order");
+        
+    }
+    
+    public void purchaseGames() {
+        System.out.println("OSGiCustomerImpl.purchaseGames");
+        outstandingOrders.add("Order, submitted (play.com v" + version + 
+                "), fulfilled, shipped (ParcelForce)");
+        
+        retailer2.submitOrder("Order");
+        
+    }
+    
+    public void purchaseGoods() {
+        retailer3.submitOrder("Order");
+    }
+    
+    public void notifyShipment(String order) {
+        
+        outstandingOrders.remove(order);
+        
+        System.out.print("Work thread " + Thread.currentThread() + " - ");
+        System.out.println(order);
+    }
+    
+    public boolean hasOutstandingOrders() {
+        return outstandingOrders.size() != 0;
+    }
+    
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiVersionedCustomerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiVersionedCustomerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package supplychain.retailer;
+
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+import supplychain.warehouse.Warehouse;
+
+/**
+ * This class implements the Customer service component.
+ */
+@Service(Retailer.class)
+@Scope("COMPOSITE")
+public class JavaRetailerComponentImpl implements Retailer {
+    
+    private Warehouse warehouse;
+    
+    private String retailerName;
+    
+    public JavaRetailerComponentImpl() {
+    	System.out.println("Created RetailerComponentImpl");
+    }
+    
+    @Reference
+    public void setWarehouse(Warehouse warehouse) {
+    	System.out.println("retailer setWarehouse " + warehouse);
+    	
+        this.warehouse = warehouse;
+    }
+    
+    @Property
+    public void setRetailerName(String retailerName) {
+    	this.retailerName = retailerName;
+    }
+    
+    
+    public void submitOrder(String order) {
+    	
+    	System.out.println("JavaRetailerComponentImpl.submitOrder " + warehouse);
+        warehouse.fulfillOrder(order + ", submitted (" + retailerName + ")");
+        
+    }
+
+    
+    
+   
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package supplychain.retailer;
+
+import org.osgi.service.component.ComponentContext;
+
+import supplychain.warehouse.Warehouse;
+
+/**
+ * This class implements the Customer service component.
+ */
+public class OSGiRetailerComponentImpl implements Retailer {
+    
+    private Warehouse warehouse;
+    private String retailerName;
+    
+    
+    protected void setWarehouse(Warehouse warehouse) {
+    	this.warehouse = warehouse;
+    }
+    
+    protected void unsetWarehouse(Warehouse warehouse) {
+    	this.warehouse = null;
+    }
+    
+    public void submitOrder(String order) {
+    	
+    	System.out.println("OSGiRetailerComponentImpl.submitOrder , warehouse is " + warehouse);
+        warehouse.fulfillOrder(order + ", submitted (" + retailerName + ")");
+        
+    }
+
+    protected void activate(ComponentContext context){
+        System.out.println("Activated OSGiRetailerComponentImpl bundle ");
+        
+        Object prop = context.getProperties().get("retailerName");
+	    if (prop instanceof String[])
+	        retailerName = ((String [])prop)[0];
+        
+        
+    }
+
+    protected void deactivate(ComponentContext context){
+        System.out.println("Deactivated OSGiRetailerComponentImpl bundle ");
+    }
+
+	
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package supplychain.retailer;
+
+
+import java.util.Hashtable;
+
+import supplychain.OSGiBundleImpl;
+import supplychain.warehouse.Warehouse;
+
+/**
+ * This class implements the Retailer service component.
+ */
+public class OSGiRetailerImpl extends OSGiBundleImpl {
+    
+    protected Warehouse warehouse;
+    
+    public OSGiRetailerImpl() {
+
+        super(new String[]{"warehouse"}, 
+                new String[]{"(component.service.name=WarehouseComponent1/Warehouse)"});
+        
+        Hashtable<String, Object> props1 = new Hashtable<String, Object>();
+        props1.put("retailerName", "amazon.com");
+        registerService(new OSGiRetailerServiceImpl(this, "amazon.com"),
+                "supplychain.retailer.Retailer", props1);
+        
+        Hashtable<String, Object> props2 = new Hashtable<String, Object>();
+        props2.put("retailerName", "play.com");
+        registerService(
+                new OSGiRetailerServiceImpl(this, "play.com"),
+                "supplychain.retailer.Retailer", props2);
+        
+        Hashtable<String, Object> props3 = new Hashtable<String, Object>();
+        props3.put("retailerName", "ebay.com");
+        registerService(
+                new OSGiRetailerServiceImpl(this, "ebay.com"),
+                "supplychain.retailer.Retailer", props3);
+    }
+    
+   
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerServiceImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerServiceImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerServiceImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package supplychain.retailer;
+
+
+/**
+ * This class implements the Retailer service.
+ */
+public class OSGiRetailerServiceImpl implements Retailer {
+
+    private OSGiRetailerImpl retailerImpl;
+
+    private String retailerName;
+
+    OSGiRetailerServiceImpl(OSGiRetailerImpl retailerImpl, String retailerName) {
+        this.retailerImpl = retailerImpl;
+        this.retailerName = retailerName;
+        
+    }
+
+    public void submitOrder(String order) {
+
+        System.out.println("Retailer.submitOrder, warehouse is " + retailerImpl.warehouse);
+        retailerImpl.warehouse.fulfillOrder(order + ", submitted ("
+                + retailerName + ")");
+
+    }
+
+}
\ No newline at end of file

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerWithQueryComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerWithQueryComponentImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerWithQueryComponentImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerWithQueryComponentImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package supplychain.retailer;
+
+import org.osgi.service.component.ComponentContext;
+
+import supplychain.warehouse.Warehouse;
+import supplychain.warehouse.WarehouseQuery;
+
+/**
+ * This class implements the Customer service component.
+ */
+public class OSGiRetailerWithQueryComponentImpl implements Retailer, RetailerQuery {
+    
+    private Warehouse warehouse;
+    private WarehouseQuery warehouseQuery;
+    private String retailerName;
+    
+    
+    protected void setWarehouse(Warehouse warehouse) {
+    	this.warehouse = warehouse;
+    }
+    
+    protected void unsetWarehouse(Warehouse warehouse) {
+    	this.warehouse = null;
+    }
+    
+    protected void setWarehouseQuery(WarehouseQuery warehouseQuery) {
+        this.warehouseQuery = warehouseQuery;
+    }
+    
+    protected void unsetWarehouseQuery(WarehouseQuery warehouse) {
+        this.warehouseQuery = null;
+    }
+    
+    public void submitOrder(String order) {
+    	
+    	System.out.println("OSGiRetailerComponentImpl.submitOrder , warehouse is " + warehouse);
+        warehouse.fulfillOrder(order + ", submitted (" + retailerName + ")");
+        
+    }
+    
+    public boolean isAvailable(String order) {
+        return warehouseQuery.isAvailable(order);
+    }
+
+    protected void activate(ComponentContext context){
+        System.out.println("Activated OSGiRetailerComponentImpl bundle ");
+        
+        Object prop = context.getProperties().get("retailerName");
+	    if (prop instanceof String[])
+	        retailerName = ((String [])prop)[0];
+        
+        
+    }
+
+    protected void deactivate(ComponentContext context){
+        System.out.println("Deactivated OSGiRetailerComponentImpl bundle ");
+    }
+
+	
+}

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerWithQueryComponentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerWithQueryComponentImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerWithQueryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerWithQueryImpl.java?view=auto&rev=552481
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerWithQueryImpl.java (added)
+++ incubator/tuscany/java/sca/itest/osgi-implementation/src/main/java/supplychain/retailer/OSGiRetailerWithQueryImpl.java Mon Jul  2 05:16:31 2007
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package supplychain.retailer;
+
+
+import java.util.Hashtable;
+
+import supplychain.OSGiBundleImpl;
+import supplychain.warehouse.Warehouse;
+import supplychain.warehouse.WarehouseQuery;
+
+/**
+ * This class implements the Retailer service component with query.
+ */
+public class OSGiRetailerWithQueryImpl extends OSGiBundleImpl implements Retailer, RetailerQuery {
+    
+    private Warehouse warehouse;
+    private WarehouseQuery warehouseQuery;
+    
+    public OSGiRetailerWithQueryImpl() {
+
+        super(new String[]{"warehouse", "warehouseQuery"}, null);
+        
+        Hashtable<String, Object> props1 = new Hashtable<String, Object>();
+        props1.put("retailerName", "amazon.com");
+        registerService(this,
+                "supplychain.retailer.Retailer", props1);
+        
+        registerService(this,
+                "supplychain.retailer.RetailerQuery", props1);
+        
+    }
+    
+    public void submitOrder(String order) {
+
+        System.out.println("Retailer.submitOrder, warehouse is " + warehouse);
+        warehouse.fulfillOrder(order + ", submitted ("
+                + "amazon.com" + ")");
+
+    }
+
+    public boolean isAvailable(String order) {
+        return warehouseQuery.isAvailable(order);
+    }
+
+    
+   
+}



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