private Component wrapWithCompositeOfTypeA(int index, Component wrappee) throws Exception { Component wrapper = Setup.createCompositeOfTypeA("composite_a" + index); GCM.getContentController(wrapper).addFcSubComponent(wrappee); GCM.getBindingController(wrapper).bindFc("i1", wrappee.getFcInterface("i1")); GCM.getBindingController(wrappee).bindFc("i2", wrapper.getFcInterface("i2")); return wrapper; }
public static final Set<WebServiceInformationBean> getAllBeans( final ContentController parentContentController) { Set<WebServiceInformationBean> result = new HashSet<WebServiceInformationBean>(); Set<Component> components = FractalHelper.getAllComponents(parentContentController); for (Component component : components) { try { String name = Fractal.getNameController(component).getFcName(); Object[] itfs = component.getFcInterfaces(); for (Object object : itfs) { Class<?>[] cs = object.getClass().getInterfaces(); for (Class<?> class1 : cs) { boolean isWs = WebServiceHelper.hasWebServiceAnnotation(class1); if (isWs) { WebServiceInformationBean bean = new WebServiceInformationBean(); bean.clazz = class1; bean.componentName = name; bean.implem = object; result.add(bean); } } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } return result; }
@org.junit.Test public void action() throws Exception { initializeComponentSystems(); // System.out.println("testing unwrapped system"); GCM.getGCMLifeCycleController(systemWithoutWrapping).stopFc(); GCM.getGCMLifeCycleController(systemWithoutWrapping).startFc(); result1 = ((I1) systemWithoutWrapping.getFcInterface("i1")).processInputMessage(new Message("foo")); // waiting for the future is only for having an ordered logging output PAFuture.waitFor(result1); Thread.sleep(2000); // System.out.println("testing wrapped system without shortcuts"); GCM.getGCMLifeCycleController(systemWithWrappingWithoutShortcuts).stopFc(); GCM.getGCMLifeCycleController(systemWithWrappingWithoutShortcuts).startFc(); result2 = ((I1) systemWithWrappingWithoutShortcuts.getFcInterface("i1")) .processInputMessage(new Message("foo")); PAFuture.waitFor(result2); Thread.sleep(2000); // System.out.println("testing wrapped system with shortcuts -- fist invocation"); // first call, which performs tensioning result3 = ((I1) systemWithWrappingWithShortcuts.getFcInterface("i1")) .processInputMessage(new Message("foo")); PAFuture.waitFor(result3); Thread.sleep(2000); GCM.getGCMLifeCycleController(systemWithWrappingWithShortcuts).stopFc(); GCM.getGCMLifeCycleController(systemWithWrappingWithShortcuts).startFc(); // second call, which goes directly through the shortcut // System.out.println("testing wrapped system with shortcuts -- second invocation"); result4 = ((I1) systemWithWrappingWithShortcuts.getFcInterface("i1")) .processInputMessage(new Message("foo")); PAFuture.waitFor(result4); Thread.sleep(2000); // TODO manage shortcuts with reconfigurations // reset while shortcut exists // resetComponentSystem(); // initializeComponentSystems(); // first call, which performs tensioning // result5 = ((I1) // systemWithWrappingWithShortcuts.getFcInterface("i1")).processInputMessage(new // Message("foo")); // a shortcut is now realized. Compare with previous result // result6 = ((I1) // systemWithWrappingWithShortcuts.getFcInterface("i1")).processInputMessage(new // Message("foo")); Assert.assertEquals(expectedResult, (PAFuture.getFutureValue(result4)).getMessage()); Assert.assertEquals(expectedResult, (PAFuture.getFutureValue(result3)).getMessage()); Assert.assertEquals(expectedResult, (PAFuture.getFutureValue(result2)).getMessage()); Assert.assertEquals(expectedResult, (PAFuture.getFutureValue(result1)).getMessage()); }
private Component wrapWithSynchronousCompositeOfTypeB(int index, Component wrappee) throws Exception { Component wrapper = Setup.createSynchronousCompositeOfTypeB("sync_composite_b" + index); GCM.getContentController(wrapper).addFcSubComponent(wrappee); GCM.getBindingController(wrapper).bindFc("i2", wrappee.getFcInterface("i2")); return wrapper; }
public static void main(String[] args) throws ADLException, IllegalLifeCycleException, NoSuchInterfaceException, ProActiveException, DistributedEtalisException, IOException { CentralPAPropertyRepository.JAVA_SECURITY_POLICY.setValue("proactive.java.policy"); CentralPAPropertyRepository.GCM_PROVIDER.setValue( "org.objectweb.proactive.core.component.Fractive"); // Start component. Factory factory = FactoryFactory.getFactory(); HashMap<String, Object> context = new HashMap<String, Object>(); Component root = (Component) factory.newComponent("DistributedEtalis", context); GCM.getGCMLifeCycleController(root).startFc(); // Register component. Registry registry = LocateRegistry.getRegistry(); Fractive.registerByName(root, "dEtalis1"); // Configure component. ConfigApi configApi = ((ConfigApi) root.getFcInterface(ConfigApi.class.getSimpleName())); configApi.setConfig(new DetalisConfigLocal("play-epsparql-clic2call-historical-data.trig")); // Subscribe to print complex events to local console. // testApi = ((eu.play_project.dcep.distributedetalis.api.DistributedEtalisTestApi) // root.getFcInterface(DistributedEtalisTestApi.class.getSimpleName())); // try { // subscriber = PAActiveObject.newActive(ComplexEventSubscriber.class, new Object[] {}); // } catch (ActiveObjectCreationException e) { // e.printStackTrace(); // } catch (NodeException e) { // e.printStackTrace(); // } // testApi.attach(subscriber); System.out.println("Press 3x RETURN to shutdown the application"); System.in.read(); System.in.read(); System.in.read(); }
private void initializeComponentSystems() throws Exception { // system without wrapped components Component unwrappedA = Setup.createPrimitiveA(); Component unwrappedB = Setup.createPrimitiveB1(); GCM.getBindingController(unwrappedA).bindFc("i2", unwrappedB.getFcInterface("i2")); GCM.getGCMLifeCycleController(unwrappedA).startFc(); GCM.getGCMLifeCycleController(unwrappedB).startFc(); systemWithoutWrapping = unwrappedA; // system with wrapping but without shortcuts Component wrappedAWithoutShortcuts = Setup.createPrimitiveA(); for (int i = 0; i < NB_WRAPPERS; i++) { wrappedAWithoutShortcuts = wrapWithCompositeOfTypeA(NB_WRAPPERS - i, wrappedAWithoutShortcuts); } Component wrappedBWithoutShortcuts = Setup.createPrimitiveB1(); for (int i = 0; i < NB_WRAPPERS; i++) { wrappedBWithoutShortcuts = wrapWithCompositeOfTypeB(NB_WRAPPERS - i, wrappedBWithoutShortcuts); } GCM.getBindingController(wrappedAWithoutShortcuts) .bindFc("i2", wrappedBWithoutShortcuts.getFcInterface("i2")); GCM.getGCMLifeCycleController(wrappedAWithoutShortcuts).startFc(); GCM.getGCMLifeCycleController(wrappedBWithoutShortcuts).startFc(); systemWithWrappingWithoutShortcuts = wrappedAWithoutShortcuts; // system with wrapping and with shortcuts Component wrappedAWithShortcuts = Setup.createPrimitiveA(); for (int i = 0; i < NB_WRAPPERS; i++) { wrappedAWithShortcuts = wrapWithSynchronousCompositeOfTypeA(NB_WRAPPERS - i, wrappedAWithShortcuts); } Component wrappedBWithShortcuts = Setup.createPrimitiveB1(); for (int i = 0; i < NB_WRAPPERS; i++) { wrappedBWithShortcuts = wrapWithSynchronousCompositeOfTypeB(NB_WRAPPERS - i, wrappedBWithShortcuts); } GCM.getBindingController(wrappedAWithShortcuts) .bindFc("i2", wrappedBWithShortcuts.getFcInterface("i2")); GCM.getGCMLifeCycleController(wrappedAWithShortcuts).startFc(); GCM.getGCMLifeCycleController(wrappedBWithShortcuts).startFc(); systemWithWrappingWithShortcuts = wrappedAWithShortcuts; }