Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Atg Core

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 123
At a glance
Powered by AI
The document talks about different types of e-commerce like B2C, B2B and leading e-commerce software like ATG, IBM Websphere, MarketLive

The main types of e-commerce mentioned are B2C (Business to Consumer) and B2B (Business to Business)

The leading e-commerce software mentioned are ATG, IBM Websphere e-commerce, MarketLive

ATG Relationship Management Platform

03/01/2011

Citrisys Solutions, Chennai

Overview of E-Commerce
E-Commerce, which stands for electronic commerce (also called electronic marketing) is a way of buying and selling goods using electronic systems such as the internet or other computer networks. Main types of E-Commerce *B2C Most large retail stores have an online website for purchasing goods. This type of e-commerce is called business to consumer(B2C). *B2B B2B is selling goods between companies. It is like manufacturer supplying goods to the retailer or wholesaler. Leading E-commerce Software's * ATG * IBM Websphere e-commerce * MarketLive

03/01/2011

Citrisys Solutions, Chennai

Introduction to ATG Platform


ATG is an ecommerce software for building powerful ecommerce applications. It is purely a java based software. ATG comes with a collection of products such as Dynamo Application Server (DAS), Dynamo Commerce Server (DCS), Content Administration, ACC etc..

ATG Framework includes the following core modules. * DAF (Dynamo Application Framework) * DPS (Dynamo Personalization Server) * DSS (Dynamo Scenario Server)

03/01/2011

Citrisys Solutions, Chennai

Introduction to ATG Platform

ATG Portal

ATG ATG Commerce Publishing

ATG Personalization + ATG Scenarios

Dynamo Application Framework


Application Server

03/01/2011

Citrisys Solutions, Chennai

Dynamo Application Framework (DAF)


The Dynamo Application server sits on the top of our application server and supplies essential features to our application. It includes: Nucleus Repositories Tag Libraries Droplets and Form Handlers

This framework is designed to run on industrys leading J2ee application server including ATGs own Dynamo Application server (DAS), Jboss, IBM Websphere, BEA Weblogic.

03/01/2011

Citrisys Solutions, Chennai

Dynamo Personalization Server (DPS)


The DPS module provides tools for setting up profile repositories, creating targeting rules and services. ATG applications use profile repositories to manage user profiles. A standard profile repository is a SQL repository component of class atg.adapter.gsa.GSARepository. A user profile is a set of attributes that represent the data you want to store for a site user, for example login name, password, e-mail address, registration date, and so on. Another feature by ATG, is to match content to individuals based on their needs and preferences. The ATG Dynamo e-Business Platform provides a rich set of features that allow companies to create rules for targeting content to particular users. These rules can be created using a graphical user interface or directly through code.

03/01/2011

Citrisys Solutions, Chennai

Dynamo Scenario Server (DSS)


Scenarios are a customer-centric method for modeling a users experience on a website. Scenarios cut development and maintenance time, allowing more features to be built in less time.

The following figure shows a scenario which sends the user a friendly reminder email if the user doesnt log in again within 3 weeks.

03/01/2011

Citrisys Solutions, Chennai

DAF- 1.Nucleus
The DAF implements a component development model based on JavaBeans and JSPs. Developers assemble applications out of component beans (based on standard ATG classes or custom Java classes) by linking them together through configuration files in Nucleus, ATGs open object framework. Nucleus lets you assemble applications through simple configuration files that specify what components are used by the application, what parameters are used to initialize those components, and how those components hook up to each other. Any Java object with an empty constructor can act as a component in Nucleus Nucleus also takes on the task of creating and initializing components. Nucleus is the mechanism that gives those components a place to live, and a way for those components to find each other. Nucleus by itself provides no application-specific functions

03/01/2011

Citrisys Solutions, Chennai

DAF- 1.Nucleus Creating a Nucleus Component


Define the class with two properties: name (a String) and age (an integer): public class Person { String name; int age; public Person () {} public String getName () { return name; } public void setName (String name) { this.name = name; } public int getAge () { return age; } public void setAge (int age) { this.age = age; } } Put this class definition in your classes directory with the name Person.java. Next Step is to create a Nucleus component. For that create a file called Person.properties with the following contents: $class=Person (path of the java class) name=Stephen age=20 You can now view the Person component in the Components window.

03/01/2011

Citrisys Solutions, Chennai

DAF- 1.Nucleus Starting a Nucleus Component


You can start your Nucleus component by registering it with the Initial.properties file. Copy the Initial.properties file to your module and add your component to the Initial.properties file like the below: $class=atg.nucleus.InitialService initialServices=\ /atg/Initial,\ VMSystem,\ /atg/dynamo/StartServers

03/01/2011

Citrisys Solutions, Chennai

10

Nucleus- Full component names


Full component names are unique, containing folder names followed by the simple component name, separated by forward slashes

/atg/dynamo/service/SMTPEmail

03/01/2011

Citrisys Solutions, Chennai

11

GLOBAL. properties
GLOBAL.properties is a special properties file, not associated with any specific component that is often used to set logging levels for sets of components ATG7.x/DAS/config/GLOBAL.properties loggingError=true loggingWarning=true loggingInfo=true loggingDebug=false

Logging properties

Places logging messages into log files # Uncomment the ScreenLog while in production mode logListeners=\ atg/dynamo/service/logging/LogQueue,\ atg/dynamo/service/logging/ScreenLog Outputs logging messages to screen

03/01/2011

Citrisys Solutions, Chennai

12

DAF- 1.Nucleus Component Scopes


An application component can be set to one of the following scopes: Global: Component is shared among all users. Session: Separate instances of the component are provided to each user. Request: Separate instances of the component are provided to each active request. Window: Separate instances of the component are provided to each browser window.

03/01/2011

Citrisys Solutions, Chennai

13

DAF- 1.Nucleus Configuration Layering


We can start with an example: Lets say : /artists/d/DaveMathews/DaveMathews.properties file contains:

$class= atg.music.Artist $scope=global name=Dave Mathews genre=folk/pop website= email=


Here, we have defined a single global nucleus component of class atg.music.Artist which can be referenced by the name /artists/d/DaveMathews from within the Dynamo. Then the name property of the instance will be set to Dave Mathews and the genre property will be set to folk/pop. In this case even though our Artist bean has website and email properties we have not set these properties so they remain uninitialized.

03/01/2011

Citrisys Solutions, Chennai

14

DAF- 1.Nucleus Configuration Layering


Nucleus name Scope Java Instance (bean) atg.music.Artist name genre website email Dave Mathews folk/pop

/artists/d/DaveMathews global

03/01/2011

Citrisys Solutions, Chennai

15

DAF- 1.Nucleus Configuration Layering


In the previous example, there is only one component which is refers to the class Artist. But in reality, two or more properties files can specify the same component. For example:
A c:\music\artists\d\DaveMathews.properties file containing $class= atg.music.Artist $scope=global name=Dave Mathews genre=folk/pop A second c:\moreinfo\artists\d\DaveMathews.properties file containing website=http://www.dmb.com email=dave@dmb.com genre=rock

03/01/2011

Citrisys Solutions, Chennai

16

DAF- 1.Nucleus Configuration Layering


Nucleus name Scope Java Instance (bean) atg.music.Artist name genre website email Dave Mathews rock http://www.dmb.com dave@dmb.com

/artists/d/DaveMathews global

Here, genre properties has been replaced with a new value rock and the other two properties ( website and email ) has been initialized with
http://www.dmb.com and dave@dmb.com resp.

03/01/2011

Citrisys Solutions, Chennai

17

DAF- 1.Nucleus Configuration Layering


How does this happen? The config path is read from left to right. Properties set in later entries in the CONFIGPATH override earlier entries. In our case the genre property is specified in both properties files. The property is set to rock because that is the last value specified, (as we go from left to right through the CONFIGPATH). This process is know as configuration layering.

03/01/2011

Citrisys Solutions, Chennai

18

DAF- 2.Nucleus Tag Libraries


