Search in sources :

Example 41 with AcsJContainerServicesEx

use of alma.JavaContainerError.wrappers.AcsJContainerServicesEx in project ACS by ACS-Community.

the class AlarmSystemContainerServices method deactivateOffShoot.

@Override
public void deactivateOffShoot(Object offshootImpl) throws AcsJContainerServicesEx {
    if (offshootImpl instanceof Servant) {
        Servant cbServant = (Servant) offshootImpl;
        try {
            checkOffShootServant(cbServant);
            POA rootPOA = alSysCorbaServer.getRootPOA();
            if (cbServant == null || rootPOA == null) {
                String msg = "deactivateOffShoot called with missing parameter.";
                AcsJContainerEx ex = new AcsJContainerEx();
                ex.setContextInfo(msg);
                throw ex;
            }
            byte[] id = null;
            try {
                POA offshootPoa = getPOAForOffshoots(rootPOA);
                id = offshootPoa.servant_to_id(cbServant);
                offshootPoa.deactivate_object(id);
            } catch (AcsJContainerEx e) {
                throw e;
            } catch (Throwable thr) {
                String msg = "failed to deactivate offshoot of type '" + cbServant.getClass().getName() + "' (ID=" + String.valueOf(id) + ")";
                logger.log(Level.WARNING, msg, thr);
                AcsJContainerEx ex = new AcsJContainerEx(thr);
                ex.setContextInfo(msg);
                throw ex;
            }
        } catch (AcsJContainerEx ex) {
            throw new AcsJContainerServicesEx(ex);
        }
    } else {
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx();
        ex.setContextInfo("Not yet implemented");
        throw ex;
    }
}
Also used : AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) POA(org.omg.PortableServer.POA) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) Servant(org.omg.PortableServer.Servant)

Example 42 with AcsJContainerServicesEx

use of alma.JavaContainerError.wrappers.AcsJContainerServicesEx in project ACS by ACS-Community.

the class AlarmSystemContainerServices method createNotificationChannelSubscriber.

@Override
public <T> AcsEventSubscriber<T> createNotificationChannelSubscriber(String channelName, String channelNotifyServiceDomainName, Class<T> eventType) throws AcsJContainerServicesEx {
    if (eventType == null || !IDLEntity.class.isAssignableFrom(eventType)) {
        throw new IllegalArgumentException("With Corba-NC based pub-sub, the event must be an instance of IDLEntity.");
    }
    AcsEventSubscriber<T> subscriber = null;
    try {
        // TODO: try to get the naming service ref in a nicer way (from ORB etc)
        NamingContext namingService = Helper.getNamingServiceInitial(this);
        // This is dirty omitting of <T> because NCSubscriber needs something like "<U extends T & IDLEntity>"
        // Note that this problem does not exist in the ContainerServicesImpl because there we instantiate via reflection.
        subscriber = new NCSubscriber(channelName, channelNotifyServiceDomainName, this, namingService, this.getName(), eventType);
    } catch (Throwable e) {
        logger.log(AcsLogLevel.ERROR, "Unexpected error while creating new AcsEventSubscriber object", e);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(e);
        throw ex;
    }
    //		m_subscribers.put( (channelNotifyServiceDomainName == null ? "" : channelNotifyServiceDomainName) + "/" + channelName, subscriber);
    return subscriber;
}
Also used : NCSubscriber(alma.acs.nc.NCSubscriber) NamingContext(org.omg.CosNaming.NamingContext) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 43 with AcsJContainerServicesEx

use of alma.JavaContainerError.wrappers.AcsJContainerServicesEx in project ACS by ACS-Community.

the class AlarmSystemContainerServices method activateOffShoot.

@Override
public <T extends Servant & OffShootOperations> OffShoot activateOffShoot(T cbServant) throws AcsJContainerServicesEx {
    if (cbServant == null) {
        String msg = "activateOffShoot called with missing parameter.";
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx();
        ex.setContextInfo(msg);
        throw ex;
    }
    POA offshootPoa;
    try {
        offshootPoa = getPOAForOffshoots(alSysCorbaServer.getRootPOA());
    } catch (Exception e) {
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(e);
        throw ex;
    }
    org.omg.CORBA.Object actObj = null;
    try {
        offshootPoa.activate_object(cbServant);
        actObj = offshootPoa.servant_to_reference(cbServant);
        // just to provoke an exc. if
        actObj._hash(Integer.MAX_VALUE);
        // something is wrong with our
        // new object
        logger.finer("offshoot of type '" + cbServant.getClass().getName() + "' activated as a CORBA object.");
    } catch (Throwable thr) {
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
        ex.setContextInfo("failed to activate offshoot of type '" + cbServant.getClass().getName());
        throw ex;
    }
    return OffShootHelper.narrow(actObj);
}
Also used : POA(org.omg.PortableServer.POA) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 44 with AcsJContainerServicesEx

