Recents

Extension Library concept for Extending GeneXus for Smart DevicesOfficial Content

Extension Library concept is introduced as of GeneXus 15 to ease the development of extensions for Smart Devices.

Library concept

Library is a way to group implementation details for some extension points such as User Controls, External Objects and External Providers for Smart Devices, and it consists of two main components:

  • A XML-like file with extension *.library where the developer must list the extensibility components for each platform and their implementations.
  • The binaries and any other dependent file needed for the implementation.
     

The *.library file defines tags with a special semantic:

  • <ExtensionLibrary>...</ExtensionLibrary>
    Root tag which indicates the begin-end of the library file.
     
  • <Implements>...</Implements>
    Lists which components are implemented in the library.
    The tags for its items must match with GeneXus's object name. A few examples below:
     
    • <ExternalObject name="my_external_object" />
      Refers to an External Object implementation.
       
    • <UserControl name="my_user_control" />
      Refers to an User Control implementation.
       
    • <NotificationProvider name="my_notification_provider" />
      Refers to a notification provider implementation.
       
    • <CacheProvider name="my_cache_provider" />
      Refers to a cache provider implementation.
       
    • <StorageProvider name="my_storage_provider" />
      Refers to a storage provider implementation.
       
  • <Android>...</Android>
    Indicates the implementation dependencies for Android generator.
    Also, it defines special tags.
     
    • <ModuleClass>...</ModuleClass>
      Class instantiated at runtime responsible for mapping the extension to the components that use it.
       
    • <GroupId>...</GroupId>
      Package group identifier for Maven repository where there are AAR files that implement the library (with its transitive dependencies).
       
    • <Name>...</Name>
      Name of library in Maven repository.
       
    • <Version>...</Version>
      Version code of the library in Maven repository.
       
    • <GradleExtensionFile>...<GradleExtensionFile>
      Optional. A *.gradle file for library building.
       
  • <iOS>...</iOS>
    Indicates the implementation dependencies for iOS generator.
    Also, it defines special tags (details on this site).
     
    • <ModuleClass>...</ModuleClass>
      Optional. Class instantiated at runtime responsible for mapping the extension to the components that use it. It is optional in the case that the only component using the extension is a User Control.
       
    • <PodFile>...</PodFile>
      Optional. A *.pod complete filename for indicating the library dependencies.
       
    • <XCProjExtensionFile>...</XCProjExtensionFile>
      Optional. An XML filename for extending the generated XCode project.
       
    • <CopyListFile>...</CopyListFile>
      Optional. An XML filename which lists a set of files or directories to be copied to generated project.

Example

For example, let's take a*.library  file defined as follows:

<ExtensionLibrary>
    <Implements>
        <UserControl name="MyUserControl"/> 
        <UserControl name="MyUserControlVariant"/>
        <ExternalObject name="MyExternalObject"/>
    </Implements>
    <Android>
        <GroupId>com.example</GroupId>
        <Name>MyExtension</Name>
        <Version>1.0</Version>
        <ModuleClass>com.example.MyExtensionLibraryClassName</ModuleClass>
        <GradleExtensionFile>mylibraryextension.gradle</GradleExtensionFile>
    </Android>
    <iOS>
        <PodFile>MyExtension.Template.pod</Library>
        <ModuleClass>MyExtensionLibraryClassName</ModuleClass>
        <XCProjExtensionFile>MyExtension.XCExtensionTemplate.xml</XCProjExtensionFile>
        <CopyListFile>MyExtension.CopyListTemplate.xml</CopyListFile>
    </iOS>
</ExtensionLibrary>

As we mentioned before, the <ModuleClass> tag references a class where each component is initialized. 

Android initialization code sample

class com.mypackage.MyExtensionLibraryClassName {

    @Override
    public void initialize(Context context) {

         UserControlDefinition ucDefinition = new UserControlDefinition("MyUserControl", MyUserControl.class);
         UcFactory.addControl(ucDefinition);

         UserControlDefinition ucDefinition = new UserControlDefinition("MyUserControlVariant", MyUserControlVariant.class);
         UcFactory.addControl(ucDefinition);

         ExternalApiDefinition apiDefinition = new ExternalApiDefinition("Module.Example.MyExternalObject", MyExternalObject.class);
         ExternalApiFactory.addApi(apiDefinition);

         // Other components initialization.

    }

}

The Library itself details which component implements. the External Object does not need to fill the platform specific parameters.

iOS initialization code sample

@objc(MyExtensionLibraryClassName)
public class MyExtensionLibraryClassName: NSObject, GXExtensionLibraryProtocol {

    public func initializeExtensionLibrary(withContext context: GXExtensionLibraryContext) {

        GXActionExternalObjectHandler.register(MyGXActionExternalObjectHandlerSubclass.self, forExternalObjectName: "Module.Example.MyExternalObject")

        // Other components initialization, except for User Controls because GeneXus automatically generate the mapping by using the UC definition.

    }

}

Note that the implementation uses Swift language. In such case, the @objc(MyExtensionLibraryClassName) notation must be used in order to instantiated this class at runtime via reflection.

Availability

Android support as of GeneXus 15 Upgrade 3.
iOS support as of GeneXus 15 Upgrade 6.

See Also



Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.