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

juliac.generated.SCACompositeIntentControllerImpl Maven / Gradle / Ivy

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

import java.lang.annotation.Annotation;
import org.objectweb.fractal.julia.control.lifecycle.ChainedIllegalLifeCycleException;
import java.util.Collection;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.julia.ComponentInterface;
import org.objectweb.fractal.julia.Controller;
import org.objectweb.fractal.julia.loader.Generated;
import java.util.HashMap;
import org.objectweb.fractal.api.control.IllegalLifeCycleException;
import org.objectweb.fractal.julia.InitializationContext;
import org.objectweb.fractal.api.factory.InstantiationException;
import org.ow2.frascati.tinfi.control.intent.IntentHandler;
import org.objectweb.fractal.api.Interface;
import org.ow2.frascati.tinfi.control.intent.InterfaceFilter;
import org.ow2.frascati.tinfi.control.intent.InterfaceMethodFilter;
import org.objectweb.fractal.api.control.LifeCycleController;
import java.util.List;
import java.util.Map;
import java.lang.reflect.Method;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.ow2.frascati.tinfi.control.intent.SCABasicIntentController;
import org.ow2.frascati.tinfi.control.intent.SCAIntentController;
import org.ow2.frascati.tinfi.TinfiComponentInterceptor;
import org.ow2.frascati.tinfi.TinfiRuntimeException;

/** 
 * @see org.objectweb.fractal.julia.BasicControllerMixin
 * @see org.ow2.frascati.tinfi.control.intent.SCABasicIntentControllerMixin
 * @see org.objectweb.fractal.julia.UseComponentMixin
 * @see org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin
 * @see org.ow2.frascati.tinfi.control.intent.LifeCycleIntentMixin
 */
public class SCACompositeIntentControllerImpl implements Controller , Generated , SCABasicIntentController , SCAIntentController {
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.LifeCycleIntentMixin#addFcIntentHandler(org.ow2.frascati.tinfi.control.intent.IntentHandler)
     */
    public void addFcIntentHandler(IntentHandler handler) throws IllegalLifeCycleException {
        checkFcStopped();
        addFcIntentHandler$0(handler);
    }
    
    /** 
     * @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$1(final InitializationContext ic) throws InstantiationException {
    }
    
    /** 
     * @see org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin#weaveableOptLC
     */
    public LifeCycleController weaveableOptLC;
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.SCABasicIntentControllerMixin#addFcIntentHandler(org.ow2.frascati.tinfi.control.intent.IntentHandler)
     */
    private void addFcIntentHandler$0(IntentHandler handler) {
        Map>  interceptors = getFcInterceptors();
        Collection>  tcis = interceptors.values();
        for (TinfiComponentInterceptor  tci : tcis) {
            tci.addIntentHandler(handler);
        }
    }
    
    /** 
     * @see org.objectweb.fractal.julia.UseComponentMixin#weaveableOptC
     */
    public Component weaveableOptC;
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.LifeCycleIntentMixin#addFcIntentHandler(org.ow2.frascati.tinfi.control.intent.IntentHandler,java.lang.Class,java.lang.String)
     */
    public  void addFcIntentHandler(IntentHandler handler, Class  annotcl, String value) throws IllegalLifeCycleException {
        checkFcStopped();
        addFcIntentHandler$0(handler ,annotcl ,value);
    }
    
