Gnizr Architecture (for developers)
Upcoming SlideShare
Loading in...5

Gnizr Architecture (for developers)



How WebWork and Spring function in gnizr. For developers who want to extend gnizr.

How WebWork and Spring function in gnizr. For developers who want to extend gnizr.



Total Views
Views on SlideShare
Embed Views



3 Embeds 4 2 1 1



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution-NonCommercial LicenseCC Attribution-NonCommercial License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

Gnizr Architecture (for developers) Gnizr Architecture (for developers) Presentation Transcript

  • Gnizr Architecture Dr. Harry Chen CMSC 491S/691S February 25, 2008
  • Agenda
    • Design patterns in gnizr
    • WebWork and Spring configurations
    • HelloWorldDemo revisit
  • Design Patterns Found in Gnizr
    • Data Access Object (DAO)
    • Inversion of Control (IoC)
      • a.k.a Dependency Injection
    • Singleton
    • Interceptor
  • Gnizr Architecture What’s DAO?
  • What’s DAO?
    • A design pattern that allows developers to abstract and encapsulate the access to the data source.
    User DB (MySQL) User Registration
    • - add(user)
    • delete(user)
    • update(user)
    • lookup(user)
    • User record
    • is OP okay?
    How do you design your program to do these?
  • Why use DAO?
    • Hide SQL statements from the high-level program. Don’t want to write the same SQL multiple times in different class files
    • Allow high-level programs to access DB records without knowing how the DB schema is designed
  • Tight-coupling is a bad idea Do you really want to write SQL every time you need to access the “customers” DB? Fetching data from “ResultSet” is complicated – it’s column-driven . Not natural for OO programming
  • DAO Design Pattern
  • DAO Example
  • DAO Example User Registration User DB (MySQL) User (class) UserDAO
    • UserDao implements…
    • addUser(User): int
    • deleteUser(User): boolean
    • updateUser(User): boolean
    • getUser(id): User
  • Gnizr DAO package
    • Let’s scan through gnizr DAO API
      • Bookmark
      • User
      • Tag
      • Link
      • Etc.
  • Gnizr DAO Classes
    • Let’s walkthough some DAO class implementation in gnizr
      • (interface)
        • (class impl)
      • (interface)
        • (class impl)
    • [Switching to Eclipse…]
  • How Gnizr Business Logic is Created When are these objects created? What’s the life span of these objects? How are JDBC connections initialized?
  • Inversion of Control (IoC)
    • IoC is a principle that encourage the decoupling of code.
      • A.K.A. Dependency Injection.
    Problem : The use of “MovieFinderImpl” is hardwired into “MovieLister”. Change this logic will require code rewrite and re-compile “MovieFinderImpl” Read:
  • Spring IoC
    • A framework that can be coupled with WebWork to provide Dependency Injection.
    Spring IoC implements a flexible “Assembler”. Developers can tell this “Assembler” how to perform “<create>” via XML configuration.
  • IoC in Gnizr
    • How to create “hocks” for
      • Connecting DAO objects to Gnizr Core class objects
      • Connecting Gnizr Core class objects to WebWork action objects
      • Injecting application configuration at runtime
    • [Switching to Eclipse…]
  • Design Pattern: Singleton
    • A design pattern that restricts the instantiation of a class to one object.
    • Singleton is used when you want exactly one object to be created in the system.
    • Singletons in gnizr, for example,
      • GnizrBasicDataSource (holds JDBC settings)
      • All DAO objects (not Transport objects)
      • Gnizr Core class objects
  • WebWork Actions are not Singletons
    • 99% of times, you should not define WebWork actions as Singletons.
    • Because….
  • Actions are not Singleton
    • WebWork actions are not singletons because multiple action objects are needed to serve multiple user sessions.
    user session action DAO MySQL Singleton is okay under what condition?
  • WebWork Actions in gnizr
    • Let’s review some Action class in gnizr
    • [switching to Eclipse…]
  • WebWork Interceptors
    • Interceptors are classes that can be defined to pre-process request or post-process response.
      • Validate parameter value (e.g., password length must 8, no symbols are allowed)
      • Map HTTP parameter values to Beans and call “set” methods.
      • Create HTTP session automatically
  • Interceptor
  • Interceptor
  • Gnizr WebWork configuration
    • Let’s review Gnizr’s webwork configuration.
    • [switching to Eclipse]
  • WebWork Result Types
    • Result Types are classes that determine what happens after an Action executes and a Result is returned.
  • Which Result Type to Choose
    • The “name” of the result determines which Result Type to apply after an Action executes
      • The “name” maybe “success”, “error” or any string that you choose return in your “execute()” method, or “go()” if you extends the “AbstractAction” class.
  • Gnizr Result Type Examples
    • Let’s review some example of Action configuration in gnizr, and see how different Result Types play a role in the application
      • File: gnizr-useradmin.xml
      • File: gnizr-bookmark.xml
      • File: gnizr-json.xml (searchproxy action)
    • [swithcing to Eclipse…]