Show TOC Start of Content Area

Process documentation Developing J2EE Applications  Locate the document in its SAP Library structure

Purpose

J2EE applications typically consist of three layers: the presentation layer built of JSPs and/or servlets to generate HTML pages that are displayed to the client, the business logic layer that holds the application logic implemented in enterprise beans, and a persistence layer where access to data is provided by the Java Database Connectivity (JDBC). The J2EE toolset provided by the SAP NetWeaver Developer Studio supports you by handling the generation of standard code such as enterprise beans’ home and remote interfaces, skeletons of servlet classes, and so on. Consequently, you concentrate only on the application’s logic.

Use of the Process

This process is part of the following IT scenarios:

IT Scenario

Scenario Variant

Developing, Configuring, and Adapting Applications

Leveraging J2EE Standards for Porting and Adopting Applications

Prerequisites

You have created a UML model of your application and have created the corresponding projects in line with the SAP component model concept in the SAP NetWeaver Developer Studio.

Process Flow

The following IT process runs in usage type DI:

...

       1.      Implement EJBs and persistence

The enterprise beans form the layer where the business logic of the application is implemented. For applications following the MVC architecture, they represent the model components.

In the SAP NetWeaver Developer Studio, you implement enterprise beans in EJB Module projects in the J2EE Perspective. The tools provided by this project type support you in generating the standard code and home and remote interfaces for each of the enterprise bean types defined by the J2EE standard (namely, stateless or stateful session beans, entity beans, and message-driven beans). You can choose whether the home and remote interfaces are built with support for local or remote access, or both, thus reflecting the specifics of your application scenario. Defining business methods is simple and less time-consuming using the graphical tools, where you define the parameters’ types and the method’s return types and the source code is generated automatically.

The J2EE standard defines two persistence models: relational persistence using JDBC, and object-relational persistence using container-managed enterprise beans (EJB CMP). The SAP NetWeaver platform provides a portable database access layer to J2EE applications though the Open SQL for Java framework. Thus, applications can be written in a database-independent fashion, whether using a direct relational interface (Open SQL/JDBC) or an object-based interface (EJB CMP). Higher-level persistence models are streamlined through the Open SQL for Java channel.

SAP NetWeaver comes with a preconfigured system DataSource that you can use in your application to get a connection to the database. It is good practice to use it through a custom DataSource alias that you define for your application.

       2.      Use JMS and JCA for connectivity and Web services for interoperability

You can enhance your J2EE application and connect it to external messaging or legacy systems using the implementation of the JMS and JCA technologies in the SAP NetWeaver. The AS Java provides its own JMS provider that you can use to connect components of your application using this standard messaging technique. Apart from that, you can integrate the application with any existing JMS messaging system using the JMS Connector service, which is based on a standard, JCA-compatible resource adapter implementation.

As far as JCA connectivity is concerned, you can deploy and configure standards-conformant resource adapters into the available Connector Container infrastructure and use them in your application code to access external back end systems.

SAP NetWeaver allows you to extend your applications by providing support for Web services. The SAP NetWeaver Developer Studio provides an environment for publishing, discovering, and accessing Web services. It provides graphical wizards supporting the inside-out approach to developing Web services. Using your existing EJB, a Web service interface is generated that is visible to the Web service consumer. This interface provides an abstraction layer and, consequently, independence from the specific implementation.

       3.      Implement JSPs and servlets

The presentation layer of your J2EE application is built of servlets and JSP pages. The application can use those components in accordance with the Model-View-Controller (MVC) design pattern, where JSP pages are used as view elements, and servlets manage the control flow.

You perform the actual implementation in a Web Module project in the J2EE Perspective of the SAP NetWeaver Developer Studio. Creating servlet classes is as easy as typing just the name and selecting the package the servlet resides in – the generator does the rest by generating standard code as the methods’ signatures and importing the necessary J2EE packages. Similar generation tools are available also for the other Web components defined by the J2EE specification, such as filters and all types of listeners. Your responsibility is reduced only to writing the code that contains the application logic.

JSP pages are build in a separate editor that provides code assistance functions for both standard JSP syntax elements and ordinary HTML tags. Using the preview function of the editor you can see the HTML layout of the page at implementation time.

       4.      Implement custom authentication

You can add flexibility to your J2EE application in terms of authentication using your custom JAAS login modules. You can develop them in the SAP NetWeaver Developer Studio and assemble them as a library and deploy them on the AS Java. You can then plug them into the authentication scheme your application uses by configuring the login modules stack in the deployment descriptors in the corresponding Web Module project.

       5.      Instrument J2EE applications for supportability

AS Java provides a flexible management infrastructure based on the JMX (Java Management Extensions) standard used to instrument, manage, and monitor J2EE applications and AS Java components. J2EE applications can use the JMX to monitor their important parameters, thus keeping track of the application data and performance.

In addition, J2EE developers can use a common logging infrastructure to increase the supportability level of their applications in two main directions: writing log and trace statements. The log statements help create and store a permanent record of events that can be reviewed, printed, and analyzed. Using the tracing functionality, J2EE developers can write detailed information about an operation to an output file. The trace facility produces a detailed sequence of statements that describe the events of an operation as they are executed. You use the SAP Logging API in the source code and then configure the logging behavior and output using the log-configurator.xml under the META-INF directory of your Enterprise Application project.

       6.      Execute testing and debugging

You have different test frameworks available in the SAP NetWeaver Developer Studio for testing your J2EE application. It integrates JLin that you can use for static testing of your code. It includes a pre-defined set of tests that you can run out-of-the-box to test aspects like code convention adherence, evaluation of metrics and statistics, check architectural patterns, and so on. The integration of the widely-recognized, open-source JUnit testing framework saves time and effort when performing functional unit testing of your code. You can write your own unit tests and embed them in JUnit, thus building a comprehensive test suite incrementally.

The SAP NetWeaver Developer Studio provides support for remote debugging of J2EE applications that are deployed on a test server. It is integrated with the AS Java’s cluster management infrastructure and allows you to run a server node in debug mode with a single mouse-click directly from your development environment. You then set breakpoints, start the debugger, and analyze the application’s behavior.

Result

You have developed the building components of your J2EE application and have tested it locally for functional correctness.

 

End of Content Area