[go: up one dir, main page]

0% found this document useful (0 votes)
269 views210 pages

FrameworksFundamentals Trainingv5

This document provides an overview and agenda for a training course on frameworks fundamentals. The course objectives are to teach solution architects and developers about the components that make up a typical Java/J2EE application at TELUS and how to use key framework building blocks. The agenda covers topics like module stereotypes, service design, Spring fundamentals, and configuration frameworks. The document defines what a framework is and discusses the TELUS methods for specifying and designing architectural frameworks. It also provides examples of concepts like the services layer, persistence layer, and domain objects.

Uploaded by

Sana Raheel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
269 views210 pages

FrameworksFundamentals Trainingv5

This document provides an overview and agenda for a training course on frameworks fundamentals. The course objectives are to teach solution architects and developers about the components that make up a typical Java/J2EE application at TELUS and how to use key framework building blocks. The agenda covers topics like module stereotypes, service design, Spring fundamentals, and configuration frameworks. The document defines what a framework is and discusses the TELUS methods for specifying and designing architectural frameworks. It also provides examples of concepts like the services layer, persistence layer, and domain objects.

Uploaded by

Sana Raheel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 210

1

Frameworks
Fundamentals
(Compressed Version Part 1 of 2)
Critical Skills Training
EA - Frameworks

August 2007

TELUS Confidential

Agenda Part 1 of 2
Introduction and Objectives
Overview
Services Architecture
Module Stereotypes
Services Layer
Persistence Layer
Break
Assembling the Service
Spring Fundamentals
Configuration Framework
Break
Service Consumers
Web Application
Other Frameworks
Design & Implementation Guidelines
Review
Q&A
Wrap-up
August 2007

TELUS Confidential

Introduction
Instructor:
Gabriel Rosu

Logistics:
Restrooms
Water / refreshments
Fire exits
Other / Questions?

August 2007

TELUS Confidential

Introduction Course Description


Prerequisites

JAVA

(or Knowledge of)

J2EE Concepts

Audience

Solution Architects
D&S J2EE Developers

Objectives

Team members will


Learn about the various components that should make up a typical TELUS
J2EE Application.
Understand when and how to use key framework building blocks.

Content

An in-depth discussion of
Module stereotypes
Service design
Frameworks

August 2007

TELUS Confidential

Overview
Introduction and Objectives

Overview
Services Architecture
Module Stereotypes
Services Layer
Persistence Layer
Assembling the Service
Spring Fundamentals
Configuration Framework
Service Consumers
Web Application
Other Frameworks
Design & Implementation Guidelines
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

Frameworks

What is a FRAMEWORK?

August 2007

TELUS Confidential

Frameworks
Definitions (from dictionary.reference.com)
A structure for supporting or enclosing something else, especially a skeletal support
used as the basis for something being constructed.
A set of assumptions, concepts, values, and practices that constitutes a way of viewing
reality
In object-oriented systems, a set of classes that embodies an abstract design for
solutions to a number of related problems.

In the context of TELUS Java/J2EE Applications, frameworks consist of:


Standards and guidelines
Building block code
Architectural directions
Design approaches and considerations

August 2007

TELUS Confidential

TELUS Methods
Architectural Frameworks are driven by requirements specified within:
Execution Services Specification (TA235-A)
Completed by the technical architect of each project
Created during the Define Technical Architecture task and refined during the Execution
Environment tasks in the Design Technical Architecture activity

Collection of run-time technology services, control structures, and supporting


infrastructures upon which application software runs
Highlights the guiding principles, frameworks, and/or methodology to apply during the
subsequent steps
August 2007

TELUS Confidential

TELUS Methods
Architectural Frameworks are designed and detailed within:
Execution Services Design (TA355)
Completed by the component technical designers of each project (eg. Frameworks team)
Created during the Select and Design Execution Environment task and detailed during
the Install and Build Execution Environment task

Documents the design specifics for the selected execution architecture services

August 2007

TELUS Confidential

10

Services Architecture
Introduction and Objectives
Overview

Services Architecture
Module Stereotypes
Services Layer
Persistence Layer
Assembling the Service
Spring Fundamentals
Configuration Framework
Service Consumers
Web Application
Other Frameworks
Design & Implementation Guidelines
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

11

High-Level Architecture
Service-Oriented Approach

August 2007

TELUS Confidential

12

Module Stereotypes
Introduction and Objectives
Overview
Services Architecture

Module Stereotypes
Services Layer
Persistence Layer
Assembling the Service
Spring Fundamentals
Configuration Framework
Service Consumers
Web Application
Other Frameworks
Design & Implementation Guidelines
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

13

Module Stereotypes
The Module Stereotypes should serve as a roadmap for the technical design and the
building of an application
Purpose
To identify and describe the various components that are used within a typical TELUS
Java/J2EE application
To show the relationships and interactions of components with one another
To depict architectural directions and design approaches
To identify which components are application-specific and which ones are architectural in
nature (i.e. framework component)

August 2007

TELUS Confidential

14

Module Stereotypes

August 2007

TELUS Confidential

15

Services Layer
Introduction and Objectives
Overview
Services Architecture
Module Stereotypes

Services Layer
Persistence Layer
Assembling the Service
Spring Fundamentals
Configuration Framework
Service Consumers
Web Application
Other Frameworks
Design & Implementation
Guidelines
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

16

Services Layer
What is a Service?
Logical grouping of operations that perform a
business function
A means to expose functionality that can be
used by various systems

Characteristics
Use case centric
Self-contained
May stand on its own or be part of a larger set
of functions
Stateless
Designed for and provides a networkaccessible interface
Designed to receive requests from any source
Coarse-grained

August 2007

TELUS Confidential

17

Service Interface
Description
Represents the API to a business service
Public contract with service consumers
Declares service methods, parameters, return values and application exceptions

Characteristics
Strongly typed
Purely business methods
No transport, location or technology specific code

Example
public interface CustomerMgtService
{
public Customer getCustomerById(int customerId) throws ObjectNotFoundException;
public Customer[] findCustomersByLastName(String lastName)
throws ExceedResultLimitException;
public void createCustomer(Customer customer) throws DuplicateKeyException;
public void updateCustomer(Customer customer)
throws ObjectNotFoundException , ConcurrencyConflictException;
...
}

August 2007

TELUS Confidential

18

Service Implementation
Service Interface

ServiceImpl
Responsibilities
Assert validity of input data
Process business rules
Interact with persistence layer to retrieve or store data
Assemble information to send back to service consumer

Characteristics
Plain old java object (POJO)
Implements a service interface
NO transaction management
NO db connection reference
Can be tested without an application server

August 2007

TELUS Confidential

19

Service Implementation Example

public class CustomerMgtServiceImpl implements CustomerMgtService


{
private CustomerDao m_customerDao;
private AddressDao m_addressDao;
...

public void createCustomer(Customer customer) throws DuplicateKeyException


{
assert customer != null : "customer object is null";
customer.setCreationDate( new Date() );
customer.setLastUpdated( new Date() );
m_customerDao.insertCustomer( customer );
}

...
}

August 2007

TELUS Confidential

20

Service Wrapper EJB


Characteristics

Example

Stateless session EJB


public class CustomerMgtServiceEJB

May be a remote or local ejb

extends AbstractStatelessSessionBean
{
private CustomerMgtService m_customerService;

Holds an instance of the service object


using the service interface as type

....

Has business methods that correspond to


those in the service impl

public Customer retrieveCustomerById(int customerId)


throws ObjectNotFoundException
{
return m_customerService.retrieveCustomerById(customerId);

Business method code simply delegates


to the method in the service impl

}
...
}

August 2007

TELUS Confidential

21

Domain Object
A Domain Object is a representation of a
business concept, its attributes and its
inherent behavior.

example
Customer

Address

Characteristics

Account

Attributes with their setters and getters


Used by persistence layer for mapping to/from
the data store
Used by service object to process business
logic

typical

Methods to execute inherent business rules

public Class Customer {


private Address[] m_addresses;
private Account[] m_accounts;
...
}
public Class Address { ... }
public Class Account { ... }

Design considerations
Intended to be the applications
implementation of the domain model
Primarily used as value holder
Behaviour is abstracted and encapsulated
into independent business rules classes
Often used as transfer object among
architectural layers/tiers

August 2007

TELUS Confidential

22

Data Transfer Object (DTO)

DTO

Characteristics
Simple and lightweight value holder
Used for transferring data between architectural boundaries
Used to combine data from different domain objects
Contains only setters and getters
Typically used as parameter in calls to services
Typically used as return type of service methods

August 2007

TELUS Confidential

23

Persistence Layer
Introduction and Objectives
Overview
Services Architecture
Module Stereotypes
Services Layer

Persistence Layer
Assembling the Service
Spring Fundamentals
Configuration Framework
Service Consumers
Web Application
Other Frameworks
Design & Implementation Guidelines
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

24

Persistence Layer
Purpose
Abstracts interaction with the data store
(i.e. DB)
Provides flexibility in choice of persistence
mechanism
Responsible for mapping data store entities
to domain objects and vice versa

Design Approach
Use Data Access Object (DAO) interface
Use IBatis SQLMap as the underlying
persistence mechanism

August 2007

TELUS Confidential

25

DAO Interface
Characteristics
Its methods represent the various ways in which a given domain object may be obtained
from or persisted to a data store.
Independent of the underlying persistence mechanism
example
public interface CustomerDao
{
public Customer getCustomerById(Integer customerId)
throws ObjectNotFoundException;
public Customer[] getCustomerListByLastName(String lastName)
throws ExceedResultLimitException;
public void updateCustomer(Customer customer)
throws ObjectNotFoundException, ConcurrencyConflictException;
public void insertCustomer(Customer customer)
throws ObjectNotFoundException, DuplicateKeyException;
public void deleteCustomer(Integer customerId)
throws ObjectNotFoundException, ConcurrencyConflictException;
}

August 2007

TELUS Confidential

26

DAO Implementation
Description
Technology-specific implementation of the DAO interface
Interact with the data store using API calls specific to the persistence mechanism
Perform mapping of data store result sets into corresponding domain objects and vice-versa

Design Approach
Use IBatis SQLMap as persistence mechanism
Use the framework-supplied abstract class:

