All Downloads are FREE. Search and download functionalities are using the official Maven repository.

juliac.generated.SCAPrimitiveBindingControllerImpl Maven / Gradle / Ivy

There is a newer version: 2.7
Show newest version
package juliac.generated;

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.julia.ChainedNoSuchInterfaceException;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.julia.ComponentInterface;
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 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.julia.Interceptor;
import org.objectweb.fractal.api.Interface;
import org.objectweb.fractal.api.type.InterfaceType;
import org.objectweb.fractal.api.control.LifeCycleController;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.SuperController;
import org.objectweb.fractal.api.Type;

/** 
 * @see org.objectweb.fractal.julia.BasicControllerMixin
 * @see org.objectweb.fractal.julia.UseComponentMixin
 * @see org.ow2.frascati.tinfi.control.binding.BasicBindingControllerMixin
 * @see org.objectweb.fractal.julia.control.binding.CheckBindingMixin
 * @see org.objectweb.fractal.julia.control.binding.TypeBindingMixin
 * @see org.objectweb.fractal.julia.control.content.UseSuperControllerMixin
 * @see org.objectweb.fractal.julia.control.binding.ContentBindingMixin
 * @see org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin
 * @see org.objectweb.fractal.julia.control.binding.LifeCycleBindingMixin
 */
public class SCAPrimitiveBindingControllerImpl implements BindingController , Controller , Generated {
    /** 
     * @see org.ow2.frascati.tinfi.control.binding.BasicBindingControllerMixin#listFc()
     */
    public String[] listFc() {
        Object[] itfs = weaveableC.getFcInterfaces();
        int size = 0;
        for (Object o : itfs) {
            Interface itf = ((Interface)(o));
            InterfaceType it = ((InterfaceType)(itf.getFcItfType()));
            if (it.isFcClientItf()) {
                size++;
            } 
        }
        String[] names = new String[size];
        int i = 0;
        for (Object o : itfs) {
            Interface itf = ((Interface)(o));
            InterfaceType it = ((InterfaceType)(itf.getFcItfType()));
            if (it.isFcClientItf()) {
                names[i] = itf.getFcItfName();
                i++;
            } 
        }
        return names;
    }
    
    /** 
     * @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$2(final InitializationContext ic) throws InstantiationException {
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.content.UseSuperControllerMixin#weaveableSC
     */
    public SuperController weaveableSC;
    
    /** 
     * @see org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin#weaveableOptLC
     */
    public LifeCycleController weaveableOptLC;
    
    /** 
     * @see org.objectweb.fractal.julia.UseComponentMixin#weaveableOptC
     */
    public Component weaveableOptC;
    
