JustAnswer.com

Tuesday, August 7, 2007

java Architecture tutorial

6 Sun recommendation: Java IDL should be used when accessing existing CORBA servers is the main purpose, whereas RMI-IIOP should be used when serving requests from CORBA clients is the main purpose. Development Process: Write interface in IDL, compile to Java (results in interface and several classes). Use interface in client programming. Descend server from generated ImplBase class (aka ‘implementation skeleton’). IDL-to-Java also generates ‘Stub’ class (client proxy), ‘Holder’ class (for out or inout parameters) and ‘Helper’ class (for narrowing and reading/writing). ORB interface (org.omg.CORBA.ORB) and implementations (e.g. com.sun.CORBA.iiop.ORB). Getting an ORB: static ORB.init. NamingContext in package org.omb.CosNaming. Object references: Temporary references (through proxy) and long-lived ‘stringified’ interoperable object references (IOR). JNI Java Native Interface (JNI) is a standard for linking Java to native programs written in other languages like C and C++. A good way to integrate a legacy application that is not written in Java into a distributed
Next Page
Previous Page



7

Design Patterns 1) State the benefits of using design patterns. Improves communication between designers by use of pattern names vs. the details of the patterns. Captures experience of solving a type of problem. Provide a way of reusing design. Provide a mechanism for making designs more reusable. Provides a mechanism for systematizing the reuse of things that have been seen before. Can be used to teach good design. 2) From a list, select the most appropriate design pattern for a given scenario. 3) State the name of a GOF design pattern given the UML diagram and/or a brief description of the pattern’s functionality. 4) Select from a list benefits of a specified GOF pattern. Identify the GOF pattern associated with a specified J2EE feature. Types of patterns Creational: Involved with the process of object creation. Structural: Deals with the composition of classes or objects. Behavioral: Characterize the ways in which classes or objects interact and distribute responsibility. Abstract Factory: (Creational) Provide an interface for creating families of related or dependent objects (products) without specifying
Next Page
Previous Page


EJB objects.

It isolates concrete classes. It makes exchanging product families easy. It promotes consistency among products. Supporting new kinds of products is difficult. Factory Method: (Creational) Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses. J2EE technology uses this pattern for the EJB Home interface, which creates new EJB objects. Eliminates the need to bind application-specific classes into your code. Gives subclasses a hook for providing an extended version of an object being constructed. Prototype: (Creational) Specify the kinds of objects to create using a prototypical instance create new objects by copying this prototype Hides the concrete product classes from the client Allows adding and removing products at run-time Can specify new object by varying the values of an object’s variables. Singleton: (Creational) Ensure a class only has one instance, and provide a global point of access to it. Provides controlled access to a sole instance of a class.
Next Page
Previous Page


Permits a variable number of instances.

More flexible than static methods. Adapter: (Structural) Convert the interface of a class into another interface clients expect.


8 Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces. Permits you to use an existing class that has an interface that does not match the one you need. You want to create a reusable class that cooperates with unrelated or unforeseen classes. The Object Adapter pattern can be used when you need to use several existing subclasses but it is impractical to adapt their interface by subclassing every one. Bridge: (Structural) Decouple an abstraction from its implementation so that the two can vary independently. Use when you want to avoid a permanent binding between an abstraction and its implementation. Use when both the abstractions and the implementations should be extensible by subclassing. Changes in the implementation should not impact clients. Composite: (Structural) Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.
Next Page
Previous Page


Allows clients to treat composite structures and individual objects uniformly.

Makes it easier to add new kinds of components. A disadvantage is that it can make a design overly general. Flyweight: (Structural) Use sharing to support large numbers of fine-grained objects efficiently. Decorator: (Structural) Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality. In J2EE technology, The EJB object is a decorator for the bean because the bean’s functionality is expanded to include remote behavior. Proxy: (Structural) Provide a surrogate or placeholder for another object to control access to it. The EJB’s remote interface acts as a proxy for the bean. Proxy is also used in RMI. Façade: (Structural) Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use. Can use to achieve runtime binding without using inheritance. The Session Entity Façade pattern is a derivation of Façade that uses a Session bean as a façade for multiple Entity beans. Command: (Behavioral) Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. The Command pattern can be used to provide pluggable