diff options
Diffstat (limited to 'branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse')
7 files changed, 343 insertions, 0 deletions
diff --git a/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/JavaWarehouseComponentImpl.java b/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/JavaWarehouseComponentImpl.java new file mode 100644 index 0000000000..9edf3567e5 --- /dev/null +++ b/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/JavaWarehouseComponentImpl.java @@ -0,0 +1,48 @@ +/* + * 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.warehouse; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +import supplychain.shipper.Shipper; + +/** + * This class implements the Warehouse service component. + */ +@Service(Warehouse.class) +@Scope("STATELESS") +public class JavaWarehouseComponentImpl implements Warehouse { + + private Shipper shipper; + + @Reference + public void setShipper(Shipper shipper) { + this.shipper = shipper; + } + + public void fulfillOrder(String order) { + System.out.println("JavaWarehouseComponentImpl.fulfillOrder : shipper is " + shipper); + + shipper.processShipment(order + ", fulfilled"); + } + + +} diff --git a/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/JavaWarehouseWithQueryComponentImpl.java b/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/JavaWarehouseWithQueryComponentImpl.java new file mode 100644 index 0000000000..659f16be7f --- /dev/null +++ b/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/JavaWarehouseWithQueryComponentImpl.java @@ -0,0 +1,52 @@ +/* + * 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.warehouse; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +import supplychain.shipper.Shipper; + +/** + * This class implements the Warehouse service component. + */ +@Service(interfaces={Warehouse.class, WarehouseQuery.class}) +@Scope("COMPOSITE") +public class JavaWarehouseWithQueryComponentImpl implements Warehouse, WarehouseQuery { + + private Shipper shipper; + + @Reference + public void setShipper(Shipper shipper) { + this.shipper = shipper; + } + + public void fulfillOrder(String order) { + System.out.println("JavaWarehouseComponentImpl.fulfillOrder : shipper is " + shipper); + + shipper.processShipment(order + ", fulfilled"); + } + + public boolean isAvailable(String order) { + return true; + } + + +} diff --git a/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/OSGiWarehouseComponentImpl.java b/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/OSGiWarehouseComponentImpl.java new file mode 100644 index 0000000000..7c9e102fd2 --- /dev/null +++ b/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/OSGiWarehouseComponentImpl.java @@ -0,0 +1,57 @@ +/* + * 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.warehouse; + + +import org.osgi.service.component.ComponentContext; + +import supplychain.shipper.Shipper; + +/** + * This class implements the Warehouse service component. + */ + +public class OSGiWarehouseComponentImpl implements Warehouse { + + private Shipper shipper; + + protected void setShipper(Shipper shipper) { + this.shipper = shipper; + } + + protected void unsetShipper(Shipper shipper) { + // this.shipper = null; + } + + public void fulfillOrder(String order) { + System.out.println("OSGiWarehouseComponentImpl.fulfillOrder : shipper is " + shipper); + + shipper.processShipment(order + ", fulfilled"); + + } + + protected void activate(ComponentContext context){ + System.out.println("Activated OSGiWarehouseComponentImpl "); + } + + protected void deactivate(ComponentContext context){ + System.out.println("Deactivated OSGiWarehouseComponentImpl "); + } + +} diff --git a/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/OSGiWarehouseImpl.java b/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/OSGiWarehouseImpl.java new file mode 100644 index 0000000000..bb04ff42e0 --- /dev/null +++ b/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/OSGiWarehouseImpl.java @@ -0,0 +1,68 @@ +/* + * 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.warehouse; + + +import java.util.Hashtable; + +import org.osgi.framework.BundleContext; + +import supplychain.OSGiBundleImpl; +import supplychain.shipper.Shipper; + +/** + * This class implements the Warehouse service component. + */ + +public class OSGiWarehouseImpl extends OSGiBundleImpl implements Warehouse { + + protected Shipper shipper; + private OSGiWarehouseServiceImpl warehouseService1; + private OSGiWarehouseServiceImpl warehouseService2; + + public OSGiWarehouseImpl() { + super(new String[]{"shipper"}, null); + + Hashtable<String, Object> props1 = new Hashtable<String, Object>(); + props1.put("component.name", "WarehouseComponent1"); + warehouseService1 = new OSGiWarehouseServiceImpl(this, 2); + registerService(warehouseService1, + "supplychain.warehouse.Warehouse", props1); + + Hashtable<String, Object> props2 = new Hashtable<String, Object>(); + props2.put("component.name", "WarehouseComponent2"); + warehouseService2 = new OSGiWarehouseServiceImpl(this, 1); + registerService(warehouseService2, + "supplychain.warehouse.Warehouse", props2); + } + + protected void started(BundleContext bc) { + warehouseService1.started(bc); + warehouseService2.started(bc); + } + + public void fulfillOrder(String order) { + System.out.println("OSGiWarehouseImpl.fulfillOrder : shipper is " + shipper); + + shipper.processShipment(order + ", fulfilled"); + + } + + +} diff --git a/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/OSGiWarehouseServiceImpl.java b/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/OSGiWarehouseServiceImpl.java new file mode 100644 index 0000000000..3317816557 --- /dev/null +++ b/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/OSGiWarehouseServiceImpl.java @@ -0,0 +1,62 @@ +/* + * 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.warehouse; + +import org.osgi.framework.BundleContext; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceReference; + +import supplychain.shipper.Shipper; + + +/** + * This class implements the Warehouse service. + */ +public class OSGiWarehouseServiceImpl implements Warehouse { + + private OSGiWarehouseImpl warehouseImpl; + private Shipper shipper; + private int shipperNum; + + + OSGiWarehouseServiceImpl(OSGiWarehouseImpl warehouseImpl, int shipperNum) { + this.warehouseImpl = warehouseImpl; + this.shipperNum = shipperNum; + } + + + protected void started(BundleContext bc) { + try { + ServiceReference[] refs = bc.getServiceReferences(Shipper.class.getName(), + "(component.service.name=ShipperComponent" + shipperNum + "/Shipper)"); + if (refs != null && refs.length > 0) { + shipper = (Shipper) bc.getService(refs[0]); + } + } catch (InvalidSyntaxException e) { + } + } + + public void fulfillOrder(String order) { + System.out.println("OSGiWarehouseImpl.fulfillOrder : shipper is " + warehouseImpl.shipper); + + shipper.processShipment(order + ", fulfilled"); + + } + +} diff --git a/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/Warehouse.java b/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/Warehouse.java new file mode 100644 index 0000000000..6f1f6b8730 --- /dev/null +++ b/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/Warehouse.java @@ -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 supplychain.warehouse; + +/** + * This is the business interface of the Warehouse service component. + */ +public interface Warehouse { + + public void fulfillOrder(String order); + +} diff --git a/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/WarehouseQuery.java b/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/WarehouseQuery.java new file mode 100644 index 0000000000..6d1ad76796 --- /dev/null +++ b/branches/sca-java-1.x/itest/osgi-implementation/src/main/java/supplychain/warehouse/WarehouseQuery.java @@ -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 supplychain.warehouse; + +/** + * This is the business interface of the RetailerQuery service. + */ +public interface WarehouseQuery { + + public boolean isAvailable(String order); + +} |