use of alma.JavaContainerError.wrappers.AcsJContainerServicesEx in project ACS by ACS-Community.

the class DAOManager method backupCDB.

public void backupCDB() {
    DAL dal = null;
    WDAL wdal = null;
    try {
        dal = _contServ.getCDB();
    } catch (AcsJContainerServicesEx e) {
        return;
    }
    wdal = WDALHelper.narrow(dal);
    if (wdal == null)
        return;
    String src = "Alarms";
    String dst;
    int i = 1;
    do {
        dst = src + ".bkp." + i;
        i++;
    } while (nodeExists(wdal, "", dst));
    copyNode(wdal, src, dst);
}
Also used : WDAL(com.cosylab.CDB.WDAL) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) DAL(com.cosylab.CDB.DAL) WDAL(com.cosylab.CDB.WDAL)

Example 45 with AcsJContainerServicesEx

use of alma.JavaContainerError.wrappers.AcsJContainerServicesEx in project ACS by ACS-Community.

the class ACSAlarmSystemInterfaceFactory method init.

/**
	 * Init the static variables of the class
	 * This method has to be called before executing any other
	 * method. 
	 * 
	 * @param logger The logger
	 * @param dal The DAL to init the AS with CERN or ACS implementation
	 * @throws AcsJContainerServicesEx 
	 */
public static void init(ContainerServicesBase containerServices) throws AcsJContainerServicesEx {
    if (containerServices == null) {
        throw new AcsJContainerServicesEx(new Exception("Invalid null ContainerServicesBase"));
    }
    ACSAlarmSystemInterfaceFactory.containerServices = containerServices;
    ACSAlarmSystemInterfaceFactory.logger = containerServices.getLogger();
    DAL dal = containerServices.getCDB();
    if (logger == null || dal == null) {
        throw new IllegalArgumentException("Invalid DAL or Logger from ContainerServicesBase");
    }
    alarmSourceFactory = new AlarmSourceFactory(containerServices);
    useACSAlarmSystem = retrieveImplementationType(dal);
    if (logger != null) {
        if (useACSAlarmSystem) {
            logger.log(AcsLogLevel.DEBUG, "Alarm system type: ACS");
        } else {
            logger.log(AcsLogLevel.DEBUG, "Alarm system type: CERN");
            try {
                initCmwMom();
            } catch (Throwable t) {
                throw new AcsJContainerServicesEx(new Exception("Error initing cmw-mom", t));
            }
        }
    }
}
Also used : AlarmSourceFactory(alma.acs.alarmsystem.source.AlarmSourceFactory) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) DAL(com.cosylab.CDB.DAL)

Aggregations

AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)51 AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)10 AcsJException (alma.acs.exceptions.AcsJException)6 AcsJmaciErrTypeEx (alma.maciErrType.wrappers.AcsJmaciErrTypeEx)6 ComponentDescriptor (alma.acs.component.ComponentDescriptor)5 DAL (com.cosylab.CDB.DAL)5 ComponentLifecycleException (alma.acs.component.ComponentLifecycleException)4 ComponentInfo (si.ijs.maci.ComponentInfo)4 OffShootOperations (alma.ACS.OffShootOperations)3 AcsJIllegalArgumentEx (alma.ACSErrTypeCommon.wrappers.AcsJIllegalArgumentEx)3 EntityT (alma.entities.commonentity.EntityT)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 Any (org.omg.CORBA.Any)3 NamingContext (org.omg.CosNaming.NamingContext)3 Servant (org.omg.PortableServer.Servant)3 OffShoot (alma.ACS.OffShoot)2 AcsJCORBAProblemEx (alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)2 AcsJContainerEx (alma.JavaContainerError.wrappers.AcsJContainerEx)2 ComponentClient (alma.acs.component.client.ComponentClient)2 AcsManagerProxy (alma.acs.container.AcsManagerProxy)2