@Test public void testRemoveConnection() throws Exception { SharedComponentList list = new SharedComponentList(); List<AdaptrisConnection> good = Arrays.asList(new AdaptrisConnection[] {new MockConnection(getName()), new MockConnection(getName() + "_1")}); list.setConnections(good); assertEquals(2, list.getConnections().size()); Collection<AdaptrisConnection> removed = list.removeConnection(getName()); assertEquals(1, removed.size()); assertFalse(list.containsConnection(getName())); assertEquals(1, list.getConnections().size()); }
public Collection<AdaptrisConnection> removeConnection(String id) { List<AdaptrisConnection> keep = new ArrayList<>(); List<AdaptrisConnection> remove = new ArrayList<>(); for (AdaptrisConnection c : connections) { if (c.getUniqueId().equals(id)) { remove.add(c); } else { keep.add(c); } } setConnections(keep); unbindQuietly(remove); return remove; }
SharedComponentList implements ComponentLifecycle, ComponentLifecycleExtension { public Collection<AdaptrisConnection> removeConnection(String id) { List<AdaptrisConnection> keep = new ArrayList<>(); List<AdaptrisConnection> remove = new ArrayList<>(); for (AdaptrisConnection c : connections) { if (c.getUniqueId().equals(id)) { remove.add(c); } else { keep.add(c); } } setConnections(keep); unbindQuietly(remove); return remove; } }
SharedComponentList implements ComponentLifecycle, ComponentLifecycleExtension { public Collection<AdaptrisConnection> removeConnection(String id) { List<AdaptrisConnection> keep = new ArrayList<>(); List<AdaptrisConnection> remove = new ArrayList<>(); for (AdaptrisConnection c : connections) { if (c.getUniqueId().equals(id)) { remove.add(c); } else { keep.add(c); } } setConnections(keep); unbindQuietly(remove); return remove; } SharedComponentList(); }
SharedComponentList implements ComponentLifecycle, ComponentLifecycleExtension { public Collection<AdaptrisConnection> removeConnection(String id) { List<AdaptrisConnection> keep = new ArrayList<>(); List<AdaptrisConnection> remove = new ArrayList<>(); for (AdaptrisConnection c : connections) { if (c.getUniqueId().equals(id)) { remove.add(c); } else { keep.add(c); } } setConnections(keep); unbindQuietly(remove); return remove; } SharedComponentList(); List<AdaptrisConnection> getConnections(); void setConnections(List<AdaptrisConnection> l); List<Service> getServices(); void setServices(List<Service> serviceLists); @Override void init(); @Override void start(); @Override void stop(); @Override void close(); @Override void prepare(); void bindJNDI(String componentId); Collection<String> getConnectionIds(); Collection<String> getServiceIds(); boolean addService(Service c); Collection<Service> addServices(Collection<Service> coll); boolean addConnection(AdaptrisConnection c); Collection<AdaptrisConnection> addConnections(Collection<AdaptrisConnection> coll); Collection<AdaptrisConnection> removeConnection(String id); Collection<Service> removeService(String id); boolean containsConnection(String id); boolean containsService(String id); Boolean getDebug(); void setDebug(Boolean debug); SharedComponentLifecycleStrategy getLifecycleStrategy(); void setLifecycleStrategy(SharedComponentLifecycleStrategy ls); TransactionManager getTransactionManager(); void setTransactionManager(TransactionManager tm); }
SharedComponentList implements ComponentLifecycle, ComponentLifecycleExtension { public Collection<AdaptrisConnection> removeConnection(String id) { List<AdaptrisConnection> keep = new ArrayList<>(); List<AdaptrisConnection> remove = new ArrayList<>(); for (AdaptrisConnection c : connections) { if (c.getUniqueId().equals(id)) { remove.add(c); } else { keep.add(c); } } setConnections(keep); unbindQuietly(remove); return remove; } SharedComponentList(); List<AdaptrisConnection> getConnections(); void setConnections(List<AdaptrisConnection> l); List<Service> getServices(); void setServices(List<Service> serviceLists); @Override void init(); @Override void start(); @Override void stop(); @Override void close(); @Override void prepare(); void bindJNDI(String componentId); Collection<String> getConnectionIds(); Collection<String> getServiceIds(); boolean addService(Service c); Collection<Service> addServices(Collection<Service> coll); boolean addConnection(AdaptrisConnection c); Collection<AdaptrisConnection> addConnections(Collection<AdaptrisConnection> coll); Collection<AdaptrisConnection> removeConnection(String id); Collection<Service> removeService(String id); boolean containsConnection(String id); boolean containsService(String id); Boolean getDebug(); void setDebug(Boolean debug); SharedComponentLifecycleStrategy getLifecycleStrategy(); void setLifecycleStrategy(SharedComponentLifecycleStrategy ls); TransactionManager getTransactionManager(); void setTransactionManager(TransactionManager tm);  }