com.telus.framework.persistence.AbstractSqlMapDao
public class SqlMapCustomerDao extends AbstractSqlMapDao implements CustomerDao {
private static final String GET_BY_ID_STMT = "Customer.getCustomerById";
...
public Customer getCustomerById(Integer customerId) throws ObjectNotFoundException {
return (Customer) queryForObject(GET_BY_ID_STMT, customerId);
}
public Customer[] getCustomerListByLastName(String lastName) throws
ObjectNotFoundException {
return queryForList(GET_BY_LASTNAME_STMT, lastName);
}
...
August 2007

TELUS Confidential

27

IBatis SQLMap
What is it?
It is a framework that maps JavaBeans to SQL statements using very simple XML descriptors.
It is an object-relational mapping mechanism

How Does it Work?


Call SQLMap API passing an object as parameter (JavaBean, Map, Primitives)
SQLMap executes a SQL statement defined in an XML file substituting parameter placeholders with
values from the parameter objects
SQLMap maps result into a Java object of a type defined in the XML file
Parameter
Object (input)

SQLMap.
xml

SQLMapConfig.
xml

JavaBean

Result Object
(output)
JavaBean

SQL Map
Map

Primitive
Wrappers

August 2007

Mapped
Statement

JDBC

TELUS Confidential

Map

Primitive
Wrappers

28

SQLMap Configuration
sqlmap-config.xml
Configuration file that specifies global settings such as caching, datasource, lazy-loading, etc.
Identifies all the SQLMap XML files (i.e. mapping files)
Typically have only one per application
example
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings
cacheModelsEnabled="false"
lazyLoadingEnabled="true"
useStatementNamespaces="true" />

You normally wouldn't need


this. It will be set elsewhere

<transactionManager type="JDBC">
<dataSource type="JNDI">
<property name="DataSource" value="java:comp/env/jdbc/sampleds" />
</dataSource>
This is where you declare all
your mapping files

</transactionManager>
<sqlMap resource="conf-appl/sqlmaps/Customer.xml"/>
<sqlMap resource="conf-appl/sqlmaps/Address.xml"/>
</sqlMapConfig>
August 2007

TELUS Confidential

29

SQLMap Mapping File


Mapping File
Contains the SQL statements
Contains mapping of Java objects to result sets and parameters
Typically have 1 mapping file per domain object
example: conf-appl/sqlmaps/customer.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="Customer">
<typeAlias alias="customer" type="com.telus.framework.sampleapp.domain.Customer"/>
<resultMap id="resultCustomer" class="customer">
<result property="customerId" column="ID"/>
<result property="firstName" column="FIRSTNAME"/>
<result property="lastName" column="LASTNAME"/>
<result property="sin" column="SIN"/>
...
</resultMap>
<statement id="getCustomerById" resultMap="resultCustomer" parameterClass="int">
select * from Customer where ID=#value#
</statement>
...
</sqlMap>

August 2007

TELUS Confidential

30

SQLMap Code Usage


What you WOULD HAVE needed to do:
String resource = "conf-appl/sqlmaps/sqlMap-config.xml";
Reader reader = Resources.getResourceAsReader (resource);
SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMap(reader);
Customer customer = (Customer)sqlMap.queryForObject("Customer.getCustomerById", customerId);

<statement id="getCustomerById"...

What you ACTUALLY HAVE to do:


Customer customer = (Customer) queryForObject("Customer.getCustomerById", customerId);

<sqlMap namespace="Customer">

The framework class "com.telus.framework.persistence.AbstractSqlMapDao":


Abstracts the IBatis SQLMap API calls
Provides an injection point for Spring to set configuration settings
Translates the exceptions to standard com.telus exceptions

August 2007

TELUS Confidential

31

Assembling the Service


Introduction and Objectives
Overview
Services Architecture
Module Stereotypes
Services Layer
Persistence Layer

Assembling the Service


Spring Fundamentals
Configuration Framework
Service Consumers
Web Application
Other Frameworks
Design & Implementation Guidelines
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

32

Assembling a Service
Questions
How will the Service Wrapper EJB get an
instance of the Service implementation object?
How will the Service object get instances of
the DAO implementations it needs?

Bea
n

(se
r

vic
e

nam
e

How will the DAO SQLMap Impl object get its


configuration settings?

get

Answer:

se
t

Cu

st

om

er

Da

se
t

Jn

di
T

em

pl
a

te

Wire them together via Spring

August 2007

TELUS Confidential

33

Spring Fundamentals
Introduction and Objectives
Overview
Services Architecture
Module Stereotypes
Services Layer
Persistence Layer
Assembling the Service

Spring Fundamentals
Configuration Framework
Service Consumers
Web Application
Other Frameworks
Design & Implementation Guidelines
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

34

Spring Fundamentals
What is Spring?
A layered Java/J2EE application framework
Comprehensive and modular
An Inversion of Control (IOC) / Dependency Injection container
A "super-factory"

Spring aims to:


make J2EE easier
make existing technologies easier to use
promote good programming practice

August 2007

TELUS Confidential

35

Spring Features

Features we are using

Features we are partially using

Features we NOT using.

Usage in Telus J2EE Applications


Wiring of classes (dependency injection)
Proxies and interceptors
Support / convenience classes
Used mostly by the Telus Framework components (transparent to application code)

August 2007

TELUS Confidential

36

Spring Configuration
The visibility of Spring in your application should be limited to the Spring configuration files.
How to define a bean in Spring
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">

Spring will create an instance of


this class

<beans>
<bean id="name_of_bean" class="fully_qualified_class_name">
<property name="attribute1">

Spring will call setAttribute1 on


the class passing it "somevalue"

<value>somevalue</value>
</property>
<property name="attribute2">

Spring will call setAttribute2 on


the class passing it an instance of
a class also defined as a bean

<ref local="another_bean" />


</property>
<property name="attribute3">
<props>
<prop key="propertyKey1">propertyValue1</prop>
<prop key="propertyKey2">propertyValue2</prop>
</props>
</property>
</bean>
...
</beans>

August 2007

TELUS Confidential

Spring will call setAttribute3 on


the class passing it a Properties
object with the enclosed keyvalue pairs.

37

Spring Configuration Sample


Define the DataSource
Traditionally, in order to get the DataSource you would have needed to do this:
Hashtable props = new Hashtable();
props.put("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
props.put("java.naming.provider.url", "t3://localhost:7001");
Context ctx = new InitialContext(props);
DataSource ds = (DataSource)ctx.lookup("datasource1");

Using Spring, you can instead define this in the configuration file as follows:
<bean id="jndiSetting" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
<prop key="java.naming.provider.url">t3://localhost:7001</prop>
</props>
</property>
</bean>
<bean id="sampleds" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"><value>datasource1</value></property>
<property name="jndiTemplate">
<ref local="jndiSetting"/>
</property>
</bean>
August 2007

TELUS Confidential

38

Spring Configuration Sample


Define the IBatis SQLMap Client
If you were programmatically accessing IBatis SQLMap...
String resource = "conf-appl/sqlmaps/sqlMap-config.xml";
Reader reader = Resources.getResourceAsReader (resource);
SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMap(reader);
Customer customer = (Customer)sqlMap.queryForObject("Customer.getCustomerById", customerId);

Using Spring, you can instead define this in the configuration file as follows:
<bean id="sqlMap" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>classpath:conf-appl/sqlmaps/sqlMap-config.xml</value>
</property>
<property name="dataSource"><ref local="sampleds"/></property>
</bean>

This is the datasource we


defined in the previous slide

August 2007

TELUS Confidential

39

Spring Configuration Sample


Define the Data Access Objects (DAO)
<bean id="addressDao" class="com.telus.framework.sampleapp.dao.SqlMapAddressDao">
<property name="sqlMapClient"><ref local="sqlMap"/></property>
</bean>
<bean id="customerDao" class="com.telus.framework.sampleapp.dao.SqlMapCustomerDao">
<property name="sqlMapClient"><ref local="sqlMap"/></property>
</bean>

The DAO Interface


public interface CustomerDao {
...
public Customer getCustomerById(Integer customerId) throws ObjectNotFoundException
...
}

The DAO SQLMap implementation class


public class SqlMapCustomerDao extends AbstractSqlMapDao implements CustomerDao {
...
public Customer getCustomerById(Integer customerId) throws ObjectNotFoundException {
return (Customer) queryForObject( GET_BY_ID_STMT, customerId );
}
...
}

August 2007

TELUS Confidential

40

Spring Configuration Sample


Define the Service
<bean id="customerService"
class="com.telus.framework.sampleapp.services.customermgtservice.CustomerMgtServiceImpl">
<property name="customerDao"><ref local="customerDao"/></property>
<property name="addressDao"><ref local="addressDao"/></property>
</bean>

The service implementation class


public class CustomerMgtServiceImpl implements CustomerMgtService {
private CustomerDao customerDao;
private AddressDao addressDao;
...
public void setCustomerDao(CustomerDao customerDao) {
this.customerDao = customerDao;
}
public void setAddressDao(AddressDao addressDao) {
this.addressDao = addressDao;
}
...
}

August 2007

TELUS Confidential

41

Wiring the Service to the EJB


Spring does not control the creation of the EJB which means it cannot inject properties to it.
public class CustomerMgtServiceEJB extends AbstractStatelessSessionBean {
private CustomerMgtService m_customerService;
...
public Customer retrieveCustomerById(int customerId) throws ObjectNotFoundException {
return m_customerService.retrieveCustomerById(customerId);
}

So how do we get the service


which was created by Spring?

...

The EJB will have to ask Spring to get the service programmatically.
Spring provides a "convenience" abstract class that the EJB wrapper class can extend from
org.springframework.ejb.support.AbstractStatelessSessionBean
Provides an abstract method called "onEjbCreate" which you implement as follows:
...
protected void onEjbCreate() throws CreateException {
m_customerService = (CustomerMgtService) getBeanFactory().getBean("customerService");
}
...
concrete method in the
AbstractStatelessSessionBean

August 2007

<bean id="customerService" >


in the spring configuration file

TELUS Confidential

42

Assembling The Service - Recap

nam
e

Write Java code for the following:

Write the service interface

Write the service implementation

Write the domain objects

Write the DTOs (if needed)

Write the DAO interface

Write the DAO SQLMap implementation

vic
e

Write SQLMap configuration/mapping files

Define bean for jndi settings

Define bean for DataSource with jndiTemplate as a


property

Define bean for SqlMap client with the datasource as


a property

Define beans for DAOs with the SqlMap client as a


property

Define bean for Service with the DAOs as properties.

Write or generate service EJB wrapper

se
t

Cu

st

om

er

Da

se
t

Jn

di
T

em

pl
a

te

get

Bea
n

(se
r

Write Spring configuration files

August 2007

TELUS Confidential

43

Configuration Framework
Introduction and Objectives
Overview
Services Architecture
Module Stereotypes
Services Layer
Persistence Layer
Assembling the Service
Spring Fundamentals

Configuration Framework
Service Consumers
Web Application
Other Frameworks
Design & Implementation Guidelines
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

44

Configuration Framework
Purpose
To provide a mechanism for retrieving application-wide and environment-specific
properties.

Usage in Application Code


From anywhere in the application code, you can use the class:

com.telus.framework.config.ConfigContext
The class provides various methods that return a single property value or a group of
property values
Recommended best practice is to have a single utility class within an application that
uses the ConfigContext class.

Initialization and Setup


ConfigProvider class LDAP or File-based repository
Repository-specific settings
Configuration components to load

August 2007

TELUS Confidential

45

Configuration Data Structure


example

int smtpPort = ConfigContext.getPropertyAsInt(

<group name="irrelevant">

new String[]{"smtp", "port"});

<group name="smtp">
<prop name="host">smtp.telus.com</prop>
<prop name="port">22</prop>

int smtpPort =

<list name="recipients">

ConfigContext.getPropertyNode("smtp")
.getPropertyAsInt("port");

<string>john.doe@telus.com</string>
<string>bill.gates@telus.com</string>
</list>
</group>
</group>

XML tag

Java Type

Accessor Methods (ConfigContext)

<group>

com.telus.framework.config.PropertyNode
java.util.Properties (contains only <prop> elements)

getPropertyNode()
getProperties()

<list>

java.util.List

getList()

<prop>

java.lang.String
int
long
boolean
double

getProperty()
getPropertyAsInt()
getPropertyAsLong()
getPropetyAsBoolean()
getPropertyAsDouble()

<string>

String value within a List

getList().get(idx)

August 2007

TELUS Confidential

46

Configuration Framework API


com.telus.framework.config.ConfigContext
getPropertyNode( String )

getPropertyNode( String[] )

getProperty( String )

getProperty( String[] )

getPropertyAsInt( String )

getPropertyAsInt( String[] )

getPropertyAsBoolean( String )

getPropertyAsBoolean( String[] )

getList( String )

getList( String[] )

getProperties( String )

getProperties( String[] )
...

...

Example: using an array of Strings as parameter


List recipientList = ConfigContext.getList( new String[] {"smtp", "recipients"} );
int smtpPort = ConfigContext.getPropertyAsInt( new String[] {"smtp", "port"} );
String host = ConfigContext.getProperty( new String[] {"smtp", "host"} );
Example: using String as parameter
PropertyNode smtpGroup = ConfigContext.getPropertyNode( "smtp" );
List recipientList = smtpGroup.getList( "recipients" );
int smtpPort = smtpGroup.getPropertyAsInt( "port" );
String host = smtpGroup.getProperty( "host" );

August 2007

TELUS Confidential

47

Configuration Repository File Based


When to use
Configuration Root
(Directory)

Development and testing only

Provider Class
com.telus.config.provider.file.FileXmlProvider

Application1
(Directory)

Setup
Identify a directory/folder as the configuration
root. (e.g. c:\configroot)

MailConfig
(File)

Create a subdirectory within the configuration


root that corresponds to the application.
Within the subdirectory, put all configuration
XML files. Each file represents a
configuration component

Logging
(File)

Application2
(Directory)

Sample Structure
c:\configroot\
sampleapp\

Logging
(File)

log4JLogger.xml
codestable-general.xml
servicesConfig.xml

Misc
(File)

webappConfig.xml

August 2007

TELUS Confidential

48

Configuration Repository - LDAP


When to use
Testing and Production

Provider Class

com.telus.framework.config.provider.ldap.LdapXmlProvider

Setup

August 2007

Identify an LDAP node as repository root


Sub-nodes for each application
Configuration components will be sub-nodes of the application node
The description attribute holds the XML-formatted data for the configuration component

TELUS Confidential

49

Configuration Framework Initialization


You need 2 properties files to initialize the configuration framework

appCtx.properties
Packaged with the application and accessible through the applications class path
Contains a property named "appId
appId" and a value that specifies the application name
Contain a property named "loadSequence
loadSequence" and a comma delimited list of values corresponding to the
applications configuration components

environment.properties
Located somewhere in the application server's environment and part of the global classpath.
Contains a property named "configProviderClass
configProviderClass" the value of which should be one of the following:

com.telus.framework.config.ldap.LdapXmlProvider to use the LDAP-based repository

com.telus.framework.config.file.FileXmlProvider to use the XML file-based repository

If file-based, specify a property named "configRootPath


configRootPath" to indicate the configuration root directory
If LDAP-based, specify the properties needed by JNDI to connect to the LDAP server

August 2007

jndi.url (i.e. jndi.url=ldap://localhost/ou=development, ou=configuration, o=telus, c=ca)

jndi.factory

jndi.authentication

jndi.principal

jndi.credentials

TELUS Confidential

50

Configuration and Spring


Usage Notes:
NEVER use Spring to set environment-specific attributes directly.
Spring configuration files are intended to be packaged with the application (i.e. in the ear,
jar or war file)
Use the configuration framework for values that are intended to be set at runtime.
Use the configuration framework for any environment-specific attribute.
So what about this Spring configuration?
<bean id="jndiSetting" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
<prop key="java.naming.provider.url">t3://localhost:7001</prop>
</props>
</property>
</bean>

August 2007

TELUS Confidential

51

Configuration and Spring Integration


The configuration framework provides a facility to ask Spring to call our configuration API

First, you need to add this bean definition in your Spring configuration file:
<bean id="telusSpringConfigurer"
class="com.telus.framework.config.spring.PlaceholderConfigurer"/>
Then you can use placeholders delimited by ${ } in your bean definitions as follows:
<bean id="jndiSetting" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
<prop key="java.naming.provider.url">${servicesConfig/jndiProviderUrl}</prop>
</props>
</property>
</bean>

The equivalent of calling:


ConfigContext.getProperty(new String[] {"servicesConfig", "jndiProviderUrl"});

August 2007

TELUS Confidential

52

Service Consumers
Introduction and Objectives
Overview
Services Architecture
Module Stereotypes
Services Layer
Persistence Layer
Assembling the Service
Spring Fundamentals
Configuration Framework

Service Consumers
Web Application
Other Frameworks
Design & Implementation Guidelines
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

53

Service Consumers
A service may be called by one of the
following client types:
A Web Application
The messaging layer
A bridge or adapter component

Regardless of the type, the client application


code should have visibility only to the
following:
Service Interface
DTO
Domain Object

To interact with a service, proxy classes will


be used via configuration.
For synchronous calls, the Service Proxy will
be used.
For asynchronous calls, the Message Proxy
will be used.

August 2007

TELUS Confidential

54

Web Application
Introduction and Objectives
Overview
Services Architecture
Module Stereotypes
Services Layer
Persistence Layer
Assembling the Service
Spring Fundamentals
Configuration Framework
Service Consumers

Web Application
Other Frameworks
Design & Implementation Guidelines
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

55

Web Application Overview


Typical Model-View-Controller (MVC) pattern
Three different approaches:
1. Struts
2. JSF
3. Web Controller Framework
Customized framework that extends Struts
Provides functionality relating to conversation scope, context parameters
Shields the application code from a lot of Struts-specific and servlet-specific APIs
Extends the Struts HTML tags

The Model (M) is injected via Spring configuration

Use taglibraries (HTML-EL for Struts and webcontroller, JSF tags and JSTL tags)
in the JSPs Avoid scriptlets

August 2007

TELUS Confidential

56

Struts Action class


Your action class will be instantiated by Spring. Also all the dependencies will be

injected through Spring.


import org.apache.struts.action.Action;

Will be injected by Spring

...
public class SearchCustomerAction extends Action {
private CustomerMgtService m_customerService;
...
public ActionForward

execute(ActionMapping mapping, ActionForm form,

HttpServletRequest request, HttpServletResponse response) {


...
}
public void

setCustomerService(CustomerMgtService customerService) {

m_customerService = customerService;
}
...

August 2007

TELUS Confidential

57

Struts - Configuration
<struts-config>
...
<action-mappings>
...
<action path="/searchCustomer" name="searchCustomerForm"
type="com.telus.framework.sampleapp.action.SearchCustomerAction"
...
</action>
...
Support class provided by Spring that
tells Struts to delegate the creation of
the action classes to Spring

</action-mappings>
<controller

processorClass="org.springframework.web.struts.DelegatingTilesRequestProcessor"/>
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/web-spring.xml"/>
</plug-in>
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml"/>
<set-property property="moduleAware" value="false"/>
</plug-in>
...
</struts-config>
August 2007

TELUS Confidential

Bootstrap class that loads a Spring


BeanFactory

58

Struts Spring Configuration


For each action mapping, you'll need to provide a bean definition in the web-spring.xml
Spring configuration file

<bean name="/searchCustomer"
class="com.telus.framework.sampleapp.action.SearchCustomerAction">
<property name="customerService">
<ref bean="customerServiceProxy"/>
</property>

Should match the "path" attribute of the


action element in the Struts config

</bean>

August 2007

TELUS Confidential

59

Service Proxy
<bean id="telusSpringConfigurer" class="com.telus.framework.config.spring.PlaceholderConfigurer"/>
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate" >
<property name="environment">
<props>
<prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
<prop key="java.naming.provider.url">${webappConfig/sevicesJNDI/url}</prop>
</props>

Support class provided by


Frameworks to create a dynamic
proxy that connects to a stateless
session EJB

</property>
</bean>

<bean id="customerServiceProxy class="com.telus.framework.util.spring.ServiceProxy">


<property name="jndiName">
<value>com.telus.service.CustomerMgtService</value>
</property>
<property name="jndiTemplate"><ref bean="jndiTemplate"/></property>
<property name="businessInterface">
<value>com.telus...customermgtservice.CustomerMgtService</value>
</property>
</bean>

August 2007

TELUS Confidential

60

Struts - Recap

Write Action and ActionForm classes


In the Struts configuration, set the controller requestProcessor class to the delegator
class provided by Spring
Specify a plug-in with a class attribute that points to the ContextLoaderPlugin from
Spring
Specify the Struts Tiles plug-in (if using tiles)
In a Spring configuration file, define beans for each action mapping in the Struts config
that needs dependency injection
In the Spring configuration for each action bean inject the appropriate properties (like
service proxies to invoke SLSBs)
For the proxy definition's provide the businessInterface and the lookup properties

August 2007

TELUS Confidential

61

JSF Managed Beans


Mananged Beans responsabilities:
delegates the business logic to the services (services injected by Spring)
behave as a object factory for the domain objects or DTOs to be passed to the service
public class CustomerBean {
private String m_firstName;
private String m_lastName;
...

Delegate the business logic to


the service

public void createCustomer() {


Customer customer = createCustomer();
m_customerService.createCustomer(customer);
}

Will be injected by Spring


private CustomerMgtSvc m_customerService;
public void setCustomerService(CustomerMgtService customerService) {
m_customerService = customerService;
}

Factory method for


DO/DTOs

protected Customer createCustomer() {


Customer customer = new Customer();
customer.setFirstName(m_firstName);
customer.setLastName(m_lastName);
...
return customer;
}
...

August 2007

TELUS Confidential

62

JSF - Configuration
<faces-config>
...
Injected by Spring
(customerSvcProxy bean defined in
the spring configuration)

<managed-bean>
<managed-bean-name>CustomerBean</managed-bean-name>
<managed-bean-class>test.beans.CustomerBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>customerService</property-name>
<value>#{customerSvcProxy}</value>

Support class provided by Spring that


tells delegate the creation of the
managed bean instances

</managed-property>
</managed-bean>

<application>
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
...
</application>

</faces-config>

August 2007

TELUS Confidential

63

JSF Spring Configuration

<! spring configuration file -->


<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate" >
...
</bean>

<bean id="customerSvcProxy" class="com.telus.framework.util.spring.ServiceProxy">


<property name="jndiName" value="com.telus.service.CustomerMgtService" />
<property name="jndiTemplate"><ref bean="jndiTemplate"/></property>
<property name="businessInterface">
<value>com.telus...customermgtservice.CustomerMgtService</value>
</property>

Should match the value of the managed


property defined in the faces-config.xml

</bean>

August 2007

TELUS Confidential

64

JSF web.xml for Spring support

<! web.xml file -->


<web-app>

Spring configuration file

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/web-spring.xml</param-value>
</context-param>
...
<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

Bootstrap class that loads a Spring


BeanFactory

...
</web-app>

August 2007

TELUS Confidential

65

JSF - Recap

Specify the ContextLoaderListener listener and the spring configuration file(s) through
the contextConfigLocation context parameter in the web.xml file
In a Spring configuration file, define the service beans (POJOs or service proxies that
point to SLSBs)
Write managed bean classes that delegate the business logic to services
In the JSF configuration file faces-config.xml declare the spring
DelegatingVariableResolver variable-resolver that is used to inject the dependencies
into the managed beans.

August 2007

TELUS Confidential

66

WebController Framework
WebController Framework Features
Simplified Action class interface
execute() method
Access to HttpSession as a map or a bean

Two additional scope introduced

August 2007

TELUS Confidential

67

WebController Framework
WebController
All Action implementation MUST Extend IcsAction Class
execute() method called by the Framework
Return type String instead of ActionForward in basic Struts

August 2007

TELUS Confidential

68

WebController Framework
WebController Continued
IcsActionContext provides access to containers
Session via getSessionMap() or getSessionBean() methods
Conversation via getConversationMap() or getConversationBean() methods
ContextParam can be set or retrieved
Set output object

No direct access to HttpSession Object


Accessed via Map or JavaBean interface

No direct access to HttpServletRequest Object


Masked completely
Internal Token processing to prevent multiple request (Optional)

August 2007

TELUS Confidential

69

WebController Framework
Output Object
Request Scoped Container
To be set from Action and retrieved from JSP

Output Object Usage Example


setOutput in Action
publicclassAccountActionextendsIcsAction
{
...
publicStringexecute(ActionFormactionForm,
IcsActionContexticsActionContext)
{
...
AccountDTOaccountDTO=newAccountDTO();
accountDTO.setAccountNumber(12345678910);
icsActionContext.setOutput(accountDTO);
...
}
}

August 2007

TELUS Confidential

70

WebController Framework
Output Object Usage Example Continued
Retrival of Output Object in JSP
<html:textproperty=actionBean.accountNumber/>
value="${requestScope.actionBean.accountNumber}"/>

August 2007

TELUS Confidential

71

WebController Framework
Conversation Scope
Logical Group of ActionMappings
Configured in struts-config.xml
Multiple browser windows support
Enforce Valid Entry Point to Conversation (optional)

August 2007

TELUS Confidential

72

WebController Framework
Conversation Configuration Continued
web.xml Conversation Timeout
<contextparam>
<paramname>
webcontroller.conversation.timeout.value
</paramname>
<paramvalue>1800</paramvalue>
</contextparam>
struts-config.xml Valid Conversation Entry Point

<globalforwards>
<forwardname="icsConversationStart"
path="/searchCustomer.do"/>
</globalforwards>

August 2007

TELUS Confidential

73

WebController Framework
Conversation Configuration
struts-config.xml - <action-mappings>
<actionpath="/searchCustomer"name="searchCustomerForm"
scope="request"
type="com.telus.framework.sampleapp.action.SearchCustomerAction"
input="searchCust.page"
validate="true">
<setpropertyproperty="conversationId"
value="icsConversation"/>
<forwardname="multiResult"
path="searchCust.page"/>
<forwardname="singleResult"
path="customerDetail.page"/>
</action>
<actionpath="/retrieveCustomer"name="retrieveCustomerForm"
scope="request"
type="com.telus.framework.sampleapp.action.RetrieveCustomerAction"
validate="false">
<setpropertyproperty="conversationId"
value="icsConversation"/>
<forwardname="success"
path="customerDetail.page"/>
<forwardname="failed"path="searchCust.page"/>
</action>

August 2007

TELUS Confidential

74

WebController Framework
Conversation Usage Example
Access Conversation as a Map
publicclassEditCustomerActionextendsIcsAction
{
...
publicStringexecute(ActionFormactionForm,
IcsActionContexticsActionContext)
{
RetrieveCustomerFormformBean=
(RetrieveCustomerForm)actionForm;

Customercustomer=
customerMgtSvc.getCustomer(formBean.getId());
icsActionContext.getConversationState().put(
CUSTOMER,
customer);
...
}
}

August 2007

TELUS Confidential

75

WebController Framework
Conversation Usage Example
Access Conversation as a Bean (recommended approach)

publicclassAddCustomerActionextendsIcsAction
{
...
publicStringexecute(ActionFormactionForm,
IcsActionContexticsActionContext)
{
NameBeannameBean=
(NameBean)icsActionContext.getConversationBean(
NameBean.class);
nameBean.setFirstName(John);
...
}
}

August 2007

TELUS Confidential

76

WebController Framework
Conversation Usage Example
Access from JSP using JSTL

<c:outvalue="${requestScope.conversationMap.firstName}"/>

Access from JSP using custom Tag html-el.tld

<html:textproperty="firstName"
value="${requestScope.conversationMap.firstName}"/>

August 2007

TELUS Confidential

77

WebController Framework
Context Parameter
String Value carried from one HttpServletRequest to the next HttpServletRequest
Predefined Key to limit usage to designed data only
Last longer than Conversation Scope

Context Parameter Example


web.xml Define Context Parameter Key
<contextparam>
<paramname>webcontroller.validcontextkeys</paramname>
<paramvalue>accountNumber,accountName</paramvalue>
</contextparam>

August 2007

TELUS Confidential

78

WebController Framework
Context Parameter Example Continued
Set Context Parameter

publicclassAccountActionextendsIcsAction
{
...
publicStringexecute(ActionFormactionForm,
IcsActionContexticsActionContext)
{
...
icsActionContext.setContextParameter(
accountNumber,
12345678910);
...
}
}

August 2007

TELUS Confidential

79

WebController Framework
Context Parameter Example Continued
Get Context Parameter
StringaccountNumber=
(String)icsActionContext.getContextParameter(
accountNumber);
Get Context Parameter in JSP
<c:outvalue="${param.accountNumber}"/>

Clear Context Parameter


//ClearspecificContextParameter
icsActionContext.setContextParameter("accountNumber",null);
//ClearallContextParameters
icsActionContext.clearContextParameters();

August 2007

TELUS Confidential

80

WebController Framework
Access To HttpSession
Direct Access is discouraged
Access via Map or JavaBean Interface
getSessionBean()
getSessionState()
Similar Usage as Conversation

August 2007

TELUS Confidential

81

WebController Framework
html-el.tld
Custom Taglib for Form Elements
Supports JSTL Expression Language
Means to retrieve values to display
Direct Replacement for Struts-html-el.tld

August 2007

TELUS Confidential

82

WebController Framework
Review
Create ActionForm Class
Create IcsAction Class
Create JSP
Add elements to web.xml
Servlet-Filter
Struts Servlet

Add elements to struts-config.xml


Global Forward <valid conversation entry>
ActionForm
ActionMapping
Plug-in Validator, Plug-in Spring

Add tiles definition to tiles-def.xml to correspond with Action Forward element

August 2007

TELUS Confidential

83

Reference ODS
Introduction and Objectives
Overview
Services Architecture
Module Stereotypes
Services Layer
Persistence Layer
Assembling the Service
Spring Fundamentals
Configuration Framework
Service Consumers
Web Application

Reference ODS
Reference Table Framework
Logging Framework
Review
Q&A
Wrap-up
August 2007

TELUS Confidential

84

Reference ODS
Description
The Reference ODS consists of Reference Tables and data that can be used for three
types of look ups: Code/Decode, Cross Reference, and Messages. Lookups are made
using the supplied Reference ODS APIs.

Capabilities
Supports Multiple code and decode values.
Multi-language.
Supports effective dates.
Configured as a Service.

Benefits
The Reference Table data is loaded and cached by each application at startup, thus,
improving performance.
Eliminates the hard-coding of values and improves performance.
Should be used when values are static and retrieved frequently.
Consistent mechanism to retrieve code and decode values.

August 2007

TELUS Confidential

85

Reference Ods Sample Configuration


1. Define Bean in Spring configuration file
<bean id=refOdsCodesTableBootstrap"
class="com.telus.framework.codestable.config.DatabaseCodesTableConfigurator"
init-method="initialize laxy-init=false>
<property name="nodelistPath"><value>codestable/nodelist</value></property>
<property name=sourceType value=service />
<property name=codesTableSourceSvc ref=codesTableSourceSvc />
</bean>
<bean id=codesTableSourceSvc class=com.telus.framework.util.spring.ServiceProxy lazy-init=false>
<property name=jndiName value=${connections/ejbServices/referenceOdsAccessSvc/jndiName} />
<property name=businessInterface
value=com.telus.framework.codestable.serviceCodesTableSourceSvc/>
<property name=jndiEnvironment>
<props>
<prop key=java.naming.factory.initial>weblogic.jndi.WLInitialContextFactory</prop>
<prop key=java.naming.provider.url>${connections/ejbServices/referenceOdsAccessSvc/url}</prop>
</props>
</property>
</bean>

This portion is optional if you intend


to use the default list as defined in
the configuration data

JNDI name of the ReferenceODS


Service

August 2007

TELUS Confidential

86

Reference Ods Sample Configuration continued


2. Obtain reference-ods-config.xml from Reference Ods and declare in appCtx.properties.

<group name=irrelevant>
<group name="codestable">
<list name="nodelist">
<string>ReferenceOds/generic-code-reference-config</string>
<string>ReferenceOds/message-reference-config</string>
<string>ReferenceOds/xref-reference-config</string>
</list>
</group>
<group name=ReferenceOds">
<group name=generic-code-reference-config>
<group name="initParams">
<prop name=codesTableName>GenericCodeReference</prop>
</group>
<prop name=statementId">ReferenceOdsCodesTable.GenericCodeReference</prop>
<group name="categoryDefinition">
<prop name="columnName">VIEW_NAME</prop>
</group>
<group name="languageDefinition">
<prop name="columnName">LANG</prop>
</group>

August 2007

TELUS Confidential

87

Reference ODS APIs


Using ReferenceOdsAccess:
ReferenceDecode ReferenceOdsAccess.getDecode( category, language, code)
Collection ReferenceOdsAccess.getView( category, language)
Collection ReferenceOdsAccess.getXrefDecodeView( view, code, language)
ReferenceMessageDecode ReferenceOdsAccess.getMessage( messageCode, language)

Examples
//get decode for Province = BC
ReferenceDecode decode = ReferenceOdsAccess.getDecode(Province, ReferenceOdsAccessSvc.LANG_EN,
BC);
//get decodes for all Provinces
Collection list = ReferenceOdsAccess.getView(Province, ReferenceOdsAccessSvc.LANG_EN);
//get Cross References between CATEGORY and TEMPLATE TYPE for code = TC
Collection list = ReferenceOdsAccess.getXrefDecodeView(GCC_CATEGORY_GCC_TEMPLATE_TYPE,
TC, ReferenceOdsAccessSvc.LANG_EN);
//get French message for message code E0001
ReferenceMessageDecode msg = ReferenceOdsAccess.getMessage( E0001,
ReferenceOdsAccessSvc.LANG_FR);

August 2007

TELUS Confidential

88

Other Frameworks
Introduction and Objectives
Overview
Services Architecture
Module Stereotypes
Services Layer
Persistence Layer
Assembling the Service
Spring Fundamentals
Configuration Framework
Service Consumers
Web Application

Other Frameworks
Design & Implementation Guidelines
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

89

Other Frameworks
Webservices Framework
Read-audit Framework
Performance Framework
Portal Framework
Content for Webapps Framework
Logging Framework

Use Jakarta Commons Logging as an independent abstract.

Use Log4j as the logging toolkit implementation.

Use the Configuration framework to load logging properties.

Validation & Formatting Routines

Convenience classes for doing common, generic validations and formatting (e.g. Date formats, basic credit card checking,
type checking, etc)

Base Exception Classes

All custom exceptions must extend from these.

Framework Mock Objects

For use in Unit Testing.

Static Mocks for CodesTable, WebController & Configuration Framework

August 2007

TELUS Confidential

90

Design & Implementation Guidelines


Introduction and Objectives
Overview
Services Architecture
Module Stereotypes
Services Layer
Persistence Layer
Assembling the Service
Spring Fundamentals
Configuration Framework
Service Consumers
Web Application
Other Frameworks

Design & Implementation Guidelines


Review
Q&A
Wrap-up

August 2007

TELUS Confidential

91

Design & Implementation Guidelines


Some key focused design & implementation guidelines documents:
Error Handling Guidelines
Business Rules Processsing
Server-side Validation
Limiting Query ResultSets
Processing Currency Amount Attributes
Session Caching Guidelines
Web Error Handling
Integration Approach Selection Guidelines

August 2007

TELUS Confidential

92

Review
Introduction and Objectives
Overview
Services Architecture
Module Stereotypes
Services Layer
Persistence Layer
Assembling the Service
Spring Fundamentals
Configuration Framework
Service Consumers
Web Application
Other Frameworks
Design & Implementation Guidelines

Review
Q&A
Wrap-up

August 2007

TELUS Confidential

93

Course Review
Key Course Concepts
Module Stereotypes as design and development roadmap
Writing and assembling the various components that make up a service
Basics of Spring
Configuration Framework
Service Consumers in General
Web Application at a High Level
Reference ODS
Other Frameworks
Key Design & Implementation Guidelines

August 2007

TELUS Confidential

94

Q&A
Introduction and Objectives
Overview
Services Architecture
Module Stereotypes
Services Layer
Persistence Layer
Assembling the Service
Spring Fundamentals
Configuration Framework
Service Consumers
Web Application
Other Frameworks
Design & Implementation Guidelines
Review

Q&A
Wrap-up

August 2007

TELUS Confidential

95

Questions ??

August 2007

TELUS Confidential

96

Wrap-up
Introduction and Objectives
Overview
Services Architecture
Module Stereotypes
Services Layer
Persistence Layer
Assembling the Service
Spring Fundamentals
Configuration Framework
Service Consumers
Web Application
Other Frameworks
Design & Implementation Guidelines
Review
Q&A

Wrap-up

August 2007

TELUS Confidential

97

End of Part 1

The End
for Part 1 of 2

August 2007

TELUS Confidential

98

Frameworks
Fundamentals
(Compressed Version Part 2 of 2)
Critical Skills Training
Environment Management Frameworks

August 2007

TELUS Confidential

99

Introduction
Instructors:
Gabriel Rosu

Logistics:
Restrooms
Water / refreshments
Fire exits
Other / Questions?

August 2007

TELUS Confidential

100

Agenda Part 2 of 2
Introduction and Objectives
Logging Framework
Encryption Framework
Read-Audit Framework
Asynchronous Message Processing
Asynchronous Error Handling
Batch Framework
Development & Build Tools
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

101

Asynchronous Message Processing


Introduction and Objectives

Logging
Encryption
Read-Audit
Asynchronous Message Processing
Asynchronous Error Handling
Batch Framework
Development & Build Tools
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

102

Logging Framework
Description
Log4j logging through Commons Logging framework by leveraging the Configuration
Framework to retrieve the log4j configuration data.

In your code
Using commons-logging APIs. No framework nor log4j specific code

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
...
public class MyClass
{
private static Log logger = LogFactory.getLog(MyClass.class);
...
}

August 2007

TELUS Confidential

103

Logging Framework
Log4J Configuration through the Configuration Frmw format
<group name="irrelevant">
<group name="logging">
<prop name="log4j.rootLogger">ERROR, CONSOLE</prop>
<!-- prop name="log4j.debug">true</prop -->
<prop
<prop
<prop
<prop

name="log4j.appender.CONSOLE">org.apache.log4j.ConsoleAppender</prop>
name="log4j.appender.CONSOLE.Threshold">DEBUG</prop>
name="log4j.appender.CONSOLE.layout">org.apache.log4j.PatternLayout</prop>
name="log4j.appender.CONSOLE.layout.ConversionPattern">[%d{DATE} %c %t %-5p]- %m%n%n</prop>

<prop
<prop
<prop
<prop
<prop
<prop

name="log4j.appender.FRMWLOG">org.apache.log4j.DailyRollingFileAppender</prop>
name="log4j.appender.FRMWLOG.Append">true</prop>
name="log4j.appender.FRMWLOG.Threshold">DEBUG</prop>
name="log4j.appender.FRMWLOG.layout">org.apache.log4j.PatternLayout</prop>
name="log4j.appender.FRMWLOG.layout.ConversionPattern">[%d{DATE} %c %t %-5p]- %m%n%n</prop>
name="log4j.appender.FRMWLOG.file">${log/frameworks}/customerMgtService.log</prop>

<prop name="log4j.logger.com.telus.framework">DEBUG, FRMWLOG</prop>


...
</group>
</group>

August 2007

TELUS Confidential

104

Asynchronous Message Processing


Introduction and Objectives
Logging

Encryption
Read-Audit
Asynchronous Message Processing
Asynchronous Error Handling
Batch Framework
Development & Build Tools
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

105

Encryption Framework
Strong encryption (AES-256) backed up by the Avalon service (exposed as a webservice) part
of the PCI project
Weak encryption through the old framework

Encryption API
package com.telus.framework.crypto;
...
public class EncryptionUtil
{
public static byte[] encrypt(byte[] plainData, String entityType)
public static byte[] decrypt(byte[] chipherData, String entityType)
public static byte[] transientEncrypt(byte[] plainData, String entityType)
public static byte[] transientDecrypt(byte[] chipherData, String entityType)
public static String retrieveEncryptionTokenId(byte[] plainData, String entityType)
}

August 2007

TELUS Confidential

106

Encryption Framework
Valid entity types supported by the encryption:
CC

= CREDIT CARD NUMBER

BAN

= BANK ACCOUNT NUMBER

SIN

= SOCIAL INSURANCE NUMBER

PID

= PROVINCIAL ID

PRC

= PERMANENT RESIDENT CARD

PSP

= PASSPORT

SID

= STUDENT ID

LCD

= LIBRARY CARD

// credit card encryption sample


String clearString = "111111111111111";
byte[] encryptedData = EncryptionUtil.encrypt( clearString.getBytes(), "CC" );
...
// decryption sample
byte[] dencryptedData = EncryptionUtil.decrypt(encryptedData, "CC" );
...

August 2007

TELUS Confidential

107

Encryption Framework
Configuring the Encryption Framework for strong encryption
<!-- encryption-spring.xml -->
<beans>
<!-- encryption bean configured for strong encryption only -->
<bean id="crypto" class="com.telus.framework.crypto.EncryptionUtil">
<property name="strongEncryption" ref="strongEncryptionWS" />
<property name="strongEncryptionByDefault" value="true" />
</bean>
<!-- PCI service -->
<bean id="strongEncryptionSvc" class="com.telus.framework.ws.spring.axis.AxisPortProxyFactoryBean">
<property name="serviceFactoryClass" value="org.apache.axis.client.ServiceFactory" />
<property name="serviceInterface" value="com.telus.framework.crypto.service.EncryptionSvc" />
<property name="portName" value="EncryptionSoapPort" />
<property name="endpointAddress" value="https://pci-po:7005/services/EncryptionService" />
<property name="jaxRpcService">
<bean id="encryptionWSStub" class="com.telus.encryption.service.EncryptionWebServiceLocator">
<constructor-arg>
<bean class="org.apache.axis.configuration.FileProvider">
<constructor-arg>
<value>axis_client.wsdd</value>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
</property>
</bean>
</beans>

August 2007

TELUS Confidential

108

Encryption Framework
Configuring the Encryption Framework for using both strong and weak encryption
<!-- encryption-spring.xml -->
<beans>
<!-- encryption bean configured for strong encryption for credit cards only (CC) -->
<bean id="crypto" class="com.telus.framework.crypto.EncryptionUtil">
<property name="strongEncryption" ref="strongEncryptionWS" />
<property name="weakEncryption" ref="weakEncryptionSvc" />
<property name="strongEncryptionByDefault" value="false" />
<property name="alternateEntityList">
<list>
<value>CC</value>
</list>
</property>
</bean>
<!-- PCI service as in the previous slide -->
<bean id="strongEncryptionSvc" class="com.telus.framework.ws.spring.axis.AxisPortProxyFactoryBean">
...
</bean>
<!-- Weak encryption POJO -->
<bean id="weakEncryptionSvc" class="com.telus.framework.crypto.impl.pilot.PilotCryptoImpl " init-method="init">
<property name="key1"><value>${...}</value></property>
<property name="key2"><value>${...}</value></property>
<property name="key3"><value>${...}</value></property>
</bean>
</beans>

August 2007

TELUS Confidential

109

Asynchronous Message Processing


Introduction and Objectives

Read-Audit
Asynchronous Message Processing
Asynchronous Error Handling
Batch Framework
Development & Build Tools
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

110

Read-Audit Framework
Overall Architecture

August 2007

TELUS Confidential

111

Read-Audit Framework
Description
The Read-Audit is a framework that intercepts developers component calls and using
Castor serializes the request (and optional the response) into XML and logs it against a
predefined database (read-audit database) or a file store

Data being logged


The service methods name
The service methods parameters
The return values (optional)
The thrown exception if any
Current User ID
The ID of the system initiating the request
The timestamp of the request
The name of the web action making the service call

August 2007

TELUS Confidential

112

Read-Audit Framework
Use
Note that we should not abuse the usage of this framework as this will result in
generating huge amount of data

When & Where:


Decided by Solution Architects working together with Security Architects

Developers need to provide two things:


Spring configuration to set up the read-audit inteceptors
Castor mapping files for the objects being marshalled the Solution and Security
Architects also need to establish how much of these objects gets serialized into XML

August 2007

TELUS Confidential

113

Read-Audit Framework (spring config)


<beans>
<import resource="classpath:fw-abstract-audit-spring.xml" />
<bean id="marshaller" class="com.telus.framework.audit.marshaller.impl.CastorAuditMarshaller">
<property name="mappingFiles">
<list>
<value>castor/fw-audit-mapping.xml</value>
<value>castor/sample_mapping.xml</value>
</list>
</property>
</bean>
<bean id=workerFactory" parent="abstractWorkerFactory">
<property name="auditMarshaller" ref="marshaller" />
<property name="loggers">
<list>
<ref bean="dbLogger" />
<ref bean=fileLogger" />
</list>
</property>
<property name="period" value="5000" />
</bean>
<bean id="dbLogger" parent="abstractAuditSvcProxy">
<property name="jndiName value=com.telus.framework.audit.service.db.AuditSvc />
<property name="jndiEnvironment"> </property>
</bean>
<bean id="fileLogger" class="com.telus.framework.audit.logger.impl.FileAuditLogger">
<property name="auditLogName value=audit_local />
</bean>

August 2007

TELUS Confidential

114

Read-Audit Framework (spring config)


<bean id="sampleSvcAuditAdvisor" parent="abstractAuditAdvisor">
<property name="mappedNames">
<list>
<value>get*</value>
</list>
</property>
</bean>

<bean id="sampleSvcProxy" class="com.telus.framework.util.spring.ServiceProxy">


<property name="jndiName" value="tcisample.service.SampleSvc" />
<property name="businessInterface" value="tcisample.service.SampleSvc" />
<property name="jndiEnvironment">
<props>
<prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
<prop key="java.naming.provider.url">t3://localhost:7001</prop>
</props>
</property>
<property name="interceptorNames">
<list>
<value>sampleSvcAuditAdvisor</value>
</list>
</property>
</bean>

...
</beans>

August 2007

TELUS Confidential

115

Read-Audit Framework (castor config)


<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version 1.0//EN"
"http://castor.exolab.org/mapping.dtd">

<mapping>
<description>SampleParam mapping file</description>
<class name="tcisample.service.SampleParam">
<map-to xml="param" />
<field name="anAttribute" direct="false">
<bind-xml name="an-attribute" node="element" />
</field>
<field name="anotherAttribute" direct="false">
<bind-xml name="another-attribute" node="element" />
</field>
</class>
</mapping>

August 2007

TELUS Confidential

116

Asynchronous Message Processing


Introduction and Objectives

Asynchronous Message Processing


Asynchronous Error Handling
Batch Framework
Development & Build Tools
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

117

Asynchronous Application Integration


Overall Messaging Architecture

August 2007

TELUS Confidential

118

Asynchronous Application Integration


Messaging Proxy Framework

August 2007

TELUS Confidential

119

Messaging Proxy
Description
The Messaging Proxy is a framework component that abstracts the details of connecting
and writing to a message queue using Java Messaging Service (JMS) API for the purpose
of invoking a service asynchronously

Capabilities
Writes a message onto a queue as an Object or SOAP message that identifies the service
and operation to be invoked
Supports multiple proxies for a single service interface

Benefits
Provides a dynamic implementation of the service interface to the service consumer
Implementation of the framework is transparent to the client application code, which only
sees the service interface

Use
When a business service or any one of its operations need to be invoked asynchronously.

August 2007

TELUS Confidential

120

Messaging Proxy (spring config)


<bean id="sampleSvcProxy" class="com.telus.framework.util.spring.ServiceProxy">
<property name="jndiName" value="tcisample.service.SampleSvc" />
<property name="businessInterface" value="tcisample.service.SampleSvc" />
<property name="jndiEnvironment"> ... </property>
<property name="interceptorNames">
<list>
<value>asyncAdvisor</value>
</list>
</property>
</bean>

<bean id="asyncAdvisor" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">


<property name="mappedNames">
<list>
<value>saveFeedback</value>
</list>
</property>
<property name="advice">
<bean id="auditAdvice" class="com.telus.framework.messaging.MessagingAdvice">
<property name="jmsSender" ref="asyncJmsSender" />
<property name="syncWhenJmsError" value="true" />
</bean>
</property>
</bean>
...
</beans>

August 2007

TELUS Confidential

121

Messaging Proxy (spring config)


<bean id="asyncJmsSender" class="com.telus.framework.monitor.JMSArtifactSender">
<property name="connFactoryJndiName" value="sampleAsyncQueueCF" />
<property name="connFactoryJndiTemplate" ref="asyncJndiSettings" />
<property name="destinationJndiName" value="sampleAsyncQueue" />
<property name="destinationJndiTemplate" ref="asyncJndiSettings" />
</bean>

<bean id="asyncJndiSettings" class="org.springframework.jndi.JndiTemplate" lazy-init="true">


<property name="environment">
<props>
<prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
<prop key="java.naming.provider.url">...</prop>
<prop key="java.naming.security.principal">...</prop>
<prop key="java.naming.security.credentials">...</prop>
</props>
</property>
</bean>
...
</beans>

August 2007

TELUS Confidential

122

Messaging Proxy
Data Flow Overview

August 2007

TELUS Confidential

123

Asynchronous Application Integration


Asynchronous Message Processing

August 2007

TELUS Confidential

124

Asynchronous Message Processing Framework


Description
The Asynchronous Message Processor" is a framework for invoking business services
asynchronously through a message queue.

Capabilities
Receive messages in Object or SOAP format to invoke business service
Object messages are based on the Framework JmsObjectMessage
SOAP messages are based on Apache project Axis implementation of Java Web Services
Mapping of messages to SLSB EJBs

Benefits
Abstracts the underlying details of how the message is sent and processed.

August 2007

TELUS Confidential

125

Asynchronous Error Handling


Introduction and Objectives
Web Controller Framework
Asynchronous Message Processing

Asynchronous Error Handling


Batch Framework
Development & Build Tools
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

126

Asynchronous Application Integration


Overall Messaging Architecture

August 2007

TELUS Confidential

127

Asynchronous Error Handler Framework


Description
An Asynchronous Error Handler" is a framework for processing exceptions that occur
during asynchronous processing.

Capabilities
Out-of-the-box it has support for retrying the message, or storing to a database or file.
Granularity of error handler is configurable.
Extendable to support custom handlers.

Benefits
Consistent implementation for asynchronous processing.
Centralizes error handling processing.

August 2007

TELUS Confidential

128

Asynchronous Error Handler Framework


Usage:
Any message driven bean implementation should extend

com.telus.framework.messaging.AbstractMessageHandler
Implement the processMessage which will contain the business logic

Used by the Asynchronous Message Processing framework


public class ServiceMdb extends AbstractMessageHandler implements
MessageDrivenBean, MessageListener

August 2007

TELUS Confidential

129

Asynchronous Error Handler Framework


Composed of three major components:
Message Handler
Performs the initial processing when the message is received.
Catches all exceptions and passes it to the processor.

Error Processor
Contains all the error handlers for all the MDBs.
Configuration establishes the associated between error handlers and MDBs.

Error Handler
Contains the exception classes that are supported by the handler.
Configuration establishes the association between exception and error
handler.

August 2007

TELUS Confidential

130

Asynchronous Error Handler Message Handler


Configuration of the Message Handler
Specify a name for the MDB (i.e., mdbName env-entry)
List the error handlers that support the MDB
a type of handler can be specified more than once
the order the handlers are specified is the order the exception is processed

Specify an Error Processor to handle the exception


a single error processor can support multiple MDBs
deployed as a Stateless Session Bean
one configuration for each processor

August 2007

TELUS Confidential

131

Asynchronous Error Handler Configuration


Asynchronous Error Processor
Must be deployed in a separate transaction container
Iterates through each of the Error Handlers in the order specified
Continue until a handler has successfully processed the exception

August 2007

TELUS Confidential

132

Asynchronous Error Handler Configuration


Error Handler Configuration
Handler configuration will be in the Spring configuration file specified in the
Processor deployment descriptor
Each handler will be configured to handle certain exceptions
The handler will process the class specified AS WELL AS all sub-classes
For example, specifying
<property name="exceptionClasses">
<list>
<value>java.lang.Throwable</value>
</list>
</property>

.. will cause the handler to process all exceptions


THIS IS WHY THE ORDER OF THE HANDLERS ARE SPECIFIED IS IMPORTANT!!!!!!

August 2007

TELUS Confidential

133

Asynchronous Error Handler Configuration


Out-of-the-Box Handlers
Retry Error Handler
File Store Error Handler

August 2007

TELUS Confidential

134

Asynchronous Error Handler Configuration

Retry Error Handler


Typically used for system exceptions
No requirement to manipulate message content
No intervention required between attempts
Configurable parameters:
Retry delay time (specified in minutes)
Retry limit
Retry queue

August 2007

TELUS Confidential

135

Asynchronous Error Handler Configuration


File Store Error Handler
Typically used for application exceptions
May be required to manipulate the message content
May require manual intervention to correct the problem

Configurable parameters:
specify the folder path

August 2007

TELUS Confidential

136

Asynchronous Error Handler Resubmit Configuration


Resubmitting the Message
Uses the Batch Execution Container
Uses the JmsTemplate and JndiTemplate

August 2007

TELUS Confidential

137

Batch Framework
Introduction and Objectives
Webapp Development using Frameworks
Asynchronous Message Processing
Asynchronous Error Handling

Batch Framework
Development & Build Tools
Review
Q&A
Wrap-up

August 2007

TELUS Confidential

138

Batch
Batch Application
Doing a process repeatedly without User interaction.
Triggered by Date, Time, or arrival of a file or message
Consists of One or more jobs, each with one or more steps.

Examples:
Extracting database records for processing and distribution (e.g. collections)
Loading ODS tables from Master databases
Separating Usage files into OldStack & NewStack files, distributing them and processing them in
the correct Batch applications.

August 2007

TELUS Confidential

139

Batch
Frameworks team developed Batch Execution Container (BEC) to provide common
functionality used in virtually all batch jobs

concept of job steps to further sub-divide complex jobs

checkpoint capability for transaction control

restartability at last good step and checkpoint

job step audit capability

security authorization controls for registration of BDUs in Ref ODS

provision for security reference data for inclusion in DB audit columns

common functionality like shelling-out to OS, invoking Syncsort, XMLRecordParser

Majority of TELUS custom jobs use BEC, except the following

Filewatcher jobs using Control Ms native command

Some primitive UNIX command lines (such as mv, cp)

Complex UNIX command sequences using customized Korn shell scripting

August 2007

TELUS Confidential

140

Batch Execution Container (BEC)


What Does It Do?
Provides optional checkpoint/restart capability near the failed point of your batch program for
faster restart processing from a job failure.
Provides audit trail of the start and end time of each job step and their status, including an
optional method for you to store summary information.
Standardizes batch java programming & looks after the looping, auditing, & error handling for
you.

What are the extras?


Input and Output file checkpoint/restart repositioning
FileSplitterModule to split an input file into a specified number of files for parallel processing.
ExecModule to call the OS to execute a Unix command or Script, SqlLoader, Sqlplus, PL/Sql,
Syncsort.

August 2007

TELUS Confidential

141

Running Your BEC Job

Out of the box script for starting a batch job:


./fw-BEC.sh

Which essentially does:


CLASSPATH=.framework jars & dependent jars
java com.telus.framework.batch.JobController <dev-spring-file>.jdef

August 2007

TELUS Confidential

142

Batch developing batch apps


Job definition config files (spring file)
<beans default-lazy-init="true">
<import resource="classpath:fw-base.jdef" />
<bean id="job" parent="baseJob">
<property name="steps">
<list>
<bean id="STEP01" parent="baseStep">
<property name="moduleName" value="noCheckpoint" />
</bean>
<bean id="STEP02" parent="baseStep">
<property name="moduleName" value="checkpoint" />
<property name="commitFrequency" value="50" />
</bean>
</list>
</property>
</bean>
...

August 2007

TELUS Confidential

143

Batch developing batch apps


Job definition config files (spring file)
<bean id="noCheckpoint" class="com.telus.framework.sample.batch.CopyFileBatch">
<property name="inputFile" value="${inbox}/fileProcessingSample-input.txt" />
<property name="outputFile" value="${outbox}/noCheckpoint-output.txt" />
</bean>
<bean id="checkpoint" class="com.telus.framework.sample.batch.CopyFileBatch">
<property name="inputFile"

value="${inbox}/fileProcessingSample-input.txt" />

<property name="outputFile" value="${outbox}/chkp-output.txt" />


<property name="failurePoint" value="0" />
</bean>
</beans>

August 2007

TELUS Confidential

144

Batch developing batch apps


Framework base jdef file, fw-base.jdef
<beans default-lazy-init="true">
<bean id="baseJob" class="com.telus.framework.batch.JobDefinition" abstract="true">
<property name="applicationName" value="${appname}" />
<property name="jobName" value="${jobname}" />
<property name="transactionManager" ref="${beantype}-txMgr" />
<property name="jobDao" ref="${beantype}-jobDao" />
</bean>
<bean id="baseStep" class="com.telus.framework.batch.StepDefinition" abstract="true">
<property name="commitFrequency" value="0" />
<property name="autoRestartable" value="true" />
<property name="logCommits" value="true" />
</bean>
...

August 2007

TELUS Confidential

145

Checkpoint/Restart
What is It?
Checkpointing is the process of committing data changes and saving the execution state of the
Batch program at regular intervals (i.e. Checkpoint Frequency).
It allows a failed Batch program to resume execution by restoring the execution state.

Requirements
Transaction Manager (rollbacks to last commit point on failure)
File Repositioning
Managing 4 Batch Control Tables (by Stream at DV, Enterprise tables at AT and beyond)

What you need to do:


Set a non-zero checkpoint frequency
At checkpoint provide the info needed for repositioning the files/recordsets at restart time
On restart, restores the execution state of the Batch program to the last checkpointed positions.

August 2007

TELUS Confidential

146

Batch developing batch apps

Job Controller

Initialization:
setters
launch
restoreState

August 2007

Loop:
Exit:
hasNext
getSummary
execute
onExit
getStateForRestart

TELUS Confidential

147

Batch developing batch apps


Frameworks Module interface
package com.telus.framework.batch;
public interface Module
{
public void launch(BatchContext batchContext) throws ModuleException;
public void restoreState(Properties state) throws ModuleException;

public boolean hasNext() throws ModuleException;


public void execute() throws ModuleException;
public Properties getStateForRestart() throws ModuleException;

public Properties getSummary() throws ModuleException;


public int onExit(boolean success) throws ModuleException;
}

August 2007

TELUS Confidential

148

ControlM Architecture
Key Points
Control M Server
dispatches and coordinates
the work between all agents

Enterprise Manager
DB

Control M Agents start and


monitor the jobs

GUI

GATEWAY

CONTROL-M/Server
GATEWAY

DB

CONTROL-M

WINDOWS

GATEWAY

GATEWAY

DB

CONTROL-M

DB

CONTROL-M

LINUX

UNIX

GATEWAY

CONTROL-M

OS/390

CONTROL-M/Agent
CONTROL-M
Agent

UNIX

August 2007

CONTROL-M
Agent

WINDOWS

CONTROL-M
Agent

LINUX

TELUS Confidential

CONTROL-M
Agent

AS/400

DB

CONTROL-M
Agent

TANDEM

149

Job Scheduling and Transition

Jobs are instantiated and monitored by Control M Agents

All UNIX-based jobs execute a UNIX command or script

A job can be configured to start based on 3 situations


at a particular time or date/time (e.g. daily at 7 a.m. GMT, every 10 mins, at 2 p.m.
GTM on the 7th of each month)
a file or group of files is detected (using the Control M filewatcher job)
an event-based condition is detected Out Conditions are created upon successful
job completion which subsequently satisfy downstream job In Conditions

Starts at 7 a..m.
GMT every
Sunday morning

Job A1

Waiting for red


flag as In Condition

Job B1
Job A2
Job B2
Job A3
Job B3

August 2007

TELUS Confidential

Stringing Jobs Together Correctly


filewatcher is only suitable for jobs that
rely on events that occur outside of
Control M (i.e. mainframe drops a file in
a directory)
Event-based conditions should always
be used to string together all Control M
initiated jobs

150

Sample CTM Filewatch Job

August 2007

TELUS Confidential

151

Sample CTM Unix Job

August 2007

TELUS Confidential

152

Sample CTM setting conditions to a Job

August 2007

TELUS Confidential

153

Sample CTM passing Parm to Unix & BEC

August 2007

TELUS Confidential

154

Sample CTM File Transfer Job

August 2007

TELUS Confidential

155

Development & Build Tools


Introduction and Objectives
Web Controller Framework
Asynchronous Message Processing
Asynchronous Error Handling
Batch Framework

Development & Build Tools


Review
Q&A
Wrap-up

August 2007

TELUS Confidential

156

Development Directory Structure

Standard directory structure for all projects


Ensures consistency across and within projects
Key to the integration of the development environment
Maven, Harvest, and Eclipse share the same structure

Covers all development artifacts


Java code, JSP, HTML, CSS, Javascript, configuration files, libraries and
build scripts

August 2007

TELUS Confidential

157

Development Directory Structure


Application-centric approach

August 2007

TELUS Confidential

158

Development Directory Structure


services_app
resource grouping
contains components
that make up the
business services
end state distribution
is an EJB jar file

August 2007

TELUS Confidential

159

Development Directory Structure


web_app
resource grouping
contains components
that make up the web
application
end state distribution is
a war file
same as services_app
with the addition of the
web_content folder

August 2007

TELUS Confidential

160

Development Directory Structure


enterprise_app
resource grouping
primarily for
assembling an
enterprise application
resource (EAR file)
typically contain 1 war
and 1 jar file
no src directory

August 2007

TELUS Confidential

161

High-Level Java Packages


Topmost level:
com.telus.{application or domain name}
Next Level:
com.telus.{???}.services
com.telus.{???}.domain (or .business)
com.telus.{???}.dao
com.telus.{???}.adapter
com.telus.{???}.web
com.telus.{???}.batch
com.telus.{???}.mdb
August 2007

TELUS Confidential

162

High-Level Java Packages


Services package:
Should have a sub-package for each service
For example, within
com.telus.somedomain.services.customermgtservice
would be the service interface, service implementation (POJO),
the EJB wrapper, the remote (and/or local) EJB interface and the
home (and/or local home) interface

August 2007

TELUS Confidential

163

Standard Development Tools


Maven
Harvest
Eclipse and myEclipse

August 2007

TELUS Confidential

164

Standard Development Tools Maven


What is it?
Project Management and Project Comprehension Tool
Based on the concept of Project Object Model (POM)
Provides structure for describing the dependencies of a
project
Integrates unit testing, code analysis, project historical
analysis reports

August 2007

TELUS Confidential

165

Standard Development Tools - Maven


Why use Maven?
Establish a consistent project structure
Facilitate Test Driven Development by integrating with
JUnit
Standardized goals for all Maven projects:
maven genapp, maven jar, maven clean,
maven eclipse, maven copylib, etc.

August 2007

TELUS Confidential

166

Standard Development Tools - Maven


Pre-build Maven Goals to automatically:

August 2007

Compile your code


Create Javadoc documentation
Run unit tests
Run source code metrics and analysis
Create HTML cross-referenced source code
Facilitate Test Driven Development by integrating with
JUnit

TELUS Confidential

167

Standard Development Tools - Maven


Managing Third Party libraries
Third-party libraries are kept in the remote Maven
repository
Eclipse project jar dependencies are defined and maintained in the project.xml
Dependent jars are downloaded to the local Maven repository (specified by the
MAVEN_REPO environment variable in Eclipse)

Open Source Library versions are managed by


Frameworks team
Frameworks team defines the versions of external open source libraries
Populate the remote Maven repository

Framework Components
Managed and maintained the same as open source libraries

August 2007

TELUS Confidential

168

Standard Development Tools - Maven


Managing Third Party libraries

August 2007

TELUS Confidential

169

Standard Development Tools - Maven


Eclipse MAVEN_REPO environment variable
Needs to be specified as:
$HOME/.maven/repository folder
where $HOME=C:\Document and Setting\{logon id}

Go to menu item:
Windows -> Preferences,
and then select Java
-> Build Path
-> Classpath Variables,
click New
to add the MAVEN_REPO variable.

August 2007

TELUS Confidential

170

Standard Development Tools - Maven


Integration with Other Tools
Establish the common directory structure to allow
integration with Eclipse/myEclipse and Harvest
Maven will generate the .project and .classpath for
Eclipse
run maven genapp using the telus-j2ee template to generate the initial setup
for J2EE development directory structure.
import/refresh your project in Eclipse. All source directories and target
directories are setup in Eclipse.
run maven eclipse:external-tools will register all the Maven goals such as jar,
clean, etc. as external tools in Eclipse.

MevenIDE plug-in for Eclipse allows editing of the


Project Object Model using a UI rather than editing the
XML file.
August 2007

TELUS Confidential

171

Standard Development Tools


Maven

Harvest
Eclipse and myEclipse

August 2007

TELUS Confidential

172

Standard Development Tools Harvest


What is it?
Process-driven, Integrated Change and Configuration
Management Tool
Underlying process is defined by Application teams
working with Configuration Management

August 2007

TELUS Confidential

173

Standard Development Tools Harvest


Harvest Concepts
Package
A package is a separate unit with a unique name and is used to transition items through
the project. A package is required to checkout or check in an item, or to move one or
more items through a lifecycle using the promotion process

Default Context
Specify the default values of the connection between Harvest and the local file system.

Update
Only one person can check-out an item for update. The item will be locked, prohibiting
anyone else from requesting an update

Concurrent Update
Multiple check-out for updates is allowed. The last check-in will need to merge the
changes.

August 2007

TELUS Confidential

174

Standard Development Tools - Harvest


Using Harvest
Initial check-in / check-out of components should use
the Harvest Workbench GUI Application
Capture files at the application level
Initial check-in is performed by the Development
Lead after using the Maven initialization process
Check in the .project and .classpath files
After initial check-in, can use the Harvest plug-in

August 2007

TELUS Confidential

175

Standard Development Tools - Harvest


Integration with Other Tools
Harvest plug-in for Eclipse
Use Harvest Workbench 5.2.1 Patch 03
Similar functionality as the CVS plug-in such as check-in, check-out,
and synchronization of local files

Harvest Limitations
Support for package delete
An empty folder cannot be deleted without involving Harvest
Administration
Renaming files back to a previously existing file names
ClassName.java ClassName1.java ClassName.java
. Is not allowed

August 2007

TELUS Confidential

176

Standard Development Tools Harvest Demo


Create a new Harvest connection:

August 2007

TELUS Confidential

177

Standard Development Tools Harvest Demo


Login to Harvest:

August 2007

TELUS Confidential

178

Standard Development Tools Harvest Demo


Setup the Harvest Context:

August 2007

TELUS Confidential

179

Standard Development Tools Harvest Demo


Harvest Repository view:

August 2007

TELUS Confidential

180

Standard Development Tools Harvest Demo


Adding the projects to the workspace:

August 2007

TELUS Confidential

181

Standard Development Tools Harvest Demo


Project connected to Harvest Repository:

August 2007

TELUS Confidential

182

Standard Development Tools Harvest Demo


Checking out from Harvest:

August 2007

TELUS Confidential

183

Standard Development Tools Harvest Demo


Specifying Checkout Mode:

August 2007

TELUS Confidential

184

Standard Development Tools Harvest Demo


Checking in Changes:

August 2007

TELUS Confidential

185

Standard Development Tools Harvest Demo


Synchronizing with Server:

August 2007

TELUS Confidential

186

Standard Development Tools Harvest Demo


Adding or Removing from Project:

August 2007

TELUS Confidential

187

Standard Development Tools


Maven
Harvest

Eclipse and MyEclipse

August 2007

TELUS Confidential

188

Standard Development Tools Eclipse & MyEclipse


What is it?
Eclipse is the TELUS Standard for Java IDE
MyEclipse is an extension to the Eclipse
workbench

August 2007

TELUS Confidential

189

Standard Development Tools - Eclipse


Eclipse configuration files
- contained in the TELUS Framework Eclipse zip file

TELUS Java Code Formatting Standards


TelusEclipseFormatting.xml

TELUS Java Code Templates


TelusEclipseCodeTemplate.xml

TELUS Java Code Assist


TelusEclipseCodeAssist.xml

TELUS Java Import Order Preferences


TelusEclipsePreferences.importorder

August 2007

TELUS Confidential

190

Standard Development Tools Eclipse


Eclipse Configuration
To import the TELUS settings:
Window | Preferences
IMPORT TelusEclipsePreferences.epf

August 2007

TELUS Confidential

191

Standard Development Tools Eclipse


Eclipse Configuration
To import the TELUS Java Formatting:
Window | Preferences | Java | CodeStyle | CodeFormatter
IMPORT TelusEclipseFormatting.xml

August 2007

TELUS Confidential

Click Here

192

Standard Development Tools Eclipse Shortcuts


Short Cut

Description

CTRL + Spacebar

Code Assist

CTRL + Shift + F

Format Java Code

CTRL + Shift + O

Organize Imports

CTRL+F

Search / Find

CTRL+K

Find Next

CTRL+Shift+K

Find Previous

CTRL+L

Go to Line number

CTRL+/

Toggle with commenting out or uncomment the current line or selected


lines by adding // or removing the prefix // to each line

Select Lines +
CTRL+Shift+/

Change all the selected lines into a Java comment using /* */

Select Lines +
CTRL+Shift+\

Remove the /* */ commented out code.

August 2007

TELUS Confidential

193

Standard Development Tools - MyEclipse


Why use MyEclipse?
Provides a number of smart source editors with code
completion, validation, and syntax coloring
JSP, HTML, XML, CSS, JavaScript, J2EE deployment descriptors

Provides Application Server Connectors


Full support for wide range of application servers including WebLogic,
WebSphere and Tomcat

Provides application debugging, validation


Full support for hot swap debugging, JSP debugging in native source code
and include files

August 2007

TELUS Confidential

194

Standard Development Tools MyEclipse


Configuring the Application Server
In MyEclipse, click menu Window -> Preferences to open the Preferences dialog

August 2007

TELUS Confidential

195

Standard Development Tools MyEclipse


Configuring the Application Server
In Preferences dialog, configure WebLogic 8 application server like the following

August 2007

TELUS Confidential

196

Standard Development Tools MyEclipse


Configuring the Application Server
For Launch options, set the following values:

August 2007

TELUS Confidential

197

Standard Development Tools MyEclipse


Starting WebLogic from within MyEclipse

August 2007

TELUS Confidential

198

Standard Development Tools


Tool Interaction
7
Harvest Eclipse Plug-in

Eclipse

6
Harvest Workbench

MyEclipse

9
WebLogic
Server

August 2007

TELUS Confidential

Harvest
Repository

199

Build and Promotion Process

August 2007

TELUS Confidential

200

Environment Design

http://bcdev110.corp.ads/envs.html

August 2007

TELUS Confidential

201

EM Stream Primes

August 2007

TELUS Confidential

202

EM Environment Primes

August 2007

TELUS Confidential

203

Code Promotion Process Flow

August 2007

TELUS Confidential

204

Review
Introduction and Objectives
Web Controller Framework
Asynchronous Message Processing
Asynchronous Error Handling
Batch Framework
Development & Build Tools

Review
Q&A
Wrap-up

August 2007

TELUS Confidential

205

Course Review
Key Course Concepts
Web Controller Framework
Asynchronous Message Processing Framework
Asynchronous Error Messaging Framework
Batch Framework
Development & Build Tools

August 2007

TELUS Confidential

206

Q&A
Introduction and Objectives
Web Controller Framework
Asynchronous Message Processing
Asynchronous Error Handling
Batch Framework
Development & Build Tools
Review

Q&A
Wrap-up

August 2007

TELUS Confidential

207

Questions ??

August 2007

TELUS Confidential

208

Wrap-up
Introduction and Objectives
Web Controller Framework
Asynchronous Message Processing
Asynchronous Error Handling
Batch Framework
Development & Build Tools
Review
Q&A

Wrap-up

August 2007

TELUS Confidential

209

Next Steps
Visit the Frameworks Website
http://isis.tsl.telus.com/is/EM/Frameworks/index.cfm
for

Critical Skills Training presentations


Design Documentation
Code Samples
Class Libraries
Deliverable contact information

August 2007

TELUS Confidential

210

Evaluation
Please fill out your course evaluation forms now.

August 2007

TELUS Confidential

You might also like