use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.
the class XmlFileStoreAlarmImpl method initialize.
/**
* Life cycle
* @see alma.acs.component.ComponentLifecycle#initialize()
*/
@Override
public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
super.initialize(containerServices);
cs = containerServices;
m_logger = cs.getLogger();
// Prepare the queue
String folderPath = System.getProperty(XmlFileStoreAlarmImpl.LOGDIR_PROPNAME, XmlFileStoreAlarmImpl.DEFAULLOGDIR);
File f = new File(folderPath);
if (!f.exists()) {
f.mkdirs();
}
int fileMax = Integer.getInteger(XmlFileStoreAlarmImpl.MAXNUMBEROFFILES_PROPNAME, XmlFileStoreAlarmImpl.DEFAULTMAXNUMBEROFFILES);
int fileSizeLimit = Integer.getInteger(XmlFileStoreAlarmImpl.MAXFILESIZE_PROPNAME, XmlFileStoreAlarmImpl.DEFAULTMAXFILESIZE);
if (fileMax < 1 || fileSizeLimit < 100000) {
StringBuilder str = new StringBuilder(XmlFileStoreAlarmImpl.MAXNUMBEROFFILES_PROPNAME);
str.append(" must be greater then 1 and ");
str.append(XmlFileStoreAlarmImpl.MAXFILESIZE_PROPNAME);
str.append(" must be greater then 100000");
throw new ComponentLifecycleException(str.toString());
}
StringBuilder str = new StringBuilder("Will save alarms files in : ");
str.append(folderPath);
str.append(" (max log file size: ");
str.append(fileSizeLimit);
str.append(", max # log files: ");
str.append(fileMax);
str.append(')');
m_logger.info(str.toString());
QueueFileHandler qFileHandler;
try {
qFileHandler = new QueueFileHandler(cs, folderPath, fileMax, fileSizeLimit, "alarmSources", "AlarmsLogger");
} catch (Throwable t) {
throw new ComponentLifecycleException("Could not create the queue file handler", t);
}
queue = new TimestampedStringQueue(qFileHandler, "<source-timestamp>");
queue.start();
// Connects to the alarm source NC
try {
alarmSourceClient = new SourceClient(cs);
alarmSourceClient.connect();
} catch (Throwable t) {
throw new ComponentLifecycleException("Could not connect to alarm source NC", t);
}
alarmSourceClient.addAlarmListener(this);
}
use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.
the class XmlFileStoreLoggerImpl method connectToLoggingChannel.
/**
*
* @param logFilePath
* @param fileMax
* @param fileSizeLimit
* @throws ComponentLifecycleException
*/
private void connectToLoggingChannel(String logFilePath, int fileMax, int fileSizeLimit) throws ComponentLifecycleException {
try {
// connect to LoggingChannel
QueueFileHandler queueFileHandler = new QueueFileHandler(cs, logFilePath, fileMax, fileSizeLimit, "log", "Logging");
engine = new LCEngine(queueFileHandler);
engine.connect(cs.getAdvancedContainerServices().getORB(), null);
engine.enableAutoReconnection(true);
} catch (Throwable e) {
m_logger.severe("Could not initialize connection to logging channel.");
cs.getAlarmSource().setAlarm("Logging", cs.getName(), 2, true);
throw new ComponentLifecycleException(e);
}
}
use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.
the class Mount6Impl method initialize.
public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
super.initialize(containerServices);
try {
ROdoubleImpl actAzImpl = new ROdoubleImpl("actAz", this);
// m_actAzDataAccess = actAzImpl.getDataAccess();
ROdoublePOATie actAzTie = new ROdoublePOATie(actAzImpl);
m_actAz = ROdoubleHelper.narrow(this.registerProperty(actAzImpl, actAzTie));
ROdoubleImpl actElImpl = new ROdoubleImpl("actEl", this);
ROdoublePOATie actElTie = new ROdoublePOATie(actElImpl);
m_actEl = ROdoubleHelper.narrow(this.registerProperty(actElImpl, actElTie));
ROdoubleImpl cmdAzImpl = new ROdoubleImpl("cmdAz", this);
ROdoublePOATie cmdAzTie = new ROdoublePOATie(cmdAzImpl);
m_cmdAz = ROdoubleHelper.narrow(this.registerProperty(cmdAzImpl, cmdAzTie));
ROdoubleImpl cmdElImpl = new ROdoubleImpl("cmdEl", this);
ROdoublePOATie cmdElTie = new ROdoublePOATie(cmdElImpl);
m_cmdEl = ROdoubleHelper.narrow(this.registerProperty(cmdElImpl, cmdElTie));
} catch (Throwable th) {
throw new ComponentLifecycleException("Failed to create properties.", th);
}
}
use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.
the class CharacteristicComponentImpl method initialize.
/**
* @see alma.acs.component.ComponentLifecycle#initialize(alma.acs.container.ContainerServices)
*/
public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
super.initialize(containerServices);
try {
DAL dal = m_containerServices.getCDB();
// create characteristic model
// TODO think of error handling; why creating model per instance...
characteristicModelImpl = new CharacteristicModelImpl("alma/" + m_instanceName, dal);
} catch (AcsJContainerServicesEx ce) {
throw new ComponentLifecycleException("Failed to create characteristic model.", ce);
}
// create properties list
properties = new HashMap<PropertyOperations, Servant>();
}
use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.
the class ComponentAdapter method initializeComponent.
void initializeComponent() throws ComponentLifecycleException {
ClassLoader contCL = Thread.currentThread().getContextClassLoader();
m_componentStateManager.setStateByContainer(ComponentStates.COMPSTATE_INITIALIZING);
Throwable thr = null;
Thread.currentThread().setContextClassLoader(m_componentClassLoader);
try {
m_component.initialize(m_containerServices);
} catch (Throwable t) {
thr = t;
} finally {
Thread.currentThread().setContextClassLoader(contCL);
}
if (thr != null) {
if (thr instanceof ComponentLifecycleException) {
m_componentStateManager.setStateByContainer(ComponentStates.COMPSTATE_ERROR);
throw (ComponentLifecycleException) thr;
}
m_componentStateManager.setStateByContainer(ComponentStates.COMPSTATE_ERROR);
throw new ComponentLifecycleException(thr);
}
m_componentStateManager.setStateByContainer(ComponentStates.COMPSTATE_INITIALIZED);
}
Aggregations