On Wed, May 20, 2009 at 1:20 PM, Simon Nash <[email protected]> wrote: > I don't agree with the change to introducing-launcher in this commit > that puts the client code inline and eliminates the use of the > introducing-client-contribution. > > Having the client code as part of the launcher is acceptable for > jumpstart-launcher to keep this sample very simple, but for the other > samples I think the pattern of having a separate contribution for > test client code is a good pattern that we should use. > > Simon > > [email protected] wrote: >> >> Author: slaws >> Date: Sun May 17 15:23:10 2009 >> New Revision: 775672 >> >> URL: http://svn.apache.org/viewvc?rev=775672&view=rev >> Log: >> Add a little more function to the simple travel booking sample and >> simplify the command line launcher contribution configuration. >> Added: >> >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Bookings.java >> (with props) >> >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Checkout.java >> (with props) >> Modified: >> >> tuscany/sandbox/travelsample/contributions/introducing-client-contribution/src/main/java/scatours/client/TestClient.java >> >> tuscany/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.java >> >> tuscany/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.java >> >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/LaunchNode.java >> >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/resources/scatours.composite >> >> Modified: >> tuscany/sandbox/travelsample/contributions/introducing-client-contribution/src/main/java/scatours/client/TestClient.java >> URL: >> http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/contributions/introducing-client-contribution/src/main/java/scatours/client/TestClient.java?rev=775672&r1=775671&r2=775672&view=diff >> >> ============================================================================== >> --- >> tuscany/sandbox/travelsample/contributions/introducing-client-contribution/src/main/java/scatours/client/TestClient.java >> (original) >> +++ >> tuscany/sandbox/travelsample/contributions/introducing-client-contribution/src/main/java/scatours/client/TestClient.java >> Sun May 17 15:23:10 2009 >> @@ -19,6 +19,8 @@ >> package scatours.client; >> +import java.math.BigDecimal; >> + >> import com.tuscanyscatours.Bookings; >> import com.tuscanyscatours.Checkout; >> @@ -40,7 +42,6 @@ >> String bookingCode = bookings.newBooking("FS1APR4", 1); >> System.out.println("Booking code is " + bookingCode); >> - checkout.makePayment(1995.00, "1234567843218765 10/10"); >> - System.out.println("Paid $1995.00"); >> + checkout.makePayment(new BigDecimal("1995.00"), "1234567843218765 >> 10/10"); >> } >> } >> >> Modified: >> tuscany/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.java >> URL: >> http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.java?rev=775672&r1=775671&r2=775672&view=diff >> >> ============================================================================== >> --- >> tuscany/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.java >> (original) >> +++ >> tuscany/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.java >> Sun May 17 15:23:10 2009 >> @@ -18,9 +18,11 @@ >> */ >> package com.tuscanyscatours; >> +import java.math.BigDecimal; >> + >> import org.osoa.sca.annotations.Remotable; >> �...@remotable >> public interface Checkout { >> - void makePayment(double amount, String cardInfo); >> + void makePayment(BigDecimal amount, String cardInfo); >> } >> >> Modified: >> tuscany/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.java >> URL: >> http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.java?rev=775672&r1=775671&r2=775672&view=diff >> >> ============================================================================== >> --- >> tuscany/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.java >> (original) >> +++ >> tuscany/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.java >> Sun May 17 15:23:10 2009 >> @@ -18,11 +18,22 @@ >> */ >> package com.tuscanyscatours; >> +import java.math.BigDecimal; >> +import java.util.ArrayList; >> +import java.util.List; >> + >> public class ShoppingCart implements Checkout, Updates { >> - public void makePayment(double amount, String cardInfo) { >> - // make payment for trips in cart giving card details >> + private static List<String> bookedTrips = new ArrayList<String>(); >> + >> + public void makePayment(BigDecimal amount, String cardInfo) { >> + System.out.print("Charged $" + amount + " to card " + cardInfo + " >> for trips" ); >> + for (String trip : bookedTrips){ >> + System.out.print(" " + trip); >> + } >> + System.out.println(); >> + bookedTrips.clear(); >> } >> public void addTrip(String resCode) { >> - // add the booked trip to the cart >> + bookedTrips.add(resCode); >> } >> } >> >> Added: >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Bookings.java >> URL: >> http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Bookings.java?rev=775672&view=auto >> >> ============================================================================== >> --- >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Bookings.java >> (added) >> +++ >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Bookings.java >> Sun May 17 15:23:10 2009 >> @@ -0,0 +1,26 @@ >> +/* >> + * 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 scatours; >> + >> +import org.osoa.sca.annotations.Remotable; >> + >> +...@remotable >> +public interface Bookings { >> + String newBooking(String trip, int people); >> +} >> >> Propchange: >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Bookings.java >> >> ------------------------------------------------------------------------------ >> svn:eol-style = native >> >> Propchange: >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Bookings.java >> >> ------------------------------------------------------------------------------ >> svn:keywords = Rev Date >> >> Added: >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Checkout.java >> URL: >> http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Checkout.java?rev=775672&view=auto >> >> ============================================================================== >> --- >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Checkout.java >> (added) >> +++ >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Checkout.java >> Sun May 17 15:23:10 2009 >> @@ -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 scatours; >> + >> +import java.math.BigDecimal; >> + >> +import org.osoa.sca.annotations.Remotable; >> + >> +...@remotable >> +public interface Checkout { >> + void makePayment(BigDecimal amount, String cardInfo); >> +} >> >> Propchange: >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Checkout.java >> >> ------------------------------------------------------------------------------ >> svn:eol-style = native >> >> Propchange: >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Checkout.java >> >> ------------------------------------------------------------------------------ >> svn:keywords = Rev Date >> >> Modified: >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/LaunchNode.java >> URL: >> http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/LaunchNode.java?rev=775672&r1=775671&r2=775672&view=diff >> >> ============================================================================== >> --- >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/LaunchNode.java >> (original) >> +++ >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/LaunchNode.java >> Sun May 17 15:23:10 2009 >> @@ -19,6 +19,9 @@ >> package scatours; >> +import java.io.IOException; >> +import java.math.BigDecimal; >> + >> import org.apache.tuscany.sca.node.SCAClient; >> import org.apache.tuscany.sca.node.SCAContribution; >> import org.apache.tuscany.sca.node.SCANode; >> @@ -33,16 +36,24 @@ >> // OK for development but you must launch the node from this module >> public static void launchFromFileSystemDir(){ >> try { >> - SCANode node = >> SCANodeFactory.newInstance().createSCANode("scatours.composite", + >> SCANode node = SCANodeFactory.newInstance().createSCANode(null, >> new SCAContribution("goodvaluetrips", >> "../../contributions/introducing-goodvaluetrips-contribution/target/classes"), >> - new SCAContribution("tuscanyscatours", >> "../../contributions/introducing-tuscanyscatours-contribution/target/classes"), >> - new SCAContribution("client", >> "../../contributions/introducing-client-contribution/target/classes"), >> - new SCAContribution("launcher", "./target/classes")); >> + new SCAContribution("tuscanyscatours", >> "../../contributions/introducing-tuscanyscatours-contribution/target/classes")); >> + >> node.start(); >> - Runnable runner = >> ((SCAClient)node).getService(Runnable.class, "TestClient/Runnable"); >> - runner.run(); >> + Bookings bookings = >> ((SCAClient)node).getService(Bookings.class, + >> "TripBooking/Bookings"); >> + System.out.println("Trip boooking code = " + + >> bookings.newBooking("FS1APR4", 1)); >> + + Checkout checkout = >> ((SCAClient)node).getService(Checkout.class, + >> "ShoppingCart/Checkout"); >> + + checkout.makePayment(new BigDecimal("1995.00"), >> "1234567843218765 10/10"); >> + + node.stop(); >> } catch (Throwable th) { >> >> Modified: >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/resources/scatours.composite >> URL: >> http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/resources/scatours.composite?rev=775672&r1=775671&r2=775672&view=diff >> >> ============================================================================== >> --- >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/resources/scatours.composite >> (original) >> +++ >> tuscany/sandbox/travelsample/launchers/introducing-launcher/src/main/resources/scatours.composite >> Sun May 17 15:23:10 2009 >> @@ -23,7 +23,7 @@ >> xmlns:tours="http://tuscanyscatours.com/" >> xmlns:trips="http://goodvaluetrips.com/" >> name="scatours"> >> - >> + <include name="client:Client" /> >> <include name="tours:Tours" /> >> <include name="trips:Trips" /> >> >> >> >> > > >
I'm trying to reduce the number of moving parts. As it stood to test the combination of introducing-goodvaluetrips-contribution introducing-tuscanyscatours-contribution required LaunchNode introducing-launcher as a contribution introducing-client-contribution which to me says Tuscany is hard to use and requires many artifacts to get it up and running. If we have a generic launcher then I could see the benefit of a client contribution. But in this case we don't as the launcher is specific to this sample so it might as well contain the test code directly. Now if your argument is that we want to test remote bindings on the tuscanyscatours service the that is a good justification. We don't in this case but I could buy it from the "consistency with other samples" point of view. I would however suggest that, if a client contribution is required, we add it to the launcher module by extending the launcher contribution to remove the requirement to have as many test contributions are there are contributions to test. Simon
