Transcript Slide 1

Javan tehokas
hyödyntäminen ja
integraatiot PL/SQL
pohjaisissa
arkkitehtuureissa
Marko Asplund
Ixonos Teknologiakonsultointi oy
Enter Information Classification here
29.3.2007
© Ixonos Oyj
About the speaker
• Senior Consultant / Ixonos Technology Consulting
• Architecture design and implementation of enterprise applications,
typically with Java technologies
• MSc., SCEA, SCBCD, SCJP, OCA
Enter Information Classification here
29.3.2007
© Ixonos Oyj
2
Ixonos in Brief
Ixonos operates in the ICT services market, producing customer specific
technology consulting, project management and software production
services
• Founded 1994, listed OMX Nordic Exchange in Helsinki
• Clientele comprises leading mobile and smartphone manufacturers,
mobile network suppliers and telecom operators operating on the
global markets as well as Finnish finance, industrial and service
companies and public administration organizations.
• Headquarters in Helsinki, offices in Salo, Tampere, Turku, Jyväskylä,
Oulu, Kemi, Haapajärvi and Slovak Republic, Estonia and Germany
• Turnover in 2007: 59,2 MEUR
• Operating profit in 2007: 4,7 MEUR
• Current personnel more than 900
Enter Information Classification here
29.3.2007
© Ixonos Oyj
3
Ixonos Service Areas and Service Focus
Strategic issues
of our customers
”Implementing Strategy”
Supporting Corporate Executives
Tactical and development
issues of our customers
Operative issues
of our customers
Project Methodologies and
Tools
Leading PMOs,
Managing Programs and
Projects
Business Processes,
Product Predevelopment etc.
SW Architectures and
Requirements
“Improving Performance”
Supporting Project Executives
“Correct Competence”
Supporting Projects
PROJECT MANAGEMENT SERVICES
Project Portfolios and PMOs
TECHNOLOGY CONSULTING SERVICES
Business Architectures
and Intelligence
USER INTERFACE & USER EXPERIENCE DESIGN SERVICES
UI Prototypes & Usability,
Graphic Design
UI Specifications
Project Delivery Processes,
Methodologies and Tools
Project Service Delivery
TESTING & QUALITY ASSURANCE SERVICES
Testing & QA Strategies
Testing Delivery Processes,
and Requirements
Methodologies and Tools
Testing and QA Service
Delivery
User Interface Concept Design
PROJECT DELIVERIES
Business Requirements
MAINTENANCE SERVICES
Service and Service Level
Requirements
Maintenance Processes,
Methodologies and Tools
Enter Information Classification here
Maintenance Service Delivery
29.3.2007
© Ixonos Oyj
4
Presentation background
• Objective
• Identify potential for Java technologies in PL/SQL based
applications
• Review integration strategies and techniques
• Audience
• People involved with PL/SQL based application development
who see potential for using Java technologies
• Java developers
• PL/SQL developers
• (project managers)
• Context
• Web application
• Java call-out to PL/SQL code
Enter Information Classification here
29.3.2007
© Ixonos Oyj
5
Agenda
•
•
•
•
Architectural differences between the two technologies
Role of Java and PL/SQL
Strategies for introducing Java in PL/SQL based applications
Techniques for integrating Java and PL/SQL
Enter Information Classification here
29.3.2007
© Ixonos Oyj
6
Strengths of Java and PL/SQL
PL/SQL
• Standard way of implementing
stored procedures
• Tight integration with the database:
types, SQL execution etc.
• Simple development and
deployment model
• Performance (network roundtrips)
• A key technology for Oracle
Java
• Momentum
• Developer mindshare
• Universal adoption – future proof
• Development tools
• Peer support
• Third party libraries and software
• Strategic technology for Oracle
Enter Information Classification here
29.3.2007
© Ixonos Oyj
7
The case for Java
•
•
•
•
Succesfull system outgrows expectations
Well suited for enterprise application development
Lack of ready-made PL/SQL packages in certain areas
Database professional resource shortage
Enter Information Classification here
29.3.2007
© Ixonos Oyj
8
PL/SQL’s strong points
•
•
•
•
Triggers
Adapting ORM and database schemas
Higher level data access abstraction layer
Sharing and enforcing centralized set of business rules across
applications
Enter Information Classification here
29.3.2007
© Ixonos Oyj
9
Architectural differences
PL/SQL
Java EE
Client
Client
WebTier
MVC,
Struts/JSF/...
HTTP Server
mod_plsql
service + data
access layers
EJB, POJO, JPA, ..
BusinessTier
Oracle RDBMS
Oracle RDBMS
or other
information
system
Enter Information Classification here
EISTier
29.3.2007
© Ixonos Oyj
10
Development environments
PL/SQL
• Toad, Oracle SQL Developer or
text editor
• Oracle RDBMS
• Apache or Oracle Web Server
• Version Control System (CVS,
SVN)
Java
• Java JDK
• JDeveloper
• OC4J
• Oracle RDBMS
• Version Control System (CVS,
SVN)
Enter Information Classification here
29.3.2007
© Ixonos Oyj
11
JDeveloper
•
•
•
•
•
•
Well integrated with Oracle RDBMS and Application Server
RAD development with ADF and JSF
Java EE support
Embedded OC4J
PL/SQL package proxy class generation
PL/SQL Web Service generation
Enter Information Classification here
29.3.2007
© Ixonos Oyj
12
Architectural issues
•
•
•
•
•
Development process
Deployment model
Importance of a well designed service layer
Performance
Licensing
Enter Information Classification here
29.3.2007
© Ixonos Oyj
13
Integration approaches and techniques
• Approaches
• Re-implement from scratch
• Horizontal migration
• Vertical migration
• Techniques
• JDBC
• Database tables
• Web Services
• Streams Advanced Queueing
• Direct server-side stored procedure calls
• Practical matters
• Exception handling
• Oracle object types
Enter Information Classification here
29.3.2007
© Ixonos Oyj
14
Re-implement from scratch
• Costly
• Risky
• Slow time to market
Enter Information Classification here
29.3.2007
© Ixonos Oyj
15
Horizontal migration
• Migrate layer at
a time
• From top to
bottom
• Original
application
should have a
layered
architecture
• If not,
refactoring
required
Original
Presentation
PL/SQL
W1
W2
Target
Presentation'
W1'
Service
PL/SQL
S1
S2
Data Access
PL/SQL
DA1
DA2
Enter Information Classification here
W2'
Java
Service
S1
S2
PL/SQL
Data Access
DA1
29.3.2007
DA2
© Ixonos Oyj
PL/SQL
16
Vertical migration
• Hybrid architecture: Java and
PL/SQL based subsystems
collectively implement application
feature set
• Migrate logical application units
vertically through all layers
• HTTP Server routes requests to the
appropriate subsystem
• Database as ”integration bus”
• Overhead due to plumbing code
duplication
• NB: caching, concurrency,
transactions etc. need to be
implemented coherently!
Client
HTTP Server
WebTier
BusinessTier
Enter Information Classification here
29.3.2007
Oracle RDBMS
© Ixonos Oyj
17
Vertical migration
Original
Target
PL/SQL
Java
PL/SQL
Presentation
Presentation
W1
W3
W2
Service
S1
Service
S2
Data Access
DA1
W4
DA2
S3
Presentation 1
Presentation 1
W2
W1'
S4
DA4
S2
S1'
Enter Information Classification here
W4
S3
S4
Data Access 1
Data Access 1
DA2
W3
Service 1
Service 1
Data Access
DA3
Java
DA1'
29.3.2007
DA3
© Ixonos Oyj
DA4
18
JDBC based integration
•
Same technique can be used across platforms
•
•
•
PL/SQL call from JDBC
PL/SQL call with Spring framework
PL/SQL call using JPublisher generated code
Enter Information Classification here
29.3.2007
© Ixonos Oyj
19
Demo PL/SQL package
CREATE OR REPLACE PACKAGE ougf AS
FUNCTION hello2(name VARCHAR2) RETURN VARCHAR2;
END ougf;
CREATE OR REPLACE PACKAGE BODY ougf AS
FUNCTION hello2(name VARCHAR2) RETURN VARCHAR2 IS
BEGIN
RETURN 'hello, ' || name;
END hello2;
END ougf;
Enter Information Classification here
29.3.2007
© Ixonos Oyj
20
PL/SQL call from JDBC
Connection c = dataSource.getConnection();
CallableStatement stmt =
c.prepareCall("{? = call ougf.hello2(?)}");
stmt.registerOutParameter(1, Types.VARCHAR);
stmt.setString(2, “ougf");
stmt.execute();
String msg = stmt.getString(1);
Enter Information Classification here
29.3.2007
© Ixonos Oyj
21
PL/SQL call with Spring framework
public class Greeter2 extends StoredProcedure {
public Greeter2(DataSource ds) {
setDataSource(ds);
setSql("ougf.hello2");
setFunction(true);
declareParameter(new SqlOutParameter("message",
Types.VARCHAR));
declareParameter(new SqlParameter("name", Types.VARCHAR));
compile();
}
public String getGreeting(String name) {
Map params = new HashMap();
params.put("name", name);
Map res = execute(params);
return (String)res.get("message");
}
}
Enter Information Classification here
29.3.2007
© Ixonos Oyj
22
PL/SQL call with Spring framework – cont.
Greeter2 g = new Greeter2(ds);
String msg = g.getGreeting(“Larry");
Enter Information Classification here
29.3.2007
© Ixonos Oyj
23
PL/SQL call using JPublisher generated code
• Use Oracle JPublisher / JDeveloper to generate Java code for
accessing PL/SQL procedures
Ougf ougf = new Ougf(dataSource);
String msg = ougf.hello2(“Charles");
Enter Information Classification here
29.3.2007
© Ixonos Oyj
24
Direct server-side stored procedure calls
•
•
•
•
•
Java can be used for implementing stored procedures
Typically Java is used in the middle tier
Java stored procedures can be called from PL/SQL and vice versa
PL/SQL call-out to Java also possible via External Procedure call
Is server-side Java going to be supported on the long term?
Dependence on DB server Java version
Enter Information Classification here
29.3.2007
© Ixonos Oyj
25
Streams Advanced Queueing
• Asynchronous messaging
• APIs: JMS + DBMS_AQ et al. + (SOAP)
Enter Information Classification here
29.3.2007
© Ixonos Oyj
26
Exception handling
DataAccessException
CleanupFailureDataAccessException
UncategorizedDataAccessException
DataAccessResourceFailureException
DataIntegrityViolationException
InvalidDataAccessApiUsageException
DataRetrievalFailureException
InvalidDataAccessResourceUsageException
IncorrectUpdateSem anticsDataAcces sException
DeadlockLoserDataAccessException
Optim isticLockingFailureException
ObjectRetvievalFailureException
ObjectOptim isticLockingFailureExcep tion
TypeMism atchDataAccessException
Enter Information Classification here
29.3.2007
© Ixonos Oyj
27
SQL exception handling
// Spring exception mapping with AspectJ
public aspect ExceptionTranslator {
private static final
SQLErrorCodeSQLExceptionTranslator translator =
new SQLErrorCodeSQLExceptionTranslator("Oracle");
after() throwing(SQLException e): call(public *
com.ixonos.plsql.jpublish..*(..)) {
throw
translator.translate(thisJoinPoint.toString(),
null, e);
}
}
Enter Information Classification here
29.3.2007
© Ixonos Oyj
28
PL/SQL exception handling
• User-defined exceptions don't include enough information to be
processed by the caller (Java)
• possible to define an exception translator or aspect to extract
data from the message
• Recommended approach
• use Oracle application errors (raise_application_error)
• define an exception class for each error condition
• define error codes for Spring translator (sql-error-codes.xml)
Enter Information Classification here
29.3.2007
© Ixonos Oyj
29
How to proceed
•
•
•
•
Business
• Define business objective and drivers
• Define IT and architectural drivers
Product management
• Plan feature roadmap
Competence management
Technology
• Evaluate existing architecture and code base (esp. layering)
• Assess reusability
• Design target architecture (hw + sw, licensing)
• Choose integration strategy
• Development process development
Enter Information Classification here
29.3.2007
© Ixonos Oyj
30
Summary
• Java and PL/SQL play well together
• Both are well supported by Oracle
• Hybrid architecture for a transition period if ”re-implement from
scratch” is not feasible
• Use JDeveloper/JPublisher generated proxy classes
• Practical matters
• Performance
• Licensing
• Exception handling
• Type mapping
Enter Information Classification here
29.3.2007
© Ixonos Oyj
31
Kiitos – Thank you
www.ixonos.com
Enter Information Classification here
29.3.2007
© Ixonos Oyj