use of nl.nn.adapterframework.configuration.IbisManager in project iaf by ibissource.
the class ConfigurationBase method doGet.
/**
* When extending this class, copy and extend the doGet method in the new
* child class.
*/
protected String doGet(IPipeLineSession session) throws PipeRunException {
IbisManager ibisManager = RestListenerUtils.retrieveIbisManager(session);
String configurationName = null;
if (configurationName == null) {
configurationName = retrieveConfigurationName(session);
}
Configuration configuration = null;
boolean configAll;
if (configurationName == null || configurationName.equalsIgnoreCase(CONFIG_ALL)) {
configAll = true;
} else {
configuration = ibisManager.getConfiguration(configurationName);
if (configuration == null) {
configAll = true;
} else {
configAll = false;
}
}
List<Configuration> allConfigurations = ibisManager.getConfigurations();
XmlBuilder configurationsXml = toConfigurationsXml(allConfigurations);
storeConfiguration(session, configAll, configuration);
XmlBuilder root = new XmlBuilder("root");
root.addSubElement(configurationsXml);
return root.toXML();
}
use of nl.nn.adapterframework.configuration.IbisManager in project iaf by ibissource.
the class ShowConfigurationStatus method doGet.
@Override
protected String doGet(IPipeLineSession session) throws PipeRunException {
IbisManager ibisManager = retrieveIbisManager();
String configurationName = null;
ShowConfigurationStatusManager showConfigurationStatusManager = new ShowConfigurationStatusManager();
String countStr = (String) session.get("count");
showConfigurationStatusManager.count = Boolean.parseBoolean(countStr);
String alertStr = (String) session.get("alert");
if (alertStr != null) {
showConfigurationStatusManager.alert = Boolean.parseBoolean(alertStr);
configurationName = CONFIG_ALL;
}
if (configurationName == null) {
configurationName = retrieveConfigurationName(session);
}
Configuration configuration = null;
boolean configAll;
if (configurationName == null || configurationName.equalsIgnoreCase(CONFIG_ALL)) {
configAll = true;
} else {
configuration = ibisManager.getConfiguration(configurationName);
if (configuration == null) {
configAll = true;
} else {
configAll = false;
}
}
List<Configuration> allConfigurations = ibisManager.getConfigurations();
XmlBuilder configurationsXml = toConfigurationsXml(allConfigurations);
List<IAdapter> registeredAdapters = retrieveRegisteredAdapters(ibisManager, configAll, configuration);
storeConfiguration(session, configAll, configuration);
XmlBuilder adapters = toAdaptersXml(ibisManager, allConfigurations, configuration, registeredAdapters, showConfigurationStatusManager);
XmlBuilder root = new XmlBuilder("root");
root.addSubElement(configurationsXml);
root.addSubElement(adapters);
return root.toXML();
}
use of nl.nn.adapterframework.configuration.IbisManager in project iaf by ibissource.
the class RestListenerUtils method doRestartShowConfigurationStatus.
private static boolean doRestartShowConfigurationStatus(ServletContext servletContext) {
String attributeKey = AppConstants.getInstance().getProperty(ConfigurationServlet.KEY_CONTEXT);
IbisContext ibisContext = (IbisContext) servletContext.getAttribute(attributeKey);
IAdapter adapter = null;
IReceiver receiver = null;
if (ibisContext != null) {
IbisManager ibisManager = ibisContext.getIbisManager();
if (ibisManager != null) {
Configuration configuration = ibisManager.getConfiguration(SHOW_CONFIG_STATUS_CONFIGURATION);
if (configuration != null) {
adapter = configuration.getRegisteredAdapter(SHOW_CONFIG_STATUS_ADAPTER);
if (adapter instanceof Adapter) {
receiver = ((Adapter) adapter).getReceiverByNameAndListener(SHOW_CONFIG_STATUS_RECEIVER, RestListener.class);
}
}
}
}
if (adapter == null) {
log.info("could not restart ShowConfigurationStatus, adapter [" + SHOW_CONFIG_STATUS_ADAPTER + "] not found");
return false;
}
if (receiver == null) {
log.info("could not restart ShowConfigurationStatus, receiver [" + SHOW_CONFIG_STATUS_RECEIVER + "] not found");
return false;
}
RunStateEnum adapterStatus = adapter.getRunState();
RunStateEnum receiverStatus = receiver.getRunState();
if (RunStateEnum.STARTED.equals(adapterStatus) && RunStateEnum.STARTED.equals(receiverStatus)) {
log.info("ShowConfigurationStatus is already running, will restart it");
ibisContext.getIbisManager().handleAdapter("stopadapter", SHOW_CONFIG_STATUS_CONFIGURATION, SHOW_CONFIG_STATUS_ADAPTER, SHOW_CONFIG_STATUS_RECEIVER, "system", true);
}
if (RunStateEnum.STOPPED.equals(adapterStatus)) {
log.info("starting adapter of ShowConfigurationStatus");
ibisContext.getIbisManager().handleAdapter("startadapter", SHOW_CONFIG_STATUS_CONFIGURATION, SHOW_CONFIG_STATUS_ADAPTER, SHOW_CONFIG_STATUS_RECEIVER, "system", true);
return true;
} else {
if (RunStateEnum.STARTED.equals(adapterStatus) && RunStateEnum.STOPPED.equals(receiverStatus)) {
log.info("starting receiver of ShowConfigurationStatus");
ibisContext.getIbisManager().handleAdapter("startreceiver", SHOW_CONFIG_STATUS_CONFIGURATION, SHOW_CONFIG_STATUS_ADAPTER, SHOW_CONFIG_STATUS_RECEIVER, "system", true);
return true;
}
}
log.info("could not restart ShowConfigurationStatus with adapter status [" + adapterStatus + "] and receiver status [" + receiverStatus + "]");
return false;
}
use of nl.nn.adapterframework.configuration.IbisManager in project iaf by ibissource.
the class ConfiguredJob method execute.
public void execute(JobExecutionContext context) throws JobExecutionException {
String ctName = Thread.currentThread().getName();
try {
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
IbisManager ibisManager = (IbisManager) dataMap.get("manager");
JobDef jobDef = (JobDef) dataMap.get("jobdef");
Thread.currentThread().setName(jobDef.getName() + "[" + ctName + "]");
log.info(getLogPrefix(jobDef) + "executing");
jobDef.executeJob(ibisManager);
log.debug(getLogPrefix(jobDef) + "completed");
} catch (Exception e) {
log.error(e);
throw new JobExecutionException(e, false);
} finally {
Thread.currentThread().setName(ctName);
}
}
use of nl.nn.adapterframework.configuration.IbisManager in project iaf by ibissource.
the class TestPipeline method getIbisManager.
private IbisManager getIbisManager() {
String attributeKey = AppConstants.getInstance().getProperty(ConfigurationServlet.KEY_CONTEXT);
IbisContext ibisContext = (IbisContext) servletConfig.getServletContext().getAttribute(attributeKey);
if (ibisContext != null) {
IbisManager ibisManager = ibisContext.getIbisManager();
if (ibisManager == null) {
log.warn("Could not retrieve ibisManager from context");
} else {
log.trace("retrieved ibisManager [" + ClassUtils.nameOf(ibisManager) + "][" + ibisManager + "] from servlet context attribute [" + attributeKey + "]");
return ibisManager;
}
}
return null;
}
Aggregations