use of nl.nn.adapterframework.configuration.IbisContext in project iaf by ibissource.
the class ApiStreamPipe method adjustFirstStringPart.
@Override
protected String adjustFirstStringPart(String firstStringPart, IPipeLineSession session) throws PipeRunException {
if (firstStringPart == null) {
return "";
} else {
boolean retrieveMessage = false;
if (XmlUtils.isWellFormed(firstStringPart, "MessageID")) {
String rootNamespace = XmlUtils.getRootNamespace(firstStringPart);
if ("http://www.w3.org/2005/08/addressing".equals(rootNamespace)) {
retrieveMessage = true;
}
}
if (retrieveMessage) {
String messageId = null;
try {
messageId = XmlUtils.evaluateXPathNodeSetFirstElement(firstStringPart, "MessageID");
} catch (Exception e) {
throw new PipeRunException(this, "Exception getting MessageID", e);
}
if (StringUtils.isEmpty(messageId)) {
throw new PipeRunException(this, "Could not find messageId in request [" + firstStringPart + "]");
} else {
// TODO: create dummyQuerySender should be put in
// configure(), but gives an error
IbisContext ibisContext = getAdapter().getConfiguration().getIbisManager().getIbisContext();
dummyQuerySender = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
dummyQuerySender.setJmsRealm(jmsRealm);
dummyQuerySender.setQuery("SELECT count(*) FROM ALL_TABLES");
try {
dummyQuerySender.configure();
} catch (ConfigurationException e) {
throw new PipeRunException(this, "Exception configuring dummy query sender", e);
}
ParameterResolutionContext prc = new ParameterResolutionContext("", session);
String slotId = AppConstants.getInstance().getResolvedProperty("instance.name") + "/" + session.get("operation");
String selectMessageKeyResult = null;
try {
selectMessageKeyResult = selectMessageKey(slotId, messageId);
} catch (Exception e) {
throw new PipeRunException(this, "Exception getting messageKey", e);
}
if (StringUtils.isEmpty(selectMessageKeyResult)) {
throw new PipeRunException(this, "Could not find message in MessageStore for slotId [" + slotId + "] and messageId [" + messageId + "]");
} else {
String selectMessageResult = null;
try {
selectMessageResult = selectMessage(selectMessageKeyResult);
} catch (Exception e) {
throw new PipeRunException(this, "Exception getting message", e);
}
if (StringUtils.isEmpty(selectMessageResult)) {
throw new PipeRunException(this, "Could not find message in MessageStore with messageKey [" + selectMessageKeyResult + "]");
} else {
try {
deleteMessage(selectMessageKeyResult);
} catch (Exception e) {
throw new PipeRunException(this, "Exception deleting message", e);
}
}
return selectMessageResult;
}
}
} else {
return firstStringPart;
}
}
}
use of nl.nn.adapterframework.configuration.IbisContext 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.IbisContext in project iaf by ibissource.
the class IbisSoapServlet method init.
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
AppConstants appConstants = AppConstants.getInstance();
String attributeKey = appConstants.getProperty(ConfigurationServlet.KEY_CONTEXT);
IbisContext ibisContext = (IbisContext) config.getServletContext().getAttribute(attributeKey);
if (ibisContext == null)
throw new IllegalStateException("No ibis context found with " + ConfigurationServlet.KEY_CONTEXT);
ibisManager = ibisContext.getIbisManager();
if ("false".equals(appConstants.getProperty("wsdl.caching"))) {
caching = false;
}
}
use of nl.nn.adapterframework.configuration.IbisContext in project iaf by ibissource.
the class ConfigurationServlet method init.
@Override
public void init() throws ServletException {
super.init();
ServletContext servletContext = getServletContext();
AppConstants appConstants = AppConstants.getInstance();
String realPath = servletContext.getRealPath("/");
if (realPath != null) {
appConstants.put("webapp.realpath", realPath);
} else {
log.warn("Could not determine webapp.realpath");
}
String projectBaseDir = Misc.getProjectBaseDir();
if (projectBaseDir != null) {
appConstants.put("project.basedir", projectBaseDir);
} else {
log.info("Could not determine project.basedir");
}
setUploadPathInServletContext();
ibisContext = new IbisContext();
setDefaultApplicationServerType(ibisContext);
String attributeKey = appConstants.getResolvedProperty(KEY_CONTEXT);
servletContext.setAttribute(attributeKey, ibisContext);
log.debug("stored IbisContext [" + ClassUtils.nameOf(ibisContext) + "][" + ibisContext + "] in ServletContext under key [" + attributeKey + "]");
ibisContext.init();
if (ibisContext.getIbisManager() == null)
log.warn("Servlet init finished without successfully initializing the ibisContext");
else
log.debug("Servlet init finished");
}
use of nl.nn.adapterframework.configuration.IbisContext 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