24
VII.1 Component based distributed systems

Component based distributed systems

  • Upload
    valmai

  • View
    51

  • Download
    3

Embed Size (px)

DESCRIPTION

Component based distributed systems. Component technologies under Java. Traditional object-oriented languages (Smalltalk, C++, but also Java) enable re-use only in limited mode (dependent on specifics of superior classes etc.) - PowerPoint PPT Presentation

Citation preview

Page 1: Component based distributed systems

VII.1

Component based distributed systems

Page 2: Component based distributed systems

VII.2

Component technologies under Java

• Traditional object-oriented languages (Smalltalk, C++, but also Java) enable re-use only in limited mode (dependent on specifics of superior classes etc.)

• Therefore: advanced encapsulation techniques on the basis of components:– Interface (s)

– explicit management of system-tied properties (for instance, corresponding to transactions and security)

– Events (optional)

• Concrete approaches under Java:– JavaBeans (Client)

– Enterprise JavaBeans (Server)

• Alternative: .NET-Components

Page 3: Component based distributed systems

VII.3

Properties of JavaBeans

• Introspection: inspection of the Bean-structure via Tools (via BeanInfo-Class respectively Patterns)

• Customization: adaptability of appearance and behavior

• Events: interaction between Beans

• Properties: attributes of Beans

• Persistence: persistent saving and re-use of Beans

More powerful than conventional class approach

Page 4: Component based distributed systems

VII.4

JavaBeans: component model

Public Methods of the ObjectEvent classes and

EventListener-classes

for Java Event Model

Constituents of the local status (Attributes):

• property (get/set)• indexed Property• bound property• constrained property

JAR Archive

- Classes as bytecode(also Events, Listener) - optional resources (data, media objects)

for graphic tools for definition of Properties

JavaBean Components

Introspection: information about Bean

(for instance, Icon, Methods, Events, Description)

Page 5: Component based distributed systems

VII.5

Development support

• Beans Development Kit (BDK) in co-operation with JDK

• Integration in other tools like for instance, IBM Websphere Studio, BEA Weblogic Workshop

• Graphical processing of Beans, Windows with List of the installed Beans, Beanbook, Editors

• Integration of ActiveX-Controls in JavaBeans (and vice versa) possible, however with limitations, for instance, corresponding to security model

Page 6: Component based distributed systems

VII.6Development support: example

Page 7: Component based distributed systems

VII.7

Enterprise JavaBeans

• Server component model

• Non-visual components, distribution

• Container as Runtime-Environment (system resources, services)

• Composition of components via Tools

• Supporting of transactional applications

• Mapping of component interactions on protocols like CORBA IIOP / RMI / SOAP

Page 8: Component based distributed systems

VII.8

Usage scenario

Goal: transfer of processing logic to the server;

implicit transactions

Client 1

Client 2

Distributed transactions

EJB

EJB

Transactionmonitor/DBMS

EJB Container

EJB-Server

Java RMI

Page 9: Component based distributed systems

VII.9EJB-Container

• Management of life cycle of Enterprise Bean• Providing of a Factory-interface for creation of new EJB-instances

(HomeInterface)• Generating of EJBObject-interface for remote use of Bean-Methods

(RemoteInterface)• Additionally: LocalInterface for efficient Comm. within a Container,

Realization via Application Server and Transaction monitors (for instance, BEA Weblogic, IBM WebSphere etc.)

Client

EJBObject

EJBFactoryEnterprise

Bean

methods

ejbCreateejbLookup

ejbDestroyDeveloped byBean Provider

EJB-Container Transaction mgmtState MgmtSecurity

<methods>

create(), finderXXX()

lookup(),destroy ()

Supported by EJBContainer

Page 10: Component based distributed systems

VII.10EJB: Session Beans and Entity Beans

• Session Beans: non-persistent; control of dialogues with Business-Objects of the application; interface to the Client(frequently one Session Bean per Client); Variants: Stateless Session Bean / Stateful Session Bean

