1 Component based distributed systems 2 Component technologies

  • Slides: 24
Download presentation
1 Component based distributed systems

1 Component based distributed systems

2 Component technologies under Java • Traditional object-oriented languages (Smalltalk, C++, but also Java)

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: – Java. Beans (Client) – Enterprise Java. Beans (Server) • Alternative: . NET-Components

3 Properties of Java. Beans • Introspection: inspection of the Bean-structure via Tools (via

3 Properties of Java. Beans • Introspection: inspection of the Bean-structure via Tools (via Bean. Info-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

4 Java. Beans: component model Introspection: information about Bean for graphic tools for definition

4 Java. Beans: component model Introspection: information about Bean for graphic tools for definition of Properties (for instance, Icon, Methods, Events, Description) Public Methods of the Object Java. Bean Components Event classes and Event. Listener-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)

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

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 Active. X-Controls in Java. Beans (and vice versa) possible, however with limitations, for instance, corresponding to security model

Development support: example 6

Development support: example 6

7 Enterprise Java. Beans • Server component model • Non-visual components, distribution • Container

7 Enterprise Java. Beans • 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

8 Usage scenario Distributed transactions Java RMI Client 1 EJB Transaction monitor/ DBMS EJB

8 Usage scenario Distributed transactions Java RMI Client 1 EJB Transaction monitor/ DBMS EJB Container Client 2 EJB-Server Goal: transfer of processing logic to the server; implicit transactions

9 EJB-Container Transaction mgmt <methods> Client create(), finder. XXX() lookup(), destroy () methods State

9 EJB-Container Transaction mgmt <methods> Client create(), finder. XXX() lookup(), destroy () methods State Mgmt Security ejb. Create ejb. Lookup Enterprise Bean EJBObject EJBFactory Supported by EJBContainer ejb. Destroy Developed by Bean Provider • Management of life cycle of Enterprise Bean • Providing of a Factory-interface for creation of new EJB-instances (Home. Interface) • Generating of EJBObject-interface for remote use of Bean-Methods (Remote. Interface) • Additionally: Local. Interface for efficient Comm. within a Container, Realization via Application Server and Transaction monitors (for instance, BEA Weblogic, IBM Web. Sphere etc. )

EJB: Session Beans and Entity Beans 10 • Session Beans: non-persistent; control of dialogues

EJB: Session Beans and Entity Beans 10 • 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

11 Enterprise Java. Beans Message-driven beans Session Beans Entity Beans Multicast-Communication (1: n) Stateless

11 Enterprise Java. Beans Message-driven beans Session Beans Entity Beans Multicast-Communication (1: n) Stateless Session Beans Stateful Session Beans Container Managed Persistence Bean Managed Persistence Stateless Service, Processing with Durable data, for instance, internal state, automatic Per- own persistence Search engine for instance, shopping sistence mechan. decision of the appl.

Persistence 12 Persistent storage of contents of Entity Beans Container Managed Persistence • Container

Persistence 12 Persistent storage of contents of Entity Beans Container Managed Persistence • 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 Bean 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 Possible alternatives: JDO (Java Data Objects): Mapping of complex data objects between Database and Container

13 Installation of Enterprise Java. Beans • Delivering as JAR-files • Constituents: – Bean-Components

13 Installation of Enterprise Java. Beans • 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

Deployment Descriptor: example <ejb-jar> <enterprise-beans> <session> <ejb-name>bank</ejb-name> <home>Bank. Home</home> <remote>Bank. Remote</remote> <ejb-class>Bank. Bean</ejb-class> <transaction-type>Container</transaction-type>

Deployment Descriptor: example <ejb-jar> <enterprise-beans> <session> <ejb-name>bank</ejb-name> <home>Bank. Home</home> <remote>Bank. Remote</remote> <ejb-class>Bank. Bean</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> 14

15 Interface-Definitions: example import javax. ejb. *; import java. rmi. Remote. Exception; public interface

15 Interface-Definitions: example import javax. ejb. *; import java. rmi. Remote. Exception; public interface Bank. Home extends EJBHome { public Bank. Session create() throws Create. Exception, Remote. Exception; } import javax. ejb. *; import java. rmi. Remote. Exception; public interface Bank. Session extends EJBObject { public void transfer. Request(Account. Identification accountident, float amount, Transfer. Order trans. Order) throws Remote. Exception, Transfer. Exception; }

16 Implementation: example import java. rmi. *; import javax. ejb. *; public class Bank.

16 Implementation: example import java. rmi. *; import javax. ejb. *; public class Bank. Session implements Session. Bean { public void ejb. Create()throws Remote. Exception, Create. Exception{ } public void transfer. Request(Account. Identification account. Ident, float amount, Transfer. Order trans. Order) throws Remote. Exception, Transfer. Exception { Account account. From = Account. Home. find. Account. By. Number(account. Ident. account. Number); //hold account. From. check. Account(account. Ident. pin, account. Ident. name); //proof access rights try { Bank. Home. find. Bank. By. BLZ(trans. Order. bank. Sorting. Code. Number); } catch(Finder. Exception) { throw new Transfer. Exception(„Bank not found“); } Account account. To = Account. Home. find. Account. By. Number(trans. Order. account. Number); account. From. debit(amount); account. To. credit(amount); } public void ejb. Activate()throws Remote. Exception { } public void ejb. Passivate()throws Remote. Exception { } public void ejb. Remove()throws Remote. Exception { } public void set. Session. Context(Session. Context session. Context) throws Remote. Exception { this. session. Context = session. Context; } }

17 Localization 1. Home Interface implemented by Home Object 2. Home Object registered by

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 Reference 5. Client calls Home Object 6. Forwarding to Bean 7. Create Bean Instance 8. Assign Reference to EJB Object 9. Call business logic methods

18 Transaction management • Requirements: Distributed Transactions with 2 -Phase. Commit must be supported

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)

19 Transaction control TX_NOT_SUPPORTED: Bean cannot be used inside of transactions (temporary suspension of

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)

20 Security aspects • Implicit mechanisms which are controlled via so called Security Descriptor

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 Java. Beans 1. 2//EN“ "http: //java. sun. com/j 2 ee/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>Bank. Bean</ejb-name> <method-name>*</method-name> </method-permission> </assembly-descriptor> </ejb-jar>

Security aspects: general overview • Authentication (user name/ password) • Authorization (role-based, configurable but

Security aspects: general overview • Authentication (user name/ password) • Authorization (role-based, configurable but no Instancebased 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 21

22 Java Messaging Service (JMS) • Standard based Messaging-Programming interface • Mapping on products

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

23 JMS: Example Sender („Supplier“) Queue bank. Queue = (Queue) naming. lookup(“Bank“); Queue. Sender

23 JMS: Example Sender („Supplier“) Queue bank. Queue = (Queue) naming. lookup(“Bank“); Queue. Sender sender = session. create. Sender(bank. Queue); Text. Message status. Message = session. create. Text. Message(“Statusabfrage“); sender. send(status. Message); Receiver („Consumer“) Queue bank. Queue = (Queue) naming. lookup(“Bank“); Queue. Receiver receiver = session. create. Receiver(bank. Queue); Text. Message status. Message = (Text. Message) receiver. receive(); . . . status. Message. acknowledge(); // optional confirmation to sender

24 Integration concept Business. Application Java as integration technology, however extensive infrastructure services necessary

24 Integration concept Business. Application Java as integration technology, however extensive infrastructure services necessary JDBC JDO JMS JIDL JTS Transaction Monitor JNDI IIOP / RMI, SOAP, further protocols Enterprise Java. Beans JMAPI Client Database • 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