The Sun way: Java, JavaBeans and EJB

squawkpsychoticΛογισμικό & κατασκευή λογ/κού

2 Δεκ 2013 (πριν από 4 χρόνια και 7 μήνες)

117 εμφανίσεις

The Sun way: Java, JavaBeans and EJB
Chapter 14
Key concepts of Java programming language
Key concepts of JavaBeans and EJB, the Java component model
Other Java services like Reflection, Object Serialization, RMI and
Java, the language
• Java is an almost pure object-oriented language
+ Class: attributes and methods
+ Object - Instance of Class
+ Single class inheritance and multiple interface inheritance
+ Non-object types: primitive types and interface types
• Java packages
+ Introduce a level of encapsulation on top of that of classes
+ Default access level: in the same package
Java, the language (cont.)
• Interface versus classes
+ Separation of interfaces and classes
+ Eliminates the diamond import problem
while preserving compatibility of class with
multiple independent interfaces.
+ Example: Observer pattern
• Exception and Exception handling
+ Exceptions and runtime errors are reflected
in Java as exception or error objects.
+ In either explicitly thrown or thrown by the
runtime system
• Threads and synchronization
+ Java supports concurrency and
+ Unit of concurrency – Thread
+ Synchronization
• Synchronized methods
• Synchronized statements
Java 2
• Java 2 consists of multiple platforms established on JRE 1.4
• Without doubt, the J2EE, coming along with the support from
various vendors, is the most successful platform
Java 2 Features
• Java 2 comes bundled with software development kits (SDK)
• Moreover Java 2 is distributed in packages with IDE’s such as
• JRE 1.4 provides more support to
+ Deployment technologies (Java web start, java plug-in)
+ Components (EJB)
• JavaBean is the Java component model
+ A reusable software component that can be visually manipulated in builder tools.
+ ‘Beyond OOP’
• Component Lifecycle
+ Compile time -> Assembly and design time -> Runtime
• Kinds of beans
+ GUI controls, Database viewers, Customizable mini-app., Word processors,
Invisible server beans
• Kinds of builders
+ GUI layout managers, Web page builders, Full-scale app.
+ Environments, Builder for invisible server apps.
Bean Model
• Main aspects of the bean model
+ Event: Connections between methods of beans
+ Properties: Chunks of bean’s state
+ Introspection: The way that assembly tools to learn about beans
+ Customization: Customize bean instances using assembly tools
+ Persistence: Bean instances need to be saved for reloading at runtime.
• Events and connections
+ Event sources and event listeners
+ Registration of listeners in event sources
+ A listener implements a given event listener interface
+ A bean fires an event
• Invokes a named, typed method on a named, typed interface
+ Event adapter
• performing event-filtering functions
• Solves multiple registration problem
Bean Model (cont.)
• Properties
+ Represent bean’s state: color, font, numerical value, ...
+ Accessible via getter/setter methods
+ Add/remove property change listeners
+ Bound properties: change notification
+ Vetoable properties: changes can be rejected
+ Customize properties: property editor and customizer classes
• Introspection
+ Using standard design patterns to deduce properties/events/methods
from beans
• the Introspector class provides a standard way
+ Developers can specify them manually by providing BeanInfo of target
Beans - Packaging and Enhancements
• JAR files - packaging of beans: a ZIP-format archive file
+ A set of class files;
+ A set of serialized objects;
+ Optional help files in HTML;
+ Optional localization information;
+ Optional icons;
+ Other resource files needed by the bean.
• Java AWT enhancements
+ Delegation-based event model
+ Data transfer and clipboard support
+ Lightweight user interface framework
+ Printing
EJB - Enterprise JavaBeans
• Even though Enterprise JavaBeans recall JavaBeans due to its name, EJB is
constructed on different fundamentals
+ EJB approach is not wiring - connection oriented programming
+ EJB implements contextual composition, rather than having the Beans have a
peer-to-peer connection
+ It implements InfoBus, which allows a flexible decoupling of event sources and
event listeners.
• The diagram demonstrates the isolation of EJB beans in containers and EJB
object interfaces
Other Java Services
• Reflection
+ Inspection of classes and interfaces for their fields and methods;
+ Construction of new class instances and new arrays;
+ Access to and modification of fields of objects and classes;
+ Access to and modification of elements of arrays;
+ Invocation of methods on objects and classes.
• Object serialization
+ Serialization of objects into byte streams
+ Serializable, Externalizable and transient
+ Current drawback: Missing support for degradation
• RMI (Java distributed object model)
+ Distributed computing
+ Remote interface and object
• JNI (Java native interface)
+ Specifies the native calling conventions of native code outside Java
JXTA and Jini
• Both JXTA and Jini is developed for solving the interoperability
problems in loosely coupled distributed systems.
• Jini focuses on Java everywhere
+ It is a specification that describes how federations of Java services and
clients of such services can be formed over loosely coupled systems
+ Implements lease method for garbage collection
• JXTA is a virtual Internet over the Internet
+ Addresses the problems of peer-to-peer computing
+ Creates a new layer over existing Internet protocols
• As a OO programming language, Java provides developer a way of
presentation close to the real life, which is composed of many
• Two winning aspects of Java: applets and JVM
• JavaBeans provides a way of development with binary components
instead of Java code.
• Java provides powerful distributed (remote) computing by
applet/serverlet, JDBC, RMI, EJB and etc.
• Clemens Szyperski
Component Software: Beyond Object-Oriented Programming
• Bruce Eckel
Thinking in Java, 2nd Edition
• Ken Arnold and James Gosling
The Java Programming Language, 2nd Edition