• Entity Beans: persistent; represent Business-Objects with interface to data level; unique primary key with Mapping to data base; integration in transactions

Client

Session Bean (for instance,

Customer Support)

Entity Bean (for instance,

Account)

EJB-Container

Page 11: Component based distributed systems

VII.11

Enterprise JavaBeans

Session BeansMessage-driven

beansEntity Beans

StatelessSession Beans

StatefulSession Beans

Container Managed

Persistence

Bean Managed

Persistence

Stateless Service,

for instance,

Search engine

Processing with

internal state,

for instance, shopping

Durable data,

automatic Per-

sistence mechan.

Durable data,

own persistence

decision of the appl.

Multicast-Communication (1:n)

Page 12: Component based distributed systems

VII.12Persistence

Persistent storage of contents of Entity Beans

Bean Managed PersistenceContainer Managed Persistence

• Bean itself provides storage, for instance, via JDBC• Precise knowledge about life cycle necessary• Container generates a transaction to keep the data base consistent

• Container saves Bean Attribute, Realization for instance via EJB QL (Query Language)• Bean is informed about state of data by Container• Simple to use, as a rule preferable

Possible alternatives: JDO (Java Data Objects): Mapping of complex data objects between Database and Container

Page 13: Component based distributed systems

VII.13

Installation of Enterprise JavaBeans

• Delivering as JAR-files

• Constituents:– Bean-Components

– Deployment Descriptor ( (static) settings of security properties, transaction properties, environment properties, persistence properties)

– Home Interface (for instance, create, destroy etc.)

– Remote Interface (call interface)

• Instantiation via EJB-Factory

• Recording of properties of the installed EJBs in Directory Service via JNDI

Page 14: Component based distributed systems

VII.14Deployment Descriptor: example

<ejb-jar> <enterprise-beans> <session>

<ejb-name>bank</ejb-name> <home>BankHome</home> <remote>BankRemote</remote><ejb-class>BankBean</ejb-class> <transaction-type>Container</transaction-type> <session-type>Stateful</session-type>

<resource-ref> ...

</resource-ref> </session> </enterprise-beans> <assembly-descriptor>

......... </assembly-descriptor> </ejb-jar>

Page 15: Component based distributed systems

VII.15

Interface-Definitions: example

import javax.ejb.*;

import java.rmi.RemoteException;

public interface BankHome extends EJBHome {

public BankSession create() throws CreateException, RemoteException;

}

import javax.ejb.*;

import java.rmi.RemoteException;

public interface BankSession extends EJBObject {

public void transferRequest(AccountIdentification accountident, float amount, TransferOrder transOrder) throws RemoteException, TransferException;

}

Page 16: Component based distributed systems

VII.16