The ATG platform supports JSPs as its primary authoring format. The ATG platform ships with two tag libraries, located at <ATG9dir>/DAS/taglib: JSTL DSP The JavaServer Pages Standard Tag Library (JSTL) from Sun Microsystems handles generic Web application tasks that are supported by all application servers. JSTL is comprised of four tag libraries: core: evaluate and display data xml: manage XML code fmt: handle internationalization sql: interact with SQL data sources

03/01/2011

Citrisys Solutions, Chennai

19

DAF- 2.Nucleus Tag Libraries


The DSP tag library lets you access all data types in ATGs Nucleus framework. Other functions provided by these tags manage transactions and determine how to render data in a JSP. You should use tags from the DSP tag library only for tasks that involve Dynamo Application Framework (DAF) resources. For generic Web application tasks, use JSTL tags.

The DSP tag library supports both scripting and the JSP Expression Language. For example, the following two tags are equivalent: <dsp:valueof param="<%= currentCourse %>"/> <dsp:valueof param="${currentCourse}"/>

03/01/2011

Citrisys Solutions, Chennai

20

DAF- 2.Nucleus Tag Converters


To enable more control over data conversions, the ATG platform provides tag converter classes. Tag converters let you specify how data in forms is interpreted and displayed, and to control when exceptions are thrown.

Some of the OOTB Tag Converters


Credit card converters Currency converters Number converters

03/01/2011

Citrisys Solutions, Chennai

21

DAF- 2.Nucleus Tag Converters


<dsp:valueof bean="CreditCard.num" converter="creditCard" numcharsunmasked="4"/> XXXXXXXXXXXX3456

<dsp:valueof bean="CreditCard.num" converter="creditCard" maskcharacter="*" numcharsunmasked="12"/>

****567890123456

03/01/2011

Citrisys Solutions, Chennai

22

DAF- 2.Nucleus Custom Tag Converter


Create a class that implements the atg.droplet.TagConverter interface. This class must implement the four methods described below : getName Returns the name of your converter. This is the name that is used as an argument to the converter attribute in a tag. For example, Dynamo has a converter whose getName method returns currency, so you can include a tag like this in your JavaServer Pages: <dsp:valueof param="myPrice" converter="currency"/> getTagAttributeDescriptors Returns the list of attribute arguments that this converter takes. These attributes are listed along with the converter attribute in your valueof, input, or param tag.

03/01/2011

Citrisys Solutions, Chennai

23

DAF- 2.Nucleus Custom Tag Converter


convertStringToObject If you are using an input tag, when that form value is submitted, this method is called before the setX method of the component is called. Your convertStringToObject method must generate the Object value for use in the setX method. It can throw a TagConversionException if an error occurs during the conversion process. This method is also called if you use this converter with a param tag when the value of the parameter is defined. convertObjectToString This method is called in two situations: When you use a converter in a valueof tag, this method is used to convert the Object value into a String value before displaying it. When you use this tag in an input tag with a bean attribute and no existing value attribute, this method is called to fill in the value attribute with the current value of the bean property.

03/01/2011

Citrisys Solutions, Chennai

24

DAF- 2.Nucleus Custom Tag Converter Example


This example creates and configures a custom tag converter for US format Zip Codes: 91322-1232 01231-0132 83243 The tag converter class converts in the following ways: from String to a 'ZipCode' formatted String from ZipCode object to a 'ZipCode' formatted String It is used in JHTML like this:
<VALUEOF PARAM="zip" converter="ZipCode">default</VALUEOF>

Where zip may be either a string or a ZipCode object.

03/01/2011

Citrisys Solutions, Chennai

25

DAF- 2.Nucleus Custom Tag Converter Example


ZipCodeTagConverter.java public class ZipCodeTagConverter extends atg.nucleus.GenericService implements atg.droplet.TagConverter { ZipCode.java This additional class is provided to show how to convert from objects other than strings. ZipCode.properties This is the configuration file for the tag converter component. I made it a component so it could be included in an Initial.properties file to cause the self registration. $class=ZipCodeTagConverter $description=ZipCodeTagConverter $scope=global loggingDebug=true

For source code please see the attachment. For More information please refer atg documentation Progamming Guide Creating CustomTag Converters.

03/01/2011

Citrisys Solutions, Chennai

26

ATG Repository API


A repository is a data access layer that defines a generic representation of a data store. Application developers use this generic representation to access data by using only interfaces such as Repository and RepositoryItem.
Developers use repositories to create, query, modify, and remove repository items. A repository item is like a JavaBean, but its properties are determined dynamically at runtime. Before knowing repository more, we need to learn about Data anywhere architecture.

03/01/2011

Citrisys Solutions, Chennai

27

Data Anywhere Architecture


ATG Data Anywhere Architecture provides a unified view of content and data across a business for organizations and their customers. The core of the ATG Data Anywhere Architecture is the Repository API. Through the Repository API, you can employ a single approach to accessing disparate data types, including SQL databases, LDAP directories, content management systems, and file systems. One of the most powerful aspects of this architecture is that the source of the data is hidden behind the ATG Repository abstraction. It is easy to change from a relational data source to an LDAP directory as none of the application logic needs to change. After data is retrieved from a data source, it is transformed into an object-oriented representation. Manipulation of the data can be done using simple getPropertyValue and setPropertyValue methods.

03/01/2011

Citrisys Solutions, Chennai

28

Data Anywhere Architecture


A high-level overview of the ATG Data Anywhere Architecture.

03/01/2011

Citrisys Solutions, Chennai

29

Data Anywhere Architecture


The main advantage is that data can even move from a relational database to an LDAP directory without requiring recoding. This is possible through xml mapping which acts as an interface for the ATG application and the database. This xml file is known as Repository Definition File (RDF).

03/01/2011

Citrisys Solutions, Chennai

31

A Sample Repository Definition File


<item-descriptor name="user"> <table name="ctdc_user" type="auxiliary" id-column-name="user_id"> <property name="maxNoOfLoginAttempt" data-type="int" category="Login Attempts" column-name="max_no_of_login_attempts" display-name="Number of Login Attempts"/> </table> <table name="ctdc_user_interests" type="multi" id-column-name="user_id" multi-columnname="sequence_num"> <property name="interests" data-type="list" category="User Interests" component-itemtype="ctdcInterest" column-name="user_interest" display-name="interests" /> </table> </item-descriptor> <item-descriptor name="ctdcInterest" display-name="CTDC User Interest"> <table name="ctdc_interest" type="primary" id-column-name="id"> <property name="id" display-name="id"/> <property name="name" data-type="string" column-name="name" display-name="Name"/> </table> </item-descriptor>

03/01/2011

Citrisys Solutions, Chennai

32

Repository API
Explanation of the Previous RDF <item-descriptor name="user"> In the SQL repository, for example, an item descriptor might correspond to a Single database table, or encompass multiple tables. In short, the itemdescriptor maps with the sql tables. <table name="ctdc_user" type="auxiliary" id-column-name="user_id"> Here the type defines whether its one-one or one-many relationships. ATG supports auxiliary one-to-one relationship. multi one-to-many relationship. In our case, its auxiliary. So its a one-to-one relationship.

03/01/2011

Citrisys Solutions, Chennai

33

Repository API
Explanation of the Previous RDF
<property name="maxNoOfLoginAttempt" data-type="int" category="Login Attempts" column-name="max_no_of_login_attempts" display-name="Number of Login Attempts"/> Here, each property maps to a column of a table. Each property is a RepositoryItem name -> property name. data-type -> represents data-type specifically to this property. If you want to define a property that refers to another item, use the item-type attribute to refer to that item (oneone relationship) category-> this will group the properties. ( you can see through the ACC). column-name-> represents the sql column-names. display-name-> represents the name to be displayed( you can see through the ACC)

Please see the attachment to see the list of data-types ATG supports.

03/01/2011

Citrisys Solutions, Chennai

34

Repository API
<table name="ctdc_user_interests" type="multi" id-columnname="user_id" multi-column-name="sequence_num"> type=multi -> represents one-to-many relationships. multi-column-name=sequence_num -> ensures that the ordering of the multi-values are maintained. The column specified by the multi-columnname attribute is used for multi-valued properties of data type array, map, and list and is not used for sets (which are unordered). For map type properties, the values in the column specified by the multi-column-name attribute must be a string. For list or array type properties, these values should be an integer or numeric type, and must be sequential.
<property name="interests" data-type="list" category="User Interests" component-item-type="ctdcInterest" column-name="user_interest" displayname="interests" />

component-item-type -> is the name of the item descriptor that defines the item type of the members of the collection of repository items.

03/01/2011

Citrisys Solutions, Chennai

35

Repository API
If the property is a collection of primitive data types such as string, int, and double, specify the data type of the members of the collection by with the component-data-type attribute in the <property> tag for the multi item property: <property name="interests" column-name="interest" data-type="array component-data-type="string"/> When you are operating on the returned value from a List, Set, or Map property, the code should be like List l = (List) item.getPropertyValue(" interests "); ArrayList al = new ArrayList(); al.addAll(l);

03/01/2011

Citrisys Solutions, Chennai

36

Repository API Overview


Interface Repository RepositoryItem RepositoryView MutableRepository Key Methods getItem(), getView() getPropertyValue() executeQuery() addItem() getItemForUpdate() updateItem() removeItem() MutableRepositoryItem setPropertyValue()
The atg.repository.Repository interface is the base definition of any repository implementation. This interface provides methods to access RepositoryItems, RepositoryViews and ItemDescriptors, corresponding to the three main elements of the repository.

03/01/2011

Citrisys Solutions, Chennai

37

Retrieving a Repository Item by ID


public void addArtistToSong(String pSongid, String pArtistid) throws RepositoryException {
Repository repository = getRepository(); // getRepository()represents the repository name. defines in the properties file. try {
RepositoryItem artistItem =
repository.getItem(pArtistid,"artist"); // artist is the item-descriptors name.

if (ifLoggingDebug())
logDebug("adding artist: " + artistItem.getPropertyValue("name"));

} catch (RepositoryException e) {
if (isLoggingError()) {

logError("Unable to add artist to song", e); } throw e; }


}

