Search in sources :

Example 11 with AdaptrisConnection

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

the class JndiHelperTest method testUnbindCollection.

@Test
public void testUnbindCollection() throws Exception {
    NullConnection connection = new NullConnection();
    connection.setUniqueId(getName());
    ArrayList<AdaptrisConnection> connectionList = new ArrayList<AdaptrisConnection>();
    connectionList.add(connection);
    JndiHelper.bind(connectionList);
    JndiHelper.unbind(connectionList, false);
    try {
        JndiHelper.unbind(connectionList, false);
        fail();
    } catch (CoreException expected) {
    }
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisConnection(com.adaptris.core.AdaptrisConnection) ArrayList(java.util.ArrayList) NullConnection(com.adaptris.core.NullConnection) Test(org.junit.Test)

Example 12 with AdaptrisConnection

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

the class FilteredSharedComponentStart method logActivity.

private void logActivity(ConnectionAction action, Collection<AdaptrisConnection> conns) {
    if (log.isTraceEnabled()) {
        List<String> names = new ArrayList<>();
        for (AdaptrisConnection c : conns) {
            names.add(c.getUniqueId());
        }
        log.trace("Filtered list for {} operation : {}", action, names);
    }
}
Also used : ArrayList(java.util.ArrayList) AdaptrisConnection(com.adaptris.core.AdaptrisConnection)

Example 13 with AdaptrisConnection

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

the class FilteredSharedComponentStart method start.

@Override
public void start(Collection<AdaptrisConnection> conns) throws CoreException {
    Collection<AdaptrisConnection> actual = filter(new ArrayList<AdaptrisConnection>(conns));
    logActivity(ConnectionAction.START, actual);
    for (AdaptrisConnection c : actual) {
        execute(ConnectionAction.START, c);
    }
}
Also used : AdaptrisConnection(com.adaptris.core.AdaptrisConnection)

Example 14 with AdaptrisConnection

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

the class FilteredSharedComponentStart method include.

private Collection<AdaptrisConnection> include(Collection<AdaptrisConnection> conns) {
    if (getIncludes().size() == 0) {
        return conns;
    }
    initialisePatterns();
    List<AdaptrisConnection> result = new ArrayList<>();
    for (AdaptrisConnection element : conns) {
        for (Pattern pattern : includePatterns) {
            if (pattern.matcher(element.getUniqueId()).find()) {
                result.add(element);
                break;
            }
        }
    }
    return result;
}
Also used : Pattern(java.util.regex.Pattern) AdaptrisConnection(com.adaptris.core.AdaptrisConnection) ArrayList(java.util.ArrayList)

Example 15 with AdaptrisConnection

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

the class ServiceUtil method cloneForTesting.

private static AdaptrisConnection cloneForTesting(AdaptrisConnection conn) throws CoreException {
    if (conn == null) {
        return null;
    }
    AdaptrisConnection cloned = conn.cloneForTesting();
    if (cloned instanceof AllowsRetriesConnection) {
        AllowsRetriesConnection retry = (AllowsRetriesConnection) cloned;
        retry.setConnectionAttempts(0);
    }
    return cloned;
}
Also used : AllowsRetriesConnection(com.adaptris.core.AllowsRetriesConnection) AdaptrisConnection(com.adaptris.core.AdaptrisConnection)

Aggregations

AdaptrisConnection (com.adaptris.core.AdaptrisConnection)15 ArrayList (java.util.ArrayList)9 NullConnection (com.adaptris.core.NullConnection)6 Test (org.junit.Test)6 InitialContext (javax.naming.InitialContext)5 CoreException (com.adaptris.core.CoreException)4 Pattern (java.util.regex.Pattern)2 AllowsRetriesConnection (com.adaptris.core.AllowsRetriesConnection)1 ServiceException (com.adaptris.core.ServiceException)1 DatabaseConnection (com.adaptris.core.jdbc.DatabaseConnection)1 Connection (java.sql.Connection)1