Implementation: exampleimport java.rmi.*;import javax.ejb.*;public class BankSession implements SessionBean { public void ejbCreate()throws RemoteException,CreateException{ } public void transferRequest(AccountIdentification accountIdent, float amount, TransferOrder transOrder) throws

RemoteException,TransferException { Account accountFrom = AccountHome.findAccountByNumber(accountIdent.accountNumber); //hold account accountFrom.checkAccount(accountIdent.pin, accountIdent.name); //proof access rights try { BankHome.findBankByBLZ(transOrder.bankSortingCodeNumber); } catch(FinderException) { throw new TransferException(„Bank not found“); } Account accountTo = AccountHome.findAccountByNumber(transOrder.accountNumber); accountFrom.debit(amount); accountTo.credit(amount); } public void ejbActivate()throws RemoteException { } public void ejbPassivate()throws RemoteException { } public void ejbRemove()throws RemoteException { } public void setSessionContext(SessionContext sessionContext) throws RemoteException { this.sessionContext = sessionContext; }}

Page 17: Component based distributed systems

VII.17

Localization

1. Home Interface implemented by Home Object

2. Home Object registered by Name Service

3. Client sends query to Name Service

4. Client obtains Reference5. Client calls Home Object6. Forwarding to Bean7. Create Bean Instance8. Assign Reference to EJB

Object9. Call business logic methods

Page 18: Component based distributed systems

VII.18

Transaction management

• Requirements: Distributed Transactions with 2-Phase-Commit must be supported by the basic infrastructure (EJB-Server)

• Use of Java Transaction Service (JTS), i.e. Java Binding of CORBA OTS (Object Transaction Service)

• Different transaction modes (for instance, optional, compulsory or implicit transactions)

Page 19: Component based distributed systems

VII.19

Transaction control

TX_NOT_SUPPORTED: Bean cannot be used inside of transactions (temporary suspension of a transaction)

TX_SUPPORTS: Using of the Bean in transaction context possible

TX_REQUIRED: Transaction possible; implicit starting of a new transaction (if there are no active transactions)

TX_REQUIRES_NEW: Transaction compulsory, new transaction started during method call of the Bean (temporary suspension of a existing transaction)

TX_MANDATORY: Transaction compulsory, must already exist before (otherwise exception notification)

Page 20: Component based distributed systems

VII.20

Security aspects• Implicit mechanisms which are controlled via so called

Security Descriptor Objects, relatively simply;

Example:

<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.2//EN“ "http://java.sun.com/j2ee/dtds/ejb_1_2.dtd">

<ejb-jar>

...

<assembly-descriptor>

<security-role> <role-name>Administrator</role-name> </security-role>

<method-permission>

<role-name>Administrator</role-name>

<method>

<ejb-name>BankBean</ejb-name> <method-name>*</method-name>

</method>

</method-permission>

</assembly-descriptor>

</ejb-jar>

Page 21: Component based distributed systems

VII.21

• Authentication (user name/ password)

• Authorization (role-based, configurable but no Instance- based access control)

• Basis: JAAS (Java Authentication and Authorization Service)

• Integrity and confidentiality via encryption using SSL and TSL

• Administration of security services via proprietary decisions inside the Application Server

Security aspects: general overview

Page 22: Component based distributed systems

VII.22

Java Messaging Service (JMS)

• Standard based Messaging-Programming interface• Mapping on products like MQ Series• Support of communication models:

– Point-to-Point

– Publish/Subscribe (also several receivers - Multicast)

• Part of Java Enterprise Edition• Integrable with JTS (Java Transaction Service), JNDI (Java Naming and

Directory Interface) and EJB (Enterprise Java Beans)• Trusted, heterogenic Program-to-Program-communication• Asynchronous with optional confirmations• Atomic delivery of messages and persistent storage possible

Page 23: Component based distributed systems

VII.23

JMS: Example

Sender („Supplier“)

Queue bankQueue = (Queue) naming.lookup(“Bank“);

QueueSender sender = session.createSender(bankQueue);

TextMessage statusMessage = session.createTextMessage(“Statusabfrage“);

sender.send(statusMessage);

Receiver („Consumer“)

Queue bankQueue = (Queue) naming.lookup(“Bank“);

QueueReceiver receiver = session.createReceiver(bankQueue);

TextMessage statusMessage = (TextMessage) receiver.receive();

...

statusMessage.acknowledge(); // optional confirmation to sender

Page 24: Component based distributed systems

VII.24

Integration concept

Client

TransactionMonitor JM

AP

I

JND

I

JTS

JID

L

JMS

JDB

C

Enterprise JavaBeans

BusinessApplication

DatabaseIIOP / RMI, SOAP,further protocols

• JMAPI - Java Management API• JNDI - Java Naming & Directory

Services• JTS - Java Transactional Services• JIDL - Java IDL• JMS - Java Messaging Service• JDBC - Java Database Connectivity• JDO – Java Data Objects

Java as integration technology,however extensive infrastructure services necessary

JDO