FrameworksFundamentals Trainingv5
FrameworksFundamentals Trainingv5
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
JAVA
J2EE Concepts
Audience
Solution Architects
D&S J2EE Developers
Objectives
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.
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
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
...
}
August 2007
TELUS Confidential
20
Example
extends AbstractStatelessSessionBean
{
private CustomerMgtService m_customerService;
....
}
...
}
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
typical
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
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
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" />
<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
August 2007
TELUS Confidential
30
<statement id="getCustomerById"...
<sqlMap namespace="Customer">
August 2007
TELUS Confidential
31
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
get
Answer:
se
t
Cu
st
om
er
Da
se
t
Jn
di
T
em
pl
a
te
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"
August 2007
TELUS Confidential
35
Spring Features
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">
<beans>
<bean id="name_of_bean" class="fully_qualified_class_name">
<property name="attribute1">
<value>somevalue</value>
</property>
<property name="attribute2">
August 2007
TELUS Confidential
37
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
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>
August 2007
TELUS Confidential
39
August 2007
TELUS Confidential
40
August 2007
TELUS Confidential
41
...
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
TELUS Confidential
42
nam
e
vic
e
se
t
Cu
st
om
er
Da
se
t
Jn
di
T
em
pl
a
te
get
Bea
n
(se
r
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.
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.
August 2007
TELUS Confidential
45
<group name="irrelevant">
<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
<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>
getList().get(idx)
August 2007
TELUS Confidential
46
getPropertyNode( String[] )
getProperty( String )
getProperty( String[] )
getPropertyAsInt( String )
getPropertyAsInt( String[] )
getPropertyAsBoolean( String )
getPropertyAsBoolean( String[] )
getList( String )
getList( String[] )
getProperties( String )
getProperties( String[] )
...
...
August 2007
TELUS Confidential
47
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)
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
Provider Class
com.telus.framework.config.provider.ldap.LdapXmlProvider
Setup
August 2007
TELUS Confidential
49
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:
August 2007
jndi.factory
jndi.authentication
jndi.principal
jndi.credentials
TELUS Confidential
50
August 2007
TELUS Confidential
51
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>
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
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
Use taglibraries (HTML-EL for Struts and webcontroller, JSF tags and JSTL tags)
in the JSPs Avoid scriptlets
August 2007
TELUS Confidential
56
...
public class SearchCustomerAction extends Action {
private CustomerMgtService m_customerService;
...
public ActionForward
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
58
<bean name="/searchCustomer"
class="com.telus.framework.sampleapp.action.SearchCustomerAction">
<property name="customerService">
<ref bean="customerServiceProxy"/>
</property>
</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>
</property>
</bean>
August 2007
TELUS Confidential
60
Struts - Recap
August 2007
TELUS Confidential
61
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>
</managed-property>
</managed-bean>
<application>
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
...
</application>
</faces-config>
August 2007
TELUS Confidential
63
</bean>
August 2007
TELUS Confidential
64
<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>
...
</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
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
August 2007
TELUS Confidential
69
WebController Framework
Output Object
Request Scoped Container
To be set from Action and retrieved from JSP
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}"/>
<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
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}"/>
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
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
August 2007
TELUS Confidential
86
<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
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
Convenience classes for doing common, generic validations and formatting (e.g. Date formats, basic credit card checking,
type checking, etc)
August 2007
TELUS Confidential
90
August 2007
TELUS Confidential
91
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
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>
August 2007
TELUS Confidential
104
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
BAN
SIN
PID
= PROVINCIAL ID
PRC
PSP
= PASSPORT
SID
= STUDENT ID
LCD
= LIBRARY CARD
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
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
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
August 2007
TELUS Confidential
113
August 2007
TELUS Confidential
114
...
</beans>
August 2007
TELUS Confidential
115
<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
August 2007
TELUS Confidential
117
August 2007
TELUS Confidential
118
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
August 2007
TELUS Confidential
121
August 2007
TELUS Confidential
122
Messaging Proxy
Data Flow Overview
August 2007
TELUS Confidential
123
August 2007
TELUS Confidential
124
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
August 2007
TELUS Confidential
126
August 2007
TELUS Confidential
127
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
com.telus.framework.messaging.AbstractMessageHandler
Implement the processMessage which will contain the business logic
August 2007
TELUS Confidential
129
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
August 2007
TELUS Confidential
131
August 2007
TELUS Confidential
132
August 2007
TELUS Confidential
133
August 2007
TELUS Confidential
134
August 2007
TELUS Confidential
135
Configurable parameters:
specify the folder path
August 2007
TELUS Confidential
136
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
August 2007
TELUS Confidential
140
August 2007
TELUS Confidential
141
August 2007
TELUS Confidential
142
August 2007
TELUS Confidential
143
value="${inbox}/fileProcessingSample-input.txt" />
August 2007
TELUS Confidential
144
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)
August 2007
TELUS Confidential
146
Job Controller
Initialization:
setters
launch
restoreState
August 2007
Loop:
Exit:
hasNext
getSummary
execute
onExit
getStateForRestart
TELUS Confidential
147
August 2007
TELUS Confidential
148
ControlM Architecture
Key Points
Control M Server
dispatches and coordinates
the work between all agents
Enterprise Manager
DB
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
Starts at 7 a..m.
GMT every
Sunday morning
Job A1
Job B1
Job A2
Job B2
Job A3
Job B3
August 2007
TELUS Confidential
150
August 2007
TELUS Confidential
151
August 2007
TELUS Confidential
152
August 2007
TELUS Confidential
153
August 2007
TELUS Confidential
154
August 2007
TELUS Confidential
155
August 2007
TELUS Confidential
156
August 2007
TELUS Confidential
157
August 2007
TELUS Confidential
158
August 2007
TELUS Confidential
159
August 2007
TELUS Confidential
160
August 2007
TELUS Confidential
161
TELUS Confidential
162
August 2007
TELUS Confidential
163
August 2007
TELUS Confidential
164
August 2007
TELUS Confidential
165
August 2007
TELUS Confidential
166
August 2007
TELUS Confidential
167
Framework Components
Managed and maintained the same as open source libraries
August 2007
TELUS Confidential
168
August 2007
TELUS Confidential
169
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
TELUS Confidential
171
Harvest
Eclipse and myEclipse
August 2007
TELUS Confidential
172
August 2007
TELUS Confidential
173
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
August 2007
TELUS Confidential
175
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
August 2007
TELUS Confidential
177
August 2007
TELUS Confidential
178
August 2007
TELUS Confidential
179
August 2007
TELUS Confidential
180
August 2007
TELUS Confidential
181
August 2007
TELUS Confidential
182
August 2007
TELUS Confidential
183
August 2007
TELUS Confidential
184
August 2007
TELUS Confidential
185
August 2007
TELUS Confidential
186
August 2007
TELUS Confidential
187
August 2007
TELUS Confidential
188
August 2007
TELUS Confidential
189
August 2007
TELUS Confidential
190
August 2007
TELUS Confidential
191
August 2007
TELUS Confidential
Click Here
192
Description
CTRL + Spacebar
Code Assist
CTRL + Shift + F
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+/
Select Lines +
CTRL+Shift+/
Select Lines +
CTRL+Shift+\
August 2007
TELUS Confidential
193
August 2007
TELUS Confidential
194
August 2007
TELUS Confidential
195
August 2007
TELUS Confidential
196
August 2007
TELUS Confidential
197
August 2007
TELUS Confidential
198
Eclipse
6
Harvest Workbench
MyEclipse
9
WebLogic
Server
August 2007
TELUS Confidential
Harvest
Repository
199
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
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
August 2007
TELUS Confidential
210
Evaluation
Please fill out your course evaluation forms now.
August 2007
TELUS Confidential