Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagexml
titleComponents.xml
linenumberstrue
collapsetrue
...
  <e Name="CPP_HELLO_COMP"
     Code="HelloComponentImpl"
     Type="IDL:acsws/workshop/HelloComponent:1.0"
     Container="bilboContainer"
     ImplLang="cpp"/>
  <e Name="JAVA_HELLO_COMP"
     Code="acsws.workshop.HelloComponentImpl.HelloComponentHelper"
     Type="IDL:acsws/workshop/HelloComponent:1.0"
     Container="frodoContainer"
     ImplLang="java"/>
  <e Name="PY_HELLO_COMP"
     Code="workshop.HelloComponentImpl"
     Type="IDL:acsws/workshop/HelloComponent:1.0"
     Container="aragornContainer"
     ImplLang="py"/>
...

...

Code Block
languagepy
titlepyHelloComponent/src/workshop/HelloComponentImpl.py
linenumberstrue
collapsetrue
#Client stubs and definitions, such as structs, enums, etc.
import workshop
#Skeleton infrastructure for server implementation
import workshop__POA
 
#Base component implementation
from Acspy.Servants.ACSComponent import ACSComponent
#Services provided by the container to the component
from Acspy.Servants.ContainerServices import ContainerServices
#Basic component lifecycle (initialize, execute, cleanUp and aboutToAbort methods)
from Acspy.Servants.ComponentLifecycle import ComponentLifecycle
 
class HelloComponentImpl(<Module>__POA.HelloComponent, ACSComponent, ContainerServices, ComponentLifecycle):
    def __init__(self):
        ACSComponent.__init__(self)
        ContainerServices.__init__(self)
        self._logger = self.getLogger()
    def printHello():
            print("Just printing 'Hello World!'")

Java

Code Block
> getTemplateForDirectory MODROOT_WS jHelloComp
> cd jHelloComp/src
> mkdir -p acsws/workshop/HelloComponentImpl
> touch acsws/workshop/HelloComponentImpl/HelloComponentImpl.java
> cp ../../idlHelloComp/src/acsws/workshop/HelloComponentImpl/HelloComponentComponentHelper.java.tpl acsws/workshop/HelloComponentImpl/HelloComponentComponentHelper.java

We modify the Makefile for this component:

Code Block
titlejHelloComponent/src/Makefile
...
JARFILES = HelloComponentImpl
HelloComponentImpl_DIRS = acsws
...

We fill the component code as follows:

Code Block
languagejava
titlejHelloComponent/src/acsws/workshop/HelloComponentImpl/HelloComponentImpl.java
linenumberstrue
collapsetrue
//Suggested: import alma.<Module>.<Interface>Impl; //But anything, really
package acsws.workshop.HelloComponentImpl;
 
//Base component implementation, including container services and component lifecycle infrastructure
import alma.acs.component.ComponentImplBase;
 
//Skeleton interface for server implementation
import acsws.workshop.HelloComponentOperations;


//ClassName usually is <Interface>Impl, but can be anything
public class HelloComponentImpl extends ComponentImplBase implements HelloComponentOperations {
    public HelloComponent() {
    }
    public void printHello() {
        System.out.println("Just printing 'Hello World!'");
    }
}

C++

We create the needed directories:

...