Persistence Strategies for Web Services

Download Report

Transcript Persistence Strategies for Web Services

Persistence Strategies for WebServices
[email protected]
Senior Consultant
Java Forum Stuttgart, 27. Juni 2002
1
Agenda
 Web Services Architecture
 Persistence Strategies for Web Services
 Transparent Java Persistence with Versant
 Summary
 Q&A
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
2
A Web Service Definition
“A collection of functions that are packaged as a single entity and published to
the network for use by other programs.
Web services are building blocks for creating open distributed systems, and
allow companies and individuals to quickly and cheaply make their digital
assets available worldwide.“ (*)
(*) http://www-106.ibm.com/developerworks/webservices/library/ws-peer1.html?dwzone=ws
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
3
The Web Services Reference Architecture
Web Services
Registry
UDDI
ebXML
Business Services
WSDL
WSDL
WSDL
Service
Oriented
Interfaces
description
discovery
Web Services Container
Web
Services
Client
SOAP/
HTTP(S)
execution
Web
Services
Runtime
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
Business Processes
4
Web Content
Delivery
Web Services
Gateway
JSP
Servlets
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
EIS
Line of Business Systems
Application Servers
Clustering
Web Application Servers
Clustering
HTTP Servers
Load Balancing
Users
SOAP
HTTP
Business
Logic
EJB
JDBC
JMS
5
The case for Middle-tier Persistence
 Need to store/retrieve “Application Data”
 Distinct from “Enterprise Data”
 “Application Data” modeled as objects
 Never need leave middle-tier
 Interactions & Business transactions
 “Interactions” have different data access requirements to traditional business
transactions
 Process-centric versus data-centric
Need solution able to handle “object” complexities
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
6
Web Content
Delivery
Web Services
Gateway
Business
Logic
EIS
Line of Business Systems
Application Servers
Clustering
Web Application Servers
Clustering
HTTP Servers
Load Balancing
Users
Application Data
SOAP
HTTP
JSP
Servlets
EJB
Object
Server
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
JDBC
JMS
7
Persistent Strategies for Web Services:
Entity Beans
 standard way to persist the domain model
 encapsulate the persistence mechanism
 distributed objects
 but should not be accessed remotely,
 common design practice
 to wrap entity beans with session beans
 supposed to be transaction aware objects
 the transactional context is to be managed by the calling session bean
Is there really a big difference between
Entity Beans and Persistent Java Objects ?
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
8
Persistent Strategies for Web Services:
Session Beans
 Tests have shown that using Session Beans with direct access to persistent
Java objects can lead to much more
 Performance and scalability
 Ease of use in typical EJB projects
 Clean design and implementation
 Persistence Layer is independent of the component framework
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
9
Persistent Strategies for Web Services:
Transparent Java Persistence
 Transparent persistence of Java objects
 No relational transformation code required
 Versus mapping of Java to relational models
 All you need to know is Java!
 Transparent object navigation of complex models
 Full support for inherent object complexity
 Inheritance, collections, multi-valued types
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
10
Transparent Java Persistence:
Development process
 No changes in source code for persistence
 Based on byte-code enhancement
 Java applications can be easily adapted
Employee
.java
Employee
.class
javac
java
com.versant.
Enhance
Employee
.class
c Employee
c Department
config.jvi
a LoadDatabase
a QueryDatabase
java
Employee
mydb
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
11
Transparent Java Persistence:
The UML Model
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
12
Class Employee
public class Employee
{
String name;
float salary;
Employee (String name) {
this.name
= name;
this.salary = (float) 70000;
}
void modifySalary(float delta) {
salary = salary + delta;
}
public String toString () {
return "Employee: " + name + " salary: " + salary;
}
}
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
13
Class Department
import java.util.Vector;
public class Department
{
String name;
Employee manager;
Vector employees;
Department (String name, Employee manager) {
this.name
= name;
this.manager = manager;
employees = new Vector();
}
void addEmployee(Employee emp) {
int size = employees.size();
employees.setSize( size + 1 );
employees.setElementAt( emp, size );
}
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
14
Class Department (cont)
Employee getManager() {
return manager;
}
Vector getEmployees() {
return employees;
}
public String toString ()
{
return "Department: " + name +
" employees:" + employees;
}
}
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
15
Load Database
Open database; create Boss, Department and Employees; commit.
import com.versant.trans.*;
public class LoadDatabase
{
public static void main (String[] args) {
String
database = args [0];
TransSession session = new TransSession (database);
Employee boss = new Employee ("Boss");
Department department = new Department("RD", boss);
Employee emp1 = new Employee ("Walt");
Employee emp2 = new Employee ("Dilbert");
department.addEmployee(emp1);
department.addEmployee(emp2);
session.makePersistent(department);
session.commit();
session.endSession ();
}
}
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
16
Query Database
import com.versant.trans.*;
import java.util.Vector;
import java.util.Enumeration;
public class QueryDatabase
{
public static void main (String[] args) {
String
database = args [0];
TransSession session = new TransSession (database);
VQLQuery query = new VQLQuery ( session,
"select selfoid from Department where manager->name = 'Boss'" );
Enumeration e = query.execute ();
if ( !e.hasMoreElements() ) {
System.out.println ("No objects were found.");
} else {
while ( e.hasMoreElements() ) {
typicalDilbertAction( (Department) e.nextElement() );
}
}
session.commit();
session.endSession ();
}
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
17
Query Database (cont)
private static final float increase = 5000;
private static void typicalDilbertAction(Department dep)
{
Vector employees = dep.getEmployees();
// Boss gets 5000$ more salary
dep.getManager().modifySalary(increase);
float decrease = increase/ employees.size();
for (int i = 0; i < employees.size(); i++)
{
Employee currentEmployee = (Employee) employees.elementAt(i);
currentEmployee.modifySalary(-decrease);
}
}
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
18
Web Content
Delivery
Web Services
Gateway
Business
Logic
EIS
Line of Business Systems
Application Servers
Clustering
Web Application Servers
Clustering
HTTP Servers
Load Balancing
Users
Application Data
SOAP
HTTP
JSP
Servlets
EJB
Object
Server
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
JDBC
JMS
19
Persistent Strategies for Web Services:
Summary
 Transparent Java Persistence
 Faster development cycles
 No Mapping
 Better performance with Navigation
 No Joins
 Full Database Management System Features
 Scalability
 Client- and Server-Cache
 Distributed Database
 Object-Level Locking
 24x7 Support
 Fault Tolerant Server
 On-Line Backup, HA-Backup
© 2002 Versant GmbH
Die hier vermittelten Informationen sind vertraulich zu behandeln und dürfen Dritten nur nach Genehmigung durch Versant zugänglich gemacht werden.
All products are trademarks or registered trademarks of their respective companies. The information contained in this document is property of Versant GmbH.
20