diff options
Diffstat (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic')
8 files changed, 276 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/Cart.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/Cart.java new file mode 100644 index 0000000..b636de2 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/Cart.java @@ -0,0 +1,81 @@ +package examples.shop.logic;
+
+import java.util.List;
+
+import examples.shop.impl.entity.LineItem;
+
+/**
+ * The Cart interface.
+ */
+public interface Cart {
+
+ /**
+ * Adds an item to the shopping cart
+ */
+ public void add(LineItem lineItem);
+
+ /**
+ * Changes the quantities of contents in the shopping cart
+ */
+ public void modify(String productID, int quantity)
+ throws Exception;
+
+ /**
+ * Returns all the shopping cart line items
+ *
+ * @return A collection of Cart LineItems
+ */
+ public List<LineItem> getAll();
+
+ /**
+ * Empties the shopping cart
+ */
+ public void clear();
+
+ /**
+ * Get/set methods for the shopping cart owner's name
+ */
+ public String getOwner();
+
+ public void setOwner(String owner);
+
+ /**
+ * Purchases this cart. The cart will create an order in the database.
+ *
+ * @return The Order confirmation number
+ */
+ public String purchase();
+
+ /**
+ * Returns the subtotal price which has been previously set by
+ * setSubtotal().
+ *
+ * @return the subtotal of this cart items.
+ */
+ public double getSubtotal();
+
+ /**
+ * Sets the subtotal price. Our external pricer bean is responsible for
+ * calculating the subtotal. It calculates it based upon customer discounts
+ * (and can be extended to include other rules as well).
+ */
+ public void setSubtotal(double subTotal);
+
+ /**
+ * Returns the taxes for this Quote.
+ */
+ public double getTaxes();
+
+ /**
+ * Sets the taxes for this Quote.
+ */
+ public void setTaxes(double taxes);
+
+ /**
+ * Returns the total price. Total Price is computed from: 1) Subtotal price
+ * 2) Tax
+ */
+ public double getTotalPrice();
+
+
+}
diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/Catalog.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/Catalog.java new file mode 100644 index 0000000..32310fd --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/Catalog.java @@ -0,0 +1,31 @@ +package examples.shop.logic; + +import java.util.*; + +import examples.shop.impl.entity.Product; + +/** + * This is the Catalog business interface. + */ + +public interface Catalog { + + /** + * @return a vector of Products + */ + public List<Product> getProductList(); + + /** + * @return a Product for the given product id. + */ + public Product getProduct(String productId); + + /** + * Add a new product to the catalog + * @param product + */ + public void addProduct(Product product); + +} + + diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/InvalidLoginNameException.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/InvalidLoginNameException.java new file mode 100644 index 0000000..4583f48 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/InvalidLoginNameException.java @@ -0,0 +1,19 @@ +package examples.shop.logic; + +/** + * Exceptions thrown by usermanager + */ +public class InvalidLoginNameException extends Exception { + + public InvalidLoginNameException() { + super(); + } + + public InvalidLoginNameException(Exception e) { + super(e.toString()); + } + + public InvalidLoginNameException(String s) { + super(s); + } +} diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/InvalidPasswordException.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/InvalidPasswordException.java new file mode 100644 index 0000000..5d0db3c --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/InvalidPasswordException.java @@ -0,0 +1,19 @@ +package examples.shop.logic; + +/** + * Exceptions thrown by usermanager + */ +public class InvalidPasswordException extends Exception { + + public InvalidPasswordException() { + super(); + } + + public InvalidPasswordException(Exception e) { + super(e.toString()); + } + + public InvalidPasswordException(String s) { + super(s); + } +}
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/OrderException.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/OrderException.java new file mode 100644 index 0000000..bd08de0 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/OrderException.java @@ -0,0 +1,19 @@ +package examples.shop.logic;
+
+/**
+ * Exceptions thrown by Order
+ */
+public class OrderException extends Exception {
+
+ public OrderException() {
+ super();
+ }
+
+ public OrderException(Exception e) {
+ super(e.toString());
+ }
+
+ public OrderException(String s) {
+ super(s);
+ }
+}
diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/Pricer.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/Pricer.java new file mode 100644 index 0000000..5c10b41 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/Pricer.java @@ -0,0 +1,50 @@ +package examples.shop.logic;
+
+import java.util.List;
+
+import examples.shop.impl.entity.LineItem;
+
+/**
+ * These are the business logic methods exposed publicly by the
+ * Pricer component, a function that computes a price for a
+ * given user and base price.
+ */
+
+public interface Pricer {
+ /**
+ * Computes the price of a set of goods
+ */
+
+ public double priceSubtotal(String user, List<LineItem> items);
+
+ public double priceTaxes(double subtotal);
+
+ /**
+ * @return the applicable tax rate
+ */
+ double getTaxRate();
+
+ /**
+ * @return the current discount rate for buying lots of items
+ */
+ double getBulkDiscountRate();
+
+ /**
+ * @return the discount rate for a given user in percent
+ */
+ double getPersonalDiscountRate(String userName);
+
+ /**
+ * This method computes the applicable discount in absolute
+ * figure, based on bulk and personal discounts that may apply.
+ *
+ * @param quantity the number of items that a user intends to buy
+ * @param basePrice the overall, non-discounted volume of the
+ * purchase (individual price times quantity)
+ * @param the user name
+ * @return the subTotal for the line item after applying any
+ * applicable discounts, excluding taxes
+ */
+ double getDiscount(int quantity, double basePrice, String user);
+
+}
diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/PricerException.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/PricerException.java new file mode 100644 index 0000000..e198a6a --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/PricerException.java @@ -0,0 +1,19 @@ +package examples.shop.logic;
+
+/**
+ * Exceptions thrown by Pricer
+ */
+public class PricerException extends Exception {
+
+ public PricerException() {
+ super();
+ }
+
+ public PricerException(Exception e) {
+ super(e.toString());
+ }
+
+ public PricerException(String s) {
+ super(s);
+ }
+}
diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/UserManager.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/UserManager.java new file mode 100644 index 0000000..f34575d --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/shop/logic/UserManager.java @@ -0,0 +1,38 @@ +package examples.shop.logic; + +import java.util.List; + +import examples.shop.impl.entity.Customer; + +/** + * This is the UserManager interface. + */ +public interface UserManager { + + /** + * It uses the customer entity bean to crate a record in the databse + */ + public Customer createUser(String customerId, String name, String password, + String address); + + /** + * Returns an user object for the given customer id. It uses customer entity + * bean to retrieve the user record. + */ + public Customer getUser(String customerId); + + /** + * Authenticate the user. + */ + public boolean validateUser(String login, String password) + throws InvalidPasswordException; + + /** + * Demo lookup + * + * @return + */ + public List<Customer> findAllCustomers(); + + public void removeAllCustomers(); +} |
