Skip to Content
Author's profile photo Nic Botha

Creating a custom HCI Adapter – Part 2

Overview

Part 2 – Create the HCI adapter

In Part 1 of this series we created the Camel component.  Now we need to wrap that component in a HCI adapter project. We will create the echo adapter using the echo component created in part 1.  The outcome of this part is a HCI adapter deployed on a tenant.

Step – Create the adapter project

The first thing todo is to create the adapter project.  For this you will need to open Eclipse and select File > New > Other..  Expand the SAP HANA Cloud Integration section and select Adapter Project

/wp-content/uploads/2016/05/eclipse_wiz1_944534.png

click Next.

/wp-content/uploads/2016/05/eclipse_wiz2_944535.png

fill in required fields and click Finish

Step – Generate metadata

At this step you should have a project looking similar to:

/wp-content/uploads/2016/05/adap_1_944536.png

The project itself contains a few empty folders and a metadata.txt file.  Next we want to copy the echo-*.jar from the echo camel component project into the component folder of the echo adapter project.  Once done your adapter project should look like:

/wp-content/uploads/2016/05/adap_2_944540.png

The next action is to generate the component metadata.  You can read all about what component metadata is in the online help.  But it is basically the place where you setup the info required by the editor in design time. 


Right click on the echo-adapter project and select Generate Component Metadata

/wp-content/uploads/2016/05/adap_3_944541.png

Next, right click on the echo-adapter project and select Execute Checks.  The output of this step should be:

/wp-content/uploads/2016/05/adap_4_944542.png

Step – Modify metadata.xml

Expand the metadata folder and you will see a newly generate file named metadata.xml.  Open this file.  Notice that the generation tool inspected our echo component and generated appropriate xml content from it.  What we will do now is modify it a bit by removing unnecessary elements.