03/01/2011

Citrisys Solutions, Chennai

38

Mutable Repositories
Repository and RepositoryItem provide a read-only view of repository elements MutableRepository is an extension that allows repository elements to be: Created Updated Deleted Manipulating a MutableRepositoryItem (a local copy of the data) only changes the repository when an explicit call to updateItem()or addItem()is made. Allow an item to be checked out of the repository, modified, and then resubmitted (so that the change will be reflected in the underlying data store) Provide a locking mechanism which prohibits any access of the data store while it is being modified

03/01/2011

Citrisys Solutions, Chennai

39

Mutable Repositories- Creating a new Item


Please see the code snippet below: public String createArtistFromUser(String pUserid) throws RepositoryException { MutableRepository mutRepos = (MutableRepository) getRepository(); RepositoryItem user = getUserRepository().getItem(pUserid, "user"); String username = (String)user.getPropertyValue("firstName") + " " + user.getPropertyValue("lastName"); MutableRepositoryItem mutArtistItem = mutRepos.createItem("artist"); mutArtistItem.setPropertyValue("name", username); copy all relevant properties mutRepos.addItem(mutArtistItem); return mutArtistItem.getRepositoryId();

03/01/2011

Citrisys Solutions, Chennai

40

Mutable Repositories- Creating a new Item


MutableRepository mutRepos = (MutableRepository) getRepository(); For creating a new item, MutableRepository is used. The method getRepository() will get the repository and we are casting it to a MutableRepository. RepositoryItem user = getUserRepository().getItem(pUserid, "user"); This code will fetch the particular user details by passing the userId. It will be a RepositoryItem because we are just retrieving the data. String username = (String)user.getPropertyValue("firstName") + " " + user.getPropertyValue("lastName"); This code will fetch the particular users firstname and LastName, then concatenated to a string. MutableRepositoryItem mutArtistItem = mutRepos.createItem("artist"); This code will create a MutableRepositoryItem for the itemDescriptor artist. mutArtistItem.setPropertyValue("name", username); This code will set the value to the property username of the itemdescriptor artist. This will only change the local copy of the data. We need to call explicitly addItem() To make changes to the repository. mutRepos.adItem(mutArtistItem); This will make the changes to the repository thus creating a new item.

03/01/2011

Citrisys Solutions, Chennai

41

Mutable Repository updating an item


Please see the code snippet.

public void addArtistToSong(String pSongid, String pArtistid) throws RepositoryException {


MutableRepository mutRepos = (MutableRepository) getRepository(); try {
RepositoryItem artistItem =
repository.getItem(pArtistid,"artist");

MutableRepositoryItem mutSongItem =
mutRepos.getItemForUpdate(pSongid,"song");

mutSongItem.setPropertyValue("artist",artistItem); mutRepos.updateItem(mutSongItem);

}
03/01/2011 Citrisys Solutions, Chennai 42

Mutable Repository updating an item


MutableRepositoryItem mutSongItem = mutRepos.getItemForUpdate(pSongid,"song"); mutSongItem.setPropertyValue("artist",artistItem); mutRepos.updateItem(mutSongItem); Fetch a mutable version of the repository item through the getItemForUpdate and getItemsForUpdate methods. These methods return instances of MutableRepositoryItem. This interface extends RepositoryItem and adds one method:setPropertyValue(String pPropertyName, Object pPropertyValu e) Use the setPropertyValue method of MutableRepositoryItem to change as many properties as you wish. These changes are not reflected in the repository until the final updateItem operation is invoked. Save the changes with the updateItem method. This method extracts all the changes required for the item and updates the item in the data store. 03/01/2011 Citrisys Solutions, 43 Chennai

Mutable Repository removing an item


Removing an item from the repository is very easy. Pass the ID and ItemDescriptor name of the item you want to remove persistently to the removeItem method. The items property values are deleted and are no longer accessible from the repository: removeItem(String pId, String pDescriptorName)

03/01/2011

Citrisys Solutions, Chennai

44

Repository Queries
The most straightforward way of executing queries in a repository is using RQL using the RqlStatement class You can create an RQLStatement from a string using parseRQLStatement() RqlStatement statement = RqlStatement.parseRqlStatement( rql string); RQL statements are executed against a RepositoryView

03/01/2011

Citrisys Solutions, Chennai

45

Repository Queries - Parameterized RQL


public RepositoryItem findArtistByName(String pArtistName) throws RepositoryException {
1
2

Repository repos = getRepository(); RqlStatement findArtistRQL; RepositoryView artistView = repos.getView("artist"); Object rqlparams[] = new Object[1]; rqlparams[0] = pArtistName; findArtistRQL = RqlStatement.parseRqlStatement("name = ?0"); RepositoryItem [] artistList =
findArtistRQL.executeQuery (artistView,rqlparams);

if (artistList != null) {
return artistList[0];

} return null;

} 03/01/2011

Citrisys Solutions, Chennai

46

Named Queries (1)


You can also define a query in the SQL repository definition file
songs.xml

Example: a named <item-descriptor name="song"> query to return all jazz songs in the <named-query> repository <rql-query> <query-name>jazzSongs</query-name> <rql>genre = "jazz"</rql> </rql-query> </named-query> </item-descriptor>

Named Queries (2)


Two ways to execute a named query
- programmatically (use the NamedQueryView object)
SongsManager
jazzSongs

- in JSP (use the NamedQueryForEach droplet)

Named Queries: Programmatic Execution SongsManager.java


SongsManager jazzSongs

public RepositoryItem[] getJazzSongs() { try { RepositoryView songView = getRepository().getView("song"); 1 if(songView instanceof NamedQueryView) { NamedQueryView nameView = 2 (NamedQueryView)songView; Query namedQuery = nameView.getNamedQuery("jazzSongs"); RepositoryItem[] results = nameView.executeQuery(namedQuery); } return results; }

Named Queries: JSP


jazzsongs.jsp

<dsp:droplet name="/atg/dynamo/droplet/NamedQueryForEach"> <dsp:param name="repository" bean="/dynamusic/SongsRepository" /> <dsp:param name="queryName" value="jazzSongs" /> <dsp:param name="itemDescriptor" value="song" /> <dsp:oparam name="output"> <li> <dsp:a href="song.jsp"> <dsp:param name="itemId" param="element.id"/> <dsp:valueof param="element.title"/> </dsp:a> </dsp:oparam> </dsp:droplet>

Item-Descriptor Relationships
1. One-to-One Relationships: Lets see the Repository Definition file below;
<item-descriptor name="user"> <table name="ctdc_user" type="auxiliary" id-column-name="user_id"> <property name="maxNoOfLoginAttempt" data-type="int" category="Login Attempts" column-name="max_no_of_login_attempts" display-name="Number of Login Attempts"/> </table> Explanation: We have to use the type=auxiliary for 1-1 relationship. Here, the property maxNoOfLoginAttempt of data-type int has been added to the item-descriptor user.

Item-Descriptor Relationships
dps_user
1-1 relationship

ctdc_user

03/01/2011

Citrisys Solutions, Chennai

52

Item-Descriptor Relationships
One-Many Relationship: Lets see the repository Definition File below:
<item-descriptor name="user">
<table name="ctdc_user_interests" type="multi" id-column-name="user_id" multicolumn-name="sequence_num"> <property name="interests" data-type="list" category="User Interests" componentitem-type="ctdcInterest" column-name="user_interest" display-name="interests" /> </table> </item-descriptor> <item-descriptor name="ctdcInterest"> <table name="ctdc_interest" type="primary" id-column-name="id"> <property name="id" display-name="id"/> <property name="name" data-type="string" column-name="name" displayname="Name"/> </table> </item-descriptor>

03/01/2011

Citrisys Solutions, Chennai

53

Item-Descriptor Relationships
Explanation:
1. For one-to-many the type should be multi. 2. multi-column-name="sequence_num is used to maintain an order. It is used with list data-type. 3. Atg supports Set, List, Map, or array data-types. 4. component-item-type="ctdcInterest - the name of the item descriptor that defines the item type of the members of the collection of repository items. We can use the String array for storing the multi-valued properties like component-data-type=String. 5. You cannot establish a default value for multi-valued attributes. 6. In Code, we can get the multi-valued properties like: List l = (List) item.getPropertyValue(" interests ");

03/01/2011

Citrisys Solutions, Chennai

54

Cascade Operations
The SQL repository uses the cascade attribute in a <property> tag to better handle hierarchical properties, which is to say properties with the item-type or component- tem-type attributes. The cascade attribute can have one or more of the values insert,update, or delete. For example: <property name="scenarios" itemtype="scenario" cascade="update,delete"/> The item is created, added, updated, and deleted along with the parent item. Cascade Insert: A new item of the type declared by the item-type attribute is also created. The cascade="insert" attribute is typically used with cascade="update" and cascade="delete" so management of this item is completely automatic. The cascade="insert" attribute is ignored for properties that use component-itemtype.

03/01/2011

Citrisys Solutions, Chennai

55

Cascade Operations
Cascade update: When you call updateItem, any modified referenced items are automatically updated. Any referenced items that are new (transient) items are added.

Cascade delete:
If a repository item has a property with the cascade="delete" attribute set, when you remove the repository item, any items that are referenced by the property are also removed. Also, when you remove a reference to this item, the item is automatically removed.

03/01/2011

Citrisys Solutions, Chennai

56

Item Descriptor Inheritance


You can define an item descriptor that inherits properties from another item descriptor in the same repository. In the following example, a simple clothing store catalog offers coats and shorts. You can model this by creating independent item descriptors to represent coats and shorts and putting each in its own database table. The XML repository definition for this model looks something like: <!-- The "coat" item type --> <item-descriptor name="coat"> <table name="coat" id-column-names="id" type="primary"> <property name="name"/> <property name="description"/> <property name="color"/> <property name="shippingWeight"/> <property name="size"/> <property name="season"/> </table> </item-descriptor>

03/01/2011

Citrisys Solutions, Chennai

57

Item Descriptor Inheritance


<!-- The "shorts" item type --> <item-descriptor name="shorts"> <table name="shorts" id-column-names="id" type="primary"> <property name="name"/> <property name="description"/> <property name="color"/> <property name="shippingWeight"/> <property name="size"/> <property name="pleated" data-type="boolean"/> </table> </item-descriptor> And the database data model has two unrelated tables:

03/01/2011

Citrisys Solutions, Chennai

58

Item Descriptor Inheritance


This approach has several drawbacks: Coats and shorts have a lot of properties in common, which in the above model means duplicated database columns and probably duplicated code. This model does not allow you to easily perform a query like: find all the items of clothing (shorts and coats) that have Star Wars in their description

An object-oriented approach like that used by the SQL repository lets you define a base item descriptor class called clothing to hold the attributes common to coats and shorts. You can use simple inheritance to make coats and shorts subclasses of clothing. You can then model the data in your clothing catalog as follows:

03/01/2011

Citrisys Solutions, Chennai

59

Item Descriptor Inheritance


The corresponding XML repository definition (with changes in bold type) looks like this:
<!-- The "clothing" item type, a base type --> <item-descriptor name="clothing" sub-type-property="type"> <!-- This is the primary table that holds clothing data --> <table name="clothing" type="primary" id-column-names="id"> <property name="type" data-type="enumerated"> <option value="coat"/> <option value="shorts"/> </property> <property name="name"/> <property name="description"/> <property name="color"/> <property name="size"/> <property name="shippingWeight"/> </table> </item-descriptor>

03/01/2011

Citrisys Solutions, Chennai

60

Item Descriptor Inheritance


<!-- The "coat" item type, now a subclass of "clothing" --> <item-descriptor name="coat" super-type="clothing" sub-typevalue="coat"> <table name="coat" type="auxiliary" id-column-names="id"> <property name="season"/> </table> </item-descriptor>
<!-- The "shorts" item type, now a subclass of "clothing" --> <item-descriptor name="shorts" super-type="clothing" sub-typevalue="shorts"> <table name="shorts" type="auxiliary" id-column-names="id"> <property name="pleated" data-type="boolean"/> </table> </item-descriptor>

03/01/2011

Citrisys Solutions, Chennai

61

Derived Properties
This feature enables one repository item to derive property values from another repository item or from another property in the same repository item. For example, an organization might have divisions, departments, and employees, organized in a tree structure. A repository represents this tree structure with division, department, and employee item descriptors. Each of these item descriptors might define a property called spendingLimit. A business rule might specify that an employees spending limit comes from their department if it is not set for that employee. If the spending limit is not set for the department it should be derived from the spending limit for the division. This derived property relationship is represented in a repository definition file as follows:

03/01/2011

Citrisys Solutions, Chennai

62

Derived Properties
<item-descriptor name="employee"> <property name="department" item-type="department"/> <property name="empSpendingLimit" data-type="int"/> <property name="spendingLimit" writable="false"> <derivation> <expression>empSpendingLimit</expression> <expression>department.spendingLimit</expression> </derivation> </property> </item-descriptor> <item-descriptor name="department"> <property name="division" item-type="division"/> <property name="deptSpendingLimit" data-type="int"/> <property name="spendingLimit" writable="false"> <derivation> <expression>deptSpendingLimit</expression> <expression>division.divSpendingLimit</expression> </derivation> </property> </item-descriptor> <item-descriptor name="division"> <property name="division" item-type="division"/> <property name="divSpendingLimit" data-type="int"/> </item-descriptor>

03/01/2011

Citrisys Solutions, Chennai

63

SQL Repository Item Properties


Enumerated Properties <property name="transactionType" data-type="enumerated"> <option value="credit" code="0"/> <option value="debit" code="1"/> <option value="purchase" code="2"/> </property>
Required Properties You can specify that a repository item property is required by setting a property tags required attribute: <property name="lastName" data-type="string" required="true" /> Unique Properties You may want a repository item property to require a unique value. <property name="login" data-type="string" required="true"> <attribute name="unique" value="true"/> </property>

03/01/2011

Citrisys Solutions, Chennai

64

SQL Repository Item Properties


Date and Timestamp Properties You can have a property whose value is set to the current time or date at the moment a repository item is created. You can do this by setting the feature descriptor attribute useNowForDefault. For example: <property name="creationDate" data-type="timestamp"> <attribute name="useNowForDefault" value="true"/> </property> Last-Modified Properties In some applications, it is useful to know when a repository item was last modified most recently. <item-descriptor name="article" last-modified-property="lastActivity"> <attribute name="updateLastModified" value="true"/> <table name=article type="primary> <property name="lastActivity" data-type="timestamp"/> ... </table> </item-descriptor When items of this type are added or updated, the lastActivity property is updated with the current time.

03/01/2011

Citrisys Solutions, Chennai

65

SQL Repository Item Properties


Transient Properties
The SQL repository lets you define properties of a repository item that are transient. Transient properties are never stored or read from the persistent data store. They are readable and writable, but not queryable. Transient properties provide applications a hook for custom objects that are not persisted by the repository. <item-descriptor name="user" sub-type-property="userType"> <property name="loggedIn" data-type="boolean"> <table name="user" type="primary" id-column-names="id"> <property name="userType" data-type="enumerated" column-name="user_type"> ... Here, the property loggedIn is a transient property.

03/01/2011

Citrisys Solutions, Chennai

66

SQL Repository Item Properties


Linking between Repositories
A property value can refer not just to another type of repository item, but also to a repository item in another repository.

<table name="employees" id-column-names="id"> ... <property name="work_address" item-type="workAddress" repository="/atg/userprofiling/LDAPRepository"/> </table>

03/01/2011

Citrisys Solutions, Chennai

67

SQL Repository Caching


Item and Query Caches Item caches hold the values of repository items, indexed by repository IDs. Item caching can be explicitly enabled for each item descriptor. Even if caching is explicitly disabled, item caching occurs within the scope of each transaction Query caches hold the repository IDs of items that match the given queries. Query caching is turned off by default.

03/01/2011

Citrisys Solutions, Chennai

68

SQL Repository Caching


Caching Modes Simple caching handles caches in each server locally; no attempt is made to synchronize updates across multiple server instances. This is the default cache mode.

Locked caching uses read and write locks to synchronize access to items stored by multiple caches.
Distributed TCP caching uses TCP to broadcast cache invalidation events to all servers in a cluster. Distributed JMS caching uses JMS to broadcast cache invalidation events to all servers in a cluster. Distributed hybrid caching uses TCP to send cache invalidation events only to those servers that are known to cache the target items.

03/01/2011

Citrisys Solutions, Chennai

69

ATG Servlet Bean (Droplet)


Most applications require a way to dynamically generate HTML from a Java object. The dsp:droplet tag lets you do this by embedding an ATG servlet bean. The servlet bean produces output that is included in the HTML page. Droplets will generate dynamic output at run time. There are OOTB droplets. Few are given below.
For ForEach RQLForEach Switch Range TargettingForEach RepositoryLookup IsEmpty IsNull

03/01/2011

Citrisys Solutions, Chennai

70

ATG Servlet Bean (Droplet)


The DynamoServlet class implements the javax.servlet.Servlet interface. It passes requests to the service method by passing a DynamoHttpServletRequest and DynamoHttpServletResponse as parameters. The DynamoServlet class extends atg.nucleus.GenericService, which allows an ATG servlet bean to act as a Nucleus component. This means that the ATG servlet bean has access to logging interfaces, can be viewed in the Component Browser, and has all the other advantages of a Nucleus service. Use of Droplet Separates Jsp code and java Code.

03/01/2011

Citrisys Solutions, Chennai

71

ATG Servlet Bean (Droplet)


How to Implement the Droplet in a Page? Import the Droplet <dsp:droplet name="/atg/dynamo/droplet/ForEach">

Implement the For Each to fetch the results. <dsp:droplet name=ForEach> <dsp:param name="array" bean="ClassroomService.enrolledStudents" /> <dsp:setvalue param=CurrentStudent paramvalue=element/> <dsp:oparam name=empty> No students in the class. </dsp:oparam> 03/01/2011 Citrisys Solutions, Chennai 72

ATG Servlet Bean (Droplet)


<dsp:oparam name=outputStart> Here is the list of students: </dsp:oparam> <dsp:oparam name=output> <dsp:valueof param=CurrentStudent.fullName/> </dsp:oparam> </dsp:droplet> Note:
The below code will fetch the results from an array. It is similar to for loop. It will loop through the array and display the results.

03/01/2011

Citrisys Solutions, Chennai

73

ATG Servlet Bean (Droplet)


Next, we can see how to extend the OOTB Droplets to add our custom requirements. Override the OOTB component and point it to your custom class. (The path of the component should be same as in the OOTB). For Example, lets try to override the ForEach Droplet. $class=com.test.MyCustomForEach. Create a class MyCustomForEach inside com/test, extends ForEach Droplet. public class MyCustomForEach extends ForEach { //include you custom requirements. }

03/01/2011

Citrisys Solutions, Chennai

74

ATG Servlet Bean (Droplet)


Next, we will see how to write a custom Droplet.
Create a Nucleus component. For example: $class=com.droplet.CTDCPriceRangeDroplet $scope=request Create a class which extends DyanmoServlet like the below. public class CTDCPriceRangeDroplet extends DynamoServlet{ //override the service method public void service(final DynamoHttpServletRequest pRequest, final DynamoHttpServletResponse pResponse) throws ServletException, IOException { //set the results: pRequest.setParameter("minPrice", minPrice); pRequest.setParameter("maxPrice", maxPrice); pRequest.serviceLocalParameter("output", pRequest, pResponse); }

03/01/2011

Citrisys Solutions, Chennai

75

ATG Servlet Bean (Droplet)


Next, we will see how to display the custom Droplet in jsp.
Import the droplet using importBean as we seen the previous section Implement the droplet like the below.

<dsp:droplet name=" CTDCPriceRangeDroplet"> <dsp:oparam name="output"> <dsp:valueof param="minPrice/> <dsp:valueof param=maxPrice/> </dsp:droplet> Note:
The minPrice and maxPrice are the custom parameters which we created in the customDroplet. Please see the previous slide.

03/01/2011

Citrisys Solutions, Chennai

76

FormHandlers
Atg Form handlers that can perform these tasks: Validate data before it is submitted. Detect missing information and display appropriate messages to the user. Direct users to different pages depending on form submission results. Read and write database or repository data. Form handlers are components that you typically build from one of the form handler classes provided by the ATG Adaptive Scenario Engine. All provided form handler classes are subclasses of atg.repository.servlet.GenericFormHandler, and inherit its properties and methods:

03/01/2011

Citrisys Solutions, Chennai

77

FormHandlers
ATG Relationship Management Platform includes the following form handler classes: SimpleSQLFormHandler for working with form data that is stored in a SQL database. RepositoryFormHandler for saving repository data to a database. ProfileFormHandler class to connect forms with user profiles stored in a profile repository. SearchFormHandler for specifying properties available to a search engine. You can also extend these and other form handler classes to handle the specific needs of your application.
03/01/2011 Citrisys Solutions, Chennai 78

FormHandlers - Form Error Handling


A Web application must identify and gracefully handle errors that might occur on form submission. For example, a user enters an alphabetic character in a field where an integer is required. Then, it should throws an error. If the form uses a form handler of class GenericFormHandler or one of its subclasses, exceptions that occur during form processing are saved to one of these form handler component properties: Property Purpose

formError

Boolean that is set to true if any errors occur during form processing.
A vector of the exceptions that occur during form processing.

formExceptions

03/01/2011

Citrisys Solutions, Chennai

79

FormHandlers - Form Error Handling


propertyExceptions A read-only property that returns a Dictionary of subproperties, one for each property set by the form. For each property that generates an exception, a corresponding subproperty in the propertyExceptions Dictionary contains that exception. For each property that does not generate an exception, the corresponding subproperty in the propertyExceptions Dictionary is unset.

03/01/2011

Citrisys Solutions, Chennai

80

SimpleSQLFormHandler
Dynamo defines a class, atg.droplet.sql.SimpleSQLFormHandler, which implements a form handler for querying, inserting, updating, and deleting rows from a database table. This form handler requires that each row to be edited can be uniquely identified by a set of key columns. In other words, it cannot be used for queries, updates, or deletes that operate on more than one row at a time. The SimpleSQLFormHandler lets you interact with a SQL database directly, by specifying the table rows to query or update. This form handler relies only minimally on the repository layer, it requires you to know exactly which items are required.

03/01/2011

Citrisys Solutions, Chennai

81

SimpleSQLFormHandler Navigation Properties


Handler method handleLookup handleUpdate handleDelete handleInsert Success/failure URL properties lookupSuccessURL lookupErrorURL updateSuccessURL updateErrorURL deleteSuccessURL deleteErrorURL insertSuccessURL insertErrorURL

03/01/2011

Citrisys Solutions, Chennai

82

SQL Form Handler Example


$class=atg.droplet.sql.SimpleSQLFormHandler $scope=session connectionURL^=TableManager.connectionURL keyColumns=NAME tableName=SKIER DBErrorURL=sqlError.jsp Lets name the component as SkierHandler. You can use the SkierHandler component to look up or change the properties of skiers who are registered with an application. For example, skiers can change the value of their preferredActivity property with this portion of the editPerson.jsp page:

03/01/2011

Citrisys Solutions, Chennai

83

SQL Form Handler Example


<tr> <td align=right><b>Your preferred activity:</b></td> <td><dsp:select bean="SkierHandler.value.preferredActivity"> <dsp:option value="Skiing">Skiing</dsp:option> <dsp:option value="Snowboarding">Snowboarding</dsp:option> <dsp:option value="X-Country">X-Country</dsp:option> </dsp:select> </td> </tr>

When a user submits this form, the preferredActivity property of the value property of the SkierHandler is set to the selected option, and is inserted in the appropriate row of the SKIER database table.

03/01/2011

Citrisys Solutions, Chennai

84

Repository Form Handler


The atg.repository.servlet.RepositoryFormHandler class provides methods and properties for working with repository items. You can use a component of this class to add, update, and delete repository items that use the same item descriptor. The RepositoryFormHandler offers several benefits: Requires only the repository item type for updates. Supports all repository types: HTML, XML, LDAP, and SQL. Caches repository data .Optimizes data access.

03/01/2011

Citrisys Solutions, Chennai

85

RepositoryFormHandler Properties
checkForRequiredProperties A boolean, specifies whether the form handler checks that all required properties are present during operation.
clearValueOnSet A boolean, specifies whether the value dictionary for an item is cleared and reset from the database when its repositoryId property changes. itemDescriptorName A string that specifies the item descriptor items handled by this RepositoryFormHandler. repository Specifies the repository where items are added, updated, and deleted. requireIdOnCreate A boolean, specifies whether an item ID must be user-supplied when an item is created. If set to true (the default), an error is thrown if no ID is provided. If set to false and no ID is provided, an ID is generated for the item on the fly.

03/01/2011

Citrisys Solutions, Chennai

86

RepositoryFormHandler Operations
Operation create Function Creates a repository item based on the value set in the form and adds it to the repository. If the repositoryId property is specified in the form, the new item is created with the given repository ID; otherwise, an auto-generated ID is used. Deletes from the repository the item specified by repositoryId.

delete

update

Updates the item described by repositoryId from the form values.

You associate one of these operations with a submit input tag. For example, the following input tag defines a submit button that creates a repository item: <dsp:input type="submit" bean="atg/dynamo/droplet/MyRepositoryFormHandler.create" value="Add CD"/>

03/01/2011

Citrisys Solutions, Chennai

87

ProfileFormHandler
Connects forms with user profiles stored in a profile repository. You can use the ProfileFormHandler to set user profile properties without writing any Java or SQL code. The ProfileFormHandler handles the following tasks: Profile creation and updates User login and logout. Assignment of existing roles and organizations to individual users and groups of users.

For example, when a user logs into a site, a form can invoke the login operation as follows: <dsp:input bean="ProfileFormHandler.login" type="submit" value="Submit"/>

03/01/2011

Citrisys Solutions, Chennai

88

Setting Profile Values


First Name: <dsp:input bean="ProfileFormHandler.value.firstname" maxlength="30size="25" type="text"/> Last Name: <dsp:input bean="ProfileFormHandler.value.lastname" maxlength="30 size="25" type="text"/> Email Address: <dsp:input bean="ProfileFormHandler.value.email" maxlength="30 size="25" type="text"/> <dsp:input bean="ProfileFormHandler.value.gender" type="radio" value="female"/>Female

<dsp:input bean="ProfileFormHandler.value.gender" type="radio value="male"/>Male


<dsp:input bean="ProfileFormHandler.create" type="submit" value=" Save "/>

03/01/2011

Citrisys Solutions, Chennai

89

Customizing ProfileFormHandler
You can extend the ProfileFormHandler in the same way you are extending the other FormHandlers. public class MyProfileFormHandler extends ProfileFormHandler. { protected void preCreateUser // invokes before the handlecreate() public boolean handleCreate()// create user. protected void postCreateUser // Invokes after the handleCreate() }

03/01/2011

Citrisys Solutions, Chennai

90

Writing Custom Form Handlers


Sometimes we need to create a custom form handler to meet our business requirements.
The Custom FormHander should extend atg.droplet.GenericFormHandler .

The GenericFormHandler class provides simple implementations of the DropletFormHandler interfaces methods and adds basic error handling logic. If errors occur in processing a form that uses GenericFormHandler, the errors are saved and exposed as properties of the form handler component.

Form handlers use special handler methods for linking form elements with Nucleus components. A handler method has the name handleX, where X represents the name of the form handler property being set. For Example, public boolean handleCreate (javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) { } 03/01/2011 Citrisys Solutions, 91 Chennai

Writing Custom Form Handlers


Form handlers typically implement an interface called DropletFormHandler. This interface has the following methods, which are called at specific points as the form is processed:
Method beforeSet afterSet When Called Before any setX methods are called After all setX methods are called

beforeGet
afterGet handleFormExc eption

Before any input tags that reference this component are rendered
After page rendering is complete, before the socket is closed If an exception occurs when trying to call the setX method of a form

03/01/2011

Citrisys Solutions, Chennai

92

Writing Custom Form Handlers


Now, let us look into creating a new custom formhandler. 1. Create a component for the formhandler. $class = path of the class. $scope= request. 2. Create a Formhandler on the same path mentioned by the component. public class customFormHandler extends GenericFormHandler. { public boolean handleRegister (javax.servlet.http.HttpServletRequest request,javax.servlet.http.HttpServletResponse response) { // this method can invoked through Jsp. } } 3. In Jsp, you can invoke this using the following code.
<dsp:input type="submit" value="Register Now" bean=" customFormHandler.register"/>

03/01/2011

Citrisys Solutions, Chennai

93

Form Handler Scope


A form handler component should be either request- scoped or sessionscoped. Most of the case it will be request scope. But, in certain situation it has to be Session scope. For Example, if your registration page contains multi-page, then , it will be necessary to set the scope to session.

03/01/2011

Citrisys Solutions, Chennai

94

Request Handling pipeline

One of Dynamos most important tasks is handling HTTP requests


Dynamo uses two request-handling pipelines: DAS servlet pipeline for JHTML requests DAF servlet pipeline for JSP requests Request handling can usually be broken down into a series of independent steps. In Nucleus-based applications, each of these steps is represented by a single Nucleus service that also implements the Servlet interface. Most requests handled by Nucleus are dispatched to the PageFilter filter or DynamoProxyServlet, either of which start the servlet pipeline. When the application server invokes PageFilter, it starts the DAF servlet pipeline by calling DynamoHandler, the first servlet in the pipeline. The last servlet in the pipeline is TailPipelineServlet.

03/01/2011

Citrisys Solutions, Chennai

95

Request Handling pipeline


Customizing Request handling Pipeline
A standard servlet pipeline is invoked every time Dynamo handles a request The atg.servlet.pipeline package provides interfaces that provide various mechanisms for linking servlets to create a pipeline. The heart of the servlet pipeline is the PipelineableServlet interface.

Dynamo also provides an implementation class PipelineableServletImpl that implements this interface; your own classes can implement PipelineableServlet by sub classing PipelineableServletImpl.

03/01/2011

Citrisys Solutions, Chennai

96

Request Handling pipeline


For example, suppose you have a servlet pipeline where a servlet called Servlet1 invokes a servlet called Servlet2.
Now suppose you want to insert another servlet, Servlet1a, between these two servlets in the pipeline. If Servlet1a implements PipelineableServlet, you can reroute the pipeline by changing the value of the Servlet1.nextServlet property so it points to Servlet1a rather than Servlet2, and set Servlet1a.nextServlet to point to Servlet2. But if Servlet1a implements InsertableServlet, you only have to set Servlet1a.insertAfterServlet to point to Servlet1, and Servlet1a is automatically spliced into the pipeline right after Servlet1 and before Servlet2.

03/01/2011

Citrisys Solutions, Chennai

97

Request Handling pipeline


PipelinableServlet Servlets that implement the PipelineableServletImpl interface have an nextServlet property which tells the sequence where the servlet to be inserted. PipelineableServlet interface has two sub-interfaces DispatcherPipelineableServlet InsertableServlet InsertableServlet Servlets that implement the InsertableServlet interface have an insertAfterServlet property that enables the servlet to insert itself in a specific spot in the pipeline. The key advantage of this mechanism is that it does not require modifying any existing servlets in the pipeline. To implement the InsertableServlet interface, you can subclass InsertableServletImpl. 03/01/2011 Citrisys Solutions, Chennai 98

Request Handling pipeline


Steps to customize Request handling pipeline:
Create a servlet which implements PipelinableServletImpl / InsertableServletImpl based on your implementation Create a component for the servlet created with property nextServlet or insertAfterServlet. Add the path of your servlet to the InitialServices Property of /atg/dynamo/servlet/Initial InitialServices+=/myServlet

Example for Insertable servlet: 1. Create a component $class=atg.dynamo.servlet.pipeline.URIPrinter insertAfterServlet=/atg/dynamo/servlet/pipeline/DynamoServlet

03/01/2011

Citrisys Solutions, Chennai

99

Request Handling pipeline


2.Create a class URIPrinter extends InsertableServletImpl on the same path mentioned in the component. public class URIPrinter extends InsertableServletImpl { public void service (DynamoHttpServletRequest request, DynamoHttpServletResponse response) throws IOException, ServletException { if(isloggingInfo) logInfo ("Handling request for " + request.getRequestURI ()); } passRequest (request, response); }

03/01/2011

Citrisys Solutions, Chennai

100

Request Handling pipeline


Example for Pipelinable Servlet 1.Create a component. $class=atg.dynamo.servlet.pipeline.URIPrinter nextServlet=/atg/dynamo/servlet/pipeline/DynamoServlet Also Change the components next property of servlet after which you are going to insert your servlet. 2. Create a class URIPrinter extends PipelineableServletImpl on the same path mentioned in the component. public class URIPrinter extends PipelineableServletImpl { public void service (DynamoHttpServletRequest request, DynamoHttpServletResponse response) throws IOException, ServletException { if(isloggingInfo) logInfo ("Handling request for " + request.getRequestURI ()); } passRequest (request, response); }

03/01/2011

Citrisys Solutions, Chennai

101

Transaction Management

A transaction is a set of actions that is treated as an atomic unit.


Either all the actions take place , or none of them take place. When all the actions runs successfully the transaction commits, otherwise the transaction roll backs. For example transfer from one bank account to another. The transfer requires two separate actions. An amount is debited from one account, then credited to another account. Here either both the actions should take place or none. This means that both actions must take place within the same transaction. Each active transaction is represented by a transaction object, which implements the interface javax.transaction.Transaction. This object keeps track of its own status, indicating if it is active, if it has been committed or rolled back, and so on.

03/01/2011

Citrisys Solutions, Chennai

102

Transaction Management
TransactionManager
A transaction Manager provides services to support the management of transactional resources. The Transaction Manager is a services provided by the application server. The service implements a java interface javax.transaction.TransactionManager. The detailed operation of the Transaction Manager is normally hidden from the developer. The programmer need only worry about setting up transactional boundaries within the code. ATG uses TransactionManager as nucleus components. These components can be difficult to use. Fortunately ATG provides TransactionDemarcation class that allows you to demarcate program areas.

03/01/2011

Citrisys Solutions, Chennai

103

Transaction Management
TransactionDemarcation
This a a helper class that simplify the management of transaction boundaries. Transaction Demarcation is a term used to define the start and end points of a Transaction. This class contains two methods.

1.The begin() method is used to indicate the involvement of this process in the current transaction .Depending upon the arguments passed to this method,TransactionManager will decide whether to start a new transaction or have this process join in an existing transaction or produce an error. void begin(javax.transaction.TransactionManager pTransactionmanager,int pTransAtrribute)throws TransactionDemorcationExeception.
2. The end() method is used to indicate that the current process has completed its part of the transaction. Depending upon the mode, this may result in a commit or it may defer the commit to some other process. public int end() This method returns a status code indicating what happened to the transaction during the demarcated area.

03/01/2011

Citrisys Solutions, Chennai

104

Transaction Management
To use Transaction you need to understand the transaction demarcation modes: 1) Required: Indicates that a transaction must be in place in the demarcated area. If a transaction is already in place in the area, nothing further is done. If no transaction is in place, one is created when the demarcated area is entered and ended when the demarcated area ends.
2) RequiresNew: Indicates that all activity within the demarcated area must occur in its own separate transaction. If no transaction is in place in the area, a transaction is created at the beginning of the demarcated area and ended at the end of the demarcated area. If a transaction is in place when the demarcated area is entered, that transaction is suspended, and a new transaction is begun, at the end of the demarcated area, the new transaction is ended, and the original transaction is resumed. 3) NotSupported: Indicates that a transaction must not be in place in the demarcated area. If no transaction is in place in the area, nothing further is done. If there is a transaction in place when the demarcated area is entered, that transaction is suspended, then resumed at the end of the demarcated area.

03/01/2011

Citrisys Solutions, Chennai

105

Transaction Management
4) Supports: This mode does nothing. If a transaction is in place when the demarcated area is entered then that transaction remains in place. Otherwise, the area is executed without a transaction in place.
5) Mandatory: Throws an exception if a transaction is not in place when the demarcated area is entered. This mode does not create a transaction; it is used to verify that a transaction is in place where the developer expects 6 )Never: Throws an exception if there is a transaction in place when demarcated area is entered. This mode does not end or suspend any existing transactions; it is used to verify that a transaction is not in place where the developer does not expect one.

03/01/2011

Citrisys Solutions, Chennai

106

Scheduler Services
Most server-side applications have routine tasks that must be performed periodically. For example, a component in the application might need to clear a cache every 10 minutes. Dynamo includes a Scheduler service, atg.service.scheduler.Scheduler, for doing this job. Writing a Schedulable Component. 1. Configure a Schedulable Component. scheduler=/atg/dynamo/service/Scheduler schedule=every 10 seconds. scheduler points to a Scheduler such as the standard Dynamo Scheduler. schedule points to the standard Dynamo Scheduler. The schedule property can be set in a wide variety of formats. Please refer the Atg Programming Guide for different time settings.

03/01/2011

Citrisys Solutions, Chennai

107

Scheduler Services
Write a class which implements Scehdulable public class HelloJob extends GenericService implements Schedulable { // Scheduler property Scheduler scheduler; public Scheduler getScheduler () { return scheduler; } public void setScheduler (Scheduler scheduler) { this.scheduler = scheduler; } // Schedule property Schedule schedule; public Schedule getSchedule () { return schedule; } public void setSchedule (Schedule schedule) { this.schedule = schedule; }
// Schedulable method public void performScheduledTask (Scheduler scheduler, ScheduledJob job) { System.out.println ("Hello"); }

03/01/2011

Citrisys Solutions, Chennai

108

Scheduler Services
// Start method int jobId; public void doStartService () throws ServiceException { ScheduledJob job = new ScheduledJob ("hello", "Prints Hello", getAbsoluteName (), getSchedule (), this, ScheduledJob.SCHEDULER_THREAD); jobId = getScheduler ().addScheduledJob (job); } // Stop method public void doStopService () throws ServiceException { getScheduler ().removeScheduledJob (jobId); }
}

03/01/2011

Citrisys Solutions, Chennai

109

Dynamo Message System


The Dynamo Application Framework includes a number of JMS-related tools, which are known collectively as the Dynamo Messaging System (DMS). The DMS supports two JMS Providers - Local JMS -> Non Durable (Message will not be persisted). - SQL JMS -> Durable ( Message will be stored in the Database and it is most widely used.) PatchBay is an API and configuration system layered on top of JMS. Patch Bay is designed to ease the development of messaging applications in Dynamo. The PatchBay API allows Nucleus components to send and receive messages. The PatchBay system uses an XML file to specify how these components should be connected. NOTE: The DMS System is very flexible. We can use a third-party JMS Provider, with or without PatchBay.

03/01/2011

Citrisys Solutions, Chennai

110

Dynamo Message System


Local JMS
Local JMS can travel only between components in the same Dynamo process. Local JMS delivers messages synchronously. This means that when a component sends a message, the sending component will block until the receiving components have received and processed the message. In fact, the entire message sending and receiving process occurs within a single thread. As a result, both the sending and receiving of the message occurs in the same transaction.

To make sure the sender and receiver both carry out their actions in the same request, the message should be carried over Local JMS.
However, many messaging applications require messaging to be asynchronous( SQL JMS). When a sender sends a message asynchronously, the message is handed off to the JMS provider, and the sender continues on with its work.

03/01/2011

Citrisys Solutions, Chennai

111

Dynamo Message System


SQL JMS
For example, ATG Commerce uses asynchronous messaging to process an order. Each stage in the order (calculating tax, checking inventory, sending orders to shipping houses, sending confirmation e-mail to the user) is a single action that is activated by an incoming message from the previous stage, and ends by sending a message to the next stage in the process. Another key difference between Local JMS and SQL JMS is message persistence. Local JMS stores no state, so if the system fails, all messages are lost. SQL JMS uses an SQL database for persistence of messages. This insures that messages will not get lost in the event of a system failure, and enables support for persistent queues and durable subscriptions. In SQL JMS, the sending of a message and the receiving of a message occur in separate transactions. This doesnt mean that the receiver has successfully received the message. It just means that SQL JMS has successfully delivered the message to its destination.

03/01/2011

Citrisys Solutions, Chennai

112

Dynamo Messaging System


Patch Bay
Patch Bay is designed to simplify the process of creating JMS applications.

Patch Bay includes a simplified API for creating Nucleus components that send and receive messages, and a configuration file where we declare these components and your JMS destinations.
When Dynamo starts up, it examines this file and automatically creates the destinations and initializes the messaging components. This means our code does not need to handle most of the JMS initialization tasks, such as obtaining a ConnectionFactory, obtaining a JMS Connection, creating a JMS Session, etc.

03/01/2011

Citrisys Solutions, Chennai

113

Dynamo Messaging System


The Patch Bay is represented in Nucleus as the component /atg/dynamo/messaging/MessagingManager, which is of class atg.dms.patchbay.PatchBayManager.
In addition to the properties file, the MessagingManager uses an XML file called the DMS configuration file to configure the individual parts of the Patch Pay system, such as JMS providers, message sources and sinks, and destinations. The definitionFile property of the MessagingManager component names the DMS configuration file whose value is /atg/dynamo/messaging/dynamoMessagingSystem.xml

03/01/2011

Citrisys Solutions, Chennai

114

Dynamo Messaging System


JMS Destinations
JMS defines two types of destinations, topics and queues. Most JMS providers support both topics and queues, and an application can make use of both. Dynamo applications typically use topics, as they offer the most flexibility for expansion. However, a messaging application might use queues for certain purposes, such as load balancing. Topics - are non-persistent by default. If a message is sent to a topic, it is delivered to all subscribers to that topic that are currently online, and then removed. Any subscriber that is offline does not receive the message. If no subscribers are currently online, the message is simply removed from the topic without being delivered anywhere. Queue -typically are persistent. If a message is sent to a queue but no receiver is online, the message is kept in the queue, waiting for a receiver to connect and start reading from the queue. After a message is delivered to a single receiver, it is removed from the queue. 03/01/2011 Citrisys Solutions, 115 Chennai

Dynamo Messaging System


Steps to Implement 1) Create a Message Source:
Message Source/Sender A nucleus component with the java class implementing MessageSource class. Create a message a MessageSourceContext . Implement the Interface methods. Create a sender method to send the Message of particular Type using the CreateMessage. Send the Message using the sendMessage method and by specifying the Import.

Please see the next slide for the sample Message source.

03/01/2011

Citrisys Solutions, Chennai

116

Dynamo Messaging System


public class SampleJMSSender implements MessageSource,Serializable{ private MessageSourceContext mContext; private boolean mStarted=false; public void setMessageSourceContext(MessageSourceContext pContext) { mContext=pContext; } public void startMessageSource() { mStarted=true; } public void stopMessageSource() { mStarted=false; } public void SendMessage(String msgText) throws JMSException { if(mStarted && mContext != null) { TextMessage msg= mContext.createTextMessage("JMSPort"); msg.setJMSType("jms.SampleJMSSender"); msg.setText(msgText); mContext.sendMessage("JMSPort",msg); } } 03/01/2011 Citrisys Solutions, 117 }

Chennai

Dynamo Messaging System


From the previous slide, SendMessage method is used to send a message to the corresponding JMS port Messages Type can be Text Message,ObjectMessage, MapMessage,BytesMessage,StreamMessage JMSPort Specifies the corresponding port where the message has to be delivered, these port information's are configured in the Patch Bay.

03/01/2011

Citrisys Solutions, Chennai

118

Dynamo Messaging System


1) Create a Message Sink:
Message Sink/Receiver A nucleus component with the java class implementing MessageSink class. Implement the Interfaces receive Message method to receive the Message of particular Type.

