Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
VII.1 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 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 VII.4 JavaBeans: component model Introspection: information about Bean for graphic tools for definition of Properties (for instance, Icon, Methods, Events, Description) Public Methods of the Object JavaBean Components Event 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) 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 Development support: example VII.6 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 VII.8 Usage scenario Distributed transactions Java RMI Client 1 EJB EJB Transaction monitor/ DBMS EJB Container Client 2 EJB-Server Goal: transfer of processing logic to the server; implicit transactions VII.9 EJB-Container EJB-Container Transaction mgmt <methods> EJBObject create(), finderXXX() Client lookup(), destroy () EJBFactory methods State Mgmt Security ejbCreate ejbLookup Enterprise Bean ejbDestroy Supported by EJBContainer Developed by Bean Provider • 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.) EJB: Session Beans and Entity Beans VII.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 VII.11 Enterprise JavaBeans 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, Durable data, for instance, internal state, automatic Per- own persistence Search engine for instance, shopping sistence mechan. decision of the appl. Persistence VII.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 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 Deployment 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> VII.14 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; } VII.16 Implementation: example import 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; } } 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 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 VII.18 Transaction management • Requirements: Distributed Transactions with 2-PhaseCommit 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) 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) 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> VII.21 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 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 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 VII.24 Integration concept BusinessApplication Java as integration technology, however extensive infrastructure services necessary JDBC JDO JMS JIDL JTS Transaction Monitor JNDI IIOP / RMI, SOAP, further protocols Enterprise JavaBeans 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