00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.core.component.controller;
00032
00033 import java.io.Serializable;
00034
00035 import org.apache.log4j.Logger;
00036 import org.objectweb.fractal.api.Component;
00037 import org.objectweb.fractal.api.Interface;
00038 import org.objectweb.fractal.api.NoSuchInterfaceException;
00039 import org.objectweb.fractal.api.Type;
00040 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
00041 import org.objectweb.fractal.api.control.LifeCycleController;
00042 import org.objectweb.fractal.api.type.InterfaceType;
00043 import org.objectweb.proactive.core.ProActiveRuntimeException;
00044 import org.objectweb.proactive.core.body.migration.MigrationException;
00045 import org.objectweb.proactive.core.component.Constants;
00046 import org.objectweb.proactive.core.component.identity.ProActiveComponent;
00047 import org.objectweb.proactive.core.node.Node;
00048 import org.objectweb.proactive.core.util.log.Loggers;
00049 import org.objectweb.proactive.core.util.log.ProActiveLogger;
00050
00051
00058 public abstract class AbstractProActiveController extends AbstractRequestHandler
00059 implements Interface, Serializable, ProActiveController {
00060 private boolean isInternal = true;
00061 private InterfaceType interfaceType;
00062 protected static Logger controllerLogger = ProActiveLogger.getLogger(Loggers.COMPONENTS_CONTROLLERS);
00063
00069 public AbstractProActiveController(Component owner) {
00070 this.owner = (ProActiveComponent)owner;
00071 setControllerItfType();
00072 }
00073
00074
00075
00076
00077 public void init() {
00078
00079 }
00080
00081
00082
00083
00084
00085
00086
00087
00088 public boolean isFcInternalItf() {
00089 return isInternal;
00090 }
00091
00092
00093
00094
00095
00096
00097
00098
00099 public String getFcItfName() {
00100 return interfaceType.getFcItfName();
00101 }
00102
00103
00104
00105
00106
00107
00108
00109
00110 public Type getFcItfType() {
00111 return interfaceType;
00112 }
00113
00114
00115
00116
00117 protected void checkLifeCycleIsStopped() throws IllegalLifeCycleException {
00118 try {
00119 if (!((LifeCycleController) getFcItfOwner()
00120 .getFcInterface(Constants.LIFECYCLE_CONTROLLER)).getFcState()
00121 .equals(LifeCycleController.STOPPED)) {
00122 throw new IllegalLifeCycleException(
00123 "this control operation should be performed while the component is stopped");
00124 }
00125 } catch (NoSuchInterfaceException nsie) {
00126 throw new ProActiveRuntimeException(
00127 "life cycle controller interface not found");
00128 }
00129 }
00130
00131 protected void setItfType(InterfaceType itfType) {
00132 this.interfaceType = itfType;
00133 }
00134
00135 protected abstract void setControllerItfType();
00136
00143 public void migrateDependentActiveObjectsTo(Node node) throws MigrationException {
00144
00145 }
00146 }