/** * Runs the activity as defined in @see ComponentRunActive. The default behaviour is to serve * non-functional requests in FIFO order, until the component is started. Then the functional * activity (as defined in @see InitActive, @see RunActive and @see EndActive) begins. * * <p>When redefining the @see RunActive#runActivity(Body) method, the @see Body#isActive() * returns true as long as the lifecycle of the component is @see LifeCycleController#STARTED. * When the lifecycle of the component is @see LifeCycleController#STOPPED, @see Body#isActive() * returns false. */ @Override public void runActivity(Body body) { if ((componentRunActive != null) && (componentRunActive != this)) { componentRunActive.runActivity(body); } else { // this is the default activity of the active object // the activity of the component has been initialized and started, now // what we have to do is to manage the life cycle, i.e. start and stop the // activity // that can be redefined on the reified object. try { Service componentService = new Service(body); NFRequestFilterImpl nfRequestFilter = new NFRequestFilterImpl(); MembraneControllerRequestFilter memRequestFilter = new MembraneControllerRequestFilter(); while (body.isActive()) { ComponentBody componentBody = (ComponentBody) body; /* * While the membrane is stopped, serve calls only on the Membrane Controller */ while (Utils.getPAMembraneController(componentBody.getPAComponentImpl()) .getMembraneState() .equals(PAMembraneController.MEMBRANE_STOPPED)) { componentService.blockingServeOldest(memRequestFilter); } while (LifeCycleController.STOPPED.equals( GCM.getGCMLifeCycleController(componentBody.getPAComponentImpl()).getFcState())) { PriorityController pc = GCM.getPriorityController(componentBody.getPAComponentImpl()); NF3RequestFilter nf3RequestFilter = new NF3RequestFilter(pc); if (componentService.getOldest(nf3RequestFilter) != null) { // NF3 bypass all other request // System.err.println( // "STOPPED ComponentActivity : NF3"); componentService.blockingServeOldest(nf3RequestFilter); } else { componentService.blockingServeOldest(nfRequestFilter); } if (!body.isActive()) { // in case of a migration break; } } if (!body.isActive()) { // in case of a migration break; } // 3.1. init object Activity // life cycle started : starting activity of the object if (functionalInitActive != null) { functionalInitActive.initActivity(body); // functionalInitActive = null; // we won't do it again } ((ComponentBody) body).startingFunctionalActivity(); // 3.2 while object activity // componentServe (includes filter on priority) functionalRunActive.runActivity(body); ((ComponentBody) body).finishedFunctionalActivity(); if (functionalEndActive != null) { functionalEndActive.endActivity(body); } /* * While the membrane is started, serve non-functional calls with priority (the * same as for Lifecycle Stopped) */ while (Utils.getPAMembraneController(componentBody.getPAComponentImpl()) .getMembraneState() .equals(PAMembraneController.MEMBRANE_STARTED)) { PriorityController pc = GCM.getPriorityController(componentBody.getPAComponentImpl()); NF3RequestFilter nf3RequestFilter = new NF3RequestFilter(pc); if (componentService.getOldest(nf3RequestFilter) != null) { // NF3 bypass all other request // System.err.println( // "STOPPED ComponentActivity : NF3"); componentService.blockingServeOldest(nf3RequestFilter); } else { componentService.blockingServeOldest(nfRequestFilter); } if (!body.isActive()) { // Don't know if this is OK // in case of a migration break; } } } } catch (NoSuchInterfaceException e) { logger.error( "could not retreive an interface, probably the life cycle controller of this component; terminating the component. Error message is : " + e.getMessage()); } } }