Show TOC

Enabling CAF Application Services for ExtensibilityLocate this document in the navigation structure

Use

Application services in CAF can be enabled for extensibility.

There are cases in which you want to provide a composite application to your customers. This composite, may require a little bit different functionality for each different customer. In the regular case that would mean that you have to implement different composite for each of your customers. However, instead of following that approach, you may choose to create extension points in your composite, allowing the customers to create different customized implementations (extensions) for it. Then your customers receive the composite or its archive and create their extensions (in the CAF use case the extension is an EJB).

Prerequisites

You have created a composite application and application services in it. For more information, see Creating Application Services and Creating Composite Application Development Components .

Procedure

These are the steps to enable CAF application service extension point. You have to manually insert the source code annotations and manually mark the whole project as enabled for extensibility:

1. Insert the Source Code Annotations

  1. Open the Composite Designer perspective. In the Composite Explorer , click the project that contains the application service you want to extend with the secondary mouse button and from the context menu, choose Open Composite Designer .

  2. Using the palette, create new CAF application service.

    For more information about the wizard that appears, see Creating Application Services .

  3. Create an operation for the new applications service. To do that click the application service with the secondary mouse button and choose Start of the navigation path Open With Next navigation step Editor in Composite Application perspective End of the navigation path.

  4. From the palette, under Objects, choose Operation and drag and drop it on the new application service you have created.

    The wizard for creating an application service operation appears. For more information about using this wizard, see Modeling Service Operations .

  5. For the operation type, choose Custom operation . Enter a name for the operation and leave the other options by default.

    The operation you have created allows the extensibility for a part of the implementation of the original service. The implementation of the operation delegates a call to the method of the original service that allows extensibility.

  6. Open the Implementation tab page and implement the operation you have created.

  7. Open the Composite Designer perspective. Use the speed button Create Relation to create a relation from the new application service to the original application service you want to extend.

  8. Create a new operation for the original application service, repeating the same steps as for the new application service.

  9. Open the Implementation tab page of the original application service and in the implementation bean, before the empty constructor public <application_service_name>BeanImpl() {} add the following source code:

                         @EJB(name="<Original_application_service_name>/<ext_point_name>", 
    mappedName = 
    "beanName=<reversed_vendor_name>.<caf_package>.appsrv.<Additional_application_service_name>, 
    interfaceName=
    <reversed_vendor_name>.<caf_package>.appsrv.<Additional_application_service_name>Local")
    
    private <Additional_application_service_name>Local <ext_point_name> = null;
    
                      

    In the method of the operation you have created for the additional application service, add the following as a return value:

                         return <ext_point_name>.<Operation_of_the_additional_application_service>()
                      
Sample Code
                  @EJB(name="ExtAS/cafExtPoint",
                        beanInterface=org.example.mainproduct.bl.caf.modeled.appsrv.defaultextas.DefaultExtASServiceLocal.class,
                        mappedName=     "beanName=org.example.mainproduct.bl.caf.modeled.appsrv.defaultextas.DefaultExtAS,
interfaceName=org.example.mainproduct.bl.caf.modeled.appsrv.defaultextas.DefaultExtASServiceLocal")
        @Reference(name="cafExtPoint")
        private org.example.mainproduct.bl.caf.modeled.appsrv.defaultextas.DefaultExtASServiceLocal cafExtPoint;


        @com.sap.caf.dt.CAFOperation(name = "getExtensibleString")
        public java.lang.String getExtensibleString() {
                return "This string is extended with: "+cafExtPoint.getExtensionString();
        }

               

2. Enable the CAF Application for Extensibility

  1. In the Java EE perspective, in the Navigator view click the project that contains the application service you want to extend with the secondary mouse button.

  2. From the context menu, choose Start of the navigation path Extensibility  Next navigation step Enable Extensibility Configuration End of the navigation path

  3. Save, generate, and build your application.

  4. Open the Implementation tab page of the original application service again and in the implementation bean, before the EJB annotation you have added, add the following annotation:

                         @Reference(name="<ext_point_name>")
                      

    Add the corresponding import:

                         import org.osoa.sca.annotations.Reference;
                      

3. Modify the EJB Module

You have to manually modify the content of the ejbModule/META-INF/ejb-j2ee-engine.xml file. You have to add the following content:

               <enterprise-beans>
<enterprise-bean> 
<ejb-name> <Original_application_service_name> </ejb-name>
<bean-props>
<property>
<property-name>PoolClass</property-name>
<property-value>com.sap.engine.services.ejb3.util.pool.EmptyContainerPool</property-value>
</property>
</bean-props>
</enterprise-bean>
</enterprise-beans>
            
Sample Code
                  <enterprise-beans> 
<enterprise-bean> 
<ejb-name> ExtAS</ejb-name> 
<bean-props> 
<property> 
<property-name> PoolClass</property-name> 
<property-value> com.sap.engine.services.ejb3.util.pool.EmptyContainerPool</property-value> 
</property> 
</bean-props> 
</enterprise-bean> 
</enterprise-beans> 
               

4. Modify the Development Components Permissions

Modify the development component and public part permissions. Open the Development Infrastructure perspective. For the /ear and the /ejbmodule development components, configure the following:

In the Component Properties view, open the Permissions tab page of each of these development components and mark Unrestricted Access . Make sure that Entity Forwarding Allowed is enabled for the /ejbmodule development component of your application. In the /ejbmodule development components make sure that each public part has unrestricted access, and entity forwarding is allowed for each public part that requires entity forwarding.