Navigation Bar

Saturday, June 26, 2010

Struts 1.1 : StockCode project using Java Design Patterns

For an understanding of Java design patterns one can refer to the below post

For the StockCode Add/Modify/Delete screen we use the Factory Design pattern.

Details of the factory design pattern are in the link below

    ┌────────────────────────────────────────────────────────┐
    │                Struts Framework Class                  │
    │                        Action                          │
    └───────────────────────────▲────────────────────────────┘
                                │
                                │ (Inherits / Extends)
    ┌───────────────────────────┴────────────────────────────┐
    │                   «Abstract Class»                     │
    │                     CommonAction                       │
    ├────────────────────────────────────────────────────────┤
    │ # log : Logger                                         │
    ├────────────────────────────────────────────────────────┤
    │ + execute(mapping, form, request, response) : Forward  │
    │ + commonExecute(mapping, form, req, resp)* : Forward   │
    └───────────────────────────┬────────────────────────────┘
                                │
                                │ (Instantiates & Uses)
                                .
                                . (Dependency via 'new')
                                ▼
┌──────────────────────────────────────┐
│     «interface»                      │
│     StockQuoteManagerFactoryIF       │
├──────────────────────────────────────┤
│ + createStockQuoteManager()          │
└──────────────────▲───────────────────┘
                   │
                   │ (extends)
┌──────────────────┴───────────────────┐
│     «interface»                      │
│     DbStockQuoteManagerFactoryIF     │
├──────────────────────────────────────┤
│ + getDataSource()                    │
└──────────────────▲───────────────────┘
                   │
                   ║ (implements)
                   │
┌──────────────────┴───────────────────┐               creates                ┌──────────────────────────────┐
│     DbStockQuoteManagerFactory       ├─────────────────────────────────────►│   DatabaseStockQuoteManager  │
├──────────────────────────────────────┤                                      ├──────────────────────────────┤
│ - dataSource : DataSource            │                                      │ - dataSource : DataSource     │
├──────────────────────────────────────┤                                      │ - log : Logger               │
│ + DbStockQuoteManagerFactory()       │                                      ├──────────────────────────────┤
│ + getDataSource()                    │                                      │ + setDataSource()            │
│ + createStockQuoteManager()          │                                      │ + createStockQuote()         │
└──────────────────┬───────────────────┘                                      │ + getStockQuote()            │
                   │                                                          │ + updateStockQuote()         │
                   │ (composes inner class)                                   │ + deleteStockQuote()         │
                   ▼                                                          └──────────────┬───────────────┘
┌──────────────────────────────────────┐                                                     │
│             MyDataSource             │◄────────────────────────────────────────────────────┘
├──────────────────────────────────────┤                                     (uses to get connections)
│ + getConnection()                    │
└──────────────────────────────────────┘
                                                                                             │
                                                                                             ║ (implements)
                                                                                             │
                                                                              ┌──────────────▼───────────────┐
                                                                              │     «interface»              │
                                                                              │     StockQuoteManagerIF      │
                                                                              ├──────────────────────────────┤
                                                                              │ + createStockQuote()         │
                                                                              │ + updateStockQuote()         │
                                                                              │ + deleteStockQuote()         │
                                                                              │ + getStockQuote()            │
                                                                              └──────────────────────────────┘

 

For the Java code link is below 

Struts 1.1 : StockCode project using Java Design Patterns - java code

The front end JSP UI code 

Struts 1.1 : StockCode project using Java Design Patterns - UI JSP code

The web.xml and struts.config.xml

Struts 1.1 : StockCode project using Java Design Patterns - config 

The list of dtds and tlds required for struts 1.1 project are below
struts-bean.tld
struts-config_1_2.dtd
struts-html.tld
struts-logic.tld
struts-nested.tld
struts-tiles.tld
tiles-config_1_1.dtd
tiles-defs.xml
validator-rules.xml
web-app_2_3.dtd
 

The dtds and tlds - II

Alternatively you can download the dtds, tlds and xmls from below site
Struts 1.1 : StockCode project using Java Design Patterns - tlds, dtds and xml


God's Word for the day

Varieties of Speech
The conversation of the godly is always wise
  But the fool changes like the moon.
Among stupid people limit your time,
  but among thoughtful people linger on.
The talk of fools is offensive
  And their laughter is wantonly sinful.
Their cursing and swearing make one's hair stand on end
  and their quarrels make others stop their ears.
The strife of the proud leads to bloodshed,
  and their abuse is grievous to hear.
Sirach 27:11 - 15

Gospel teachings of Jesus

The rich young man
Then Jesus said to his disciples,
"Truly I tell you, it will be hard for a rich person
  to enter the kingdom of heaven. Again I tell you,
it is easier for a camel to go through the eye of a needle
  than for someone who is rich to enter the kingdom of God."
When the disciples heard this, they were greatly astounded
  and said, "Then who can be saved?" But Jesus looked at
them and said, "For mortals it is impossible, but for God
  all things are possible."
Mathew 19:23 - 26

No comments:

Post a Comment