use of com.adaptris.core.AdaptrisConnection in project interlok by adaptris.
the class AdapterManager method addSharedConnection.
@Override
public boolean addSharedConnection(String xmlString) throws CoreException, IllegalArgumentException {
ensureState(ClosedState.getInstance());
AdaptrisConnection comp = (AdaptrisConnection) DefaultMarshaller.getDefaultMarshaller().unmarshal(xmlString);
boolean result = getWrappedComponent().getSharedComponents().addConnection(comp);
if (result) {
marshalAndSendNotification();
}
return result;
}
use of com.adaptris.core.AdaptrisConnection in project interlok by adaptris.
the class JdbcServiceList method applyServices.
@Override
protected void applyServices(AdaptrisMessage msg) throws ServiceException {
try {
AdaptrisConnection c = connection();
if (c != null) {
Connection conn = c.retrieveConnection(DatabaseConnection.class).connect();
msg.getObjectHeaders().put(JdbcConstants.OBJ_METADATA_DATABASE_CONNECTION_KEY, conn);
}
super.applyServices(msg);
// We may not have a valid connection here if we're using pooled connections. If not, then no point in committing on a new connection.
Connection conn = (Connection) msg.getObjectHeaders().get(JdbcConstants.OBJ_METADATA_DATABASE_CONNECTION_KEY);
if (conn != null && !conn.isClosed())
JdbcUtil.commit(conn);
} catch (Exception e) {
rollback(msg, e);
throw ExceptionHelper.wrapServiceException(e);
} finally {
Connection conn = (Connection) msg.getObjectHeaders().get(JdbcConstants.OBJ_METADATA_DATABASE_CONNECTION_KEY);
JdbcUtil.closeQuietly(conn);
}
}
use of com.adaptris.core.AdaptrisConnection in project interlok by adaptris.
the class FilteredSharedComponentStart method exclude.
private Collection<AdaptrisConnection> exclude(Collection<AdaptrisConnection> conns) {
if (getExcludes().size() == 0) {
return conns;
}
initialisePatterns();
List<AdaptrisConnection> toBeRemoved = new ArrayList<>();
for (AdaptrisConnection element : conns) {
for (Pattern pattern : excludePatterns) {
if (pattern.matcher(element.getUniqueId()).find()) {
toBeRemoved.add(element);
break;
}
}
}
conns.removeAll(toBeRemoved);
return conns;
}
use of com.adaptris.core.AdaptrisConnection in project interlok by adaptris.
the class FilteredSharedComponentStart method init.
@Override
public void init(Collection<AdaptrisConnection> conns) throws CoreException {
Collection<AdaptrisConnection> actual = filter(new ArrayList<AdaptrisConnection>(conns));
logActivity(ConnectionAction.INIT, actual);
for (AdaptrisConnection c : actual) {
execute(ConnectionAction.INIT, c);
}
}
use of com.adaptris.core.AdaptrisConnection in project interlok by adaptris.
the class JndiHelperTest method testBindCollection_WithContext.
@Test
public void testBindCollection_WithContext() throws Exception {
NullConnection connection = new NullConnection();
connection.setUniqueId(getName());
ArrayList<AdaptrisConnection> connectionList = new ArrayList<AdaptrisConnection>();
connectionList.add(connection);
InitialContext initialContext = new InitialContext(env);
try {
JndiHelper.bind(initialContext, connectionList, true);
NullConnection lookedup = (NullConnection) initialContext.lookup("adapter:comp/env/" + getName());
assertNotNull(lookedup);
assertTrue(lookedup instanceof NullConnection);
assertEquals(getName(), lookedup.getUniqueId());
} finally {
JndiHelper.unbindQuietly(initialContext, connectionList, true);
}
}
Aggregations