Persistence Problems
By Geir Magnusson Jr. and Jeremy Boynes
June 9, 2004
By Geir Magnusson and Jeremy Boynes
We seem to have a big problem in the Java persistence community, and it’s one that seems to have a surprisingly simple solution.
Storm clouds
About mid-May 2004, we began to suspect that things weren’t quite right, about the time the SE/EE Executive Committee voted on JSR-243 for JDO 2.0. Several EC members voted against the JSR, although it did pass. You can read about it here. [Full Disclosure from Geir : I'm the Apache EC rep and voted yes because I think that despite assertions to the contrary, there is no overlap with existing technology, and if there *is* overlap, competition is good - let the market decide.] Looking back, there was a hint of storm clouds on the horizon with Oracle’s comment, namely that JDO 2.0 overlaps work being done in the EJB expert group. We didn’t think anything of it at the time (“JDBC overlaps work being done in the JNDI expert group” if you believe that both are ways of retrieving data) but with the benefit of hindsight, it’s almost as if Oracle was warning us about what was coming.
Looking back at the comments, we also have several references to J2EE. JDO isn’t part of the J2EE spec – JSR-243 notes it will work to be more “aligned” with J2EE – and J2EE isn’t the only platform under which people build applications. JDO is important for non-J2EE developers working on J2SE applications. With further hindsight, we see from those comments that several platform vendors appear to have identified a developer need unfilled in the J2EE platform.
The Three Tiers of the Persistence Inquisition
We tend to think about persistence tools in the way we think about any other set of developer tools for a given technology. Generally, once software engineers have enough experience in a problem domain, they will produce a set of development techniques or models which are designed to address different levels of complexity in that problem domain. They tend to build on one another and if lucky, there’s a reasonable path for moving ‘up the chain’ as an application’s complexity increases. This model and tool approach is true with persistence as well:
- Simple and Uncomplicated: At the bottom of the complexity stack of Java data persistence is the old ‘fast and dirty’ standby that we all know and don’t truly love – JDBC. We’ve all used it and gotten quite a bit done with it, but it’s not terribly pleasant when we live in an object-oriented world (or even a data-structure world). We tend to write simple tools to help us around the “bare metal”, and after a while, we stand back, look at those simple tools, and and decide that we need a better level of abstraction to handle the domain model that we work in. That leads to tools and models of medium complexity.
- Medium complexity: This consists of tools that allow us to work easier with the everyday objects and data structures that make up our applications. This isn’t a new idea, and probably extends from seeing object database systems and, not being able to actually find any in the market
, wanting to use general purpose RDBM systems for the same purpose. There is a wide range of approaches to this problem, from populating JavaBeans from XML (and back) to POJO persistence, with solutions ranging from standard to proprietary, commercial to open-source. Examples include the Java JDO specification with it’s implementations, commercial proprietary O/R systems like TopLink and the current crop of open-source solutions like Hibernate, OJB, Cheyanne, et al. The basic idea in middle-complexity-land is fundamentally about persisting POJOs (Plain Old Java Objects). These approaches generally are very convenient to use, allow you to work without any component contracts forced on your classes by the environment, and more or less give you the freedom to easily save objects or graphs of objects to some kind of data store and get them back later. They tend to be “deliberate” – the programmer makes the decision about when to save with some kind of explicit POJOFramework.save(myObject) call or -ish. They also are very popular (and becoming increasingly so) because most applications seem to be at this level of complexity – you just want to work with your domain objects in a deliberate way. (Or even just use to ‘persisted data structures’, which is my favorite use for Hibernate, for example). - High Complexity: To address high levels of complexity, we have complicated frameworks like EJB that provide middleware services such as transactions, security, data storage, component relationship management, etc. This third tier is generally very powerful, very complicated, and seems to be often misapplied. Because it’s part of the ‘enterprise’ Java standard, it’s the ‘natural’ choice for persisting data in an ‘enterprise’ application, although there are other solutions that, depending on the application, would be just as appropriate and easier for the developer to use, deploy and maintain – solutions from medium-complexity-land that aren’t part of the J2EE spec.
J2EE, EJB and Thee
With the preceding discussion in mind, lets look at what’s been happening with the next version of J2EE. According to the text of JSR-244, the theme of J2EE 1.5 is “ease of development”, with the goal of addressing the needs of a wide range of developers, “including less sophisticated developers”. This is a laudable goal, and quite frankly, it’s about time. By adding new features that enable better tool support, ease of application development, and ease of maintenance, the Java will hopefully become more widely adopted and remain a competitive platform for enterprise development.
Expert groups that are part of the J2EE “umbrella” are working to support that goal, and this includes Enterprise Java Beans (EJB). The JSR for EJB 3, JSR-220, has the following as its declared purpose :
“The Enterprise JavaBeans architecture is a component architecture for the development and deployment of component-based business applications. The purpose of Enterprise JavaBeans (EJB) 3.0 is to improve the EJB architecture by reducing its complexity from the developer’s point of view.”
It makes it pretty clear that EJB is a component architecture (and happens to include the ‘high complexity tier’ of data persistence) and the intent of this version is to improve the architecture by reducing complexity. This is just fabulous.
POJO Persistence and Mission Creep
As we’ve heard at TheServerSide Symposium and other places, the EJB expert group is working on what amounts to splitting the EJB spec into two concurrent ‘tracks’. They don’t talk about it like this, but it’s a reasonable interpretation :
- an addition of a new and incompatible POJO persistence model
- a continuation of the EJB 2 component architecture with new POJO persistence model features backported (changes to query language, for instance)
We think that one conclusion that we can safely draw from this is that the EJB3 expert group recognizes that EJB2 persistence doesn’t satisfy the needs of a large number, if not the majority, of enterprise application developers. Further, they recognize that POJO persistence is a valid persistence strategy and developers like to use it for their applications. They are so interested in having it available, the EJB expert group is willing to alter the objective of the JSR to accommodate.
I think that we should appreciate the EJB3 EG for the courageous step of effectively saying “We realize there’s more to enterprise data persistence than EJBs and we want to do something about it” It’s not unreasonable, though, to presume that this ‘bifurcation’ of the EJB spec will be fairly confusing for developers because now EJBs are going to be “EJBv2 EJBs” and “persisted POJO EJBs”.
Paying attention to customer demand is laudable, but when you consider that these two technologies (POJO persistence and EJBs) are arguably two distinct solutions to data persistence appropriate for differing levels of application complexity (and EJB is more than just data persistence), this bifurcation of the spec begs a question :
“Could we prevent an over-broad and potentially confusing EJB model by simply adding POJO persistence separately to the J2EE spec for 1.5?”
One would assume, given the investment made by users and vendors of J2EE, that an incremental revision of the J2EE spec (from 1.4 to 1.5) would presume a compatibility path that preserves existing investment and allows those implementations to smoothly take advantage of new features. Users aren’t going to want to rewrite critical business applications just to keep up with vendors. What we seem to be seeing here is a discontinuous change from EJB2 to EJB3 and there is no smooth path from EJB2 applications to EJB3 applications.
To answer the question above, we could achieve the same result by making a POJO persistence model available in J2EE distinct from EJB without compromising EJBs, which are a valuable and appropriate solution for a small percentage of highly-complex enterprise applications. Not everyone needs EJB, but when you do, you do!
The obvious solution – “Well, you’ve had a JSR for POJO persistence for some years now… JDO – why not add it to J2EE?” – is an answer that no one seems to want to hear because there appears to be a war going on between the JDO and EJB communities. Technology battles aren’t new, but this one is astounding in it’s irony. The EJB3 group, by adding POJO persistence, is validating the whole argument for JDO or a JDO-like technology in J2EE. There will be arguments about technical details such as choice of query language, approaches to detaching object graphs, etc but at the end of the day, the EJB EG is advocating the addition of a technology approach that already exists in the “Java ecosystem” – JDO – into J2EE.
We’re optimistic that this can be resolved. We don’t believe that a spec lead can be held responsible for the public behavior of the expert group members or non-EG members of the community. However, as both specs are Sun sponsored, both spec leads are Sun employees and most importantly, all parties agree on the fundamental need for POJO persistence in J2EE, it’s conceivable that through a concerted effort by Sun to recognize the gap in J2EE and work towards an architecturally clean solution, partisans from both sides can work with each other rather than against each other.
Solution!
The simplest solution is to add POJO persistence (via JDO 2.0 or other) to the J2EE umbrella. As a bonus, require that POJO persistence and EJB work from the same persistence layer, so that concurrently deployed applications written using both technologies have coherent views of the same data. (And if vendors are smart, they’ll provide a JDBC driver to access the same persistence layer….)
While fixing J2EE to support what programmers want today, it also offers a compelling path to J2EE from J2SE, because J2SE applications that are written using the same POJO persistence model will be able to migrate to the J2EE environment without requiring changes to their persistence model. Further, we can take a lesson from Microsoft’s ADO and tools such as Hibernate and OJB in Java – that there is a strong demand for persistent objects in the base platform. So lets also ensure that we take what we learn from J2EE 1.5 and push what we can ‘down’ to J2SE 1.6. (On that note, how many people know about the rejected JSR-20?)
JDO 2.0 just got started. Any of the supposed deficiencies in JDO can be addressed. If, in the opinion of the J2EE EG, that JDO’s model is inappropriate – that recent work in open-source or commercial solutions offer compelling alternatives – start a new EG and include members from JDO as well as EJB.
We feel that this is an important problem, but a very manageable one, and hope that the broad Java community supports this approach – addressing the needs of the development community is one of the core purposes of the JCP. Lets use it.
Note: The above represents the personal opinion of Geir and Jeremy and should be not construed to represent the position of any other organization. Specifically, this does not represent the position of the Apache Software Foundation.
Full Disclosure: Geir is the Apache representative to the JCP Executive Committee and recently the current Apache representative on the J2EE 1.5 Expert Group. Jeremy is the Apache representative on the EJB3 expert group. This article is an original work by Geir and Jeremy based on public information and should not be construed to represent either EC or EG confidential information, future intention or past or current discussion. If any of this has been discussed in an EG, it is without our knowledge and we consider ourselves lucky.
Simplifying EJB Development with EJB 3.0
By Debu Panda
October 2004
Enterprise JavaBeans (EJB) was introduced for building distributed components. When it arrived it came with a promise to solve all issues and complexities of CORBA. EJB being the heart of J2EE went through several major revisions and got fattened with many features. Early on, most of the developers fell in love with EJB and used EJB in their application even it did not make any sense. “Blame it on EJB” has been the attitude for many developers when their projects did not scale well and they used EJB.
Development of EJB was never easier and it became more complex with every release of EJB specification. EJB has been compared with an elephant due to its complexity and heavy weight nature. Many developers feel EJB is like an extra layer of sugar syrup on a doughnut. In an age where low carb and Atkins diet is craze, the EJB expert committee has no option but to produce a low carb incarnation of EJB thus simplifying the development of EJB. EJB 3.0 expert committee released a sample picture of the lightweight model during JavaOne 2004 when it announced release of first public draft of EJB 3.0 Specification.
At the first glimpse the new model for EJB looks pretty and in this article we will discuss how EJB 3.0 is trying to dress up in a smaller size pretty outfit to make it appealing for developers. In a follow up article we will discuss how EJB 3.0 is simplifying the persistence model.
Cleaning up the Dirty Laundry
Let us look at the complexities in the current EJB model before we dive down discussing the details what EJB 3.0 is bringing on to the table.
- The current EJB model requires creation of several component interfaces and implementation of several unnecessary callback methods.
- The component interfaces require implementation of EJBObject or EJBLocalObject and handling of many unnecessary exceptions is required.
- The EJB deployment descriptor is complex and error prone.
- The container managed persistence being based on the EJB model is again overly complex to develop and manage. There are several basic features missing such as a standard way to define a primary key using database sequence and EJBQL is very limited.
- EJB components do not look like its Object Oriented as it has restrictions for using inheritance and polymorphisms.
- One major drawback of EJBs is that you cannot test EJB modules outside an EJB container and debugging an EJB inside the container is a nightmare for developers.
- If you used EJB you know the complexities of looking up and invocation of EJB. It appears that you have to know minute details of JNDI to just use an EJB in your application.
Simplifying Developers view
If you developed an EJB with the latest specification you realize how difficult is develop a simple EJB like HelloWorld EJB. You need at least two interfaces, a bean class and a deployment descriptor. Most of the developers wondered why do I need all these. IDEs like Oracle JDeveloper, Eclipse and XDoclet made the life simple for developers for doing these mundane tasks however still it was the responsibility of developer to compile these classes and package the deployment descriptor before the EJB can be deployed in your container of choice.
EJB 3.0 is trying to address the complexities by:
- Removing need of interfaces and deployment descriptors and these may be generated by the container using metadata annotations
- Use regular Java classes as EJBs and regular business interfaces for EJBs
Metadata Annotations
EJB 3.0 depends heavily on metadata annotations. Metadata annotation being standardized under JSR 175 and will be part of J2SE 5.0. Annotation is a kind of attribute oriented programming and similar to XDoclet. However unlike XDoclet that requires pre-compilation, annotations are compiled into the classes (depending upon what the @Retention is set to) by the Java compiler at compile-time. In developer’s point of view, annotations are modifiers like public and can be used in classes, fields, methods, parameters, local variables, constructors, enumerations and packages.You can use annotations in your Java code by specifying attributes that can be used for either generating code, documenting code or providing special services such as enhanced business-level security or special business logic during runtime. The goal of J2EE 1.5 (5.0) is to simplify development using annotations and hence it will come up with its set of annotations. Annotations are marked with @ as follows:
@Author(“Debu Panda”)
@Bean
public class MySessionBean
The goal of EJB 3.0 is to simplify development and hence use metadata annotations to generate several artifacts like interfaces and use annotations instead of deployment descriptors.
Using POJOs and POJIs
In canonical terms, JavaBeans and interfaces often referred as Plain Old Java Objects (POJOs) and Plain Old Java Interfaces (POJIs) respectively. The EJB class and interface will now resemble POJO and POJI respectively. The requirement of the unnecessary artifacts like home interface is being removed.
The developer has to either implement one of the EJB interfaces (SessionBean, EntityBean or MessageDrivenBean) in javax.ejb package or use annotation in the bean implementation class. You can either use Stateless, Stateful, MessageDriven or Entity to annotate your bean class. For example, if you define a stateless EJB as HelloWorld you define the EJB as follows:
@Remote
@Stateless public class HelloWorldBean {
public String sayHello(String s)
{ System.out.println(“Hello: “+s; }
}
The interfaces for EJBs either remote or local do not have to implement EJBObject or EJBLocalObject. You have to either supply the business interface for your EJB and implement that interface in your bean class or have it generated during the deployment. Interfaces are optional for Entity beans however required for SessionBean and MessageDrivenDriven. If you do not implement an interface for your session bean, a bean interface will be generated for you. The type of generated interface either local or remote is dependent on the annotation you used in the bean class. If you look at the above code example, it is very clear that @Remote is used to generate a remote interface for the HelloWorld bean. If needed, you may have both remote and local interfaces for your EJB.
From the above example, it is very clear that the developer do not have to a lot of mundane tasks such as defining interfaces and implementing callback methods.
The name of the generated interface is derived from the name of the bean implementation class. Generated interfaces are well and good for developers. However, I do not see any benefit of generating interfaces as most IDE like Oracle JDeveloper generates these on fly.
This is not clear from the draft what is client side requirement for EJB lookup and it is not clear, how do we get hold of these interfaces those are required to invoke this EJB? I will recommend against using a generated interface for few reasons:
- The name of generated interface will be derived from the bean name
- You may not be willing to expose some methods in the EJB in the interface and the generated interface may expose all methods by default.
- You need the interface at the client side to invoke the EJB.
Removing need for Callback methods
EJB 2.1 and prior releases required implementation of several lifecycle methods such as ejbPassivate, ejbActivate, ejbLoad, ejbStore, etc. for every EJB even if you do not need those. For example, ejbPassivate is not required for a stateless session bean still you require to implement that method in your bean class. As EJB 3.0 now resembles regular Java classes implementation of these lifecycle methods have been made optional. If you implement any callback method in the EJB then container will invoke that method.
The only exception is the ejbRemove method in Stateful Session bean where you can use Remove annotation to annotate a Stateful session bean business method. If you use of this annotation it will hint the container to remove the Stateful session bean instance after the completion (normal or abnormal) of the annotated method. For example, you can specify the following to remove a Stateful Session Bean instance after checkOut method is executed.
@Stateful public class Cart {
…
…
@Remove public void checkOut() {
…
}
}
Annotations vs. deployment descriptors
As we discussed earlier deployment descriptors will no longer be required for EJBs and annotations will be used instead. The default values for each attribute in the deployment descriptor will be chosen and developers do not have to specify these attributes unless they want a value other than the default value. These can be specified using annotations in the bean class itself. The EJB 3.0 specification is defining a set of metadata annotations for use by developers such as bean type, type of interfaces, resource references, transaction attributes, security, etc. For example, if we want to resource reference for a particular EJB then we will define as follows:
@Resource(name=”jdbc/OracleDS”, resourceType=”javax.sql.DataSource”)
J2EE vendors such as Oracle, BEA, IBM will add annotations for attributes in their vendor specific deployment descriptors and developers will use these to avoid using deployment descriptors. This looks very attractive for developers as the nasty XML descriptors they hated most gets out of their way but this introduces few problems and we need to be careful before embracing annotations.
- This defeats the goal of portability of applications because if an EJB uses a vendor specific deployment descriptor this cannot be just changed without having to recompiling/repackaging the EJBs.
- The deployment descriptors provided a holistic view of EJB modules to the assembler/deployer (ejb-jar) without having to look at individual the EJBs and they tweaked these as per the deployment requirement and if descriptors are not available or not generated until the end of deployment this could be a nightmare for them.
- Deployment descriptors were used by the tools to identify the EJBs in an EJB module and were very useful when you try to migrate from one container to another.
EJB 3.0 spec also proposes a way to override the annotations in the deployment descriptors. However details of overriding annotations is missing in the specification.
There is no doubt that getting rid of deployment descriptors will make the life easier for new developers but this may become a management nightmare if not used carefully.
Simplifying Container Managed Persistence
CMP entity bean is getting a major overhaul in EJB 3.0 to make it compelling for developers. Persistence frameworks like OracleAS TopLink, open source Hibernate have become darling of developing persistence framework for J2EE applications that has disliked Entity beans for its complexity and heavyweight in nature. EJB 3.0 is adopting a lightweight persistence model like TopLink and Hibernate to simplify the container managed persistence and this sounds compelling for developers. Let us do a quick look on the plans for entity beans and we will discuss about the details of the persistence improvement in another article.
Entity beans are being reincarnated as POJOs and there will be no component interfaces required for entity beans. Entity beans will now look as pure objects as this will also support inheritance and polymorphism.
Following is the source code for an entity bean:
@Entity public class Employee{
private Long empNo;
private String empName;
private Address address;
private Hashmap projects = new Hashmap();
private Double salary;
@Id(generate=SEQUENCE) public Long getEmpNo() {
return empNo;
}
protected void setEmpNo(Long empNo) {
this.empNo = empNo;
}
public String getEmpName() {
return EmpName;
}
public void setEmpName(String EmpName){
this.EmpName = EmpName;
}
@Dependent public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
public Set getProjects() {
return projects;
}
public void setProjects(Set projects) {
this.projects = projects;
}
public Double getSalary() {
return salary;
}
public void setSalary(Double salary) {
this.salary = salary;
}
….
}
If you look at the code, you will find that the bean class is a concrete class and not an abstract class the current entity bean.
There are several improvements are being made for the query capabilities in EJB QL and support of SQL queries in the entity beans. A new EntityManager API similar to Hibernate and a simplified version of TopLink’ Session API is being proposed to manipulation of entity beans i.e. creation, removal, finding of entity beans.
We will closely examine the details of the proposed CMP entity beans in a followup article.
Simplifying Client View for EJBs
Using EJBs i.e. to lookup and invoke is very complex even if EJB is collocated in the application. J2EE 1.4 and EJB 3.0 spec is working on to simplify the client’s view of EJBs.
If you want to use an EJB presently you have to define the ejb-ref or ejb-local-ref in the deployment descriptor, lookup the EJB and then invoke. If we want to invoke our HelloWorld EJB, following is the simplest way you can invoke an EJB with the current implementation.
First define the EJB references in the deployment descriptor as follows:
<ejb-ref>
<ejb-ref-name>HelloWorldEJB</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>hello.HelloWorldHome</home>
<remote> hello.HelloWorld</remote>
</ejb-ref>
Then lookup the EJB as follows. You have to explicitly handle exceptions for EJB lookup and creation of a bean instance.
try
{
Context context = new InitialContext();
HelloWorldHome helloHome =
(HelloWorld)PortableRemoteObject.narrow(context.lookup
(“java:comp/env/ejb/HelloWorldEJB”), HelloWorldHome.class);
HelloWorld hello = helloHome.create();
….
}
catch(RemoteException e)
{
System.err.println(“System/communication error: ” + e.getMessage());
}
catch(NamingException e)
{
System.err.println(“Communication error: ” + e.getMessage());
}
catch(CreateException e)
{
System.err.println(“Error creating EJB instance: ” + e.getMessage());
}
As an alternative to environment variables, EJB 3.0 proposes a way to use setter injection to lookup and invoke EJBs.
Following is way our HelloWorldEJB can be looked up in another EJB by using setter injection.
@Inject private void setSessionContext(SessionContext ctx)
{
this.ctx = ctx
}
…
myHello = (HelloWorld)ctx.lookup(“java:comp/env/ejb/HelloWorldEJB”);
If you look at the code above carefully the setSessionContext method is annotated with @Inject to specify that dependency injection be used for this method. The injected methods will be invoked by the container to set the EJBContext before any business method be called on that EJB.
Another direct example to inject the HelloWorld session bean would be to simply have @EJB public HelloWorld myHello and this would cause myHello to be injected with an instance of the HelloWorld bean.
You can use dependency injection to lookup any type of environment and resource references such as DataSource, JMS, Mail, Web Service, etc.
Testability Usability Outside Container
A major concern for the current EJB developers is not only development of EJBs is complex but also testing is a nightmare. An EJB container is required is to develop and test the EJBs and the developers have to be familiar with the final deployment platform to perform testing. This may not be a major issue for many enterprise developers but is an issue for ISVs who work on supporting multiple vendors and they have to maintain multiple environments to do the testing of their EJBs. The EJB 3.0 spec promises to provide the ability to test outside the container but this is currently missing in the draft specification.
Conclusion
Although there are a lot of missing information about packaging, assembly and gory details of APIs, the proposals made in EJB 3.0 drafts looks very promising for enterprise java developers. These will certainly help remove the complexities from developers view by passing those to the container vendors. It is to be seen how the container vendors implement these and make EJB 3.0 a compelling option to develop enterprise applications.
References and further reading
Inheritance & EJBs
By Daniel O’Connor
June 2002
Introduction
One of the most common criticisms of entity EJBs is that they don’t support inheritance or polymorphism. If this were true, it would be a serious complaint for two reasons. First, entity beans are intended to provide an object-oriented view of information in a persistent store, and inheritance and polymorphism are key aspects of the object-oriented programming paradigm. Second, many bean developers are using relational database schemas that essentially implement a form of inheritance, and they need to be able to operate on these schemas with their EJBs. However, in practice, entity EJBs are capable of meeting these requirements.
In this article I’m going to show how to implement entity bean inheritance with three CMP EJBs: a “base class” PARTY EJB and two “derived class” EJBs: PERSON and CORPORATION. (This is a common design in relational database schemas.) Furthermore, I’ll demonstrate a polymorphic finder query and a couple of polymorphic method calls. The beans I produce will be absolutely portable according to the EJB 2.0 specification.
I’ll also show how these container-managed persistence beans can be mapped to a standard relational database schema for this type of data. The EJB specification does not require particular object/relational mapping capabilities from an EJB container’s CMP engine. It does not even require that the container be able to use relational databases at all, so the ability to map to a particular schema is not portable. However, I am the author of a pluggable CMP engine that provides this capability (the MVCSoft Persistence Manager). We’ll look at how this engine is able to make the sometimes-difficult translation from EJB objects and relationships to database tables, and what is involved from the user’s point of view in using this particular mapping.
Some Distinctions
It’s important to be clear exactly what we mean when we talk about inheritance. In this case there are three possibilities, and this article is mostly about a single one of these possibilities. First, there is the language inheritance with which every competent Java programmer is familiar. The Java language allows a class to extend a single immediate base class, which can in its turn extend another single base class, until the universal base class of java.lang.Object is reached. It also allows an interface to extend one or more interfaces. Finally, it allows a class to implement any number of interfaces. The EJB specification allows for any of the interfaces or implementation classes associated with a bean (remote home and component interfaces, local home and component interfaces, primary key class, and bean implementation class) to take advantage of these Java language features. (There are a few caveats, such as requirements for the return types from create methods.)
Second, there is an amorphous concept called “component inheritance.” Although frequently used (even once in the EJB spec itself), there is no generally accepted definition of the term in this context. It would probably include (1) the ability to extend an existing entity without modifying the base component or even having the source code; (2) the ability to compare component interfaces of different types for equality; and (3) the ability to return different component interfaces from a single finder or ejbSelect method.
Third, there is “data model inheritance.” This is the ability to model an inheritance hierarchy of business objects (and their polymorphic behavior) using entity EJBs. It is this last type of inheritance that this article addresses. Note that whereas language inheritance and component inheritance might be considered “implementation details,” data model inheritance directly affects what can and cannot be accomplished using EJBs.
Why the Criticism?
If entity EJBs are capable of inheritance and polymorphism, why do people frequently say they are not? One source for this criticism can be found right in the EJB 2.0 specification. Section 11.2.11 says, “The data model for container-managed persistence does not currently support inheritance. Therefore, entity objects or value classes of different types cannot be compared. EJB QL queries that contain such comparisons are invalid.” Furthermore, the list of features deferred to future releases includes “support for component-level inheritance.”
In fact, there is no framework support in the EJB spec for inheritance and polymorphism. This has consequences for all three types of inheritance discussed above. It makes component inheritance–by any reasonable definition–impossible. It places limitations on how language inheritance is used. It requires the bean developer to implement data model inheritance on his or her own, while being mindful of the limitations of the EJB component model. This lack of framework support, and the consequences, are the issues that ultimately generate the criticism.
But that’s a far cry from saying that entity EJBs are incapable of representing an inheritance hierarchy, or polymorphic behavior, in a data model. When enterprise software developers hear about the lack of inheritance in EJBs, they most likely assume that EJBs cannot work with their existing schema. But they can, and this is the important point by far. In practice, it’s not that significant that you don’t have “black box” component-level inheritance for EJBs. What’s important is that you can represent your complete existing enterprise schema using EJBs.
How to Do It
It’s not complicated to implement a schema incorporating inheritance. The fundamental technique is called “containment.” This just means that your base EJB component will have a reference to its derived class or classes, and will delegate calls as appropriate. The base class will need some way of determining how to delegate the call to a related “derived” class. Typically, there will be a field (called a discriminator) that establishes the type of the base class. In its simplest form, a business method would check this discriminator, retrieve the appropriate related entity component interface from a cmr field, and delegate the call to this interface. For example, a business method call on a PARTY component interface would be translated by the container to a call on the PARTY implementation class. The PARTY implementation class might check a discriminator CMP field, and depending on the result, delegate the business method call to the PERSON cmr field or the CORPORATION cmr field.
Polymorphic relationships between entities will actually be between base EJB components, and polymorphic EJB-QL queries will return references to the base EJB component. For instance, if there were an ORDER component, it might have a relationship to a PARTY bean, rather than either a PERSON or CORPORATION bean. Or if you called a finder that retrieved all the orders in Ohio, you would query on the PARTY bean rather than the PERSON or CORPORATION bean.
It is possible that there might be methods defined on a subclass component interface that aren’t defined on the base component interface. You can’t use Java language casting to downcast from the base interface to the subclass interface…but you could implement a business method that returned the desired derived component interface. An elegant signature might be EJBLocalObject dynamicCast( String type ).
The example code for this article implements four EJBs: a session bean fafacadeade and the three entity EJBs (PARTY, PERSON, and CORPORATION). A client will ask the session bean facade to create some sample data: three people and three corporations. It will then execute a findAll() query that returns all six of these EJBs in a single result set. It will call two polymorphic business methods, one getting a display name and one getting a credit rating. There is nothing special about any of the code, but I’ll review the parts that are relevant to inheritance or polymorphism.
First, I have provided a business interface from which every local component interface in the inheritance hierarchy derives. (See PartyIntf.java.) This is not a requirement, but it allows us to treat any local component interface in the hierarchy as a single type with polymorhic methods. If I had not done this, the business methods of all three of the component interfaces would still function correctly, but the client would not be able to treat a party component interface, a person component interface, and a corporation component interface as the same type. Really, this is just syntactic sugar.
In this example, the polymorphic behavior is implemented entirely in the PARTY bean implementation class. (See PartyBean.java.) There is a cmp field “typeCode” that indicates the derived type of the entity. There are also two cmr fields to contain the derived instance: corporation and person. In this example, they are mutually exclusive and one of them will be null, but this is not a fundamental requirement. (In other words, you can implement multiple inheritance if your schema requires it.)
There are two business methods: getDisplayName() and getCreditLimitCode(). When either of the business methods is called, the typeCode cmp field is checked and the business method is delegated appropriately. For example:
public String getDisplayName()
{
String code = getTypeCode();
if (code.equals(“I”))
return getPerson().getDisplayName();
else if (code.equals(“C”))
return getCorporation().getDisplayName();
throw new EJBException( “Unknown type” );
}
You could make a case that the typeCode is redundant and it should be possible to check which relationship is not null. But if the cmr field is being lazily loaded by the EJB container, this could result in unnecessary database I/O.
The findAll() query (used by the session bean facade and called by the client) is defined on the PARTY local home interface. Of course, it is only returning component interfaces for the PARTY EJB, but these represent both PERSON instances and CORPORATION instances. It is defined in the deployment descriptor as a query returning PARTY instances, as follows:
<query>
<query-method>
<method-name>findAll</method-name>
<method-params/>
</query-method>
<ejb-ql>select object(pb) from PartyBean pb</ejb-ql>
</query>
The last interesting pieces of code from this example are the ejbCreate and ejbPostCreate methods for the CORPORATION and PERSON beans. As well as creating the corporation or person instance, respectively, these methods need to create the corresponding PARTY instance and establish a one-one relationship between the two. You might wonder if any special technique is required, considering that the relationship between a PARTY instance and a CORPORATION or PERSON instance is likely implied by a migrated key, rather than being explicitly stored in a separate foreign key. But this is a detail of the object/relational mapping, and doesn’t enter into consideration when you are coding your component. Let’s take a look at CorporationBean.java’s ejbCreate method:
public Integer ejbCreate( ViewCorporation view )
throws CreateException
{
getPartyLocalHome().create(new ViewParty(view.getId(), “C”));
setViewCorporation( view );
return null;
}
This is just one possible implementation, but the basic steps will usually be the same. In the ejbCreate method, we create an instance of the PARTY base component, and initialize the cmp fields for this component. Then in the ejbPostCreate method, we establish the relationship between the two:
public void ejbPostCreate( ViewCorporation view )
throws CreateException
{
try
{
PartyLocal party = getPartyLocalHome().findByPrimaryKey(view.getId());
setParty( party );
}
catch (FinderException e)
{
throw new EJBException( “Party not created” );
}
}
Object/Relational Mapping
For most enterprise developers, modeling inheritance and polymorphic behavior in EJBs is just half the battle. The other half is working with an existing schema. The code with this article should work with any EJB container, but there are no requirements in the EJB spec for any set of mapping capabilities. In practice, you’ll find that there is substantial variation in capabilities between implementations, and there are three potential trouble spots here.
First, the most common database schema for this model will have a migrated primary key that establishes the relationship between the base and derived entities. In the EJB world, primary keys and relationships are completely unrelated. The persistence mechanism for your EJB container must be smart enough to realize that in this case, the primary key and relationship information in the persistent store are conflated.
Second, the typical database schema for this model will have foreign-key constraints on the migrated primary key. This requires that the database inserts take place in the correct order (to not violate these constraints). If the EJB container triggers the insert statements immediately on return from ejbCreate, you must make sure that your code is ordered correctly. The persistence manager I wrote (the MVCSoft Persistence Manager) can cache the data and write it out to the database at the end of the transaction, dynamically reordering the database i/o so as to not violate any constraints.
Finally, if your EJB container is lazily-loading relationships for large result sets, it can lead to unacceptable performance. In our example, each call from the PARTY bean to getCorporation() or getPerson() might result in a select query to the database to get the information. There are several possible solutions to this problem. For example, the MVCSoft Persistence Manager allows you to define a “fault group” for a query that defines the information you will need during the transaction, and this fault group can extend to related information. The runtime will eagerly load the required data using a minimum number of queries. If you issued a finder query that returned a hundred results and called a polymorphic method on each instance, a properly configured runtime will issue three queries, rather than 101 queries as in the lazy loading case.
Conclusion
Despite what you may have heard, entity EJBs can be used effectively to represent business objects with inheritance and polymorphic behavior. There is no support for this functionality in the EJB component model, but one simple technique–called containment–is to delegate polymorphic business method calls to appropriate “derived” component instances. The EJB specification does not mandate specific object/relational mapping functionality, but there are products that can work with your existing relational database schema.
Deciding whether EJB is appropriate
By Ed Roman
excerpted from the new “Mastering Enterprise JavaBeans 2nd edition” book
September 2001
Motivation
A recent Gartner Group report cited companies overspent $1 billion on EJB last year, when they could have just gotten by with Servlets/JSPs. This motivates our next discussion: once you’ve decided whether server-side Java is the way to go, you then need to make the all-important decision: are you actually going to use EJB on this project? Or is EJB overkill?
Example
As a motivational example, consider an E-commerce site that has involved business processes. When you buy something on an E-Commerce site, the site needs to:
- Validate your credit card
- Debit your credit card
- Perhaps run some anti-fraud checking algorithms
- Check inventory
- Send a confirmation email
- Submit the order
- Fulfill the order
- Track the order afterwards
- Handle returns
You can still achieve all of this by using vanilla Servlets and JSPs. For example, you could have the Servlets and JSPs call Java classes. Those Java classes perform your business logic. In fact, there are three scenarios that we can consider when it’s possible to use Java classes rather than EJB components:
In a browser client web-based system with Servlets and JSPs, you could use Java classes rather than EJB components.
In a web services system where business partners call your Servlets and JSPs using XML/HTTP, you can also use Java classes rather than EJB components (see for a whitepaper on how to build web services using J2EE).
In a 2-tier client/server system such as a Java applet or Java application connecting to a server, you could again use Servlets and JSPs on the server. The thick client could communicate with the server via HTTP, which easily navigates through firewalls (compared to IIOP, which doesn’t). Behind the Servlets and JSPs could be Java classes instead of EJB components.
NOTE: A Servlet/JSP HTTP layer is only important if the users of your system are going to be behind firewalls, such as anonymous Internet clients, business partners, or other departments within your organization. It’s also important if your thick client is located across the Internet, because HTTP is a lightweight protocol that travels across the Internet easily. If there is no firewall issue, or if your users are not located across the Internet (but rather are on your local area network) you could get rid of your HTTP layer and connect the client to EJB components directly. In this case, the EJB value proposition is very strong, because EJB allows the client to call the server using intuitive method names, removes the need to perform XML marshaling, and gives you automatic remotability and load-balancing.
The Fear, Uncertainty, and Doubt
So how do you decide which is the right paradigm? Let’s start out with the reasons that most people think are important for deciding between EJB and Java classes, but are actually not important at all.
EJB server cost. The major J2EE server vendors, such as IBM, BEA, and Oracle, do not sell their EJB layer separately from their Servlet/JSP layer. They sell a single “J2EE server” which bundles both layers. So if you go with a market leader, then you’re probably going to buy an EJB server whether you like it or not. The only way to avoid this cost is to purchase an open-source or inexpensive Servlet/JSP implementation. This is a viable option, this is not recommended for major deployments. Why? Because the cost of the J2EE server is often a drop in the bucket compared to the total cost of the project. If the server doesn’t work out, consider all the retraining you’ll need to pay for, and the code you may need to rewrite if the servers use different versions of the J2EE specifications. Consider the difficulty in hiring skilled professionals if you don’t go with a market leader, the cost of re-learning how to tune your new server, and the cost of learning how to administer that new server. The cost of the application server should not be an issue for most serious deployments–most major vendors are charging very reasonable fees, far less than the $50,000 per processor that was charged back in the day. Rather, you should consider whether an EJB layer or a Java class layer is appropriate for your project. The professional services fees–we call it geek time–tends to dwarf the application server cost.
Resource pooling. Some people think that only EJB can give you resource pooling. Not true. Almost all the major J2EE server vendors allow you to get connection pooling and thread pooling whether you use Servlets/JSPs or EJB components.
Clean separation of business logic and presentation logic. EJB is nice because it enforces a separation of presentation logic (Servlets and JSPs) from business logic (EJB components). We like this because in the future we can support different types of presentation logic, such as a WAP enabled phone, or an XML data stream client from a business partner. But you can achieve the same results with Java classes instead of EJB components as well. You just need to enforce some coding best-practices in your organization about the proper usage of Java classes as a business layer facade.
Deciding the right way
Now that we’ve blown away the FUD (Fear, Uncertainty, and Doubt), here are the real reasons to use EJB over Java classes:
Your system is built faster and more reliably. EJB components benefit from declarative middleware, such as instance pooling, transactions, security, container-managed persistence, container-managed relationships, and data caching. If you used regular Java classes, you’d need to write this middleware yourself over time. Eventually you might find that you have your own middleware framework. That ‘framework’ is a fancy word for building your own home-grown application server. The framework needs to be tested, debugged, features need to be added. This is a non-trivial task indeed. Can you honestly state that your staff is capable of building a better application server than the market leaders who specialize in middleware?
It is easier to hire new employees. If you build your own custom framework using Java classes, then newhires need to be trained on this framework. If your framework is complex, then you can no longer look for “EJB” on a resume when hiring a developer and expect them to be productive on your system.
You benefit from the best practices the world is building around EJB. You can figure out how to optimize your system by reading articles on the Internet, or picking up a book on EJB best practices, such as Floyd Marinescu’s “EJB Design Patterns” book. This global knowledge base is not at your disposal with a proprietary Java class framework.
You can have different user interfaces. You can reuse the same EJB component layer for a thick client as well as a Servlet/JSP client. With Java classes, you cannot achieve this because Java classes are not remotely accessible. If you wrapped those Java classes in RMI objects, you’d need to invent your own load-balancing, instance pooling, and fail-over.
You can work with industry-standard tools to rapidly develop your system. While in the short run you may think that Java classes are going to make it faster to develop than writing all those files that comprise an EJB component, in reality there are many tools around that help streamline the EJB development process. There are command-line tools that generate the files you need, there are IDEs that help you build EJB components, and there are UML editors that help you generate EJB components from UML diagrams. See for more.
You can separate your web tier and application server. If you require your business logic to be protected by a firewall, then you can deploy the web server and application server on separate machines and stick a firewall in the middle.
And here are the real reasons not to use EJB:
You can’t deal with the limitations of EJB. Examples include threading, static variables, and native code. Most companies can deal with this, because there are good reasons why the restrictions exist. But if (for example) you need to have a multi-threaded engine, and you can’t deal with the EJB paradigm of load-balancing across single-threaded instances, then EJB is not a good fit for you. EJB is a square peg–don’t try to stick it into a round hole.
Your have existing skillsets or investments in a working technology. For example, if your developers are proficient in CORBA, then great–why not stick with it? As an anecdote, The Middleware Company consulted with one of our clients who wrote a CORBA application that assisted with mapping the human genome. It worked well with CORBA, and they had no major complaints, and so we recommended they stick with CORBA and avoid the EJB hype.
Your application is a big GUI to a database. If you are just a big GUI to a database–heavy on data logic but no business logic–you could achieve a deployment easily using JSPs with tag libraries connecting to a database via JDBC.
Your application is simple. If you are prototyping, building a simple system, or developing a one-off application that will not evolve over time, EJB may be overkill.
A few tips on deciding between EJB and COM
An article by Ed Roman, CEO of The Middleware Company
Recently, there’s been much said about Enterprise JavaBeans (EJB) and Microsoft’s COM+ technologies. Some assert that EJB is new, and is therefore not ready for prime-time. Others question the historical scalability of Windows, and are uneasy about using Windows 2000 in their mission-critical deployments. So what’s a development lead to do when deciding between these two environments?
In this article, I will raise some questions that you should be asking yourself to help you decide on the technology that’s right for your business. This article will not answer all of your questions, but it will get you asking the right ones.
ISV or IT Shop?
An important question to ask yourself is: are you in the business of selling software to other companies, or do you host the software yourself?
For most companies that are selling software to other businesses, EJB is usually the pick of the litter. Why? Because EJB supports a heterogeneous deployment environment. Unless you can guarantee that every one of your customers will accept a Windows solution, you are restricting your salespeople from major accounts that may have UNIX or mainframe-based solutions. This is rarely acceptable at most ISVs. If you don’t know what your customers are using, then talk to your sales force and your consultants, and have them find out for you. Don’t be shy — the more data you have, the better.
If you’re hosting software, then you control the deployment environment. That enables you to pick COM+ as well as EJB, and the playing ground is equal.
Existing developer skill-sets
What do your developers know today? Are they Java zealots, or C++ wizards? Do they have experience with MTS/COM+, EJB, or neither? This should certainly influence your purchase decision. After all, recruiting, hiring, training, and retaining employees is going to be your #1 problem, regardless of your industry. You can gain an immense amount of leverage by choosing a technology that is compatible with your developers’ skill-sets.
Embracing Java
Your choice of programming languages is absolutely critical to your choice of middleware. Why? Because EJB components must be written in Java, which requires a whole-hearted dedication to the Java programming language. If you are unwilling to commit to the Java programming language, then COM+ is a more attractive solution.
The opposite argument applies as well. If you are willing to bet on Java, then EJB is usually the best choice. If you recall, a recent court decision has undermined Microsoft’s control of the Java platform. Because of this, Microsoft is developing new programming languages, such as COOL. While they may officially support Java, there are strong indications that they will have Java and Visual J++ on maintenance mode. If you want faith that your vendor will continue to strongly support the Java programming language, then EJB (and CORBA) are the least risky choices.
Features in the underlying middleware
Most comparisons of EJB and COM+ focus on a feature-for-feature comparison of the two platforms. These are all important differences, and you should weight each of these features as they apply to your business problem when making your architectural decision.
You should note, however, that real, successful E-Commerce systems are being developed today to both EJB and COM+. Despite the lack of support for certain features in each platform, today’s development teams have learned to cope with some of the limitations of their chosen platform, such as lack of persistent components in COM+, or lack of queued components in EJB. It is very rare that an architectural decision will be made soley on the basis of features, as the two architectures are very, very similar. Rather, the overwhelming business forces at play are much greater factors.
Cost of systems
One great feature of Microsoft technology is they always seem to undercut the competition when it comes to price. Windows 2000 is no exception. There is a remarkably low cost per transaction in Windows 2000, and this stems from the volume pricing Microsoft employs. Furthermore, the COM+ subsystem ships with Windows 2000, whereas EJB-based application servers are sold separately from the underlying platform. When you couple low-cost Intel hardware with a Microsoft-based middleware solution, the cost per transaction is remarkably low.
The reader should note, however, that the cost of the underlying middleware, operating system, and hardware is always dwarfed by the total cost of ownership of a project. When you consider the cost of hiring, training, and retaining developers, the cost of developing and maintaining the solution, the potential lost business due to wrong architectural decisions, and the inertia of your decision over the years to come, the cost of the software and hardware are minimal.
Purchasing components vs. writing from scratch
One value of EJB and COM+ is they enable ISVs to ship applications as components. In the future, this will enable E-Commerce applications to be assembled in a piecemeal fashion from components specialized to their vertical market. This paradigm is much more appealing than writing applications from scratch, and is also superior to purchasing a proprietary, out-of-the-box commerce site that is not customizable. If new components are needed, the customer can craft their own, custom components as well.
Today, there aren’t a whole lot of off-the-shelf server side components available. If, however, you do find a vendor with components in your vertical industry, then that becomes a compelling reason to choose their underlying supported middleware. A few web sites you may want to check for components include:
http://www.flashline.com
http://www.componentsource.com
Summary
In summary, the decision between EJB and COM+ is a tough one, and this article is only meant to whet your appetite for the issues at hand. Chart 1 summarizes the differences between the two platforms.
|
Feature |
EJB |
COM+ |
|
Component Language |
Java only |
All (Java: unclear future) |
|
Platforms |
All |
Windows 2000 |
|
Middleware Vendors |
30+ |
Microsoft |
|
Legacy Integration |
RMI/JNI, CORBA, Connectors (future) |
COM TI, MSMQ, OLE DB |
|
Protocol |
Any (future: IIOP) |
DCOM |
|
Stateless components |
Yes |
Yes |
|
Stateful components |
Yes |
No |
|
Persistent components |
Yes |
No |
|
Method-granularity transactions |
Yes |
No |
|
Middle-tier load balancing |
Most vendors |
Coming soon |
|
Middle-tier data caching |
Some vendors |
No |
|
Queued components |
No |
Yes |
|
Single-vendor solution |
No |
Yes |
|
Low cost per transaction |
No |
Yes |
|
Middleware comes with OS |
No |
Yes |
|
Per-machine processors |
256+ |
16 (32 via OEMs) |
|
Cluster-wide processors |
Theoretically unlimited |
Theoretically unlimited |
|
Development tools |
Choice of many |
Microsoft Dev Studio |
If you want more information about how these technologies compare, check out a transcript from a debate I recently held with Roger Sessions (a COM+ evangelist) located at http://www.middleware-company.com/debate.html. For fellow technologists, if you want more information about how this middleware compares at a technical level, see my comparison whitepaper at TheServerSide.com resources section .
But in the end, remember this: both EJB and COM+ will be successful. This is not a zero-sum game, and there is no clear-cut winner at this point. Both will have their markets, and both are backed by strong, proven industry leaders. For those of you who wish to reduce your projects’ risk levels when deciding between EJB and COM+, my advice is to make a judgment call, and then prototype a first-pass solution to test the viability of your chosen platform. Only then will you know if your chosen middleware meets your specific business needs.
Client/Server Business Issues – Q & A
Business-Focused Client/Server Architecture
When analyzing a business there are three views of the organization:
A functional model, which reflects organizational responsibilities and the way in which the people who use the system view their work.
A process model, which details the business functions of the organization (e.g. accept orders, make goods, deliver goods, bill customers, and receive money). The functional structure and process model rarely, if ever, agree.
An information model, which details the information that the organization needs to function.
Client/Server Business Application Architectures
Traditional applications architectures have been based on function. Today, to meet the needs of the business application architecture should reflect the complete range of business requirements.
Therefore, client/server computing demands a three layer view of the organization.
- The user interface layer, which implements the functional model
- The business function layer, which implements the process model
- The data layer, which implements the information model
It should be noted that this application architecture does not demand multiple hardware platforms, although such technology can be utilized, if the environment is robust and reliable enough and the business is prepared to pay the additional costs associated with workstation and LAN technology.
Business Drivers
Client/server computing has arisen because of a change in business needs. Businesses today need integrated, flexible, responsive and comprehensive applications to support the complete range of business processes.
Problems with existing systems include:
- applications were developed to model vertical applications
- applications were built in isolation
- applications were implemented as monolithic systems
- applications were complex
- the supporting technology was based on a centralized control model
Information technology, which is an enabling factor in systems building, has almost reached the stage where these systems can be designed and created. Unfortunately, most businesses have existing systems based on older technology, which must be incorporated into the new, integrated environment.
The development and implementation of client/server computing is more complex, more difficult and more expensive than traditional, single process applications. The only answer to the question “why build client/server applications?” is “because the business demands the increased benefits.
Business Benefits
There is a perceived need for vendor independence. This includes application development methodologies, programming paradigms, products and architectures.
- Organization have changed from steep hierarchies to flattened hierarchies
- Network management is replacing vertical management
- There is a change to team based management
- The customer should have a single point of contact for all business with the organization
- The customer should deal with the same person over multiple contacts.
- The user will perform as much processing as possible during customer contact time
- The time required to complete the work will be minimized
- There is a need for empowerment of staff and audit trail of actions
- Multi-skilled and multi-function teams need access to multiple applications
What does business expect from IT?
New applications should be aligned with both the user’s view and the business process view. Existing functionally aligned systems are not appropriate
- Applications need to provide a consistent user interface
- Application complexity needs to be hidden
- The user interaction must be flexible
- Consistent information across all applications
- A variety of user interface styles to reflect the needs of the work
- Users should be able to modify business rules without reference to IT staff
- IT systems will support all activity performed by the user, not just a part
- An ability to evolve IT systems to reflect changing business requirements
- It is essential that there be integrity of transactional processes
What is Business Process Reengineering?
Reengineering is the organizational process required to align people, processes and technology with strategies to achieve business integration. It can also be thought of as taking a business in its current state and forming an organizational and operational blueprint to redirect skills, policies, information (data), cultural values, organizational structures, processing and incentives towards targeted improvements.
What sites carry client-server related material?
Object Management Group:
http://www.omg.org/
DCE Questions and Answers:
http://www.osf.org/dce/qna
OSF/DCE FAQ
http://www.osf.org/dce/faq-mauney.html
ftp://ftp.dstc.edu.au/pub/DCE/
Object-Oriented Links at Cetus (Germany)
http://www.rhein-neckar.de/~cetus/software.html
Client/Server Computing Page
http://www.wenet.net/~jtmalone/
Client/Server Technical Issues – Q & A
What are the characteristics of client/server architecture?
The basic characteristics of client/server architectures are:
- Combination of a client or front-end portion that interacts with the user, and a server or back-end portion that interacts with the shared resource. The client process contains solution-specific logic and provides the interface between the user and the rest of the application system. The server process acts as a software engine that manages shared resources such as databases, printers, modems, or high powered processors.
- The front-end task and back-end task have fundamentally different requirements for computing resources such as processor speeds, memory, disk speeds and capacities, and input/output devices.
- The environment is typically heterogeneous and multi-vendor. The hardware platform and operating system of client and server are not usually the same. Client and server processes communicate through a well-defined set of standard application program interfaces (API’s) and RPC’s.
- An important characteristic of client-server systems is scalability. They can be scaled horizontally or vertically. Horizontal scaling means adding or removing client workstations with only a slight performance impact. Vertical scaling means migrating to a larger and faster server machine or multiservers.
What are the different types of servers?
The simplest form of servers is disk servers and file servers. With a file server, the client passes requests for files or file records over a network to the file server. This form of data service requires large bandwidth and can slow a network with many users down considerably. Traditional LAN computing allows users to share resources, such as data files and peripheral devices, by moving them from standalone PCUs onto a Networked File Server (NFS).
The more advanced form of servers are database servers, transaction server and application servers (Orfali and Harkey 1992). In database servers, clients passes SQL (Structured Query Language) requests as messages to the server and the results of the query are returned over the network. The code that processes the SQL request and the data resides on the server allowing it to use its own processing power to find the requested data, rather than pass all the records back to a client and let it find its own data as was the case for the file server. In transaction servers, clients invoke remote procedures that reside on servers which also contains an SQL database engine. There are procedural statements on the server to execute a group of SQL statements (transactions) which either all succeed or fail as a unit. The applications based on transaction servers are called On-line Transaction Processing (OLTP) and tend to be mission-critical applications which require 1-3 second response time, 100% of the time and require tight controls over the security and integrity of the database.
The communication overhead in this approach is kept to a minimum as the exchange typically consists of a single request/reply (as opposed to multiple SQL statements in database servers). Application servers are not necessarily database centered but are used to server user needs, such as. Download capabilities from Dow Jones or regulating an electronic mail process. Basing resources on a server allows users to share data, while security and management services, which are also based in the server, ensure data integrity and security.
What are the different client/server processing styles?
Gartner group came out with the five ways of describing the different c/s styles based on how they split the three components of any application: user interface, business or application logic, data management. The five styles are distributed presentation, remote presentation, distributed function, remote data management, and distributed data management.
(Note: This is an arbitrary classification and others may do it differently)
What is distributed or remote presentation?
For people whose roots are embedded in the mainframe IBM world, client-server is essentially distributed or remote presentation. This style maps a workstation Graphical User Interface (GUI) front end onto an existing application’s text-based screen. This is also called Remote, Mapping, Front-ending or HLLAPI (High-Level Language Application Programming Interface). The mode of operation is typically intelligent workstations intercepting and interrogating text-screen (e.g. 3270) data streams sent from a host for display in a windowed environment. This is “frontware” solution, where a GUI front end is added to an IBM/MVS 3270/5250 application and is placed on a workstation. However, most processing remains on the host or server, with the exception of user interface translation logic and possibly validation logic. For example, data from an application program is sent to a 3270 screen program on the mainframe to be displayed. The merged data is sent to the workstation as a 3270 data stream. The workstation interprets the data and converts it to graphical form in a window. (Typically every mainframe screen used by the application has a corresponding window on the workstation and vice versa). When the user enters the data in a GUI window, it is transformed by the frontware application into a corresponding 3270 data format and is sent to the host computer.
What is Remote Data Management?
In remote data management, the entire application resides on the client and the data management is located on a remote server/host. Remote Data Management is relatively easily to program for because there is just one application program. The client communicates with the server using SQL, the server then responds with data that satisfies the query. RDBMS products that offer remote data management provide a layer of software on the client to handle the communication with the DBMS server. This style represents a more traditional LAN database server or file server approach. Workstations support the presentation and function logic and interface with the data server through the data manipulation language. Distributed data management is an extension of remote data management and uses the distributed facilities of the DBMS to access distributed data in a manner transparent to users. This is most relevant for architectures having data spread across several servers and when access to a DBMS on another server is required.
What is distributed function processing?
Here the split occurs in the application functionality, one part going to the client, other to the server. Distributed function applications are the most complex of the three typologies since two separately compiled application programs must be developed. Developers must analyze where each function should reside and what type of dialog must occur between the two programs. The underlying communications facilities may implement either a message-based or remote procedure call (RPC) mechanism for transfer of dialog and data. However, there are many variants of this typology. One variant of the distributed function style is where data management and application function occur at both the client and server.
In this instance, data management at the client would include referential, read-only data. Data frequently updated or accessed by many users would reside on the server.
What is IBM’s System Application Architecture?
SAA is a collection of selected software interfaces, conventions, and protocols that are used as a framework for developing consistent, integrated applications across the major IBM computing environments.
Four major components of this architecture are:
- Common User Access (CUA) defines conventions for GUI look and feel.
- Common Programming Interface (CPI) provides languages, tools, and APIs that give applications greater portability and more consistent user interfaces across multiple platforms.
- Common Communication Support (CCS) supports existing communications standards, such as LU 6.2.
- Common Applications, written by IBM, will serve as demonstrations of SAA concepts and make it easy for users to migrate between systems.
What is Apple’s VITAL architecture?
VITAL provides a way of building information systems constructed from generalized modules that can be reused and shared. It specifies how to construct and provide interfaces for these modules. A cornerstone of Apple’s client/server architecture is Data Access Language (DAL). DAL consists of software components for the client and the server (Macintosh System 7 includes the client component, DOS and Windows clients are sold separately). DAL sits between the client and server components.
This approach allows varied clients to communicate with many different servers. With DAL, a change in the DBMS does not affect the front-end; it simply requires the appropriate DAL link.
What is Sun’s Open Network Computing Architecture?
Open Network Computing (ONC) is the Sun architecture, with third party alliances providing the missing pieces. Sun’s RPC is licensed by more than 300 companies, including DEC, IBM, and Apple Computer. It is a lean, efficient RPC that is particularly effective for installations not requiring WAN support. Transport Independent Remote Procedure Calls (TI-RPC) were co-developed by Sun and AT&T. TI-RPC runs independent of the underlying network transport, allowing applications to run unmodified over multiple transport protocols including NetWare, PCNFS, AIX/6000, Solaris, UNIX/SVR4, and AIX/ESA. NetWise developed the TI-RPC Application Toolkit source code generation technology.
What is Digital’s Network Application System (NAS) architecture?
NAS is a software suite that enables applications to be integrated across a distributed network of multivendor systems: NAS services are divided into four main groups:
- Application Access Services which support user interface (forms based, graphical or character terminal based)
- Communication and Central services which support communications using electronic mail and EDI
- Information and resource sharing, which supports database access and compound documents (collection of images, graphics and conventional text)
- System Access services which provides a standard operating system interface.
What is OSF-DCE?
DCE is the Distributed Computing Environment, from the Open Software Foundation. (It is called “the DCE” by sticklers for grammatical consistency.)
DCE consists of multiple components which have been integrated to work closely together. They are the Remote Procedure Call (RPC), the Cell and Global Directory Services (CDS and GDS), the Security Service, DCE Threads, Distributed Time Service (DTS), and Distributed File Service (DFS). The Threads, RPC, CDS, Security, and DTS components are commonly referred to as the “secure core” and are the required components of any DCE installation. DFS is an optional component.
DCE is called “middleware” or “enabling technology.” It is not intended to exist alone, but instead should be integrated or bundled into a vendor’s operating system offering. DCE’s security and distributed file system, for example, can completely replace their current, non-network, analogs.
What are Distributed Object Management Systems (DOMS)?
DOMS provide a way of pulling diverse components together and managing their communications. They are aimed at addressing the following:
- A single interface to manage the complexities of a heterogeneous environment
- A uniform framework, based on standards and extensibility, to build, integrate, and deploy open distributed-computing applications
- A method for creating location independence for client applications.
What is CORBA?
CORBA stands for the Common Object Request Broker Architecture. It is a set of standard mechanisms for naming, locating, and defining objects in a distributed computing environment.
(For technical details, peruse the Object Management Group web site at http://www.omg.org/)
What is DAE?
Distributed Application Environment is designed to allow businesses to use IBM’s RISC System/6000 and PS/2 computers in a client/server network (or standalone) for their business applications.
DAE consists
- MESSAGING services;
- DATABASE services ;
- PRESENTATION services;
- DEVICE services to capture data and to control a broad category of controllers, devices, equipment and sensors.
Client/Server – Technical Q & A
What is Client-server computing?
The short answer:
Client/server is a computational architecture that involves client processes requesting service from server processes.
The long answer:
Client/server computing is the logical extension of modular programming. Modular programming has as its fundamental assumption that separation of a large piece of software into its constituent parts (“modules”) creates the possibility for easier development and better maintainability.
Client/server computing takes this a step farther by recognizing that those modules need not all be executed within the same memory space. With this architecture, the calling module becomes the “client” (that which requests a service), and the called module becomes the “server” (that which provides the service).
The logical extension of this is to have clients and servers running on the appropriate hardware and software platforms for their functions. For example, database management system servers running on platforms specially designed and configured to perform queries, or file servers running on platforms with special elements for managing files.
It is this latter perspective that has created the widely-believed myth that client/server has something to do with PCs or UNIX machines.
What is a Client process?
The client is a process (program) that sends a message to a server process (program), requesting that the server perform a task (service).
Client programs usually manage the user-interface portion of the application, validate data entered by the user, dispatch requests to server programs, and sometimes execute business logic. The client-based process is the front- end of the application that the user sees and interacts with. The client process contains solution-specific logic and provides the interface between the user and the rest of the application system. The client process also manages the local resources that the user interacts with such as the monitor, keyboard, workstation CPU and peripherals. One of the key elements of a client workstation is the graphical user interface (GUI). Normally a part of operating system i.e. the window manager detects user actions, manages the windows on the display and displays the data in the windows.
What is a Server process?
A server process (program) fulfills the client request by performing the task requested. Server programs generally receive requests from client programs, execute database retrieval and updates, manage data integrity and dispatch responses to client requests. Sometimes server programs execute common or complex business logic. The server-based process “may” run on another machine on the network. This server could be the host operating system or network file server; the server is then provided both file system services and application services. Or in some cases, another desktop machine provides the application services. The server process acts as a software engine that manages shared resources such as databases, printers, communication links, or high powered-processors. The server process performs the back-end tasks that are common to similar applications.
What is Two-Tier Architecture?
Two-tier architecture is where a client talks directly to a server, with no intervening server. It is typically used in small environments (less than 50 users).
A common error in client/server development is to prototype and application in a small, two-tier environment, and then scale up by simply adding more users to the server. This approach will usually result in an ineffective system, as the server becomes overwhelmed. To properly scale to hundreds or thousands of users, it is usually necessary to move to three-tier architecture.
What is Three-Tier Architecture?
Three-tier architecture introduces a server (or an “agent”) between the client and the server. The role of the agent is many fold. It can provide translation services (as in adapting a legacy application on a
Mainframe to a client/server environment), metering services (as in acting as a transaction monitor to limit the number of simultaneous requests to a given server), or intelligent agent services (as in mapping a request to a number of different servers, collating the results, and returning a single response to the client.
What is Middleware?
Connectivity allows applications to transparently communicate with other programs or processes, regardless of their location. The key element of connectivity is the network operating system (NOS). NOS provide services such as routing, distribution, messaging, file and print, and network management services. NOS rely on communication protocols to provide specific services. The protocols are divided into three groups: media, transport and client-server protocols. Media protocols determine the type of physical connections used on a network (some examples of media protocols are Ethernet, Token Ring, and Fiber Distributed Data Interface (FDDI), coaxial and twisted-pair). A transport protocol provides the mechanism to move packets of data from client to server (some examples of transport protocols are Novell’s IPX/SPX, Apple’s AppleTalk, Transmission Control Protocol/ Internet Protocol (TCP/IP), Open Systems Interconnection (OSI) and Government Open Systems Interconnection Profile (GOSIP)). Once the physical connection has been established and transport protocols chosen, a client-server protocol is required before the user can access the network services.
A client-server protocol dictates the manner in which clients request information and services from a server and also how the server replies to that request (some examples of client-server protocols are NetBIOS, RPC, Advanced Program-to-Program Communication (APPC), Named Pipes, Sockets, Transport Level Interface (TLI) and Sequenced Packet Exchange (SPX)).
What is Cooperative Processing?
Cooperative processing is computing which requires two or more distinct processors to complete a single transaction. Cooperative processing is related to both distributed and client/server processing. It is a form of distributed computing where two or more distinct processes are required to complete a single business transaction. Usually, these programs interact and execute concurrently on different processors. Cooperative processing can also be considered to be a style of client/server processing if communication between processors is performed through a message passing architecture.
What is Distributed Processing?
It is the distribution of applications and business logic across multiple processing platforms. Distributed processing implies that processing will occur on more than one processor in order for a transaction to be completed. In other words, processing is distributed across two or more machines and the processes are most likely not running at the same time, i.e. each process performs part of an application in a sequence. Often the data used in a distributed processing environment is also distributed across platforms.
What is an “Intranet”?
The explosion of the World Wide Web is due to the world-wide acceptance of a common transport (TCP/IP), server standard (HTTP), and markup language (HTML). Many corporations have discovered that these same technologies can be used for internal client/server applications with the same ease that they are used on the Internet. Thus was born the concept of the “Intranet”: the use of Internet technologies for implementing internal client/server applications.
One key advantage of Web-based intranets is that the problem of managing code on the client is greatly reduced. Assuming a standard browser on the desktop, all changes to user interface and functionality can be done by changing code on the HTTP server. Compare this with the cost of updating client code on 2,000 desktops.
A second advantage is that if the corporation is already using the Internet, no additional code needs to be licensed or installed on client desktops. To the user, the internal and external information servers appear integrated.
A rapidly-disappearing disadvantage is that there is limited ability to provide custom coding on the client. In the early days of the Web, there were limited ways of interacting with the client. The Web was essentially “read-only”. With the release of code tools such as Java and JavaScript, this limitation is no longer a major issue.
ENTERPRISE JAVA BEAN – TEMPERATURE CONVERSION
STEPS
- Create a new folder say EJB in C drive (This is only for this example. But you can create anywhere…)
- Create 4 classes namely TempHome.java , TempRemote.java ,TempEJB.java and TempClient.java inside the EJB folder and place the setenv batch file inside the EJB folder
// TempRemote.java
import javax.ejb.*;
import java.rmi.*;
public interface TempRemote extends EJBObject
{
public double FTOC(double degree) throws RemoteException;
}
//TempHome.java
import javax.ejb.*;
import java.io.Serializable;
import java.rmi.*;
public interface TempHome extends EJBHome
{
public TempRemote create() throws RemoteException,CreateException;
}
//TempEJB.java
import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
public class TempEJB implements SessionBean
{
private SessionContext ctx;
public double FTOC(double f)
{
double c;
c=((f-32)*5)/9;
return c;
}
public TempEJB(){ }
public void ejbActivate()
{
System.out.println(“ejbActivate called.”);
}
public void ejbRemove()
{
System.out.println(“ejbRemove Called.”);
}
public void ejbPassivate()
{
System.out.println(“ejbPassivate called.”);
}
public void setSessionContext(SessionContext ctx)
{
System.out.println(“setSessionContext() called.”);
this.ctx = ctx;
}
public void ejbCreate() throws CreateException
{
System.out.println(“ejbCreate() called”);
}
}
//TempClient.java
import javax.naming.*;
import java.io.*;
import javax.rmi.*;
import java.rmi.*;
import java.util.*;
import java.lang.*;
public class TempClient
{
public static void main(String args[])
{
BufferedReader stdin;
try
{
System.out.println(“Before lookup”);
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,”weblogic.jndi.WLInitialContextFactory”);
prop.put(Context.PROVIDER_URL,”t3://localhost:7001″ );
InitialContext ctx = new InitialContext(prop);
System.out.println(“Got Initial Context”);
TempHome home = (TempHome) ctx.lookup(“TempEJB2″);
TempRemote rem = home.create();
System.out.println(“create called”);
try
{
double f=0;
stdin=new BufferedReader(new InputStreamReader(System.in));
System.out.println(“\n\n Enter the temperature in Fahrenheit(type ‘q’ to quit):”);
while(f!=’q')
{
f=Double.parseDouble(stdin.readLine());
double calc=rem.FTOC(f);
System.out.println(“The temperature in celcius:”+String.valueOf(calc));
}
}
catch(Exception e)
{
System.out.println(“error:”+e);
}
rem.remove();
System.out.println(“RemoveCalled”);
}
catch(Exception er)
{
System.out.println(“Called From Client Catch”);
er.printStackTrace();
}
}
}
3. Open the DOS prompt and set the environment
C:\EJB> setenv
4. Compile all the files
C:\EJB>javac *.java
5. Create Deployment descriptor
C:\EJB>java weblogic.marathon.ddinit.EJBInit .
(leave space between EJBInit and dot at the last)
(You will find a folder name META-INF in EJB folder inside which you will find two XML file)
6. Create the jar file
C:\EJB>jar –cvf Temp.jar *.class META-INF
(Temp.jar is the name of the jar file and you will find this jar file created in EJB folder)
7. Deploy the jar file into weblogic server
7.1 Start the weblogic server by clicking Start->Program->BEA Weblogic->User projects->mydomain->start server or if you find start server icon in desktop double click it.
7.2 Open the weblogic server admin console by clicking Start->Program->BEA Weblogic->Examples->Weblogic Server examples->Server Admin console.
7.3 Enter the username and password and sign in. In the right pane you will find Domain configurations->EJB modules.
7.4 Click EJB modules->Deploy new EJB module->Upload your file->Browse(go to EJB folder and select Temp.jar file)->Upload.
7.5 Select myserver->Upload->select Temp.jar->Target module->Deploy.
8. Open a new Dos prompt and run the client program
C:\EJB>setenv
C:\EJB>set classpath=%classpath%;.;
C:\EJB>java TempClient
Result
Before lookup
Got Initial Context
Create called
Enter the temperature in Fahrenheit(type ‘q’ to quit):
212
The temperature in celcius:100.0
Note:
Create setenv.bat with following text (Make necessary changes according to ur local settings)
@rem *************************************************************************
@rem This script is used to set up your environment for development with
@rem WebLogic Server. It simply calls the commEnv.cmd script under
@rem C:\bea\weblogic81\common\bin. Add domain specific configuration in this script below.
@rem *************************************************************************
set WL_HOME=C:\bea\weblogic81
@rem Set Production Mode. When this is set to true, the server starts up in
@rem production mode. When set to false, the server starts up in development
@rem mode. If it is not set, it will default to false.
set PRODUCTION_MODE=
@rem Set JAVA_VENDOR to java virtual machine you want to run on server side.
set JAVA_VENDOR=Sun
@rem Set JAVA_HOME to java virtual machine you want to run on server side.
set JAVA_HOME=C:\bea\jdk141_03
call “%WL_HOME%\common\bin\commEnv.cmd”
@rem set JAVA_VM=
set CLASSPATH=%WEBLOGIC_CLASSPATH%;%POINTBASE_CLASSPATH%;%JAVA_HOME%\jre\lib\rt.jar;%WL_HOME%\server\lib\webservices.jar
CORBA – VisiBroker
VisiBroker 3.x
Here are some additional details for the VisiBroker 3.x implementation of CORBA. See the product documentation for more details.
VisiBroker Tools
VisiBroker for Java ships with a number of tools. Some are replacements or wrappers for the standard Java compiler and interpreter. Others are specific to the VisiBroker product. The important ones are:
vbjis a wrapper forjavawhich sets some properties and adds to your classpathvbjcis a wrapper forjavacwhich sets some properties and adds to your classpathidl2javais an IDL compiler that can produce proprietary or portable stubs and skeletonsosagentlaunches the proprietary Smart Agent binding service
Using VisiBroker with Java 2
To make VisiBroker for Java 3.4 work with the Java 2 platform, a number of changes are necessary, involving both code and configuration.
The Java 2 platform ships with a standard implementation of CORBA classes in the org.omg.CORBA.* package. These classes are somewhat different from the CORBA classes included with VisiBroker. The VisiBroker classes have several nonstandard extensions to CORBA; some of these nonstandard extensions are required for successful operation. To access these functions, you must change your source code to cast the JavaIDL ORB to a VisiBroker ORB. For example:
org.omg.CORBA.ORB orb =
org.omg.CORBA.ORB.init(args, null);
org.omg.CORBA.BOA boa =
((com.visigenic.vbroker.orb.ORB)orb).BOA_init(
);
|
This example applies to the server code.
For this cast to work, you must also guarantee that the ORB returned by the ORB.init() call is indeed a VisiBroker ORB, and not the standard JavaIDL ORB from Sun. For that, you need to define two Java system properties before you launch the JVM. These properties are automatically set if you use vbj instead of java to launch your programs. But if you use java, you must set these properties as follows (where each lists the property name first and value second):
org.omg.CORBA.ORBClass-
com.visigenic.vbroker.orb.ORBorg.omg.CORBA.ORBSingletonClass-
com.visigenic.vbroker.orb.ORB
Portable Stubs and Skeletons
By default, VisiBroker for Java creates stub and skeleton code that is interoperable but not portable. This makes sense in the VisiBroker world, since the non-portable code is more efficient and slightly smaller. However, if your code needs to run on several different ORBs, you can use the command
idl2java -portable -no_bind Foo.idl
and the stubs and skeletons will be portable.
There are a few reasons for this. One is if you’re writing an applet that will run inside a remote web browser environment, such as Netscape Communicator or the Java Plug-in. The latter uses JavaIDL; the former may be running an older version of VisiBroker.
What’s the difference between portable and proprietary versions? A portable stub uses DII (Dynamic Invocation Interface) to marshal the object request; a portable skeleton uses DSI (Dynamic Skeleton Interface). The proprietary versions make direct calls (to the ORB or the implementation), and hence do not have to go through the overhead of creating and parsing the various DII and DSI objects.
Note that your code doesn’t need to change–this all happens behind the scenes with idl2java. The only difference in the portable code is that _FooImplBase extends org.omg.CORBA.DynamicImplementation instead of com.inprise.vbroker.CORBA.portable.Skeleton, and that the stub class is named _portable_stub_Foo.java instead of _st_Foo.java. (Note also that if you really want to, you can switch stubs on the fly by using FooHelper.setProxyClass(_portable_stub_Foo.class) — though that would be kind of weird).
Using the BOA with VisiBroker
The VisiBroker BOA uses a slightly modified version of the standard BOA initialization sequence. For VisiBroker, follow the following boilerplate code.
// create and initialize the ORB ORB orb = ORB.init(args, null);
The VisiBroker BOA is a customized, proprietary implementation of the CORBA.BOA interface. It has several methods that are not part of the standard interface. In order to use these proprietary methods, you must cast the ORB to a VisiBroker class, as follows.
// Initialize the BOA. // Must cast to VBJ ORB for //Java 2 compatibility org.omg.CORBA.BOA boa = ((com.inprise.vbroker.CORBA.ORB)orb).BOA_init(); |
VisiBroker objects are usually persistent. In VisiBroker terms, this means that they are initialized with a name. This is not needed with a portable, non-VisiBroker object implementation.
// create object and register it //with the ORB Stock theStock = new StockImpl(name);
The VisiBroker BOA skips the boa.create() phase and jumps straight to obj_is_ready().
// Export the newly created object. boa.obj_is_ready(theStock);
The impl_is_ready() method waits indefinitely.
// Wait for incoming requests boa.impl_is_ready();
Using the VisiBroker Smart Agent
VisiBroker for Java ships with its own location service, called the smart agent. The smart agent is a distributed location service. It collaborates with other smart agents running on the network to locate a suitable implementation of an object. If there is more than one implementation available; the smart agent selects one. This provides a degree of fault tolerance and load balancing. If a machine goes down, the smart agent will automatically find another implementation on another machine to service the request. The client is unaware of this.
If you create a persistent object, by passing in a name when you call its constructor, then the BOA will automatically inform the smart agent. The name you passed in the constructor will become the name it is known by on the smart agent network.
On the client side, the proprietary Helper object defines a method bind() that fetches an object reference for you, bypassing the need to convert a string into an object reference. The bind() method is not part of the standard CORBA-Java mapping.
// "bind" (actually lookup) the //object reference Stock theStock = StockHelper.bind(orb, "GII");