You are on page 1of 20

Developing ATG Applications

Part I
Chapter 11 • Custom Components

Using ATG Repositories, Scenario PersonalizationSM


and the Dynamo Application Framework
Objectives
After completing this chapter you will be able to
• Understand when and what type of custom

components will need to be created in your


application
• Create custom component JavaBean classes

• Integrate custom components in to the Nucleus

• Use ATG's application logging facilities in a

component

11-2
Custom Components
• Although ATG provides many useful
components and classes, your application will
probably need functionality not provided by ATG
• ATG can easily incorporate functionality
provided in components using custom Java
classes

11-3
Dynamusic Custom Components
• Dynamusic needs custom components for many
functions such as to
— Manage low-level repository operations

• Maintain item inter-relationships

— Handle complex data input forms

— Parse mp3 files and save associated repository

info
— Trigger periodic "clean-ups" of the Events

Repository for past events

11-4
Types of Components
• Most components in ATG fall in to one of these
categories
— Service – a component that provides

functionality that one or more systems


depends on (e.g. an MP3 parsing service)
— Form Handler – a component to validate and

manage form input data


— Servlet Bean – a droplet to handle page

display logic

11-5
Java Development in ATG
• In order to use your custom classes, you must
add your classes to your module's CLASSPATH
• Each module can specify one or more directories
or .jar files to add to ATG's CLASSPATH in the
manifest file

<module-name>/META-INF/MANIFEST.MF

Manifest-Version: 1.0
ATG-Required: DAS DPS DSS
ATG-Config-Path: config/
ATG-Class-Path: classes/ lib/classes.jar

11-6
Example: SongsManager

/dynamusic/ /dynamusic/ It is a common


Songs
SongsManager Repository practice to have
repository one component
userRepository
/
that handles all
… atg/userprofili
ng/ProfileAdapt
low-level
addArtistToSong()
erRepository interaction with a
createArtistFromUser()
repository
(creating item
addSongToAlbum()
relationships, etc.)

11-7
JavaBeans
• ATG components are
JavaBeans
• Properties are
implemented with get
and set methods
SongsManager.java
public class SongsManager {
private Repository mRepository = null;
public Repository getRepository() {
return mRepository;
}
public void setRepository(Repository pRepository) {
mRepository = pRepository;
}
}

11-8
GenericService (1)
• ATG provides a base class that provides smooth
integration into the ATG Nucleus:
atg.nucleus.GenericService
• Properties include
— loggingDebug/Error/Info/Warning –

properties that let the developer set the


logging level
— name/nameContext – name of the

component within the Nucleus

11-9
GenericService (2)
• Other useful methods include
— resolveName() – find a component by its

Nucleus pathname
— isRunning() – what is the current status of

this component
— doStartService/doStopService() –

methods to be overridden by the sub-class,


run when the component is started or stopped
by the Nucleus

11-10
Application Logging
• Custom components should take advantage of
ATG's logging system. Methods:
— logDebug

— logError

— logInfo

— logWarning

11-11
Logging Implementation
• ATG application logging is implemented using
the Java event listener model

Log Log File


Log File
Log listener: Log File
Log message LogQueue
source
(implements
Application
Logging) Log
message
Log
listener:
ScreenLog

11-12
Example: Application Logging
SongsManager.java
public class SongsManager extends atg.nucleus.GenericService
{
public void addArtistToSong(String pSongid, pArtistid) {
if (isLoggingDebug())
logDebug("Add artist" + pArtistid + " to " +
pSongid);
try {
/* add artist to song…*/
}
catch (RepositoryException e) {
if (isLoggingError())
logError("Unable to add artist to song", e);
}

}
}

11-13
Working With Java
• ATG and Java can be used with a variety of
development environments
• In this course you will use Eclipse

• language
sensitive
editor
• automatic
compilation

11-14
Configuring Eclipse with ATG (1)
• In order to compile code with ATG classes, you
must configure your project correctly
— ATG project wizards do most of the

configuration for you

11-15
Configuring Eclipse with ATG (2)
• You must specify the Java build path

.java
source
files

.class
compiled
output

11-16
Important Note on Compilation
• Eclipse will automatically (try to) compile
whenever you save (errors will be displayed in
the margin)
• If you change your Java class – remember
to restart Dynamo and the ACC!

11-18
Summary
In this chapter, you learned
• That ATG components are based on JavaBean

classes
• How to create custom components that subclass

ATG's GenericService base class for full


integration with Nucleus
• How your custom component can take

advantage of the ATG application logging facility

11-19
For More Information
• API Reference
— atg.nucleus package

— atg.nucleus.logging package

• Dynamo Programming Guide, "Nucleus:


Organizing JavaBean Components"
• Sample code included in ATG – many delivered
modules include a src/Java directory
• For more information about JavaBeans, see
http://java.sun.com/products/javabeans/
— Includes a tutorial, tech spec, documentation,
etc.

11-20
Exercises
• Create a SongsManager class with a repository
property and the stub for a
deleteAlbumsByArtist method
• Create, configure and test a Nucleus component
based on your class

11-21

You might also like