Title: Grammaroriented Object Design Case Study: Ebazaar
1Grammar-oriented Object DesignCase Study
E-bazaar
Maharishi University of Management
- Ali Arsanjani
- Landung Wahana
- Nyo Maw
- Rameshwor Kunwor
- Purnima Shreshta
- Sharad Acharya
- Keith Levi
- Software Architecture Group
- Computer Science Department
- Maharishi University of Management
2Aim
- Train students for industrial strength projects
- Provide expertise in latest technologies and
methods - Build a team here at MUM that could develop
software for outside clients via subcontracting,
etc. - Bring flow of wealth to Fairfield university and
faculty and students - Provide input into our courseware
- Create technical reports and experience reports
to increase expertise and knowledge base of
object and component-oriented methods and
technologies
3Background
- The E-bazaar project at Maharishi University of
Management uses Grammar-oriented Object Design
(GOOD), an evolved form of object-oriented
software engineering that is aimed at building
component-based software architecture for
business systems using a dynamic configuration,
dynamic collaboration and adaptive object model
approach to increase flexibility, reuse and
decrease maintenance costs and decrease time to
market.We utilize a new paradigm for
component-based software development to construct
a Rapidly Re-Configurable Architectural Style. - The functional characteristics of E-bazaar are
aimed at creating 1. An online order-entry
system with a generic component-based
architectureto allow adaptive modifications with
minimal maintenance costs2. A community and an
e-marketplace for business-to-business
transactionsThese will be implemented in two
phases. The e-bazaar project will be implemented
using a J2EE reference model and phase 2 will
utilize Web Services.
4Project Path
- August 2001 November 2001
- 15 Members started, left with 7
- Started reading literature
- on GOOD and Enterprise Component, Java, EJBs, XML
- Implement minimal functionality end-to-end
- Each person responsible for their component
- Shopping Cart
- Order Management
- Customer Management
- Product management
- E-Bazaar Component
- Externalize business flow in E-bazaar component
- Use open source development tools
- Orion App Server, ANT, Java JDK (IDE VAJ),
EditPlus
5Project Path
- Implement Enterprise Component Pattern in each
component - Provided uniform development paradigm and
guidance - Deployment and integration issues delayed project
for 2 weeks - Lessons team learned
- Integration should be continuous and upfront
rather than later
6The Design of a Business Complier
- Every business domain has a domain specific
language that - defines the components within it,
- their business flow (of data and messages) and
- their intent as it ties back to the business
- Capture this domain knowledge in a grammar
- An application can be composed by assembling
components and defining a grammar of how they
speak to one another - Thus, components are decoupled and changes can be
made to the application as a whole in an easier
fashion maintenance costs are lowered (see
section on adding functionality) - New paradigm of software engineering
Grammar-oriented Object design (GOOD)
7Grammar-oriented Object Design
- Every program uses a set of terminals
nonterminals and tokens (events) based on
production rules written as a domain-specific
langauge within the domain to assemble its
components (nonterminals) - Actions are executed within the grammar as events
(tokens) are detected - http//www.arsanjani.org/GOOD/
8Subsystems
9Team Structure
- Each subsystem assigned to a person or group of
people - Asked to implement thin slice then enterprise
component pattern
10The DTD
- lt?xml version"1.0" encoding"UTF-8"?gt
- lt!ELEMENT Action EMPTYgt
- lt!ATTLIST Action
- name CDATA REQUIRED
- type (adaptor command ui) REQUIRED
- info CDATA REQUIRED
- gt
- lt!ELEMENT Event EMPTYgt
- lt!ATTLIST Event
- name CDATA REQUIRED
- type (request response) REQUIRED
- info CDATA REQUIRED
- gt
- lt!ELEMENT Grammer (Production)gt
- lt!ELEMENT Non_Terminal EMPTYgt
- lt!ATTLIST Non_Terminal
- name IDREF REQUIRED
- gt
- lt!ELEMENT Production (Event Action
Non_Terminal)gt
11The Grammar for E-bazaar
- lt?xml version"1.0" encoding"UTF-8"?gt
- lt!DOCTYPE Grammer SYSTEM "http//www.arsanjani.org
8080/ebz/ec/xml/grammar_2.dtd"gt - ltGrammergt
- ltProduction name"OnlineShopping"
type"Sequence" info"optional"gt - ltNon_Terminal name"SignOn"/gt
- ltNon_Terminal name"Presentation"/gt
- ltNon_Terminal name"SignOut"/gt
- lt/Productiongt
- ltProduction name"SignOn" type"Sequence"
info"optional"gt - ltEvent name"Login" type"response"
info"optional"/gt - ltAction name"LoginChallenge" type"ui"
info"com.ebazaar.customermanagement."/gt - ltNon_Terminal name"SignOnType"/gt
- lt/Productiongt
- ltProduction name"SignOnType" type"Choice"
info"optional"gt - ltNon_Terminal name"CurrentUserSignOn"/gt
- ltNon_Terminal name"NewUserSignOn"/gt
- lt/Productiongt
12The Grammar for E-bazaar
- ltProduction name"CurrentUserSignOn"
type"Sequence" info"optional"gt - ltEvent name"LoginSubmit" type"request"
info"optional"/gt - ltAction name"LoginVerify" type"command"
info"com.ebazaar.customermanagement.security."/gt - ltNon_Terminal name"SignOnResponse"/gt
- lt/Productiongt
- ltProduction name"SignOnResponse" type"Choice"
info"optional"gt - ltNon_Terminal name"SignOnOk"/gt
- ltNon_Terminal name"SignOnNotOk"/gt
- lt/Productiongt
- ltProduction name"SignOnOk" type"Sequence"
info"optional"gt - ltEvent name"SignOnOk" type"response"
info"optional"/gt - ltAction name"LoginOk" type"adaptor"
info"com.ebazaar.customermanagement."/gt - lt/Productiongt
- ltProduction name"SignOnNotOk"
type"Sequence" info"optional"gt - ltEvent name"SignOnNotOk" type"response"
info"optional"/gt - ltAction name"LoginNotOk" type"adaptor"
info"com.ebazaar.customermanagement."/gt - ltNon_Terminal name"SignOn"/gt
- lt/Productiongt
13The Grammar for E-bazaar
- ltProduction name"Presentation" type"Sequence"
info"mandatory"gt - ltEvent name"Presentation"
type"response" info"mandatory"/gt - ltAction name"PresentationPage" type"ui"
info"com.ebazaar.productmanagement."/gt - ltNon_Terminal name"VisitorOption-
2"/gt - lt/Productiongt
- ltProduction name"VisitorOption-1"
type"Choice" info"mandatory"gt - ltNon_Terminal name"Search"/gt
- ltNon_Terminal name"Selection"/gt
- ltNon_Terminal name"SignOut"/gt
- lt/Productiongt
- ltProduction name"Search" type"Sequence"
info"mandatory"gt - ltEvent name"Search"
type"response" info"mandatory"/gt - ltAction name"SearchResult" type"ui"
info"com.ebazaar.productmanagement."/gt - ltNon_Terminal name"VisitorOption-
2"/gt - lt/Productiongt
14The Grammar for E-bazaar
- ltProduction name"VisitorOption-2" type"Choice"
info"mandatory"gt - ltNon_Terminal name"Search"/gt
- ltNon_Terminal name"Selection"/gt
- ltNon_Terminal name"SignOut"/gt
- ltNon_Terminal name"AddProduct"/gt
- ltNon_Terminal name"ShowCart"/gt
- ltNon_Terminal name"CheckOut"/gt
- ltNon_Terminal name"SaveCart"/gt
- lt/Productiongt
15The Grammar for E-bazaar
- ltProduction name"SaveCart" type"Sequence"
info"mandatory"gt - ltEvent name"SaveCart"
type"response" info"mandatory"/gt - ltAction name"SaveCart" type"ui"
info"com.ebazaar.productmanagement."/gt - ltNon_Terminal name"ShopperOption-
1"/gt - lt/Productiongt
- ltProduction name"Selection" type"Sequence"
info"mandatory"gt - ltEvent name"BrowseProductItem"
type"response" info"mandatory"/gt - ltAction name"BrowseResult" type"ui"
info"com.ebazaar.productmanagement."/gt - ltNon_Terminal name"VisitorOption-
2"/gt - lt/Productiongt
- ltProduction name"AddProduct"
type"Sequence" info"mandatory"gt - ltEvent name"AddProduct"
type"response" info"mandatory"/gt - ltAction name"AddProduct" type"ui"
info"com.ebazaar.shoppingmanagement."/gt - ltNon_Terminal name"VisitorOption-2"/gt
- lt/Productiongt
16In your JSP page
- ltform method"post" action"/ebz/ebazaarapplicatio
ngateway"gt - ltinput type"submit" name"eventToken"
value"OnlineShopping"gt - lt/formgt
17Shopping Cart SubsystemClass-Diagram
18Shopping Cart SubsystemMain Classes
- Business Objects
- -CCartItem-represents each item in Cart
- -CShoppingCart-represents cart in which items are
added or removed. - Servlets
- -ShoppingCartServlet- for adding item to cart
- -UpdateCartServlet- for updating item of cart.
- -DeleteCartServlet-for deleting item from cart.
- JSPs
- -ebz_ShoppingCart- that shows the contents of
cart with options to update, delete and checkout. - Other helper classes.
19Shopping Cart SubsytemGeneral Workflow
- User selects product and adds to cart.
- UserID and ProductID of the selected product are
passed to the subsystem as parameter from jsp
page. - This userID and ProductID along with quantity of
product is stored in database. - Once the product is added to the cart, it can be
deleted and updated until CheckOut is performed. - When user checks out, this subsystem will handle
the control to OrderManagement Subsystem and
passes along the cart through session.
20Shopping Cart SubsystemDatabase Design
- Database design is simple
- Consists only one table with fields UserID,
ProductID and quantity. - UserID is foreign key from User table, ProductID
is foreign key from product table. - UserID and ProductID combinedly forms primary key
for the table. - May be one more field is required.
21Shopping Cart SubsystemCurrent Status and
Possible Modifications
- Current Status
- 1. Presently adding, deleting and updating of
cart is reflected to database in each and every
step as in amazon.com. - 2. At present, none of the business rules are
applied to system. - 3. At present, database design doesnt reflect
completed and uncompleted orders, i.e. items will
remain in cart even after placing order.
- Future Modifications
- 1. Adding deleting and updating of cart can be
stored in session and is stored in database only
after Checkout. - 2. Business rules may be added.e.g A rule that
User has to login for adding to cart or for
Checkout etc. - 3. Some additional field may be required to
differentiate completed and uncompleted orders.
Or completed orders can be deleted from table
itself as all the details will be stored in Order
table once order is placed.
22Order Management Component
- Implemented Enterprise Component Pattern
-
- Façade Interface IOrderManagement
- Façade Class OrderManagement
- Mediator OrderController
- FactoryFactory
- Work Flow ProcessOrderWorkFlow(Future place for
GOOD rules) - Other business interfaces and classes
- IOrder, AOrder, Order
- IOrderLineItem, AOrderLineItem, OrderLineItem
- IDiscount, ADiscount, Discount, DiscountRule
-
- Database façade classes
- IDBFacade, ADBFacade, DBFacade
23Order Management Component
24OM Dependent Components
- Shopping Cart Management Component.
- Customer Management Component
-
- The published services in the façade interface
- createOrder()
- chageBillingaddress()
- changeShippingaddress()
- changeShippingMethod()
- changePaymentMethod()
- acceptTerms()
- processOrder()
- SendConfirmation()
- viewOrderHistory()
- checkOrderStatus()
- showOrderDetails()
- generateInvoices()
25Order Management
- used services that provided by ShoppingCart
Component - public String getCustomerID()
-
- addItem()
- getBillingAddress()
- getCartItems()
- getPaymentMethod()
- getShippingAddress()
- getShippingMethod()
-
-
26Order Management
- Implemented Model Control View (MVC) pattern
- JSP-Servlet-JavaBean architecture
- Used ConnectionPool for database connection
- Relational Database in MySQL.
- Tables in relational database.
- 1. orderinfo
- 2. items
- 3. billingaddress
- 4. shippingaddress
- 5. shippingmethod
- 6. paymentmethod
27Order Management
- The implemented flow in the component is shown in
the figure below
28Order Management
- Completed Portions
- Create Order
- Generate Invoices
-
- To be done
- Change Billing Address
- Change Shipping Address
- Change Shipping Method
- Change Payment Method
- View Order History
- View Order Status
- Accept Terms and Condition
- View Order Details.
29eBazaar
- Customer Management Component
30(No Transcript)
31(No Transcript)
32Customer Management Subsystem
Manages customers for the ebazaar, has following
functionality on a customer -View -Edit
-Delete -Add -Search
33Servlets
- Following Servlets (Controller) perform
request/response and database connectivity
management within the subsystem. - NewUserSignupServlet
- SignInServlet
- UpdateServlet
- DeleteServlet
34JSPs
- Following JSPs provide users view of the
subsystem - NewUserSignIn
- SignOn
- Welcome
- Search
- Update
- ViewList
35The Customermanagement component
- It is an EJB component which consists
- CustomerHome- home interface
- CustomerBean- entity bean with CMP Fields
- Customer-remote interface
- CustomerController- EJB remote interface
- CustomerControllerBean- session bean
- CustomerControllerHome- home interface
36Classes and Interfaces
- Following classes and interfaces are part of
component - CustomerManagementSystem
- PaymentMethod
- Address, BillingAddress
- CardPayment
- PaymentMethod
- ShippingMethod
37Add New feature
- Using GOOD to add new features to an existing
software application
38- lttrgtlt!-- Row 2 --gt
- lttd bgcolor"C0C0C0" align"center"gt
- ltform name"SaveCart" action"/ebz/ebazaarappl
icationgateway"gt - ltinput type"submit" value"Save Cart"gt
- ltinput typehidden name"eventToken"
value"SaveCart"gt - lt/formgtlt/tdgt
- lt/trgt
39- ltProduction name"VisitorOption-2" type"Choice"
info"mandatory"gt - ltNon_Terminal name"Search"/gt
- ltNon_Terminal name"Selection"/gt
- ltNon_Terminal name"SignOut"/gt
- ltNon_Terminal name"AddProduct"/gt
- ltNon_Terminal name"ShowCart"/gt
- ltNon_Terminal name"CheckOut"/gt
- ltNon_Terminal name"SaveCart"/gt
- lt/Productiongt
40- ltProduction name"SaveCart" type"Sequence"
info"mandatory"gt - ltEvent name"SaveCart" type"response"
info"mandatory"/gt - ltAction name"SaveCart" type"ui
info"com.ebazaar.productmanagement."/gt - ltNon_Terminal name"ShopperOption-1"/gt
- lt/Productiongt
41- package com.ebazaar.ebazaarcomponent.handlers
- import com.ebazaar.productManagement.
- import com.ebazaar.ebazaarcomponent.event.
- import com.ebazaar.common.utils.
- import com.ebazaar.shoppingcartmanagement.
- import com.ebazaar.customermanagement.ejb.
- import com.ebazaar.common.
- import javax.servlet.
- import javax.servlet.http.
-
42- public class SaveCart extends DefaultBaseEventList
ener -
- public SaveCart()
-
-
- public IBaseEvent doAction(DefaultEventEnv e)
-
- System.out.println("Save Cart Action")
-
- ResponseEvent responseEvent new
ResponseEvent() - responseEvent.setActionString("/sc/ebz
_shoppingcart.jsp") - // responseEvent.setActionString("/ec/main
.jsp") - responseEvent.setResponseType("ui")
- return responseEvent
-
-
43EBazaar
- Adding New Functionality
- MUM, 2001
447 Steps to Do
- Select the right page (jsp file)
- Add UI control source (e.g. Button)
- Open XML File that stores the Grammar
- Find the correspond Production Rule and add Non
Terminal - Create Production Rule
- Write Event Handler (Java Class)
- Compile the class, Rebuild the Application
45Case GoToMain
- Statement of Change
- A user may cancel or postpone the order when
he/she is in the confirm order screen - The screen should have a functionality to jump to
the front page. This is a short cut for a user to
log out and have some coffee break without
worrying about his/her order
46Step 1 Select the right JSP file
ebz_shoppingcart.jsp
47Step 2 Add UI Control Source
ebz_shoppingcart.jsp cut here ... ltform
name"ShowCart" action"/ebz/ebazaarapplicationgat
eway"gt ltinput type"submit" value"Continue
Shopping"gt ltinput typehidden name"eventToken"
value"ContinueShopping"gt lt/formgt ltform
name"CheckOut" action"/ebz/ebazaarapplicationgat
eway"gt ltinput type"submit" value"Check
Out"gt ltinput typehidden name"eventToken"
value"CheckOut"gt lt/formgt ltform name"GoToMain"
action"/ebz/ebazaarapplicationgateway"gt ltinput
type"submit" value"Main"gt ltinput typehidden
name"eventToken" value"GoToMain"gt lt/formgt
cut here .
48Press Button Added
49Step 3 Open The Grammar
- File Account_management_2.xml
50Step 4 Add Non-Terminal
ltProduction name"ShopperOption-1" type"Choice"
info"optional"gt ltNon_Terminal
name"ContinueShopping"/gt ltNon_Terminal
name"CheckOut"/gt ltNon_Terminal
name"GoToMain"/gt lt/Productiongt
51Step 5 Create Production Rule
ltProduction name"GoToMain" type"Sequence"
info"optional"gt ltEvent
name"GoToMain" type"response"
info"mandatory"/gt ltAction
name"GoToMain" type"ui" info"com.ebazaar.sho
ppingmanagement."/gt ltNon_Terminal
name"OnlineShopping"/gt lt/Productiongt
52Step 6 Write Event Handler
package com.ebazaar.ebazaarcomponent.handlers im
port com.ebazaar.common. import
javax.servlet. import javax.servlet.http. impo
rt com.ebazaar.ebazaarcomponent.event. public
class GoToMain extends DefaultBaseEventListener
public GoToMain() public IBaseEvent
doAction(DefaultEventEnv e)
ResponseEvent responseEvent new
ResponseEvent() responseEvent.setAc
tionString("/ec/main.jsp")
responseEvent.setResponseType("ui")
return responseEvent
53Step 7 Recompile Rebuild
54J2EE and Application Server Techniques
55What is an EAR file?
Web .html and .jsp files java .class
Deployment descriptor
war
Deployment descriptor
ear
jar
Java .class file EJBs or java beans
Deployment descriptor
ltapplicationgt ltdisplay-namegtEBAZAAR (J2EE
application)lt/display-namegt ltdescriptiongtEBAZAA
R Components Integrationlt/descriptiongt
ltmodulegt ltejbgtpm-ejb.jarlt/ejbgt
lt/modulegt ltmodulegt ltejbgtcm-ejb.jarlt/ejbgt
lt/modulegt ltmodulegt ltwebgt
ltweb-urigtebazaar-web.warlt/web-urigt
ltcontext-rootgt/ebazaar-weblt/context-rootgt
lt/webgt lt/modulegt lt/applicationgt
Application.xml
56What is the E-bazaar EAR file?
Web .html and .jsp files java .class
Deployment descriptor
war
Deployment descriptor
ear
jar
Java .class file EJBs or java beans
Deployment descriptor
ltapplicationgt ltdisplay-namegtEBAZAAR (J2EE
application)lt/display-namegt ltdescriptiongtEBAZAA
R Components Integrationlt/descriptiongt
ltmodulegt ltejbgtpm-ejb.jarlt/ejbgt
lt/modulegt ltmodulegt ltejbgtcm-ejb.jarlt/ejbgt
lt/modulegt ltmodulegt ltwebgt
ltweb-urigtebazaar-web.warlt/web-urigt
ltcontext-rootgt/ebazaar-weblt/context-rootgt
lt/webgt lt/modulegt lt/applicationgt
Application.xml
Due to a limitation in Orion App server (Session
cannot be accessed across multiple beans), We
have to put all web application files in the same
war file. EJB files are specified explicitly
(not in a war file).
57ltweb-urigtebazaar-web.warlt/web-urigt
- The Web URI specifies a logical name for the web
application - This will be referenced in the default-web-site.xm
l file so it can redirect requests to the
physical location of the application (e-bazaar)
files - http// localhost8080/ebz/ec/main.jsp
58Server.xml
- Application name is set in server.xml
- Orion server assigns an application name to the
path of the EAR application that will be used
during access to the default-web-site - Access to the app server is through the
default-web-site.xml
ltapplication-server application-directory"../app
lications" deployment-directory"../application-d
eployments" gt ltrmi-config path"./rmi.xml"
/gt ltloggt ltfile path"../log/server.log"
/gt lt/loggt ltglobal-application name"default"
path"application.xml" /gt ltweb-site
path"./default-web-site.xml" /gt ltapplication
name"EBAZAAR" path"../applications/ebazaar.ear"/
gt lt/application-servergt
59Default-web-site.xml
- Assign the logical application name to a context
and physical root directory - A reference to this directory will execute the
application - We define the context-root app name for the
default-web-site, here. - Access to the default-web-site
ltweb-app application"EBAZAAR" name"ebazaar-web"
root"/ebz" /gt
ltweb-site host"ALL" port"8080"
display-name"Default Orion WebSite"gt lt!-- The
default web-app for this site, bound to the root
--gt ltdefault-web-app application"default"
name"defaultWebApp" /gt ltweb-app
application"EBAZAAR" name"ebazaar-web"
root"/ebz" /gt lt!-- Access Log, where requests
are logged to --gt ltaccess-log path"../log/defaul
t-web-access.log" /gt lt/web-sitegt
60user
/ebz
/default-web-app
Recognizes context
Recognizes appl name
61Default-web-site.xml
Define the root (logical) path /ebz This root
will refer to the specific application
name EBAZAAR This root need to know the
URI-Context to access the physical location
inside the EAR Ebazaar-web
Application.xml defines the URI-context Server.xml
defines application name Default-web-site
defines the root
62Setting the Datasource Name
63(No Transcript)