There are only two parameters we want users of our adapter to specify: first part URI and delay.  We can remove the others as the adapter will use default values.  Once done your metadata.xml should look like:


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ComponentMetadata ComponentId="ctype::Adapter/cname::me:echo/version::1.0.0" ComponentName="me:echo" UIElementType="Adapter" IsExtension="false" IsFinal="true" IsPreserves="true" IsDefaultGenerator="true" MetadataVersion="2.0" xmlns:gen="http://www.sap.hci.adk.com/gen">
    <Variant VariantName="Echo Component Sender" gen:RuntimeComponentBaseUri="echo" VariantId="ctype::AdapterVariant/cname::me:echo/tp::echo/mp::echo/direction::Sender" MetadataVersion="2.0" AttachmentBehavior="Preserve">
        <InputContent Cardinality="1" Scope="outsidepool" MessageCardinality="1" isStreaming="false">
            <Content>
                <ContentType>Any</ContentType>
                <Schema xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></Schema>
            </Content>
        </InputContent>
        <OutputContent Cardinality="1" Scope="outsidepool" MessageCardinality="1" isStreaming="false">
            <Content>
                <ContentType>Any</ContentType>
                <Schema xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></Schema>
            </Content>
        </OutputContent>
        <Tab id="connection">
            <GuiLabels guid="f20e0d5e-6204-42b8-80db-7dc179641528">
                <Label language="EN">Connection</Label>
                <Label language="DE">Connection</Label>
            </GuiLabels>
            <AttributeGroup id="defaultUriParameter">
                <Name xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">URI Setting</Name>
                <GuiLabels guid="fef82a37-793e-45d2-9c62-261a5a2987fa">
                    <Label language="EN">URI Setting</Label>
                    <Label language="DE">URI Setting</Label>
                </GuiLabels>
                <AttributeReference>
                    <ReferenceName>firstUriPart</ReferenceName>
                    <description>Configure First URI Part</description>
                </AttributeReference>
            </AttributeGroup>
            <AttributeGroup id="echoEndpoint">
                <Name xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">Echo Endpoint</Name>
                <GuiLabels guid="7a914dcf-ab5e-4dfc-a859-d4709bd7402d">
                    <Label language="EN">Echo Endpoint</Label>
                    <Label language="DE">Echo Endpoint</Label>
                </GuiLabels>
                <AttributeReference>
                    <ReferenceName>delay</ReferenceName>
                    <description>Configure Delay</description>
                </AttributeReference>
            </AttributeGroup>      
        </Tab>
    </Variant>
    <Variant VariantName="Echo Component Receiver" gen:RuntimeComponentBaseUri="echo" VariantId="ctype::AdapterVariant/cname::me:echo/tp::echo/mp::echo/direction::Receiver" IsRequestResponse="true" MetadataVersion="2.0" AttachmentBehavior="Preserve">
        <InputContent Cardinality="1" Scope="outsidepool" MessageCardinality="1" isStreaming="false">
            <Content>
                <ContentType>Any</ContentType>
                <Schema xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></Schema>
            </Content>
        </InputContent>
        <OutputContent Cardinality="1" Scope="outsidepool" MessageCardinality="1" isStreaming="false">
            <Content>
                <ContentType>Any</ContentType>
                <Schema xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></Schema>
            </Content>
        </OutputContent>
        <Tab id="connection">
            <GuiLabels guid="8c1e4365-b434-486a-8ec8-2a8fd370f77f">
                <Label language="EN">Connection</Label>
                <Label language="DE">Connection</Label>
            </GuiLabels>
            <AttributeGroup id="defaultUriParameter">
                <Name xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">URI Setting</Name>
                <GuiLabels guid="d1004d88-8e54-4f46-a5e7-e6e4d0dca053">
                    <Label language="EN">URI Setting</Label>
                    <Label language="DE">URI Setting</Label>
                </GuiLabels>
                <AttributeReference>
                    <ReferenceName>firstUriPart</ReferenceName>
                    <description>Configure First URI Part</description>
                </AttributeReference>
            </AttributeGroup>      
        </Tab>
    </Variant>
    <AttributeMetadata>
        <Name>firstUriPart</Name>
        <Usage>false</Usage>
        <DataType>xsd:string</DataType>
        <Default></Default>
        <Length></Length>
        <IsParameterized>true</IsParameterized>
        <GuiLabels guid="eaa8b525-3e51-4d18-81ca-16ec828567dc">
            <Label language="EN">First URI Part</Label>
            <Label language="DE">First URI Part</Label>
        </GuiLabels>
    </AttributeMetadata>
    <AttributeMetadata>
        <Name>delay</Name>
        <Usage>false</Usage>
        <DataType>xsd:long</DataType>
        <Default></Default>
        <Length></Length>
        <IsParameterized>true</IsParameterized>
        <GuiLabels guid="7630e90d-5982-403b-a217-6a9be329ee04">
            <Label language="EN">Delay</Label>
            <Label language="DE">Delay</Label>
        </GuiLabels>
    </AttributeMetadata>
</ComponentMetadata>




❗ To ensure all is good run the Execute Checks again.


Step – Deploy


So at last we can deploy our adapter to a HCI tenant.  Right click on the echo-adapter project and select Deploy Adapter Project


/wp-content/uploads/2016/05/adap_5_944546.png

In the Deploy Integration Content dialog select the Tenant you want to deploy to and click OK


/wp-content/uploads/2016/05/adap_6_944547.png


Where after you should see the confirmation as below


/wp-content/uploads/2016/05/adap_7_944548.png


Test – Validate successful deployment


Double click on the tenant in the Node Explorer view and then open the Deployed Artifacts view.  You might need to refresh the view by clicking on the yellow arrows and if the deployment was a success the adapter will display as follows.


/wp-content/uploads/2016/05/adap_8_944549.png

Also, lets ensure it started on the worker node by first selecting the node in the Node Explorer and then opening the Component Status View

/wp-content/uploads/2016/05/adap_9_944550.png

Conclusion

