0

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

Shridhar
  • 11
  • 5

1 Answers1

0

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.

Marcel Offermans
  • 3,313
  • 1
  • 15
  • 23
  • I tried creating a feature called test and tried to delete it but was not able to do it. These are the steps i followed g! $w cf test g! $w lf [name=test] g! $w df "(name=test)" gogo: IllegalArgumentException: Cannot coerce df(String) to any of [(FeatureObject)]. Can you please point out what is wrong in this. – Shridhar Oct 29 '15 at 06:14
  • Yes, you are probably trying this on the latest release while I was using the latest code from SVN (which, from memory, does not support the df command with an expression as argument yet. Instead, you can query for an object using lf, and then use coll:first to get the first (and only) item, and then use that reference to df to delete it. – Marcel Offermans Oct 29 '15 at 16:13