Please see the next slide for the sample Message Sink.

03/01/2011

Citrisys Solutions, Chennai

119

Dynamo Messaging System


public class SampleJMSReciever implements MessageSink { public void receiveMessage(String portName, Message msg) throws JMSException { if(msg !=null && !msg.equals("")) { if(msg instanceof TextMessage){ TextMessage msgText=(TextMessage) msg; if(isloggingDebug) logInfo((String)msgText.getText()); } } } } In the above Code, The Message is received using the receiveMessage method, and the obtained Message is printed.
03/01/2011 Citrisys Solutions, Chennai 120

Dynamo Messaging System


3) Create PatchBay
PatchBay performs operations of establishing a connection factory between sender and receiver. PatchBay can be created by using dynamoMessagingSystem.xml.

Sample Patch Bay <?xml version="1.0" encoding="UTF-8"?> <dynamo-message-system> <patchbay> <message-source> <nucleus-name> /atg/dynamo/SampleJMSSender</nucleus-name> <output-port> <port-name>JMSPort</port-name> <output-destination> <provider-name>sqldms</provider-name> <destination-name>sqldms:/SampleJMSSender</destination-name> <destination-type>Topic</destination-type> </output-destination> </output-port> </message-source>

03/01/2011

Citrisys Solutions, Chennai

121

Dynamo Messaging System


<message-sink> <nucleus-name> /atg/dynamo/SampleJMSReciever</nucleus-name> <input-port> <port-name>JMSPort</port-name> <input-destination> <provider-name>sqldms</provider-name> <destination-name> sqldms:/SampleJMSSender </destination-name> <destination-type>Topic</destination-type> </input-destination> </input-port> </message-sink> </patchbay>

03/01/2011

Citrisys Solutions, Chennai

122

Dynamo Messaging System


<message-registry> <message-family> <message-family-name> JMSSample </message-family-name> <message-type> <jms-type> jms.SampleJMSSender </jms-type> <message-class>com.dollar66.jms.SampleJMSSender </message-class> <message-context>session</message-context> <display-name-resource> scheduledOrderEventDisplayName </display-name-resource> <description-resource> scheduledOrderEventDescription </description-resource> </message-type> </message-family> </message-registry> </dynamo-message-system>

03/01/2011

Citrisys Solutions, Chennai

123

Dynamo Messaging System


Finally, Create a SQLJmsProvider component to specify the Topics/Queues needed by the application using requiredTopics property.
requiredTopicNames+=SampleJMSSender

03/01/2011

Citrisys Solutions, Chennai

124

You might also like