Versions Compared

Key

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

Install component's IDL

Note
In case you haven't done this step already, you must Build and install IDL first.

Create component

Code Block
languagebash
cd ~/workspace
getTemplateForDirectory MODROOT_WS jHelloComp
cd jHelloComp/src
mkdir -p acsws/workshop/HelloComponentImpl
touch acsws/workshop/HelloComponentImpl/HelloComponentImpl.java
cp ..~/..workspace/idlHelloComp/src/acsws/workshop/HelloComponentImpl/HelloComponentComponentHelper.java.tpl acsws/workshop/HelloComponentImpl/HelloComponentComponentHelper.java
vim Makefile

...

Code Block
languagebash
vim acsws/workshop/HelloComponentImpl/HelloComponentImpl.java


Code Block
languagepyjava
titlejHelloComp/src/acsws/workshop/HelloComponentImpl/HelloComponentImpl.java
//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 HelloComponentImpl() {
    }
    public String printHello() {
        System.out.println("Just printing 'Hello World!'");
        return new String("Hello World!");
    }
}

Compile component

Code Block
languagebash
make all install

Add component to CDB

Code Block
languagebash
vim $ACS_CDB/CDB/MACI/Components/Components.xml

...

Code Block
languagebash
titleComponents.xml
<e Name="HelloWorldJava"
   Code="acsws.workshop.HelloComponentImpl.HelloComponentComponentHelper"
                         Type="IDL:acsws/workshop/HelloComponent:1.0"
                         Container="frodoContainer" ImplLang="java" />

Check component helper

Check ~/workspace/jHelloComp/src/acsws/workshop/HelloComponentImpl directory. There should be two files:

...

Code Block
languagebash
cp ~/workspace/idlHelloComp/src/acsws/workshop/HelloComponentImpl/HelloComponentComponentHelper.java.tpl ~/workspace/jHelloComp/src/acsws/workshop/HelloComponentImpl/HelloComponentComponentHelper.java

Testing

Create client python file:

...

Code Block
languagepy
title~/workspace/client.py
from Acspy.Clients.SimpleClient import PySimpleClient
 
client = PySimpleClient()
component 
hc_java = client.getComponent("HelloWorldJava")

print(hc_javacomponent.printHello())

Run clientcomponent:

Code Block
languagebash
# in one terminal
acsStop
acsStart
# in a different terminal
acsStartContainer -java frodoContainer
# in a different terminal
python client.py

Example output:

Code Block
...
Hello World!
...

...