Using Apache ACE for automatic OSGI software distribution

122 Views Asked by At

I am using Apache ACE for deploying OSGI bundles to targets,I am successfully able to do it manually using apace ace UI , but when I try to do it via running a shell script in "Gogo Shell client API" I am unable to check whether a feature exists or an association exists before creating one.Also I am unable to delete associations between artifacts and features via scripts in the shell. Any ideas on this would be really helpful. Thanks

1

There are 1 best solutions below

2
Marcel Offermans On

To check if a feature or association exists, you can query for it with the "lf" (for features) command on the workspace. For example, if you want to check if a feature called "test" exists, you can use:

res = ($workspace lf "(name=test)")
if { (coll:first $res) } { echo "yes" } { echo "no" }

The first line lists all features that match the pattern. It returns a collection. The second line grabs the first item from the list (if it exists) and based on that one of the clauses of the "if" is executed. You can condense this in a single line if you want, I split it up for clarity.

Deleting a feature or association goes like this:

$workspace df "(name=test)"

Which deletes all features matching the expression, or if you already have a feature object in a shell variable:

$workspace df $featureObject

Same goes for associations, for example between an artifact and a feature, let's say you want to delete an association between a bundle with a specific symbolic name and a feature called test:

$workspace da2f "(&(leftEndpoint=\\28Bundle-SymbolicName=org.foo\\29)(rightEndpoint=\\28name=test\\29))"

Note that I needed to escape the brackets in the leftEndpoint and rightEndpoint values as \\28 and \\29 as we cannot directly use them in an expression.