Commit 9ce9f362 authored by Gwenael Cattez's avatar Gwenael Cattez

Refactoring on ResourceUtil component

parent fc966ed6
...@@ -119,6 +119,15 @@ public interface FractalUtilItf ...@@ -119,6 +119,15 @@ public interface FractalUtilItf
*/ */
public boolean isSCAComponent(Component component); public boolean isSCAComponent(Component component);
/**
* Check is a fractal interface is a controller interface
* ie if it's a server interface named *-controller
*
* @param itf fractal interface
* @return true if fractal interface is a controller interface, false otherwise
*/
public boolean isFractalControllerInterface(Interface itf);
/** /**
* Get a reference to the fractal component designated by id. * Get a reference to the fractal component designated by id.
* *
...@@ -163,9 +172,8 @@ public interface FractalUtilItf ...@@ -163,9 +172,8 @@ public interface FractalUtilItf
* *
* @param owner the component to introspect * @param owner the component to introspect
* @return a list of all subComponents * @return a list of all subComponents
* @throws NoSuchInterfaceException
*/ */
public List<Component> getSubComponents(Component parent) throws NoSuchInterfaceException ; public List<Component> getSubComponents(Component parent);
/** /**
* Get a reference to the fractal Component named subComponentName owner by fractal Component parent * Get a reference to the fractal Component named subComponentName owner by fractal Component parent
......
...@@ -353,15 +353,7 @@ public class RemoteScaDomainImpl implements RemoteScaDomain ...@@ -353,15 +353,7 @@ public class RemoteScaDomainImpl implements RemoteScaDomain
logEntering("getSubComponents", componentId); logEntering("getSubComponents", componentId);
org.objectweb.fractal.api.Component parent = this.getFcComponent(componentId); org.objectweb.fractal.api.Component parent = this.getFcComponent(componentId);
List<org.objectweb.fractal.api.Component> subComponents; List<org.objectweb.fractal.api.Component> subComponents = fractalUtil.getSubComponents(parent);
try
{
subComponents = fractalUtil.getSubComponents(parent);
} catch (NoSuchInterfaceException e)
{
throw new MyWebApplicationException("The component " + componentId + " is a primitive component so it have no subcomponents");
}
Collection<Component> children = new ArrayList<Component>(); Collection<Component> children = new ArrayList<Component>();
Component child; Component child;
for (org.objectweb.fractal.api.Component subComponent : subComponents) for (org.objectweb.fractal.api.Component subComponent : subComponents)
......
...@@ -337,6 +337,16 @@ public class FractalUtilImpl implements FractalUtilItf ...@@ -337,6 +337,16 @@ public class FractalUtilImpl implements FractalUtilItf
} }
} }
/**
* @see org.ow2.frascati.remote.introspection.util.FractalUtilItf#isFractalControllerInterface(org.objectweb.fractal.api.Interface)
*/
public boolean isFractalControllerInterface(Interface itf)
{
InterfaceType itfType=(InterfaceType) itf.getFcItfType();
String interfaceName=itf.getFcItfName();
return (!itfType.isFcClientItf())&&(interfaceName.endsWith("-controller"));
}
/** /**
* Get the SCAPropertyController related to component * Get the SCAPropertyController related to component
* *
...@@ -416,15 +426,19 @@ public class FractalUtilImpl implements FractalUtilItf ...@@ -416,15 +426,19 @@ public class FractalUtilImpl implements FractalUtilItf
* @return a list of all subComponents * @return a list of all subComponents
* @throws NoSuchInterfaceException * @throws NoSuchInterfaceException
*/ */
public List<Component> getSubComponents(Component parent) throws NoSuchInterfaceException public List<Component> getSubComponents(Component parent)
{ {
logEntering("getSubComponents", parent); logEntering("getSubComponents", parent);
ContentController parentContentController = Fractal.getContentController(parent); List<Component> subComponents=new ArrayList<Component>();
if (parentContentController == null) try
{
ContentController parentContentController = Fractal.getContentController(parent);
subComponents = Arrays.asList(parentContentController.getFcSubComponents());
}
catch(NoSuchInterfaceException noSuchInterfaceException)
{ {
throw new NoSuchControllerDescriptorException("Can not find ContentController for parent component"); logger.fine("no content controller found for component "+this.getComponentName(parent));
} }
List<Component> subComponents = Arrays.asList(parentContentController.getFcSubComponents());
logExiting("getSubComponent", subComponents); logExiting("getSubComponent", subComponents);
return subComponents; return subComponents;
} }
......
...@@ -72,7 +72,8 @@ import org.ow2.frascati.util.FrascatiException; ...@@ -72,7 +72,8 @@ import org.ow2.frascati.util.FrascatiException;
* Order of the Class in the suite depending of the dependencies * Order of the Class in the suite depending of the dependencies
*/ */
@RunWith(Suite.class) @RunWith(Suite.class)
@SuiteClasses({DeploymentTest.class, FractalUtilTest.class,SCAModelUtilTest.class,BindingManagerTest.class,ResourceUtilTest.class}) //@SuiteClasses({DeploymentTest.class, FractalUtilTest.class,SCAModelUtilTest.class,BindingManagerTest.class,ResourceUtilTest.class})
@SuiteClasses({ResourceUtilTest.class})
public class IntrospectionTestSuite public class IntrospectionTestSuite
{ {
/** REST binding URI */ /** REST binding URI */
......
...@@ -42,7 +42,7 @@ import org.ow2.frascati.remote.introspection.binding.processor.BindingProcessorI ...@@ -42,7 +42,7 @@ import org.ow2.frascati.remote.introspection.binding.processor.BindingProcessorI
import org.ow2.frascati.remote.introspection.binding.processor.BindingProcessorTest; import org.ow2.frascati.remote.introspection.binding.processor.BindingProcessorTest;
import org.ow2.frascati.remote.introspection.binding.processor.JMSBindingProcessorTest; import org.ow2.frascati.remote.introspection.binding.processor.JMSBindingProcessorTest;
import org.ow2.frascati.remote.introspection.binding.processor.JSONRPCBindingProcessorTest; import org.ow2.frascati.remote.introspection.binding.processor.JSONRPCBindingProcessorTest;
import org.ow2.frascati.remote.introspection.binding.processor.RESTBindingProcessorTest; import org.ow2.frascati.remote.introspection.binding.processor.RestBindingProcessorTest;
import org.ow2.frascati.remote.introspection.binding.processor.SCABindingProcessorTest; import org.ow2.frascati.remote.introspection.binding.processor.SCABindingProcessorTest;
import org.ow2.frascati.remote.introspection.binding.processor.UPnPBindingProcessorTest; import org.ow2.frascati.remote.introspection.binding.processor.UPnPBindingProcessorTest;
import org.ow2.frascati.remote.introspection.binding.processor.WSBindingProcessorTest; import org.ow2.frascati.remote.introspection.binding.processor.WSBindingProcessorTest;
...@@ -183,7 +183,7 @@ public class BindingManagerTest ...@@ -183,7 +183,7 @@ public class BindingManagerTest
@Test @Test
public void restBindingProcessor() throws NoSuchInterfaceException, UnsupportedBindingComponentException, UnsupportedBindingException public void restBindingProcessor() throws NoSuchInterfaceException, UnsupportedBindingComponentException, UnsupportedBindingException
{ {
RESTBindingProcessorTest restBindingProcessorTest=new RESTBindingProcessorTest(); RestBindingProcessorTest restBindingProcessorTest=new RestBindingProcessorTest();
restBindingProcessorTest.initTest(fractalUtil); restBindingProcessorTest.initTest(fractalUtil);
this.getBindinProcessor(restBindingProcessorTest); this.getBindinProcessor(restBindingProcessorTest);
this.getClientBindingBundle(restBindingProcessorTest); this.getClientBindingBundle(restBindingProcessorTest);
......
...@@ -35,7 +35,7 @@ import org.ow2.frascati.remote.introspection.resources.BindingKind; ...@@ -35,7 +35,7 @@ import org.ow2.frascati.remote.introspection.resources.BindingKind;
/** /**
* *
*/ */
public class RESTBindingProcessorTest extends BindingProcessorTest public class RestBindingProcessorTest extends BindingProcessorTest
{ {
/** /**
...@@ -43,7 +43,7 @@ public class RESTBindingProcessorTest extends BindingProcessorTest ...@@ -43,7 +43,7 @@ public class RESTBindingProcessorTest extends BindingProcessorTest
* @param serverInterfacePath * @param serverInterfacePath
* @param clientInterfacePath * @param clientInterfacePath
*/ */
public RESTBindingProcessorTest() public RestBindingProcessorTest()
{ {
super(BindingKind.REST, "counter-server/server/counter","counter-client/client/counter"); super(BindingKind.REST, "counter-server/server/counter","counter-client/client/counter");
} }
......
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