You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Create component

cd ~/workspace
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
vim Makefile

We modify the Makefile for this component:

jHelloComp/src/Makefile
...
JARFILES = HelloComponentImpl
HelloComponentImpl_DIRS = acsws
...

We fill the component code as follows:

vim acsws/workshop/HelloComponentImpl/HelloComponentImpl.java
jHelloComp/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

make all install

Add component to CDB

vim $ACS_CDB/MACI/Components/Components.xml

Add the following item:

Components.xml
<e Name="HelloWorldJava" Code="HelloComponentImpl"
                         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:

|-- HelloComponentComponentHelper.java
`-- HelloComponentImpl.java

If no helper file is found, copy it from the IDL directory

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

Testing

Create client python file:

cd ~/workspace
touch client.py
vim client.py

We fill it as follow:

~/workspace/client.py
from Acspy.Clients.SimpleClient import PySimpleClient
 
client = PySimpleClient()
 
hc_java = client.getComponent("JAVA_HELLO_COMP")
print(hc_java.printHello())

Run client:

python client.py

Example output:

...
Hello World!
...
  • No labels