    /** 
     * @see org.objectweb.fractal.julia.control.binding.CheckBindingMixin#bindFc(java.lang.String,java.lang.Object)
     */
    private void bindFc$0(final String clientItfName, final Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
        if ((lookupFc(clientItfName)) != null) {
            throw new ChainedIllegalBindingException(null , weaveableOptC , null , clientItfName , null , "Already bound");
        } 
        bindFc$1(clientItfName ,serverItf);
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.content.UseSuperControllerMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
     */
    private void initFcController$0(final InitializationContext ic) throws InstantiationException {
        weaveableSC = ((SuperController)(ic.getInterface("super-controller")));
        initFcController$1(ic);
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
     */
    public void initFcController(final InitializationContext ic) throws InstantiationException {
        weaveableOptLC = ((LifeCycleController)(ic.getOptionalInterface("lifecycle-controller")));
        initFcController$0(ic);
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.binding.LifeCycleBindingMixin#unbindFc(java.lang.String)
     */
    public void unbindFc(final String clientItfName) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
        if ((weaveableOptLC) != null) {
            String state = weaveableOptLC.getFcState();
            if (!(LifeCycleController.STOPPED.equals(state))) {
                throw new ChainedIllegalLifeCycleException(null , weaveableOptC , "The component is not stopped");
            } 
        } 
        unbindFc$0(clientItfName);
    }
    
    /** 
     * @see org.objectweb.fractal.julia.UseComponentMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
     */
    private void initFcController$1(final InitializationContext ic) throws InstantiationException {
        weaveableC = ((Component)(ic.getInterface("component")));
        weaveableOptC = weaveableC;
        initFcController$2(ic);
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.binding.TypeBindingMixin#lookupFc(java.lang.String)
     */
    public Object lookupFc(final String clientItfName) throws NoSuchInterfaceException {
        ComponentType compType = ((ComponentType)(weaveableC.getFcType()));
        InterfaceType clientItfType;
        try {
            clientItfType = compType.getFcInterfaceType(clientItfName);
        } catch (NoSuchInterfaceException e) {
            throw new ChainedNoSuchInterfaceException(null , weaveableC , clientItfName);
        }
        checkFcClientInterface(clientItfType);
        return lookupFc(clientItfType ,clientItfName);
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.binding.BasicBindingControllerMixin#lookupFc(java.lang.String)
     */
    private Object lookupFc$0(final String clientItfName) throws NoSuchInterfaceException {
        ComponentInterface ci = ((ComponentInterface)(weaveableC.getFcInterface(clientItfName)));
        Interceptor interceptor = ((Interceptor)(ci.getFcItfImpl()));
        Object dst = interceptor.getFcItfDelegate();
        return dst;
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.binding.ContentBindingMixin#bindFc(org.objectweb.fractal.api.type.InterfaceType,java.lang.String,java.lang.Object)
     */
    public void bindFc(final InterfaceType clientItfType, final String clientItfName, final Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
        checkFcLocalBinding(clientItfType ,clientItfName ,serverItf);
        bindFc$0(clientItfType ,clientItfName ,serverItf);
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.binding.BasicBindingControllerMixin#bindFc(java.lang.String,java.lang.Object)
     */
    private void bindFc$1(final String clientItfName, final Object serverItf) throws NoSuchInterfaceException {
        ComponentInterface ci = ((ComponentInterface)(weaveableC.getFcInterface(clientItfName)));
        Interceptor interceptor = ((Interceptor)(ci.getFcItfImpl()));
        interceptor.setFcItfDelegate(serverItf);
    }
    
    private void initFcController$3(InitializationContext ic) throws InstantiationException {
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.binding.BasicBindingControllerMixin#unbindFc(java.lang.String)
     */
    private void unbindFc$2(final String clientItfName) throws NoSuchInterfaceException {
        ComponentInterface ci = ((ComponentInterface)(weaveableC.getFcInterface(clientItfName)));
        Interceptor interceptor = ((Interceptor)(ci.getFcItfImpl()));
        interceptor.setFcItfDelegate(null);
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.binding.CheckBindingMixin#unbindFc(java.lang.String)
     */
    private void unbindFc$1(final String clientItfName) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
        if ((lookupFc(clientItfName)) == null) {
            throw new ChainedIllegalBindingException(null , weaveableOptC , null , clientItfName , null , "Not bound");
        } 
        unbindFc$2(clientItfName);
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.binding.ContentBindingMixin#checkFcLocalBinding(org.objectweb.fractal.api.type.InterfaceType,java.lang.String,java.lang.Object)
     */
    public void checkFcLocalBinding(final InterfaceType clientItfType, final String clientItfName, final Object serverItf) throws IllegalBindingException {
        Interface sItf;
        Component sComp;
        try {
            sItf = ((Interface)(serverItf));
            sComp = sItf.getFcItfOwner();
        } catch (ClassCastException e) {
            return ;
        }
        Component[] cParents = weaveableSC.getFcSuperComponents();
        String msg;
        if (!(clientItfType.isFcClientItf())) {
            ContentController cc;
            try {
                cc = ((ContentController)(weaveableC.getFcInterface("content-controller")));
            } catch (NoSuchInterfaceException e) {
                return ;
            }
            Component[] cSubComps = cc.getFcSubComponents();
            for (int i = 0 ; i < (cSubComps.length) ; ++i) {
                if (cSubComps[i].equals(sComp)) {
                    return ;
                } 
            }
            Component thisComp;
            try {
                thisComp = ((Component)(weaveableC.getFcInterface("component")));
            } catch (NoSuchInterfaceException e) {
                throw new ChainedIllegalBindingException(e , weaveableC , sItf.getFcItfOwner() , clientItfName , sItf.getFcItfName() , "Cannot get the Component interface of the client component");
            }
            if ((sComp.equals(thisComp)) && (sItf.isFcInternalItf())) {
                return ;
            } 
            msg = "Invalid export binding";
        } else if (sItf.isFcInternalItf()) {
            for (int i = 0 ; i < (cParents.length) ; ++i) {
                if (sComp.equals(cParents[i])) {
                    return ;
                } 
            }
            msg = "Invalid import binding";
        } else {
            SuperController sCompSC;
            try {
                sCompSC = ((SuperController)(sComp.getFcInterface("super-controller")));
            } catch (NoSuchInterfaceException e) {
                return ;
            }
            Component[] sParents = sCompSC.getFcSuperComponents();
            for (int i = 0 ; i < (cParents.length) ; ++i) {
                for (int j = 0 ; j < (sParents.length) ; ++j) {
                    if (cParents[i].equals(sParents[j])) {
                        return ;
                    } 
                }
            }
            msg = "Not a local binding";
        }
        throw new ChainedIllegalBindingException(null , weaveableC , sItf.getFcItfOwner() , clientItfName , sItf.getFcItfName() , msg);
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.binding.TypeBindingMixin#bindFc(java.lang.String,java.lang.Object)
     */
    public void bindFc(final String clientItfName, final Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
        ComponentType compType = ((ComponentType)(weaveableC.getFcType()));
        InterfaceType cItfType;
        try {
            cItfType = compType.getFcInterfaceType(clientItfName);
        } catch (NoSuchInterfaceException e) {
            throw new ChainedNoSuchInterfaceException(null , weaveableC , clientItfName);
        }
        checkFcClientInterface(cItfType);
        ContentController cc;
        try {
            cc = ((ContentController)(weaveableC.getFcInterface("content-controller")));
        } catch (NoSuchInterfaceException e) {
            cc = null;
        }
        if (cItfType.isFcClientItf()) {
            weaveableC.getFcInterface(clientItfName);
        } else {
            cc.getFcInternalInterface(clientItfName);
        }
        Interface sItf;
        InterfaceType sItfType;
        try {
            sItf = ((Interface)(serverItf));
            sItfType = ((InterfaceType)(sItf.getFcItfType()));
        } catch (ClassCastException e) {
            bindFc(cItfType ,clientItfName ,serverItf);
            return ;
        }
        if (sItfType.isFcClientItf()) {
            throw new ChainedIllegalBindingException(null , weaveableC , sItf.getFcItfOwner() , clientItfName , sItf.getFcItfName() , "Cannot bind two client interfaces together");
        } 
        try {
            Class s = Class.forName(sItfType.getFcItfSignature());
            Class c = Class.forName(cItfType.getFcItfSignature());
            if (!(c.isAssignableFrom(s))) {
                throw new ChainedIllegalBindingException(null , weaveableC , sItf.getFcItfOwner() , clientItfName , sItf.getFcItfName() , "The server interface type is not a subtype of the client interface type");
            } 
        } catch (ClassNotFoundException ignored) {
        }
        if ((!(cItfType.isFcOptionalItf())) && (sItfType.isFcOptionalItf())) {
            throw new ChainedIllegalBindingException(null , weaveableC , ((Interface)(serverItf)).getFcItfOwner() , clientItfName , ((Interface)(serverItf)).getFcItfName() , "A mandatory interface cannot be bound to an optional interface");
        } 
        bindFc(cItfType ,clientItfName ,sItf);
    }
    
    private void unbindFc$3(String clientItfName) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.binding.TypeBindingMixin#unbindFc(java.lang.String)
     */
    private void unbindFc$0(final String clientItfName) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
        ComponentType compType = ((ComponentType)(weaveableC.getFcType()));
        InterfaceType clientItfType;
        try {
            clientItfType = compType.getFcInterfaceType(clientItfName);
        } catch (NoSuchInterfaceException e) {
            throw new ChainedNoSuchInterfaceException(null , weaveableC , clientItfName);
        }
        checkFcClientInterface(clientItfType);
        unbindFc(clientItfType ,clientItfName);
    }
    
    private void bindFc$1(InterfaceType clientItfType, String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.binding.TypeBindingMixin#lookupFc(org.objectweb.fractal.api.type.InterfaceType,java.lang.String)
     */
    public Object lookupFc(final InterfaceType clientItfType, final String clientItfName) throws NoSuchInterfaceException {
        return lookupFc$0(clientItfName);
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.binding.TypeBindingMixin#bindFc(org.objectweb.fractal.api.type.InterfaceType,java.lang.String,java.lang.Object)
     */
    private void bindFc$0(final InterfaceType clientItfType, final String clientItfName, final Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
        bindFc$0(clientItfName ,serverItf);
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.binding.TypeBindingMixin#unbindFc(org.objectweb.fractal.api.type.InterfaceType,java.lang.String)
     */
    public void unbindFc(final InterfaceType clientItfType, final String clientItfName) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
        unbindFc$1(clientItfName);
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.binding.TypeBindingMixin#checkFcClientInterface(org.objectweb.fractal.api.type.InterfaceType)
     */
    private void checkFcClientInterface(InterfaceType itfType) throws NoSuchInterfaceException {
        try {
            weaveableC.getFcInterface("content-controller");
            String name = itfType.getFcItfName();
            if ((!(name.equals("component"))) && (!(name.endsWith("-controller")))) {
                return ;
            } 
        } catch (NoSuchInterfaceException e) {
            if (itfType.isFcClientItf()) {
                return ;
            } 
        }
        throw new ChainedNoSuchInterfaceException(null , weaveableC , itfType.getFcItfName());
    }
    
    private Object lookupFc$1(String clientItfName) throws NoSuchInterfaceException {
        return null;
    }
    
    private void bindFc$2(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
    }
    
    public String getFcGeneratorParameters() {
        return "(org.objectweb.fractal.juliac.spoon.MixinClassGenerator juliac.generated.SCAPrimitiveBindingControllerImpl org.objectweb.fractal.julia.BasicControllerMixin org.objectweb.fractal.julia.UseComponentMixin org.ow2.frascati.tinfi.control.binding.BasicBindingControllerMixin org.objectweb.fractal.julia.control.binding.CheckBindingMixin org.objectweb.fractal.julia.control.binding.TypeBindingMixin org.objectweb.fractal.julia.control.content.UseSuperControllerMixin org.objectweb.fractal.julia.control.binding.ContentBindingMixin org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin org.objectweb.fractal.julia.control.binding.LifeCycleBindingMixin)";
    }
    
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy