From 725006d4c47e63986ac042ade23a4d193298b1fe Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:08:29 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835131 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/supplychain/customer/Customer.java | 39 ++++++++ .../customer/JavaCustomerComponentImpl.java | 88 +++++++++++++++++ .../customer/OSGiCustomerComponentImpl.java | 106 +++++++++++++++++++++ .../customer/OSGiCustomerFactoryImpl.java | 65 +++++++++++++ .../supplychain/customer/OSGiCustomerImpl.java | 92 ++++++++++++++++++ .../OSGiCustomerWithQueryComponentImpl.java | 100 +++++++++++++++++++ .../customer/OSGiCustomerWithQueryImpl.java | 82 ++++++++++++++++ .../OSGiStatelessCustomerComponentImpl.java | 30 ++++++ .../customer/OSGiStatelessCustomerImpl.java | 35 +++++++ .../customer/OSGiVersionedCustomerImpl.java | 98 +++++++++++++++++++ 10 files changed, 735 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/Customer.java create mode 100644 sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerFactoryImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiStatelessCustomerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiStatelessCustomerImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiVersionedCustomerImpl.java (limited to 'sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer') diff --git a/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/Customer.java b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/Customer.java new file mode 100644 index 0000000000..2762bc62be --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/Customer.java @@ -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(); + +} diff --git a/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java new file mode 100644 index 0000000000..80346311b1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java @@ -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 outstandingOrders = new ArrayList(); + + @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; + } + + + +} diff --git a/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java new file mode 100644 index 0000000000..a879505610 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java @@ -0,0 +1,106 @@ +/* + * 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 static ArrayList outstandingOrders = new ArrayList(); + + 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 retailer3) { + this.retailer3 = retailer3; + } + + protected void unsetRetailer3(Retailer retailer3) { + // this.retailer3 = null; + } + + + public void purchaseBooks() { + System.out.println("OSGiCustomerComponentImpl.purchaseBooks, retailer1 is " + retailer1); + outstandingOrders.add("Order, submitted (amazon.com), fulfilled, shipped (ParcelForce)"); + retailer1.submitOrder("Order"); + } + + public void purchaseGames() { + System.out.println("OSGiCustomerComponentImpl.purchaseGames, retailer2 is " + retailer2); + outstandingOrders.add("Order, submitted (play.com), fulfilled, shipped (ParcelForce)"); + + retailer2.submitOrder("Order"); + } + + public void purchaseGoods() { + System.out.println("OSGiCustomerComponentImpl.purchaseGames, retailer3 is " + retailer3); + 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; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerFactoryImpl.java b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerFactoryImpl.java new file mode 100644 index 0000000000..c8cb522cf4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerFactoryImpl.java @@ -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) { + } + + +} diff --git a/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerImpl.java b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerImpl.java new file mode 100644 index 0000000000..546971860e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerImpl.java @@ -0,0 +1,92 @@ +/* + * 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.AllowsPassByReference; + +import supplychain.OSGiBundleImpl; +import supplychain.retailer.Retailer; + +/** + * This class implements the Customer service component. + */ +@AllowsPassByReference +public class OSGiCustomerImpl extends OSGiBundleImpl implements Customer { + + private ArrayList outstandingOrders = new ArrayList(); + + 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; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryComponentImpl.java b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryComponentImpl.java new file mode 100644 index 0000000000..593e55f3f5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryComponentImpl.java @@ -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 outstandingOrders = new ArrayList(); + + 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; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryImpl.java b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryImpl.java new file mode 100644 index 0000000000..18483817ad --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiCustomerWithQueryImpl.java @@ -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 outstandingOrders = new ArrayList(); + + private Retailer retailer; + private RetailerQuery retailerQuery; + + public OSGiCustomerWithQueryImpl() { + super( new String[]{"retailer", "retailerQuery"}, + new String[]{"(component.service.name=RetailerComponent/Retailer)", + "(component.service.name=RetailerComponent/RetailerQuery)" + }); + 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; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiStatelessCustomerComponentImpl.java b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiStatelessCustomerComponentImpl.java new file mode 100644 index 0000000000..5ba42780f2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiStatelessCustomerComponentImpl.java @@ -0,0 +1,30 @@ +/* + * 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.Scope; + + +/** + * This class implements the Customer service component. + */ +@Scope("STATELESS") +public class OSGiStatelessCustomerComponentImpl extends OSGiCustomerComponentImpl { + +} diff --git a/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiStatelessCustomerImpl.java b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiStatelessCustomerImpl.java new file mode 100644 index 0000000000..bc569d0ac0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiStatelessCustomerImpl.java @@ -0,0 +1,35 @@ +/* + * 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.Scope; + + +/** + * This class implements the Customer service component. + */ +@Scope("STATELESS") +public class OSGiStatelessCustomerImpl extends OSGiCustomerImpl { + + public OSGiStatelessCustomerImpl(boolean ignore) { + super(ignore); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiVersionedCustomerImpl.java b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiVersionedCustomerImpl.java new file mode 100644 index 0000000000..599ab51a50 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.4/itest/osgi-implementation/src/main/java/supplychain/customer/OSGiVersionedCustomerImpl.java @@ -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 outstandingOrders = new ArrayList(); + + 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 props1 = new Hashtable(); + 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; + } + +} -- cgit v1.2.3