
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.
You have set up your project as described in Setting Up Your Project .
To do it, use the com.sap.caf.eu.go.co.type.api.GPCallableObjectTypeFactory .
| Getting a Reference to the IGPCallableObjectTypeManager |
|---|
IGPCallableObjectTypeManagertypeMan = GPCallableObjectTypeFactory.getCallableObjectTypeManager(); |
| Checking if the ID for the CO Type Exists |
|---|
try{ IGPCallableObjectType co = typeMan.getCallableObjectType("myType"); if (co == null) {... |
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.
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 .
| Creating an Instance of IGPCallableObjectType |
|---|
//the unique ID for the new type in the registry StringtypeName = "myType"; //the type icon name; you define it as a relative path using the standard Web Dynpro APIs StringiconName = "myType.gif"; //a flag indicating if the type defines a CO for background execution booleanflagIsBackground = 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 Stringpermission = IGPCallableObjectType.PERMISSION_BASIC; //the name of the WD implementation class and the deployable unit (WebDynproDC) for the design-time part StringwdComponentName = "com.sap.test.cotype.NewCOType"; StringwdDevComponentName = "sap.com/caf~test~cotype"; //the type of the runtime container that runs the implementation intcontainerType = IGPCallableObjectType.RUNTIME_CONTAINER_TYPE_WD; //the name of the WD implementation and the deployable unit (Web Dynpro DC) for the runtime part StringcontainerCompName = "com.sap.test.cotype.NewCOType"; StringcontainerDevCompName ="sap.com/caf~test~cotype"; //the JNDI path to the container session bean for containers of type RUNTIME_CONTAINER_TYPE_SESSION_BEAN StringcontainerJNIName = ""; //the resource accessor and the text and description keys for the CO type; if the relevant text is not available, the keys are displayed GPWebDynproResourceAccessoraccessor=null; StringtextKey = "NAME"; StringdescriptionKey = "DESCRIPTION"; //flags indicating which design-time screens are relevant for the CO type booleanrequiresInputScreen = true; booleanrequiresOutputScreen = true; booleanrequiresConfigScreen = false; //flag indicating whether the CO can be used as a service - for prefilling, for example booleanisServicePattern = false; // flad indicating whether the CO type is visible in the GP gallery booleanisVisible =true; IGPCallableObjectTypecotype = typeMan.createCallableObjectType( typeName, iconName, flagIsBackground, permission, wdComponentName, wdDevComponentName, containerType, containerCompName, containerDevCompName, containerJNIName, accessor, textKey, descriptionKey, requiresInputScreen, requiresOutputScreen, requiresConfigScreen, isServicePattern isVisible); |
You can do this in an HTTP servlet, which is executed each time the service starts.
| Registering the New Type |
|---|
typeMan.registerCallableObjectType(cotype); |
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() .