Show TOC

Customizing CAF Model with Own ImplementationLocate this document in the navigation structure

Use

After your Composite Application Framework (CAF) application has been generated, you can still enhance the functionality provided with its application services (AS) or business object nodes (BONs).

The generation itself, based on the model that you made using CAF, creates everything needed for the composite application to work: generated Java source code, data tables, and so on. The result of the generation is an abstract class, which is extended in an Enterprise Java Bean (EJB) (one EJB per AS or BON). To customize the implementation, you have to edit the Implementation class of this EJB.

In the Implementation class, CAF distinguishes between the operations generated by CAF and your own source code using the annotation of each method.

For example, for a service operation with the name MyOperation, there is a dedicated, automatically-generated method named MyOperation with the following annotation:

@com.sap.caf.dt.CAFOperation(name="MyOperation")

Enhancing ASImplementation

Note that if you provide your own source code, you have to ensure that the signature is in sync with the model. For example, if you make changes to an operation, add a new parameter, or a new exception, you have to manually change the signature of the method. CAF does not remove or change the source code that you create. You have to ensure that the implementation can be built in the end.

Implementing Operations

For the application service's operation that you have marked using the Manually Implemented checkbox in the operations list, you can find an automatically-generated method with a name that corresponds to the name of the operation.

If you want to modify the code of this automatically-generated method, you can do that directly in the Implementation class. If later on you change the operation using the CAF tools, CAF will take care of updating the method's signature. The source you implemented inside the operation's method will remain unchanged.

Overwriting Operations

For all automatically-generated operations (not marked with the Manually Implemented checkbox in the operations list), CAF generates the corresponding source code only in the abstract class. However, if you want, in the Implementation class you can overwrite the whole method of the operation. All you have to do is to create a method with the same name and parameters as the operation.

Deleting Operations

When you delete an operation using the CAF UI, the method and its entire implementation remain as part of the source code. You have to manually delete the part of the source that is not needed.

Renaming Operations

Note that if you rename an operation, CAF does not rename the method's name. Instead, CAF generates a new method for the new operation's name. In the Implementation class you have to move the source code from the old method to the newly created method.

Enhancing BON Implementation

Manually Implemented Operations

For BONs, you will find an Implementation class in which you can directly go on with changing the implementation.

Note that you have to ensure that the method signature and the model is in sync.

Deleting Operations

When you delete an operation using the CAF UI, the method and its entire implementation remain as part of the source code. You have to manually delete the part of the source that is not needed.

Renaming Operations

Note that if you rename an operation, CAF does not rename the method's name. Instead, CAF generates a new method for the new operation's name. In the Implementation class you have to move the source code from the old method to the newly created method.

Prerequisites

You have generated your CAF application.

Procedure

To enhance the implementation, in the SAP NetWeaver Developer Studio:

  1. Open the Service Composer perspective and browse the CAF project you generated.
  2. Navigate to the application service and choose the  Implementation tab page.

    The Implementation tab page displays the names of the generated classes. In addition, you can find the link that opens the class that you have to use to enhance your implementation.

  3. Choose the link to the EJB Implementation class.

    The class is opened for editing.

  4. You can now continue with developing the source as you want.