All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
juliac.generated.CompositeLifeCycleControllerImpl Maven / Gradle / Ivy
package juliac.generated;
import java.util.ArrayList;
import org.objectweb.fractal.api.control.BindingController;
import org.objectweb.fractal.julia.control.binding.ChainedIllegalBindingException;
import org.objectweb.fractal.julia.control.lifecycle.ChainedIllegalLifeCycleException;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.type.ComponentType;
import org.objectweb.fractal.api.control.ContentController;
import org.objectweb.fractal.julia.Controller;
import org.objectweb.fractal.julia.loader.Generated;
import java.util.HashSet;
import org.objectweb.fractal.api.control.IllegalBindingException;
import org.objectweb.fractal.api.control.IllegalLifeCycleException;
import org.objectweb.fractal.julia.InitializationContext;
import org.objectweb.fractal.api.factory.InstantiationException;
import org.objectweb.fractal.api.Interface;
import org.objectweb.fractal.api.type.InterfaceType;
import org.objectweb.fractal.api.control.LifeCycleController;
import org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator;
import java.util.List;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import java.util.Set;
import org.objectweb.fractal.api.Type;
/**
* @see org.objectweb.fractal.julia.BasicControllerMixin
* @see org.objectweb.fractal.julia.UseComponentMixin
* @see org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin
* @see org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin
* @see org.objectweb.fractal.julia.control.lifecycle.TypeLifeCycleMixin
*/
public class CompositeLifeCycleControllerImpl implements LifeCycleController , Controller , LifeCycleCoordinator , Generated {
/**
* @see org.objectweb.fractal.julia.UseComponentMixin#weaveableC
*/
public Component weaveableC;
/**
* @see org.objectweb.fractal.julia.BasicControllerMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
*/
private void initFcController$0(final InitializationContext ic) throws InstantiationException {
}
/**
* @see org.objectweb.fractal.julia.UseComponentMixin#weaveableOptC
*/
public Component weaveableOptC;
/**
* @see org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin#fcActive
*/
public List fcActive;
/**
* @see org.objectweb.fractal.julia.control.lifecycle.TypeLifeCycleMixin#startFc()
*/
public void startFc() throws IllegalLifeCycleException {
Component thisComponent;
try {
thisComponent = ((Component)(weaveableC.getFcInterface("component")));
} catch (NoSuchInterfaceException e) {
throw new ChainedIllegalLifeCycleException(e , weaveableC , "Cannot start the component");
}
List allSubComponents = org.objectweb.fractal.julia.control.content.Util.getAllSubComponents(thisComponent);
for (int i = 0 ; i < (allSubComponents.size()) ; ++i) {
Component subComponent = ((Component)(allSubComponents.get(i)));
try {
checkFcMandatoryInterfaces(subComponent);
} catch (IllegalBindingException e) {
throw new ChainedIllegalLifeCycleException(e , weaveableC , "Cannot start the component");
}
}
startFc$0();
}
/**
* @see org.objectweb.fractal.julia.UseComponentMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
*/
public void initFcController(final InitializationContext ic) throws InstantiationException {
weaveableC = ((Component)(ic.getInterface("component")));
weaveableOptC = weaveableC;
initFcController$0(ic);
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#fcStarted
*/
public boolean fcStarted;
/**
* @see org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin#setFcState(boolean)
*/
public void setFcState(final boolean started) throws IllegalLifeCycleException {
Component thisComponent;
try {
thisComponent = ((Component)(weaveableC.getFcInterface("component")));
} catch (NoSuchInterfaceException e) {
throw new ChainedIllegalLifeCycleException(e , weaveableC , "Cannot set the lifecycle state");
}
List allSubComponents = org.objectweb.fractal.julia.control.content.Util.getAllSubComponents(thisComponent);
for (int i = 0 ; i < (allSubComponents.size()) ; ++i) {
Component c = ((Component)(allSubComponents.get(i)));
LifeCycleCoordinator lc;
try {
lc = ((LifeCycleCoordinator)(c.getFcInterface("lifecycle-controller")));
} catch (Exception e) {
try {
lc = ((LifeCycleCoordinator)(c.getFcInterface("/lifecycle-coordinator")));
} catch (NoSuchInterfaceException f) {
continue;
}
}
if (started) {
lc.setFcStarted();
} else {
lc.setFcStopped();
}
}
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#getFcState()
*/
public String getFcState() {
return fcStarted ? LifeCycleController.STARTED : LifeCycleController.STOPPED;
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#startFc()
*/
private void startFc$0() throws IllegalLifeCycleException {
Component id;
try {
id = ((Component)(weaveableC.getFcInterface("component")));
} catch (NoSuchInterfaceException e) {
throw new ChainedIllegalLifeCycleException(e , weaveableC , "Cannot start component");
}
LifeCycleCoordinator[] clccs = getFcLifeCycleControllers(id);
for (int i = 0 ; i < (clccs.length) ; ++i) {
clccs[i].setFcStarted();
}
setFcState(true);
}
private void initFcController$1(InitializationContext ic) throws InstantiationException {
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#stopFc()
*/
public void stopFc() throws IllegalLifeCycleException {
Component id;
try {
id = ((Component)(weaveableC.getFcInterface("component")));
} catch (NoSuchInterfaceException e) {
throw new ChainedIllegalLifeCycleException(e , weaveableC , "Cannot stop component");
}
LifeCycleCoordinator[] clccs = getFcLifeCycleControllers(id);
stopFc(clccs);
setFcState(false);
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.TypeLifeCycleMixin#checkFcMandatoryInterfaces(org.objectweb.fractal.api.Component)
*/
public void checkFcMandatoryInterfaces(final Component c) throws IllegalBindingException {
BindingController bc;
try {
bc = ((BindingController)(c.getFcInterface("binding-controller")));
} catch (NoSuchInterfaceException e) {
return ;
}
ComponentType compType = ((ComponentType)(c.getFcType()));
String[] names = bc.listFc();
for (int i = 0 ; i < (names.length) ; ++i) {
InterfaceType itfType;
try {
itfType = compType.getFcInterfaceType(names[i]);
} catch (NoSuchInterfaceException e) {
continue;
}
if ((itfType.isFcClientItf()) && (!(itfType.isFcOptionalItf()))) {
Object sItf;
try {
sItf = bc.lookupFc(names[i]);
} catch (NoSuchInterfaceException e) {
continue;
}
if (sItf == null) {
throw new ChainedIllegalBindingException(null , c , null , names[i] , null , "Mandatory client interface unbound");
}
}
}
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin#fcActivated(org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator)
*/
public boolean fcActivated(final LifeCycleCoordinator component) {
synchronized(fcActive) {
if ((fcActive.size()) > 0) {
if (!(fcActive.contains(component))) {
fcActive.add(component);
}
return true;
}
return false;
}
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#setFcStarted()
*/
public boolean setFcStarted() {
if (!(fcStarted)) {
fcStarted = true;
return true;
}
return false;
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin#fcInactivated(org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator)
*/
public void fcInactivated(final LifeCycleCoordinator component) {
synchronized(fcActive) {
fcActive.remove(component);
fcActive.notifyAll();
}
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#setFcStopping(org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator)
*/
public void setFcStopping(final LifeCycleCoordinator coordinator) throws IllegalLifeCycleException {
throw new Error("Internal error");
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#setFcStopped()
*/
public boolean setFcStopped() {
if (fcStarted) {
fcStarted = false;
return true;
}
return false;
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin#stopFc(org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator[])
*/
public void stopFc(final LifeCycleCoordinator[] components) throws IllegalLifeCycleException {
fcActive = new ArrayList();
for (int i = 0 ; i < (components.length) ; ++i) {
if (components[i].getFcState().equals(LifeCycleController.STARTED)) {
fcActive.add(components[i]);
}
}
LifeCycleCoordinator c;
try {
c = ((LifeCycleCoordinator)(weaveableC.getFcInterface("lifecycle-controller")));
} catch (Exception e) {
try {
c = ((LifeCycleCoordinator)(weaveableC.getFcInterface("/lifecycle-coordinator")));
} catch (NoSuchInterfaceException f) {
throw new ChainedIllegalLifeCycleException(f , weaveableC , "Cannot stop components");
}
}
for (int i = 0 ; i < (components.length) ; ++i) {
if (components[i].getFcState().equals(LifeCycleController.STARTED)) {
components[i].setFcStopping(c);
}
}
synchronized(fcActive) {
while ((fcActive.size()) > 0) {
try {
fcActive.wait();
} catch (InterruptedException e) {
}
}
}
for (int i = 0 ; i < (components.length) ; ++i) {
if (components[i].getFcState().equals(LifeCycleController.STARTED)) {
components[i].setFcStopped();
}
}
fcActive = null;
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#getFcLifeCycleControllers(org.objectweb.fractal.api.Component)
*/
public LifeCycleCoordinator[] getFcLifeCycleControllers(final Component id) throws IllegalLifeCycleException {
List clccList = getFcInternalLifeCycleControllers();
Object[] sItfs = id.getFcInterfaces();
Set visited = new HashSet();
for (int i = 0 ; i < (sItfs.length) ; ++i) {
Interface sItf = ((Interface)(sItfs[i]));
if (!(((InterfaceType)(sItf.getFcItfType())).isFcClientItf())) {
getSExtLifeCycleControllers(sItf ,clccList ,visited);
}
}
LifeCycleCoordinator[] clccs;
clccs = new LifeCycleCoordinator[clccList.size()];
return ((LifeCycleCoordinator[])(clccList.toArray(clccs)));
}
private void startFc$1() throws IllegalLifeCycleException {
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#getSExtLifeCycleControllers(org.objectweb.fractal.api.Interface,java.util.List,java.util.Set)
*/
private void getSExtLifeCycleControllers(final Interface serverItf, final List clccList, final Set visited) throws IllegalLifeCycleException {
Object[] comps;
try {
comps = org.objectweb.fractal.julia.control.binding.Util.getFcPotentialClientsOf(serverItf).toArray();
} catch (Exception e) {
throw new ChainedIllegalLifeCycleException(e , serverItf.getFcItfOwner() , "Cannot get the LifeCycleCoordinator interfaces");
}
for (int i = 0 ; i < (comps.length) ; ++i) {
Component comp = ((Component)(comps[i]));
Interface[] clientItfs;
try {
List l = org.objectweb.fractal.julia.control.binding.Util.getFcClientItfsBoundTo(comp ,serverItf);
clientItfs = ((Interface[])(l.toArray(new Interface[l.size()])));
} catch (Exception e) {
throw new ChainedIllegalLifeCycleException(e , serverItf.getFcItfOwner() , "Cannot get the LifeCycleCoordinator interfaces");
}
for (int j = 0 ; j < (clientItfs.length) ; ++j) {
getCExtLifeCycleControllers(clientItfs[j] ,clccList ,visited);
}
}
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#getCExtLifeCycleControllers(org.objectweb.fractal.api.Interface,java.util.List,java.util.Set)
*/
private void getCExtLifeCycleControllers(final Interface clientItf, final List clccList, final Set visited) throws IllegalLifeCycleException {
Component component = clientItf.getFcItfOwner();
ContentController cc = null;
try {
cc = ((ContentController)(component.getFcInterface("content-controller")));
} catch (NoSuchInterfaceException e) {
}
if (cc != null) {
Interface itf;
String name = clientItf.getFcItfName();
try {
if (!(clientItf.isFcInternalItf())) {
itf = ((Interface)(cc.getFcInternalInterface(name)));
} else {
itf = ((Interface)(component.getFcInterface(name)));
}
} catch (NoSuchInterfaceException e) {
throw new ChainedIllegalLifeCycleException(e , component , "Cannot find the LifeCycleCoordinator interfaces");
}
if (!(visited.contains(itf))) {
visited.add(itf);
getSExtLifeCycleControllers(itf ,clccList ,visited);
}
} else if (!(visited.contains(clientItf))) {
visited.add(clientItf);
Component c = clientItf.getFcItfOwner();
LifeCycleCoordinator lcc;
try {
lcc = ((LifeCycleCoordinator)(c.getFcInterface("lifecycle-controller")));
} catch (Exception e) {
try {
lcc = ((LifeCycleCoordinator)(c.getFcInterface("/lifecycle-coordinator")));
} catch (NoSuchInterfaceException f) {
throw new ChainedIllegalLifeCycleException(f , component , "Primitive client without a LifeCycleCoordinator");
}
}
if (!(clccList.contains(lcc))) {
clccList.add(lcc);
}
}
}
/**
* @see org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#getFcInternalLifeCycleControllers()
*/
public List getFcInternalLifeCycleControllers() throws IllegalLifeCycleException {
Component thisComponent;
try {
thisComponent = ((Component)(weaveableC.getFcInterface("component")));
} catch (NoSuchInterfaceException e) {
throw new ChainedIllegalLifeCycleException(e , weaveableC , "The OptimizedLifeCycleControllerMixin requires components to provide the Component interface");
}
List allSubComponents = org.objectweb.fractal.julia.control.content.Util.getAllSubComponents(thisComponent);
List result = new ArrayList();
for (int i = 0 ; i < (allSubComponents.size()) ; ++i) {
Component c = ((Component)(allSubComponents.get(i)));
try {
c.getFcInterface("content-controller");
} catch (NoSuchInterfaceException e) {
try {
result.add(((LifeCycleCoordinator)(c.getFcInterface("lifecycle-controller"))));
} catch (Exception f) {
try {
result.add(c.getFcInterface("/lifecycle-coordinator"));
} catch (NoSuchInterfaceException ignored) {
}
}
}
}
return result;
}
public String getFcGeneratorParameters() {
return "(org.objectweb.fractal.juliac.spoon.MixinClassGenerator juliac.generated.CompositeLifeCycleControllerImpl org.objectweb.fractal.julia.BasicControllerMixin org.objectweb.fractal.julia.UseComponentMixin org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin org.objectweb.fractal.julia.control.lifecycle.TypeLifeCycleMixin)";
}
}