21 Days:
Wk1
. Wk1Ref
. Applts
. Swing
. Grph
. D13-14
. D15-21
. D22-28
cc12: Miscl . SQL . EJB . Vocab . (NotesHelp) . J2EE . Web misl: 21 Days(src) . Dictionary(foldoc) . Unicode . Tables . Print . html misl: F.Allimant . Swing (J.H.University) |
Java Home
Ch1. Introduction.
- Each companies procedures for doing various things are continually changing. Good software design can allow the software to change with the companies desired procedures for doing things. ===Preface - Vocab: abstraction - to provide an interface to a technology. This interface is implementation-independant. - Examples: JDBC accesses SQL relational databases; JNDI (Java Naming and Directory Interface). - "EJB provides an abstraction for Component Transaction Monitors (CTMs)." (pg.xi) - [ ]Question: Does this mean "this covers all about EJBs" or "this is one use of EJBs"? - ASPECTS OF EJBS COVERED BY THIS BOOK: - underlying technology, - component model - Java clases and interfaces - runtime behavior ===Introduction - EJB uses server-side components, combined with ... RMI, to simplify ap development. - EJB automatically accounts for many business system requirements: "security, resource pooling, persistence, concurrency, and transactional integrity". (EJB.pg.1) - The "EJB" book shows how to develop scalable and portable business aps. - Needed background covered in this book: - Component Models - Distributed Objects - Component Transaction Monitors (CTMs) (important) - The technology beneath EJB. - Chapters 1,2,and 3 provide EJB foundation. Remaining chapters cover sample business system. - Before this book: Should be familure with Java, and with JDBC API, or at least SQL. - (endOfPg.1) ===Setting the Stage, before defining EJBs more specifically. - Distributed Objecs, Business Objects, and Component Transaction Monitors. = 1) Distributed Objects [ ]Q: What does the phrase "object running on a machine" mean? (Are they using the term "object" to mean "an instance of a class"?) - It is comparable to a dll in win32. The difference is the dll must run on the machine that runs the ap, the object is running on one machine where the object can be accessed from multiple machines. = 2) Server Side Components = "A business system based on server-side components is..." - Vocab: fluid - "because it is objectified." - Vocab: accessible - "because the components can be distributed." (pg.4.upper.mid) = 3) Component Transaction Monitors. (similar terms) Three characteristics: 1) use of the component model, 2) focus on transactional management, and 3) resource and service management usually associated with monitors. ===Enterprise JavaBeans: Defined. Sun's definition: "The Enterprise JavaBeans architecture is a component architecture for the development and deployment of component-based distributed business applications. Applications written using the Enterprise JavaBeans architecture are scalable, transactional, and multi-user secure. These applications may be written once, and then deployed on any server platform that supports the Enterprise JavaBeans specification." - EJB Book's Definition: Enterprise JavaBeans is a standard server-side component model for Component Transaction Monitors. ===Distributed Object Architectures - To understand EJBs you NEED TO KNOW HOW DISTRIBUTED OBJECTS WORK. (EJB.pg.5.bottom) - "The object server is an instance of an object with its own uniqe state." This is the object on the middle tier. Every object server class has its matching stub and skeleton classes. (pg.6) - The stub is on client. The object server and the skeleton are on the middle tier. - Stub and skeleton make it appear as if the object server "is running locally on the client machine". Done using a type of RMI protocol. - (pg.7) - Each object server is wrapped by an instance of its skeleton class. - The skeleton listens for requests from the stub. Skeleton on a port and IP address. - Q[ ]: Is this "port and IP address" combo, used by many methods, many objects, many beans, many users? What is the one thing gets one whole combo to itself? - Both the object server and the stub implements a common interface that you create. - One of the biggest benefits of distributed objects is location transparency. (pg.11) - (pg.12) - Vocab: remote reference - is the stub on the client that references the middle tier business logic object. (pg.12.top) - An Object Request Broker (ORB) is part of a distributed ojbject protocol, like CORBA. ===Component Models. (pg.13) - javax.ejb packages - Contain classes and interfaces for developers to "create, assemble and deploy components that conform to the EJB specification." - JAVABEANS ARE UNREALTED TO ENTERPRISE JAVABEANS. - JavaBeans and EJBs only common grounds are they are both component models and they both share the name "JavaBeans". ===Component Transaction Monitors (Component Transaction Servers). (pg.14) - CTM is a hybrid combination of TP Monitors and Object Request Brokers (ORBs). = TP Monitors - are considered an operating system since they control an applications entire environment. These aps may be COBOL aps. - Vocab: synchronous - waits for responce to message (I think?) - Vocab: asynchronous - Not synchronised, proceeding independently. - RPC (Remote Procedure Calls) - like RMI but is used for procedure based aps. RMI is for distributed object systems. = Object Request Brokers (ORBs). (pg.15) - An ORB allows clients to communicate with server-side objects. (a_few_pgs_back.p.12) - "Distributed objects are usually deployed on some kind of ORB, which is responsible for helping client aps find distributed objects easily." - ORBs are comunication backbones. They are not operating systems. = CTMs: the hybrid of TP Monitors and ORBs. = Analogies to Relational Databases - "CTMs are to business objects what relational databases are to data." (pg.17) - Using a CTM, the developer can focus on the application solution while relying on the CTM to handle enterprise infrastructure issues. This saves a lot of time and work. ===CTMs and Server-Side Component Models (pg.17) - As long as the server-side component follows the specification, it can be used by the CTM. Similar to a CD being playable on a CD player as long as the CD follows the specification. = MTS - Microsoft Transaction Server - an early CTM. = EJB and CORBA CTMs (pg.19) - CORBA CTMs implemented by each vendor was platform-independant, but not compatible with other vendors similar implementaion. SOLUTION: The EJB standard made the components compatible. (first draft released in 1997) = Benefits of a Standard Server-Side Component Model (pg.20) - Properly written EJBs should run on any CTM that supports the complete EJB specification. - Mostly eliminates "vendor-lockin". Free to switch vendors. ===Titan Cruises: An Imaginary Business (pg.22) - The database layer is mentioned as the persistence layer. ===What's Next? - Next two chapters will help us develop and understanding of the EJB architechure. [ ]Q: Does the term here of "architechure" refer to the structure of EJB, or that of the EJB environment?
Ch2. Architectural Overview.
- This chapter covers core of EJB: how the beans are distributed as business objects. ===The Enterprise Bean Component - EJBs come in two types: entity beans and session beans. - Entity beans usually represent concepts that are nouns. Such as a customer or invetory item. The concepts represented by entity beans are usually persistent records in a database. The entity bean maintains a persistent state. - Session beans usually describe some action that occures. Like booking a trip on a ship. The booking process is written into a session bean. That session bean would interact with entity beans that represent the cruise, customers, and tickets for example. Session beans model interactions. They do not maintain a persistent state. - Aspects of implementing an EJB: (pg.24.bottom) - Remote Interface: Defines the methods the bean presents to the outside world. (implemented by the client stub) - Home Interface: Defines beans life cycle methods. - Bean Class: Actually implements the beans business methods. - Primary Key: Provides pointer into database (for entity beans). - [*]: Look for diference between a "container" and a "server". See end of chapter. - Vocab: Deployment Descriptors - setup application of automatic things like security. Similar to property files. - EJB 1.0 Deployment Descriptors are "serialized class instances that describe the bean and some of its runtime behavior to the container." (pg.34) - EJB 1.1 Deployment Descriptors uses XML instead of serialized class instances. - DTD - Document Type Definition - "describes how a particular XML document is structured." Info about the DTD is stored in the second element in any XML document, "!DOCTYPE". - (pg.36) - "Two missing pieces are the the EJB object itself and the EJB home." The ap programmer usually never sees these. They handle things written by the System Developer. - "The Application Developer is intimately familiar with how your business environment works and needs to be modeled, so you will focus on creating the applications and the beans that describe your business." (EJB.pg.36) ===The EBJ object - A bean's "remote interface" is implemented by the client stub. - "On the server side, an EJB object is a distributed object that implements the remote interface of the bean. It wraps the bean instance" to provide security, etc. (pg.36) It is generated by utilities from the vendor of the EJB container. Its based on bean classes and info in the deployment descriptor. ===Deploying a bean - The bean is ready to be deployed when: its files have been packaged into a JAR file. - Files of a bean that are needed are: 1) Home Interface, 2) Remote Interface, 3) and the bean classes. ===Modeling Workflow with Session Beans - Business logic is to be placed in session beans, not in client aps, or entity beans. ===The Bean Container Contract - The container implements the EJBContext interface. The bean implements a subclass of EJBContext. For entity beans it is the EntityContext interface. For session beans it is the SessionContext interface. I believe that a bean finds out about its environment by getting info from the container through this interface. - The rest of the book will refer to the container and server as one and the same thing. ===Summary (well worth while to refer to book for entire summary) (pg.48) - Beans are business object components. - "The home interface defines life-cycle methods..." - "...the remote interface defines public business methods of the bean." - [ ]Question: Does this mean the remote interface is designed by the application developer? And for that matter, how much of the home interface would be written by the ap developer? - "The bean class is where the state and behavior of the bean are implemented." - "The EJB object and EJB home are conceptual consturcts that delegat method invocations to the bean class from the client and help the container to manage the bean class." PLEASE SEE BOOK for rest of third paragraph of the Summary. (page 48)
EJB.Book. Summary of ch.1 and ch.2.
- Remote interface defines public business methods of the bean. - Home interface defines life cycle methods of the bean. - EJB object implements the remote interface and expands the bean classes functionality. - EJB home implements the home interface and works closely with the container. - Both the object server and the stub implements a common interface that you create. - A bean's "remote interface" is implemented by the client stub. - "On the server side, an EJB object is a distributed object that implements the remote interface of the bean. It wraps the bean instance" to provide security, etc. (pg.36) It is generated by utilities from the vendor of the EJB container. Its based on bean classes and info in the deployment descriptor. - A bean is ready to be deployed when its files are packaged into a JAR file. The files needed are: 1) Home Interface, 2) Remote Interface, 3) and the bean classe(s?).
Ch3. Resource Management and the Primary Services.
- This chapter covers resource managment and primary services available to Enterprise JavaBeans. ===Resource Managment - "EJB explicetly supports two mechanisms that make it easier to manage large numbers of beans at runtime: instance pooling and activation." (pg.50.top.end#2) ===Instance Pooling. Bean instances can be in one of three states: No state, Pooled state, or Ready state. - "An EJB server maintains instance pools for every type of bean deployed.`" ===Activation. The restoring of a stateful session beans instance state. (pg.55,56) ===Primary Services (pg.57) - required to create an effective CTM. - They are: 1) concurrency, 2) transactions, 3) persistence, 4) distributed objects, 5) naming, and 6) security. ===Concurrency - Entity beans represent data in the database that needs to be shared and accessed concurrently. To avoid data corruption, although many clients can be connected to on Ebj object, only one can access it at a time. - Beans interact with eachother through the same interface that the client does. (pg.59.bot) - loopback and reentrant - This practice is not allowed or is discouraged. (pg.59.bottom) ===Transaction - a unit-of-work that must be entirely complete to be successful. - Involves declaring the transactional attribute at deployment time. - Automatic management. ===Persistence - the state of an entity is stored permanently in a database. - Object-to-relational persistence - most common. Fields map to table colums. - Object database persistence - can perserve object types and object graphs. - Legacy persistence. ===Distributed Objects - - "Three main distributed services are available today: CORBA, Java RMI, and DCOM." (pg.67.top) - "As long as the EJB server supports the EJB client view, any distributed object protocal can be used." (pg.67.topOfBottom) ===Naming services - "provide clients with a mechanism for locating distributed objects." (pg.69) - Two parts (?of the mechanism?): object binding, and a lookup API. ===Security - three types: 1) Authentication, 2) Access control, and 3) Secure communication.
Ch4. Developing Your First Enterprise JavaBeans.
-
Questions.
[ ]: When creating a Pramati Desk, why does one EJB module and one WEB module folder get created?
EJB Links.
===EJB - EJB-Book Examples: ftp://ftp.oreilly.com/pub/examples/java/ejb - Browse SUN's Enterprise JavaBeans 2.1 Documentation - Enterprise JavaBeans[tm] 2.0 Specification (highly recommended for programmers new to Java and J2EE). - EJB Critisism - EJB Critisism - Reply: The current trendy thing to do is to bash EJBs to smithereens - the author of the referenced article is no exception. As he seems to write articles/books primarily concerned with .NET, I would suggest that his frame of reference is (likely) without a tremendous amount of relevant experience. I don't find EJBs too difficult or inefficient to work with - used correctly and with the right container, they work great. However this is true only if you use them as intended. Many people try to use them strictly for persistence or as a reflection of an existing database, as examples. Doing so has the potential to be both difficult and inefficient. And the fact is, EJB containers have improved greatly with 2.0 and will continue to evolve and get better both in the specs and in the container implementations. And hey - EJBs are not a magic bullet - they're just a part of a tool set called J2EE. Use each tool for their intended purpose and you'll be better off. (Cheers Ray) ===XML - XML 1.0 (2nd Ed) - XML Syntax Quick Reference ************************************************************************************* References: (EJB.pg.?) EJB = Enterprise JavaBeans, 2nd Edition; by Richard Monson-Haefel. (c)1999; 472 pages; ISBN: 1-56592-869-5 B19 - Teach Yourself Java 2 in 21 Days. 2nd ed. Lemay and Cadenhead. + 2001. *************************************************************************************