Atg Core
Atg Core
Atg Core
03/01/2011
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
ATG Framework includes the following core modules. * DAF (Dynamo Application Framework) * DPS (Dynamo Personalization Server) * DSS (Dynamo Scenario Server)
03/01/2011
ATG Portal
03/01/2011
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
03/01/2011
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
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
03/01/2011
03/01/2011
10
/atg/dynamo/service/SMTPEmail
03/01/2011
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
12
03/01/2011
13
03/01/2011
14
/artists/d/DaveMathews global
03/01/2011
15
03/01/2011
16
/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
17
03/01/2011
18
03/01/2011
19
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
20
03/01/2011
21
****567890123456
03/01/2011
22
03/01/2011
23
03/01/2011
24
03/01/2011
25
For source code please see the attachment. For More information please refer atg documentation Progamming Guide Creating CustomTag Converters.
03/01/2011
26
03/01/2011
27
03/01/2011
28
03/01/2011
29
03/01/2011
31
03/01/2011
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
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
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
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
36
03/01/2011
37
if (ifLoggingDebug())
logDebug("adding artist: " + artistItem.getPropertyValue("name"));
} catch (RepositoryException e) {
if (isLoggingError()) {
03/01/2011
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
39
03/01/2011
40
03/01/2011
41
MutableRepositoryItem mutSongItem =
mutRepos.getItemForUpdate(pSongid,"song");
mutSongItem.setPropertyValue("artist",artistItem); mutRepos.updateItem(mutSongItem);
}
03/01/2011 Citrisys Solutions, Chennai 42
03/01/2011
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
45
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
46
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>
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; }
<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
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
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
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
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
56
03/01/2011
57
03/01/2011
58
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
59
03/01/2011
60
03/01/2011
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
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
63
03/01/2011
64
03/01/2011
65
03/01/2011
66
03/01/2011
67
03/01/2011
68
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
69
03/01/2011
70
03/01/2011
71
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
03/01/2011
73
03/01/2011
74
03/01/2011
75
<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
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
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
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
79
03/01/2011
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
81
03/01/2011
82
03/01/2011
83
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
84
03/01/2011
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
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
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
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
88
03/01/2011
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
90
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
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
92
03/01/2011
93
03/01/2011
94
03/01/2011
95
Dynamo also provides an implementation class PipelineableServletImpl that implements this interface; your own classes can implement PipelineableServlet by sub classing PipelineableServletImpl.
03/01/2011
96
03/01/2011
97
03/01/2011
99
03/01/2011
100
03/01/2011
101
Transaction Management
03/01/2011
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
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
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
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
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
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
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
109
03/01/2011
110
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
111
03/01/2011
112
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
113
03/01/2011
114
Please see the next slide for the sample Message source.
03/01/2011
116
Chennai
03/01/2011
118
Please see the next slide for the sample Message Sink.
03/01/2011
119
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
121
03/01/2011
122
03/01/2011
123
03/01/2011
124