Show TOC Start of Content Area

Procedure documentation Registering a New Callable Object Type  Locate the document in its SAP Library structure

Use

To use your new callable object type in Guided Procedures (GP), you need to register it in the framework first. This includes it in the list of available types, from which you can select when you are creating a callable object in GP, and also enables the implementation to interact with the framework.

You can implement the functions to register or remove a callable object type in an arbitrary Java component. For example, you may choose to create a Web Dynpro application, which provides a user interface where you can enter the parameters for the new callable object type, and then register it, or enter the name of an existing type and remove it from the registry. You can implement similar functionality using a servlet.

Prerequisites

You have set up your project as described in Setting Up Your Project.

Procedure

       1.      In your component, get a reference to an instance of com.sap.caf.eu.gp.co.type.api.IGPCallableObjectTypeManager.

To do it, use the com.sap.caf.eu.go.co.type.api.GPCallableObjectTypeFactory.

Example

Getting a Reference to the IGPCallableObjectTypeManager

IGPCallableObjectTypeManager typeMan =

         GPCallableObjectTypeFactory.getCallableObjectTypeManager();

       2.      Check whether the callable object type registry also contains a type with the name that you want to use for your callable object type.

Example

Checking if the ID for the CO Type Exists

try {

      IGPCallableObjectType co = typeMan.getCallableObjectType("myType");

      if (co == null) {

...

       3.      If your check returns null, you can proceed with creating an instance of com.sap.caf.eu.gp.co.type.api.IGPCallableObjectType. This is the object that you register in the type registry.

You instantiate the object using the method createCallableObjectType() of the callable object type manager. The parameters of the method are explained in the code sample below.

 Note

For a resource accessor in Java implementations you can use the com.sap.caf.eu.gp.co.api.GPStandardResourceAccessor. You must create your own class that extends the GPStandardResourceAccessor, and put it in the same package as the implementation classes together with the resource bundle (a file with the extension .properties).

In Web Dynpro, you can use the com.sap.caf.eu.gp.co.api.GPWebDynproResourceAccessor.

The use of these resource accessors is described in Implementing a Callable Object for Background Execution and Implementing a Web Dynpro Callable Object.

Example

Creating an Instance of IGPCallableObjectType

//the unique ID for the new type in the registry

String typeName = "myType";

//the type icon name; you define it as a relative path using the standard Web Dynpro APIs

String iconName = "myType.gif";

//a flag indicating if the type defines a CO for background execution

boolean flagIsBackground = false;

// permission for the CO; we use BASIC for the example

// if you set a default permission (PERMISSION_NOT_SELECTED), the CO type will not be visible in design time until the GP Administrator sets the relevant permission level using the GP administration tools

String permission = IGPCallableObjectType.PERMISSION_BASIC;

 

//the name of the WD implementation class and the deployable unit (WebDynpro DC) for the design-time part

String wdComponentName = "com.sap.test.cotype.NewCOType";

String wdDevComponentName = "sap.com/caf~test~cotype";

 

//the type of the runtime container that runs the implementation

int containerType = IGPCallableObjectType.RUNTIME_CONTAINER_TYPE_WD;

 

//the name of the WD implementation and the deployable unit (Web Dynpro DC) for the runtime part

String containerCompName = "com.sap.test.cotype.NewCOType";

String containerDevCompName ="sap.com/caf~test~cotype";

 

//the JNDI path to the container session bean for containers of type RUNTIME_CONTAINER_TYPE_SESSION_BEAN

String containerJNIName = "";

           

//the resource accessor and the text and description keys for the CO type; if the relevant text is not available, the keys are displayed

GPWebDynproResourceAccessor accessor=null;

String textKey = "NAME";

String descriptionKey = "DESCRIPTION";

 

//flags indicating which design-time screens are relevant for the CO type          

boolean requiresInputScreen = true;

boolean requiresOutputScreen = true;

boolean requiresConfigScreen = false;

//flag indicating whether the CO can be used as a service - for prefilling, for example

boolean isServicePattern = false;

// flad indicating whether the CO type is visible in the GP gallery

boolean isVisible = true;

 

IGPCallableObjectType cotype =

      typeMan.createCallableObjectType(

            typeName,

            iconName,

            flagIsBackground,

            permission,

            wdComponentName,

            wdDevComponentName,

            containerType,

            containerCompName,

            containerDevCompName,

            containerJNIName,

            accessor,

            textKey,

            descriptionKey,

            requiresInputScreen,

            requiresOutputScreen,

            requiresConfigScreen,

            isServicePattern

            isVisible);

       4.      Finally, you register your callable object type using the type manager method registerCallableObjectType().

You can do this in an HTTP servlet, which is executed each time the service starts.

Example

Registering the New Type

typeMan.registerCallableObjectType(cotype);

Result

Your callable object type is available in the type registry, and you can create object instances of this type using the standard GP wizard for creating callable objects.

If you need to remove the type from the registry, you can do it by calling the type manager method unregisterCallableObjectType().

 

End of Content Area