    /** 
     * @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.UseComponentMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
     */
    private void initFcController$0(final InitializationContext ic) throws InstantiationException {
        weaveableC = ((Component)(ic.getInterface("component")));
        weaveableOptC = weaveableC;
        initFcController$1(ic);
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.LifeCycleIntentMixin#removeFcHandler(org.ow2.frascati.tinfi.control.intent.IntentHandler)
     */
    public void removeFcHandler(IntentHandler handler) throws IllegalLifeCycleException {
        checkFcStopped();
        removeFcHandler$0(handler);
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.SCABasicIntentControllerMixin#addFcIntentHandler(org.ow2.frascati.tinfi.control.intent.IntentHandler,org.ow2.frascati.tinfi.control.intent.InterfaceFilter)
     */
    public void addFcIntentHandler(IntentHandler handler, InterfaceFilter filter) {
        Object[] itfs = weaveableOptC.getFcInterfaces();
        for (Object o : itfs) {
            Interface itf = ((Interface)(o));
            boolean accept = filter.accept(itf);
            if (!accept) {
                continue;
            } 
            Object i = ((ComponentInterface)(itf)).getFcItfImpl();
            if (!(i instanceof TinfiComponentInterceptor )) {
                String name = itf.getFcItfName();
                String msg = (("Interface " + name) + " was expected to delegate to an object implementing") + " TinfiComponentInterceptor";
                throw new TinfiRuntimeException(msg);
            } 
            TinfiComponentInterceptor  tci = ((TinfiComponentInterceptor )(i));
            tci.addIntentHandler(handler);
        }
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.LifeCycleIntentMixin#checkFcStopped()
     */
    private void checkFcStopped() throws IllegalLifeCycleException {
        if ((weaveableOptLC) != null) {
            String state = weaveableOptLC.getFcState();
            if (!(LifeCycleController.STOPPED.equals(state))) {
                throw new ChainedIllegalLifeCycleException(null , weaveableOptC , "The component is not stopped");
            } 
        } 
    }
    
    private void initFcController$2(InitializationContext ic) throws InstantiationException {
    }
    
    private void addFcIntentHandler$1(IntentHandler handler) {
    }
    
    private  void addFcIntentHandler$0(IntentHandler handler, Class  annotcl, String value) {
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.SCABasicIntentControllerMixin#addFcIntentHandler(org.ow2.frascati.tinfi.control.intent.IntentHandler,org.ow2.frascati.tinfi.control.intent.InterfaceMethodFilter)
     */
    public void addFcIntentHandler(IntentHandler handler, InterfaceMethodFilter filter) {
        Object[] itfs = weaveableOptC.getFcInterfaces();
        for (Object o : itfs) {
            Interface itf = ((Interface)(o));
            Object i = ((ComponentInterface)(itf)).getFcItfImpl();
            if (!(i instanceof TinfiComponentInterceptor )) {
                String name = itf.getFcItfName();
                String msg = (("Interface " + name) + " was expected to delegate to an object implementing") + " TinfiComponentInterceptor";
                throw new TinfiRuntimeException(msg);
            } 
            TinfiComponentInterceptor  tci = ((TinfiComponentInterceptor )(i));
            Method[] methods = tci.getMethods();
            for (Method method : methods) {
                boolean accept = filter.accept(itf ,method);
                if (accept) {
                    try {
                        tci.addIntentHandler(handler ,method);
                    } catch (NoSuchMethodException nsme) {
                        throw new TinfiRuntimeException(nsme);
                    }
                } 
            }
        }
    }
    
    private void removeFcHandler$0(IntentHandler handler) {
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.SCABasicIntentControllerMixin#addFcIntentHandler(org.ow2.frascati.tinfi.control.intent.IntentHandler,java.lang.String)
     */
    public void addFcIntentHandler(IntentHandler handler, String name) throws NoSuchInterfaceException {
        Map>  interceptors = getFcInterceptors();
        if (!(interceptors.containsKey(name))) {
            throw new NoSuchInterfaceException(name);
        } 
        TinfiComponentInterceptor  tci = interceptors.get(name);
        tci.addIntentHandler(handler);
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.SCABasicIntentControllerMixin#addFcIntentHandler(org.ow2.frascati.tinfi.control.intent.IntentHandler,java.lang.String,java.lang.reflect.Method)
     */
    public void addFcIntentHandler(IntentHandler handler, String name, Method method) throws NoSuchMethodException, NoSuchInterfaceException {
        Map>  interceptors = getFcInterceptors();
        if (!(interceptors.containsKey(name))) {
            throw new NoSuchInterfaceException(name);
        } 
        TinfiComponentInterceptor  tci = interceptors.get(name);
        tci.addIntentHandler(handler ,method);
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.SCABasicIntentControllerMixin#listFcIntentHandler(java.lang.String)
     */
    public List  listFcIntentHandler(String name) throws NoSuchInterfaceException {
        Map>  interceptors = getFcInterceptors();
        if (!(interceptors.containsKey(name))) {
            throw new NoSuchInterfaceException(name);
        } 
        TinfiComponentInterceptor  tci = interceptors.get(name);
        List  handlers = tci.listIntentHandler();
        return handlers;
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.SCABasicIntentControllerMixin#listFcIntentHandler(java.lang.String,java.lang.reflect.Method)
     */
    public List  listFcIntentHandler(String name, Method method) throws NoSuchMethodException, NoSuchInterfaceException {
        Map>  interceptors = getFcInterceptors();
        if (!(interceptors.containsKey(name))) {
            throw new NoSuchInterfaceException(name);
        } 
        TinfiComponentInterceptor  tci = interceptors.get(name);
        List  handlers = tci.listIntentHandler(method);
        return handlers;
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.SCABasicIntentControllerMixin#removeFcIntentHandler(org.ow2.frascati.tinfi.control.intent.IntentHandler)
     */
    public void removeFcIntentHandler(IntentHandler handler) {
        Map>  interceptors = getFcInterceptors();
        Collection>  tcis = interceptors.values();
        for (TinfiComponentInterceptor  tci : tcis) {
            tci.removeIntentHandler(handler);
        }
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.SCABasicIntentControllerMixin#removeFcIntentHandler(org.ow2.frascati.tinfi.control.intent.IntentHandler,java.lang.String)
     */
    public void removeFcIntentHandler(IntentHandler handler, String name) throws NoSuchInterfaceException {
        Map>  interceptors = getFcInterceptors();
        if (!(interceptors.containsKey(name))) {
            throw new NoSuchInterfaceException(name);
        } 
        TinfiComponentInterceptor  tci = interceptors.get(name);
        tci.removeIntentHandler(handler);
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.SCABasicIntentControllerMixin#removeFcIntentHandler(org.ow2.frascati.tinfi.control.intent.IntentHandler,java.lang.String,java.lang.reflect.Method)
     */
    public void removeFcIntentHandler(IntentHandler handler, String name, Method method) throws NoSuchMethodException, NoSuchInterfaceException {
        Map>  interceptors = getFcInterceptors();
        if (!(interceptors.containsKey(name))) {
            throw new NoSuchInterfaceException(name);
        } 
        TinfiComponentInterceptor  tci = interceptors.get(name);
        tci.removeIntentHandler(handler ,method);
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.SCABasicIntentControllerMixin#getFcInterceptors()
     */
    private Map>  getFcInterceptors() {
        if ((interceptors) != null) {
            return interceptors;
        } 
        interceptors = new HashMap> ();
        Object[] itfs = weaveableOptC.getFcInterfaces();
        for (Object o : itfs) {
            Interface itf = ((Interface)(o));
            String name = itf.getFcItfName();
            if ((name.endsWith("-controller")) || (name.equals("component"))) {
                continue;
            } 
            Object i = ((ComponentInterface)(itf)).getFcItfImpl();
            if (!(i instanceof TinfiComponentInterceptor )) {
                String msg = (("Interface " + name) + " was expected to delegate to an object implementing") + " TinfiComponentInterceptor";
                throw new TinfiRuntimeException(msg);
            } 
            TinfiComponentInterceptor  tci = ((TinfiComponentInterceptor )(i));
            interceptors.put(name ,tci);
        }
        return interceptors;
    }
    
    /** 
     * @see org.ow2.frascati.tinfi.control.intent.SCABasicIntentControllerMixin#interceptors
     */
    private Map>  interceptors;
    
    public String getFcGeneratorParameters() {
        return "(org.objectweb.fractal.juliac.spoon.MixinClassGenerator juliac.generated.SCACompositeIntentControllerImpl org.objectweb.fractal.julia.BasicControllerMixin org.ow2.frascati.tinfi.control.intent.SCABasicIntentControllerMixin org.objectweb.fractal.julia.UseComponentMixin org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin org.ow2.frascati.tinfi.control.intent.LifeCycleIntentMixin)";
    }
    
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy