Professional Documents
Culture Documents
DEV1 Ch02 Components
DEV1 Ch02 Components
Part I
Chapter 2 • Components
ACC
— Using component logging properties
2-2
Nucleus Components
• Nucleus components implement all logic in the
ATG framework
Profile
Album
Promo
Slot
Featured
Songs
Venue Concert
Targeter Lookup
2-3
Dynamusic and Components
• All of the "back end" at Dynamusic.com is
implemented in the form of components,
including components to
— Handle access to the database where user,
music and event info is stored
— Handle user input, such as profile data and
album reviews
— Apply business logic to deliver personalized
2-4
What is Nucleus?
• Nucleus is the ATG container for managing
components
— Provides a hierarchical component name
space
• Each component has a unique full name so
2-5
The Features of Nucleus
• Naming service: pathname to object mapping
— Pages can access components
2-6
What is a JavaBean?
• A JavaBean is a Java class with
— a no-argument constructor
methods
methods: property:
public String getItemType () …
itemType
public void setItemType (String) …
2-7
What is a Nucleus Component?
property2
+ property1=abc
property2=… = property1 = abc
property2 = …
2-8
Multiple Components From One Class
SongLookup
SongLookup.properties
$class=ItemLookup
itemType=song = itemType = song
ItemLookup
+ repository=Songs repository=Songs
itemType
repository
+ ConcertLookup.properties ConcertLookup
$class=ItemLookup
itemType=concert
Repository=Events
= itemType = concert
repository=Events
2-9
Configuring a Component
• The ACC allows you to configure initial values for the
properties defined in the Java class
ellipsis button,
launches an editor
appropriate to the
property’s type
(e.g. an array editor)
2-10
Linking to Another Component
• You can link a property to another component
2-11
Component Names
• Full component names are unique, containing folder
names followed by the simple component name,
separated by forward slashes
/atg/dynamo/service/SMTPEmail
2-12
Instructor Demo: Components
• Using the ACC to view and modify components
— Browsing components
2-13
Properties Files
# /dynamusic/FeaturedSongs
#Wed Mar 26 11:29:39 EST 2003
$class=dynamusic.FeaturedSongs
$description=A simple example
component.
$scope=global
songs=Rhapsody in Blue,April
in Paris,Satisfaction,
Strawberry Fields
2-14
CONFIGPATH Environment Variable (1)
• Where does ATG look for .properties files?
— In directories specified by the CONFIGPATH
• E.g. CONFIGPATH=C:\ATG\ATG7.0\Dynamusic\config
CONFIGPATH
points here
2-15
CONFIGPATH Environment Variable (2)
• CONFIGPATH actually points to many folders
(like operating system’s PATH)
• Where does Nucleus look for the properties file
when it creates a component instance?
— In directories specified by the CONFIGPATH
2-16
Example: CONFIGPATH Layering
CONFIGPATH:
<atg_dir>\ATG7.x\DAS\config\config.jar;
<atg_dir>\ATG7.x\Dynamusic\config;
DYNAMO_HOME\localconfig
…\DAS\config.jar\atg\dynamo\Configura
tion.properties
/atg/dynamo/
emailHandlerHost=localhost Configuration
emailHandlerHost =
smtp.dynamusic.
…\Dynamusic\config\atg\dynamo\Configu com
ration.properties
emailHandlerHost=smtp.dynamusic.com
2-17
Setting CONFIGPATH
• Each module sets its own CONFIGPATH in the
module manifest file
…/Dynamusic/META-INF/MANIFEST.MF
Manifest-Version: 1.0
ATG-Config-Path: config/
ATG-Required: DAS
CONFIGPATH=
<atg_dir>\ATG7.x\DAS\config\config.j
ar;<atg_dir>\ATG7.x\Dynamusic\config
;DYNAMO_HOME\localconfig
2-18
CONFIGPATH and the ACC
• Where does the ACC save .properties files?
— The defaultForUpdates layer
…/<module-name>/config/CONFIG.properties
defaultForUpdates=true
2-19
Component Instantiation
• When Nucleus creates a new instance of a
component, it
1. Looks in CONFIGPATH folders for
properties file(s)
2. Creates a live component instance, setting
values from properties file(s)
3. If the component references other
components, Nucleus starts those
— Component instantiation can be tested in the
ACC using the (start) and (stop) buttons
2-20
Configured vs. Live Property Values
• Component property
values are initialized
from properties
configuration files
when the component
is instantiated
2-21
Component Scope
Component scope may be
• global (the default)
• session
• request
2-22
Global Scope
• One instance of the component is shared by all
users of the application
• State of the component is same for all users
Browser/User #1
TopSongs.java
dailyFave
TopSongs
+
(global instance)
2-23
Session Scope
Browser/User #1
Session #1
SongHistory
(session instance)
lastThreeSongs =
Respect,Strawberry
Fields… SongHistory.java
lastThreeSongs
Browser/User #2 +
SongHistory.properties
Session #2
$class=SongHistory
SongHistory
$scope=session
(session instance)
lastThreeeSongs = In
The Mood, April
in Paris…
2-24
Request Scope
• Each request gets a different copy of the
component
Request #1
SongSearch
(request instance) SongSearch.java
results = Man in the results
Moon, Piano Man…
+
Request #1
SongSearch.properties
Request #2
$class=SongSearch
SongSearch $scope=request
(request instance)
results = Here Comes
Request #2 the Sun, You Are My
Sunshine…
2-25
Example: Scope
• Imagine components that
1. Keep track of how long a user has been on
a site
2. Keep track of how many users are on the
site
3. Look up an item in a database?
4. Handle form input from the user?
2-26
A Prominent Session-Scoped Component
• The Profile component is central to all
personalization on the ATG platform:
— Full name is:
/atg/userprofiling/Profile
— Intimately connected to the Profile
Repository, which stores information for
registered users
• The Profile component is a live representation of
a user’s information
• At the start of a session, the Profile component is
unpopulated
2-27
Demo 2
• Explore session-scoped components:
— Container for sessions is
/atg/dynamo/servlet/sessiontracking/SessionManager
— Note one session component (for ACC)
• Drill down to see copy of the Profile
component
— Start a second session (open a new browser and
go to http://localhost:8840)
— Notice a new session component is created,
with its own copy of the Profile component
2-28
Logging
• Most components can log information about
their status
• Mainly used for trouble shooting
2-29
Types of Logging Messages
• Error: Indicates an
immediate problem
• Warning: May
indicate future problem
• Info: Events that occur
during normal
operation of component
• Debug: Events specific
to internal workings of
the component
2-30
Log Files
• Logging messages are captured in log files in
DYNAMO_HOME\logs
— info.log
— warning.log
— error.log
— debug.log
2-31
Console Logging
• By default, logging information is also directed
to the console
2-32
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 Logging properties
loggingInfo=true
loggingDebug=false 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
2-33
Creating Components in the ACC
2-34
Summary
In this chapter, you learned
• How properties files configure Nucleus
component properties
• How CONFIGPATH layering allows you to
modify component configuration in modules
• About the three component scopes: global,
session and request
• How to use the ACC to modify properties files
2-35
For More Information
• Dynamo Programming Guide, "Nucleus:
Organizing JavaBean Components"
2-36
Exercises
• Set the default update layer to your Dynamusic
module
• Modify an existing component (SMTPEmail)
using the ACC
• Create and configure a new FeaturedSongs
component based on a supplied class (which will
be used in the exercises for the next chapter)
2-37