• No se han encontrado resultados

GUIA Y PROBLEMAS DE QUÍMICA IV

EQUILIBRIO QUÍMICO

The prototype uses EJB / J2EE as a data source, which is used by an implemented EJBDataService to connect to and retrieve data from. This implementation had many advantages, as can be seen in chapter 4. However we also wanted to analyze in what other areas this technique could be used.

We have derived 4 possible usage areas for EJB / J2EE:

Having EJB as a data service, which would be used when accessing a database through an EJB API. This scenario is implemented and discussed in chapter 4.

Implementation of the CEL layer in EJB.

Create an EJB facade, which is useful for creating an API to other type of clients. Packaging of CEL in an enterprise archive, which is a concept supported by a majority of application servers.

5.6.1 Implementation of the CEL layer in EJB/J2EE

It is possible to wrap all individual classes making up the CEL structure in EJB. The purpose would be to let EJB add to, or take over functionality from the CEL classes. We would in theory benefit from all the services that EJB provides. However there are practical implications too that can be seen as major drawbacks when determining if it is worth the effort migrate. They drawbacks are:

Object oriented programming limitations of the EJB framework. EJB should more be seen as components than classes. There is a contract with restrictions to fulfill that prohibits more advanced forms of object orientation, and thus limit the flexibility of the frameworks.

Necessity to provide an EJB container with the products. This introduces a dependence of a third- party product in the application, a product which often can be rather expensive.

Difficulty to remake an existing application into EJB without a total remodeling of the application. The conclusion for implementing the CEL layer in EJB is that this is not a useful tool for distributing CEL at this time. CEL already handles much of the distributing by itself, and potential benefits from EJB does not weigh up the development cost and complexity of the solution.

5.6.2 EJB facade

Instead of implementing EJB on the fundamental elements of the CEL structure, there is another alternative, namely to create a session facade that can transfer method calls to an internal CEL structure and get results back as value objects that is not EJB. The facade should be able to wrap both the CEL structure and the specific view for thin clients structure. The solution should have facade methods for all methods in the CEL and view structures that carries out an action. It should also have data holders that are used to transport data from the client and the facade, and nothing more. The normal classes cannot be used since they have action methods as well. Data holders should have an association with an instance of CEL via a lookup service, so a data holder actually can be used as a parameter to session facade method.

So what is gained using this approach?

Wrapping of CEL in an EJB container, which makes it possible to introduce the CEL architecture into an already existing EJB solution.

Avoid tight coupling between business objects and clients. A standardized way of connecting to a remote CEL application.

EJB specialists can use their knowledge to develop clients that works against the session facade. What are the drawbacks?

One more layer on top of CEL that will decrease performance. Value holders of data increase memory usage.

Large and unmaintainable number of session facades. Difficulty in treating hierarchical and iterative algorithms.

The facades would probably be more suited to message oriented problems, such as reporting tools and HTML or XML generation tools, and not very good for business logic connected to a Swing

application. A better way would be to use facades that give whole answers back to well defined questions / parameters. This could be accomplished by letting qualifiers and entity descriptors represents the parameters, and the answer would be a selection of entities, that can be used for reporting back data to an application. The facade can also make use of a bridging pattern [Gamma 1995] so that it returns data in a given format, such as another type of data structure that is known by the client, or for example as a XML stream. However this kind of service is what the web services technology is all about. Read more about this in the evaluation of Web Services in section 5.5.

5.6.3 Packaging of CEL in an Enterprise archive

Another useful aspect of J2EE is the standardized way of distributing whole applications as one compressed archive file. In theory this file should be completely compatible with all standard compliant Java application servers. Therefore, there exists a good motivation for packaging the finished product in such a file. The file is a so called EAR file, which stands for "enterprise archive". The file contains a structured way to store the application and it has an standardized internal file structure. It has settings for both EJB and web applications, and a typical file structure has been explained in a previous section. There is one major problem to solve, and that is how to distribute the "cel.jar" package. To make it visible for EJB and the web applications, we need to add a line to the manifest part of the jar and war files:

classpath: cel.jar

This assumes that "cel.jar" is placed in the root of the ear file.

5.6.4 Summary

The creation of a data service that works against an EJB structure seems to be a good idea, since there exist legacy systems on the market that demand that data only is changed through an EJB layer. It is therefore a good project to implement, and it is studied in detail in section 4.3.

Wrapping the inner structure of CEL in EJB is not an equally good idea. EJB will add an overhead and the services that EJB offer are in many areas already covered in the CEL structure. The extremely object oriented structure of CEL is not trivial to solve with the more modular component based solution in EJB. It would require high competence in EJB design patterns to be able to solve the wrapping problems. Our conclusion is that the cost in time to do the wrapping overweights the potential gain of such a project.

Making an EJB facade to the system is a better idea, but not in the sense as to wrap CEL in detail, but rather to construct larger messages to be sent into the system from an external client and return answers in a format suitable to the independent client. However, web services may be a better way to achieve this.

In conclusion, even if we do not use EJB in the end, it is still a good idea to package at least the prototype in an enterprise archive file. This makes it easier to move the code base between application servers.

Documento similar