AbstractInformationProcessorManager implements InformationProcessorManager { public void register(InformationProcessor ip) throws Exception { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Register: information processor name=" +ip.getName()+" version=" +ip.getVersion()+" ip="+ip); } ip.init(); synchronized (_informationProcessorIndex) { boolean f_add=false; InformationProcessor existing=_informationProcessorIndex.get(ip.getName()); if (existing != null) { if (VersionUtil.isNewerVersion(existing.getVersion(), ip.getVersion())) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Replace existing information processor version=" +existing.getVersion()); } unregister(existing); f_add = true; } else { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Newer version '"+existing.getVersion() +"' already registered"); } } } else { f_add = true; } if (f_add) { _informationProcessorIndex.put(ip.getName(), ip); _informationProcessors.add(ip); } } } AbstractInformationProcessorManager(); @ServiceInit void init(); void register(InformationProcessor ip); InformationProcessor getInformationProcessor(String name); String process(String processor, String type,
                    Object info, java.util.Map<String, Object> headers, ActivityType actType); void unregister(InformationProcessor ip); @ServiceClose void close();  }
@Test public void testRegister() { InformationProcessorManager ipm=new AbstractInformationProcessorManager(){}; InformationProcessor ip=new InformationProcessor(); ip.setName(IP_NAME1); ip.setVersion("1"); try { ipm.register(ip); } catch (Exception e) { fail("Failed to register"); } if (ipm.getInformationProcessor(IP_NAME1) == null) { fail("Information processor not registered"); } }
@Test public void testRegisterFailed() { InformationProcessorManager ipm=new AbstractInformationProcessorManager(){}; InformationProcessor ip=new InformationProcessor() { public void init() throws Exception { throw new Exception("FAIL"); } }; ip.setName(IP_NAME1); ip.setVersion("1"); try { ipm.register(ip); fail("Should have failed to register"); } catch (Exception e) { } }