Search in sources :

Example 91 with CoreException

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

the class ComponentManagerImpl method requestInit.

@Override
public void requestInit(final long timeout) throws CoreException, TimeoutException {
    checkTransitionTo(InitialisedState.getInstance());
    final CyclicBarrier barrier = new CyclicBarrier(2);
    executeAndWait(timeout, barrier, new Runnable() {

        @Override
        public void run() {
            Thread current = Thread.currentThread();
            current.setName(THREAD_NAME_PREFIX + requestNumber.getAndIncrement());
            try {
                LifecycleHelper.init(getWrappedComponent());
            } catch (CoreException e) {
                current.getUncaughtExceptionHandler().uncaughtException(current, e);
            } catch (Throwable t) {
                current.getUncaughtExceptionHandler().uncaughtException(current, new CoreException(t));
            }
            try {
                barrier.await(timeout, TimeUnit.MILLISECONDS);
            } catch (Exception e) {
                current.getUncaughtExceptionHandler().uncaughtException(current, e);
            }
        }
    });
    sendLifecycleNotification(NOTIF_MSG_INITIALISED, getComponentState());
}
Also used : CoreException(com.adaptris.core.CoreException) TimeoutException(java.util.concurrent.TimeoutException) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) MalformedObjectNameException(javax.management.MalformedObjectNameException) CoreException(com.adaptris.core.CoreException) CyclicBarrier(java.util.concurrent.CyclicBarrier)

Example 92 with CoreException

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

the class ComponentManagerImpl method sendConfigUpdateNotification.

protected void sendConfigUpdateNotification() {
    try {
        Notification n = new Notification(getNotificationType(ComponentNotificationType.CONFIG), createObjectName(), sequenceNumber.getAndIncrement(), NOTIF_MSG_CONFIG_UPDATED);
        n.setUserData(getConfiguration());
        sendNotification(n);
    } catch (MalformedObjectNameException | CoreException e) {
    // Don't care about notifications really.
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) CoreException(com.adaptris.core.CoreException) Notification(javax.management.Notification)

Example 93 with CoreException

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

the class WorkflowManager method initMembers.

private void initMembers() throws MalformedObjectNameException, CoreException {
    if (isEmpty(managedWorkflow.getUniqueId())) {
        throw new CoreException("No UniqueID, this workflow cannot be managed");
    }
    // Builds up a name com.adaptris:type=Workflow, adapter=<adapter-id,>, id=<channel-id>, workflow=<workflow-id>
    myObjectName = ObjectName.getInstance(JMX_WORKFLOW_TYPE + ADAPTER_PREFIX + getParent().getParent().getUniqueId() + CHANNEL_PREFIX + getParent().getUniqueId() + ID_PREFIX + getWrappedComponent().getUniqueId());
    configureDefaultInterceptors();
    Collection<AdaptrisComponent> runtimeCandidates = CollectionUtils.union(managedWorkflow.getInterceptors(), Arrays.asList(new AdaptrisComponent[] { managedWorkflow.getConsumer(), managedWorkflow.getProducer(), defaultIfNull(managedWorkflow.getMessageErrorHandler()) }));
    for (AdaptrisComponent c : runtimeCandidates) {
        addChildJmxComponentQuietly((ChildRuntimeInfoComponent) RuntimeInfoComponentFactory.create(this, c));
    }
    marshalConfig();
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisComponent(com.adaptris.core.AdaptrisComponent)

Example 94 with CoreException

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

the class AggregatingConsumeServiceImpl method start.

protected void start(ComponentLifecycle ac) throws ServiceException {
    try {
        LifecycleHelper.prepare(ac);
        LifecycleHelper.init(ac);
        LifecycleHelper.start(ac);
    } catch (CoreException e) {
        throw new ServiceException(e);
    }
}
Also used : CoreException(com.adaptris.core.CoreException) ServiceException(com.adaptris.core.ServiceException)

Example 95 with CoreException

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

the class RegexpMetadataQuery method doQuery.

/**
 * <p>
 * Performs the query against the payload of the supplied String and
 * constructs a MetdataElement with the configured Key and the result as the
 * Value.
 * </p>
 * @param message the String to run the Query on
 * @return a MetadataElement with the configured Key and the result of the
 * Query as it's Value <b>NOTE: the Value of the MetadataElement will be null
 * if nulls have been allowed</b>
 * @throws CoreException wrapping any underlying Exception
 */
public synchronized MetadataElement doQuery(String message) throws Exception {
    Args.notBlank(getMetadataKey(), "metadata-key");
    Args.notBlank(getQueryExpression(), "query-expression");
    if (pattern == null) {
        pattern = Pattern.compile(getQueryExpression());
    }
    Matcher matcher = pattern.matcher(message);
    MetadataElement elem = new MetadataElement();
    elem.setKey(getMetadataKey());
    if (matcher.find()) {
        elem.setValue(matcher.group(1));
    } else {
        if (!allowNullResults()) {
            throw new CoreException("Failed to match pattern [" + metadataKey + "] to input string");
        }
    }
    return elem;
}
Also used : CoreException(com.adaptris.core.CoreException) Matcher(java.util.regex.Matcher) MetadataElement(com.adaptris.core.MetadataElement)

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