AbstractActiveCollectionManager implements ActiveCollectionManager { public void register(ActiveCollectionSource acs) throws Exception { ActiveCollection ac=null; synchronized (_activeCollections) { if (_activeCollectionSources.containsKey(acs.getName())) { throw new IllegalArgumentException("Active collection source already exists for '" +acs.getName()+"'"); } acs.init(_context); _activeCollectionSources.put(acs.getName(), acs); LOG.info("Registered active collection source '"+acs.getName()+"'"); if (!acs.getLazy()) { ac = acs.getActiveCollection(); _activeCollections.put(acs.getName(), ac); if (acs.getDerivedActiveCollections().size() > 0) { for (ActiveCollection dac : acs.getDerivedActiveCollections()) { _derivedActiveCollectionsRetain.put(dac.getName(), dac); } } if (LOG.isLoggable(Level.FINE)) { LOG.fine("Registered active collection '"+acs.getName()+"' immediately"); } } } if (ac != null) { synchronized (_activeCollectionListeners) { for (int i=0; i < _activeCollectionListeners.size(); i++) { _activeCollectionListeners.get(i).registered(ac); } } } } AbstractActiveCollectionManager(); @ServiceInit synchronized void init(); void setHouseKeepingInterval(long interval); long getHouseKeepingInterval(); void register(ActiveCollectionSource acs); void unregister(ActiveCollectionSource acs); ActiveCollection getActiveCollection(String name); java.util.Collection<ActiveCollection> getActiveCollections(); ActiveCollection create(String name, ActiveCollection parent, Predicate predicate,
                            java.util.Map<String,Object> properties); void remove(String name); void addActiveCollectionListener(ActiveCollectionListener l); void removeActiveCollectionListener(ActiveCollectionListener l); @ServiceClose void close();  }
@Test public void testAlreadyRegisteredACS() { ActiveCollectionManager mgr=new AbstractActiveCollectionManager() {}; ActiveCollectionSource acs=new ActiveCollectionSource(); acs.setName(TEST_AC); try { mgr.register(acs); } catch (Exception e) { fail("Failed to register active collection source: "+e); } try { mgr.register(acs); fail("Should have thrown exception as already registered"); } catch (Exception e) { } }