Search in sources :

Example 56 with CoreException

use of com.adaptris.core.CoreException in project interlok by adaptris.

the class EmbeddedConnection method removeServlet.

@Override
public void removeServlet(ServletWrapper wrapper) throws CoreException {
    try {
        JettyServerManager serverManager = JettyServerManager.getInstance();
        serverManager.stopDeployment(SERVER_ID, wrapper.getUrl());
        serverManager.removeDeployment(SERVER_ID, wrapper.getUrl());
        serverManager.removeDeployment(SERVER_ID, wrapper.getServletHolder(), wrapper.getUrl());
        log.trace("Removed {} from {}", wrapper.getServletHolder(), wrapper.getUrl());
    } catch (Exception ex) {
        throw ExceptionHelper.wrapCoreException(ex);
    }
}
Also used : CoreException(com.adaptris.core.CoreException) JettyServerManager(com.adaptris.core.management.webserver.JettyServerManager)

Example 57 with CoreException

use of com.adaptris.core.CoreException in project interlok by adaptris.

the class JettyConnection method initConnection.

/**
 * @see com.adaptris.core.AdaptrisConnectionImp#initConnection()
 */
@Override
protected void initConnection() throws CoreException {
    // Would be better to rate limit based on iptables (!).
    try {
        server = configure(new Server());
        context = new ServletContextHandler(ServletContextHandler.SESSIONS);
        context.setContextPath("/");
        context.addServlet(new ServletHolder(new DefaultServlet()), "/");
        server.setHandler(createHandler(context));
    } catch (Exception e) {
        ExceptionHelper.rethrowCoreException(e);
    }
}
Also used : Server(org.eclipse.jetty.server.Server) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) DefaultServlet(org.eclipse.jetty.servlet.DefaultServlet) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) CoreException(com.adaptris.core.CoreException)

Example 58 with CoreException

use of com.adaptris.core.CoreException in project interlok by adaptris.

the class TraversingFsConsumer method handleFile.

private int handleFile(File originalFile) throws CoreException {
    int rc = 0;
    logFile(originalFile, "handleFile ");
    try {
        if (originalFile.getName().endsWith(getWipSuffix())) {
            log.debug("ignoring part-processed file [{}]", originalFile.getName());
        } else if (fileFilter != null && !fileFilter.accept(originalFile)) {
            log.trace("File [{}] doesn't match filter", originalFile.getName());
        } else {
            if (checkModified(originalFile) && isFileAccessible(originalFile)) {
                File wipFile = renameFile(originalFile);
                AdaptrisMessage msg = createAdaptrisMessage(wipFile);
                addStandardMetadata(msg, originalFile, wipFile);
                retrieveAdaptrisMessageListener().onAdaptrisMessage(msg);
                fsWorker.delete(wipFile);
                rc++;
            } else {
                log.trace("[{}] not deemed safe to process", originalFile.getName());
            }
        }
    } catch (FsException e) {
        throw new CoreException(e);
    } catch (IOException e) {
        throw new CoreException(e);
    }
    return rc;
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) FsException(com.adaptris.fs.FsException) IOException(java.io.IOException) File(java.io.File)

Example 59 with CoreException

use of com.adaptris.core.CoreException in project interlok by adaptris.

the class JmsSyncConsumer method init.

/**
 * @see com.adaptris.core.AdaptrisComponent#init()
 */
@Override
public void init() throws CoreException {
    super.init();
    try {
        initSession();
        initConsumer();
        configuredMessageTranslator().registerSession(currentSession());
        configuredMessageTranslator().registerMessageFactory(defaultIfNull(getMessageFactory()));
        LifecycleHelper.init(configuredMessageTranslator());
    } catch (JMSException e) {
        throw new CoreException(e);
    }
}
Also used : CoreException(com.adaptris.core.CoreException) JMSException(javax.jms.JMSException)

Example 60 with CoreException

use of com.adaptris.core.CoreException in project interlok by adaptris.

the class AggregatingQueueConsumer method aggregateMessages.

@Override
public void aggregateMessages(AdaptrisMessage msg, AggregatingJmsConsumeService cfg) throws ServiceException {
    MessageConsumer consumer = null;
    ArrayList<AdaptrisMessage> result = new ArrayList<>();
    try {
        startMessageTranslator(cfg, msg.getFactory());
        consumer = cfg.getConnection().retrieveConnection(JmsConnection.class).configuredVendorImplementation().createQueueReceiver(getEndpoint(), msg.resolve(getFilterExpression()), cfg);
        Message first = firstMessage(consumer);
        result.add(getMessageTranslator().translate(first));
        Message next = nextMessage(consumer);
        while (next != null) {
            result.add(getMessageTranslator().translate(next));
            next = nextMessage(consumer);
        }
        getMessageAggregator().joinMessage(msg, result);
    } catch (CoreException | JMSException e) {
        rethrowServiceException(e);
    } finally {
        JmsUtils.closeQuietly(consumer);
        stop(messageTranslator);
    }
}
Also used : MessageConsumer(javax.jms.MessageConsumer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Message(javax.jms.Message) CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ArrayList(java.util.ArrayList) JMSException(javax.jms.JMSException)

Aggregations

CoreException (com.adaptris.core.CoreException)186 Test (org.junit.Test)110 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)44 Adapter (com.adaptris.core.Adapter)32 ObjectName (javax.management.ObjectName)29 Channel (com.adaptris.core.Channel)27 ArrayList (java.util.ArrayList)24 IOException (java.io.IOException)20 File (java.io.File)19 ServiceException (com.adaptris.core.ServiceException)14 TimeInterval (com.adaptris.util.TimeInterval)13 Document (org.w3c.dom.Document)12 MalformedObjectNameException (javax.management.MalformedObjectNameException)11 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)10 StandardWorkflow (com.adaptris.core.StandardWorkflow)9 URLString (com.adaptris.util.URLString)9 TimeoutException (java.util.concurrent.TimeoutException)9 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)8 Workflow (com.adaptris.core.Workflow)8 XPath (com.adaptris.util.text.xml.XPath)8