Skip to main content

Layers

Each application consists of 6 layers. Each layer encapsulates a set of technologies to provide specific functionality.

Shared Layer

The Shared Layer is used by all other layers (except the View Layer) and contains classes which are mainly used by the other layers to communicate.

These classes, like the StarshipDetails class, can be found in the method interfaces in each layer:

StarshipEnterer.java
private StarshipDetails starshipDetails = new StarshipDetails();
StarshipAgent.java
public CrudsResult<DataRef> create(StarshipDetails details) {}
StarshipBean.java
public CrudsResult<DataRef> create(ParameterContext<StarshipDetails> detailsParameter) {}
StarshipCruds.java
public CrudsResult<DataRef> create(ParameterContext<StarshipDetails> detailsParameter) {}

View-Control-Proxy Layers

When zooming in on the view and control layer, we can see how this layer interacts with the other layers to provide the user functionality.

In the View Layer, we have the starship-page.js javascript file, which implements the logic of the page.

When data is entered into the page, an HTTP request is sent to the server. This request is handled in the Control Layer, by the StarshipEnterer class. This class converts the json of the HTTP request to a Java Object.

This Object is an instance of the StarshipDetails class. The details classes are used throughout the backend to pass data and is provided by the Shared Layer.

Finally, the StarshipEnterer then uses the StarshipAgent to create the instance. The agents provide an easy to access interface that encapsulates the underlying technologies needed to make this happen.

Proxy-Logic Layers

The Proxy Layer provides encapsulation for the remoting technology. Artifacts in the Logic Layer use EJB to implement transactions and scaling, but they can only be accessed by retrieving the objects through JNDI lookups.

To hide this from the users of the agent classes, the StarshipProxy class performs the JDNI lookup and then exposes an interface to interact with the underlying class.

The actual implementation can be found in the StarshipBean class, which implements the StarshipRemote interface. The proxy class then requests the EJB Container for an implementation of this remote interface, which then returns the bean.

Once the StarshipProxy has successfully connected to the StarshipBean, it can start sending requests.

Logic-Data Layers

StarshipBean sends the request to StarshipCruds. The cruds classes implement the logic close to the database. The cruds class uses the StarshipData class, which describes the form of the data in the database. It does this by using JPA annotations:

@Entity(name=StarshipData.ENTITY_NAME)
@Table(name="STARSHIP", schema="SPACE")
public class StarshipData {}

During a create operation, the StarshipDetails representation is mapped to a StarshipData object by a StarshipDetailsProjector and then given to the JPA entityManager to persist. The entityManager then converts this to an INSERT query to perform on the database.

find operations on the other hand, first pass through the StarshipFinderBean. This class receives the SearchDetails and then converts it into a JPA query with the help of a query builder.

The query returns a number of StarshipData objects, which are then mapped by the projector in the StarshipCruds class.

Between Components

When an artifact in one Component needs to connect to a DataElement from another Component, the agent is used.

StarshipAgent starshipAgent = StarshipAgent.getStarshipAgent(context);