In Part 2 we have created a HCI adapter and deployed it to a HCI tenant.  At this point the echo adapter is available for use.  In the final part we will create an integration flow to use the adapter and ensure the endpoints are working.

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Simone Cattozzi
      Simone Cattozzi

      I'm facing adapter deployment errors. Have you any ideas about it?

      message: org.osgi.service.subsystem.SubsystemException: org.osgi.service.resolver.ResolutionException: Unable to resolve /tmp/.../echo-0.0.1-SNAPSHOT.jar: missing requirement org.apache.aries.subsystem.core.archive.ImportPackageRequirement: namespace=osgi.wiring.package, attributes={}, directives={filter=(&(osgi.wiring.package=org.jruby.runtime.builtin)(version>=0.0.0))}, resource=/tmp/.../echo-0.0.1-SNAPSHOT.jar

      at org.apache.aries.subsystem.core.internal.SubsystemResource.computeDependencies(SubsystemResource.java:425)
      at org.apache.aries.subsystem.core.internal.SubsystemResource.computeDependencies(SubsystemResource.java:393)
      at org.apache.aries.subsystem.core.internal.SubsystemResource.<init>(SubsystemResource.java:101)
      at org.apache.aries.subsystem.core.internal.SubsystemResource.<init>(SubsystemResource.java:92)
      at org.apache.aries.subsystem.core.internal.InstallAction.createSubsystemResource(InstallAction.java:134)
      at org.apache.aries.subsystem.core.internal.InstallAction.run(InstallAction.java:55)
      at org.apache.aries.subsystem.core.internal.InstallAction.run(InstallAction.java:33)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.apache.aries.subsystem.core.internal.BasicSubsystem.install(BasicSubsystem.java:621)
      at org.apache.aries.subsystem.core.internal.BasicSubsystem.install(BasicSubsystem.java:259)
      at org.apache.aries.subsystem.core.internal.BasicSubsystem.install(BasicSubsystem.java:63)
      at com.sap.it.nm.core.deploy.deployers.SubsystemDeployer.install(SubsystemDeployer.java:57)
      at com.sap.it.nm.core.deploy.action.DeployTask.deployArtifacts(DeployTask.java:362)
      at com.sap.it.nm.core.deploy.action.DeployTask.call(DeployTask.java:137)
      at com.sap.it.nm.core.deploy.ContentAgentImpl.doDeploy(ContentAgentImpl.java:143)
      at com.sap.it.nm.core.deploy.ContentAgentImpl.onReceive(ContentAgentImpl.java:114)
      at com.sap.it.nm.core.deploy.ds.ContentAgentComponent.onReceive(ContentAgentComponent.java:129)
      at com.sap.it.nm.core.talk2.invoker.BaseReceiverInvoker.invoke(BaseReceiverInvoker.java:69)
      at com.sap.it.nm.core.talk2.DefaultChannel.deliver(DefaultChannel.java:184)
      at com.sap.it.nm.core.talk2.DefaultHub.dispatchMessage(DefaultHub.java:315)
      at com.sap.it.nm.core.talk2.ChannelDispatcher.permitAndDispatchMessage(ChannelDispatcher.java:127)
      at com.sap.it.nm.core.talk2.ChannelDispatcher.access$300(ChannelDispatcher.java:38)
      at com.sap.it.nm.core.talk2.

      Author's profile photo Former Member
      Former Member

      Hello,

       

      we try to build a new adapter on HCI too, but on deployment we get some conflicts with our external libs and the libs which are provided by HCI himself

      DEBUG: Candidate permutation failed due to a conflict between imports; will try another if possible. (org.osgi.service.resolver.ResolutionException: Uses constraint violation. Unable to resolve resource org.apache.cxf.cxf-rt-core [/tmp/inputStreamExtract8152577104322023768.zip/cxf-rt-core-2.7.18.jar] because it is exposed to package ‘javax.xml.namespace’ from resources org.eclipse.osgi [org.eclipse.osgi_3.8.2.v20130124-134944-sap-03] and org.eclipse.osgi [org.eclipse.osgi_3.8.2.v20130124-134944-sap-03] via two dependency chains.

      It looks like that all of our external resources are important for the deloyment to include in our esa file in the lib folder. if we do this not we get a reference missing error because the dependency is missing. Is there an option available that the conflicts will be ignore with the osgi libs and the conflicts with the packaging import/export?