Commit 85ceca6b authored by Christophe Demarey's avatar Christophe Demarey

Add bindings introspections on SCA services.

parent e8e2e661
......@@ -152,7 +152,7 @@ public abstract class ScaInterfaceContext implements Context {
}
}
entries.addAll( getBindingEntriesFromComponentController(owner, itf) );
entries.addAll( getRmiBindingEntriesFromComponentController(owner, itf) );
return entries;
}
......@@ -164,7 +164,7 @@ public abstract class ScaInterfaceContext implements Context {
* @param itf The interface to search bindings on.
* @return a List with an entry for each binding.
*/
private List<Entry> getBindingEntriesFromComponentController(Component owner, Interface itf) {
private List<Entry> getRmiBindingEntriesFromComponentController(Component owner, Interface itf) {
List<Entry> entries = new ArrayList<Entry>();
try {
......
......@@ -30,7 +30,12 @@ import java.util.List;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.Interface;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.BindingController;
import org.objectweb.fractal.api.control.ContentController;
import org.objectweb.fractal.api.type.InterfaceType;
import org.objectweb.fractal.bf.AbstractSkeleton;
import org.objectweb.fractal.explorer.FcExplorer;
import org.objectweb.util.explorer.api.Entry;
import org.objectweb.util.explorer.core.naming.lib.DefaultEntry;
......@@ -68,6 +73,54 @@ public class ServiceContext extends ScaInterfaceContext {
return entries;
}
/**
* Get bindings on SCA services.
* Bindings are implemented as Fractal components. For each binding, you can
* find a skeleton component in the container (the parent) of the service owner.
* So we will search for such skeleton components.
*
* @param owner The component owning the interface to search bindings on.
* @param itf The interface to search bindings on.
* @return a List with an explorer entry for each binding.
*/
private List<Entry> getServiceBindingEntries(Component owner, Interface itf) {
List<Entry> entries = new ArrayList<Entry>();
try {
Component[] parents = FcExplorer.getSuperController(owner).getFcSuperComponents();
for (Component c : parents) {
ContentController cc = FcExplorer.getContentController(c);
Component[] children = cc.getFcSubComponents();
for (Component child : children) {
String childName = FcExplorer.getName(child);
if ( childName.endsWith("-skeleton") ) {
// check that the skeleton is bound to owner
BindingController bc = FcExplorer.getBindingController(child);
Interface servant = (Interface) bc.lookupFc(AbstractSkeleton.SERVANT_CLIENT_ITF_NAME);
if (servant == itf) {
Object bindingEntry = null;
Interface servantItf = (Interface) child.getFcInterface(AbstractSkeleton.SERVANT_CLIENT_ITF_NAME);
// Check the binding kind
if( childName.endsWith("-ws-skeleton") )
bindingEntry = new WsBindingWrapper(servantItf);
else if ( childName.endsWith("-RESTful-skeleton") )
bindingEntry = new RestBindingWrapper(servantItf);
if ( bindingEntry != null )
entries.add( new DefaultEntry(childName + "." + AbstractSkeleton.SERVANT_CLIENT_ITF_NAME, bindingEntry) );
}
}
}
}
} catch (NoSuchInterfaceException e) {
e.printStackTrace();
}
return entries;
}
/**
* @see org.objectweb.util.explorer.api.Context#getEntries(java.lang.Object)
......@@ -83,6 +136,7 @@ public class ServiceContext extends ScaInterfaceContext {
// Add entries for SCA bindings
entries.addAll( getBindingEntries(owner, itf) );
entries.addAll( getServiceBindingEntries(owner, itf) );
// Add entries for SCA intents
entries.addAll( getIntentEntries(owner, itfName) );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment