@Test public void testGetUDDIClient() throws Exception { System.out.println("getUDDIClient"); ServletContext req = createNiceMock(ServletContext.class); req.setAttribute(JUDDI_CLIENT_NAME, null); expect(req.getInitParameter(WebHelper.JUDDI_CLIENT_NAME)).andReturn(null).times(0, 1); replay(req); UDDIClient result = WebHelper.getUDDIClient(req); Assert.assertNotNull(result); }
public static UDDIClient getUDDIClient(ServletContext servletContext) throws ConfigurationException { if (servletContext.getAttribute(JUDDI_CLIENT_NAME) != null) { String clientName = String.valueOf(servletContext.getAttribute(JUDDI_CLIENT_NAME)); return UDDIClientContainer.getUDDIClient(clientName); } else { String clientName = servletContext.getInitParameter(UDDI_CLIENT_NAME); if (clientName != null) { try { UDDIClient client = UDDIClientContainer.getUDDIClient(clientName); logger.info("Client " + clientName + " was already started."); servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName); return client; } catch (ConfigurationException ce) { logger.debug("Client " + clientName + " is not yet started."); } } String clientConfigFile = servletContext.getInitParameter(UDDI_CLIENT_CONFIG_FILE); if (clientConfigFile == null) { clientConfigFile = ClientConfig.DEFAULT_UDDI_CONFIG; } logger.info("Reading the clientName from the clientConfig file " + clientConfigFile); UDDIClient client = new UDDIClient(clientConfigFile); if (client.getName() == null) { logger.warn("Deprecated, client name set to 'default', however it should be provided in the uddi.xml"); clientName = "default"; } if (client.getName() != null) { logger.info("Starting Client " + client.getName() + "..."); clientName = client.getName(); } else { throw new ConfigurationException("A client name needs to be specified in the client config file."); } client.start(); servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName); return client; } }
WebHelper { public static UDDIClient getUDDIClient(ServletContext servletContext) throws ConfigurationException { if (servletContext.getAttribute(JUDDI_CLIENT_NAME) != null) { String clientName = String.valueOf(servletContext.getAttribute(JUDDI_CLIENT_NAME)); return UDDIClientContainer.getUDDIClient(clientName); } else { String clientName = servletContext.getInitParameter(UDDI_CLIENT_NAME); if (clientName != null) { try { UDDIClient client = UDDIClientContainer.getUDDIClient(clientName); logger.info("Client " + clientName + " was already started."); servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName); return client; } catch (ConfigurationException ce) { logger.debug("Client " + clientName + " is not yet started."); } } String clientConfigFile = servletContext.getInitParameter(UDDI_CLIENT_CONFIG_FILE); if (clientConfigFile == null) { clientConfigFile = ClientConfig.DEFAULT_UDDI_CONFIG; } logger.info("Reading the clientName from the clientConfig file " + clientConfigFile); UDDIClient client = new UDDIClient(clientConfigFile); if (client.getName() == null) { logger.warn("Deprecated, client name set to 'default', however it should be provided in the uddi.xml"); clientName = "default"; } if (client.getName() != null) { logger.info("Starting Client " + client.getName() + "..."); clientName = client.getName(); } else { throw new ConfigurationException("A client name needs to be specified in the client config file."); } client.start(); servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName); return client; } } }
WebHelper { public static UDDIClient getUDDIClient(ServletContext servletContext) throws ConfigurationException { if (servletContext.getAttribute(JUDDI_CLIENT_NAME) != null) { String clientName = String.valueOf(servletContext.getAttribute(JUDDI_CLIENT_NAME)); return UDDIClientContainer.getUDDIClient(clientName); } else { String clientName = servletContext.getInitParameter(UDDI_CLIENT_NAME); if (clientName != null) { try { UDDIClient client = UDDIClientContainer.getUDDIClient(clientName); logger.info("Client " + clientName + " was already started."); servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName); return client; } catch (ConfigurationException ce) { logger.debug("Client " + clientName + " is not yet started."); } } String clientConfigFile = servletContext.getInitParameter(UDDI_CLIENT_CONFIG_FILE); if (clientConfigFile == null) { clientConfigFile = ClientConfig.DEFAULT_UDDI_CONFIG; } logger.info("Reading the clientName from the clientConfig file " + clientConfigFile); UDDIClient client = new UDDIClient(clientConfigFile); if (client.getName() == null) { logger.warn("Deprecated, client name set to 'default', however it should be provided in the uddi.xml"); clientName = "default"; } if (client.getName() != null) { logger.info("Starting Client " + client.getName() + "..."); clientName = client.getName(); } else { throw new ConfigurationException("A client name needs to be specified in the client config file."); } client.start(); servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName); return client; } }  }
WebHelper { public static UDDIClient getUDDIClient(ServletContext servletContext) throws ConfigurationException { if (servletContext.getAttribute(JUDDI_CLIENT_NAME) != null) { String clientName = String.valueOf(servletContext.getAttribute(JUDDI_CLIENT_NAME)); return UDDIClientContainer.getUDDIClient(clientName); } else { String clientName = servletContext.getInitParameter(UDDI_CLIENT_NAME); if (clientName != null) { try { UDDIClient client = UDDIClientContainer.getUDDIClient(clientName); logger.info("Client " + clientName + " was already started."); servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName); return client; } catch (ConfigurationException ce) { logger.debug("Client " + clientName + " is not yet started."); } } String clientConfigFile = servletContext.getInitParameter(UDDI_CLIENT_CONFIG_FILE); if (clientConfigFile == null) { clientConfigFile = ClientConfig.DEFAULT_UDDI_CONFIG; } logger.info("Reading the clientName from the clientConfig file " + clientConfigFile); UDDIClient client = new UDDIClient(clientConfigFile); if (client.getName() == null) { logger.warn("Deprecated, client name set to 'default', however it should be provided in the uddi.xml"); clientName = "default"; } if (client.getName() != null) { logger.info("Starting Client " + client.getName() + "..."); clientName = client.getName(); } else { throw new ConfigurationException("A client name needs to be specified in the client config file."); } client.start(); servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName); return client; } }  static UDDIClient getUDDIClient(ServletContext servletContext); }
WebHelper { public static UDDIClient getUDDIClient(ServletContext servletContext) throws ConfigurationException { if (servletContext.getAttribute(JUDDI_CLIENT_NAME) != null) { String clientName = String.valueOf(servletContext.getAttribute(JUDDI_CLIENT_NAME)); return UDDIClientContainer.getUDDIClient(clientName); } else { String clientName = servletContext.getInitParameter(UDDI_CLIENT_NAME); if (clientName != null) { try { UDDIClient client = UDDIClientContainer.getUDDIClient(clientName); logger.info("Client " + clientName + " was already started."); servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName); return client; } catch (ConfigurationException ce) { logger.debug("Client " + clientName + " is not yet started."); } } String clientConfigFile = servletContext.getInitParameter(UDDI_CLIENT_CONFIG_FILE); if (clientConfigFile == null) { clientConfigFile = ClientConfig.DEFAULT_UDDI_CONFIG; } logger.info("Reading the clientName from the clientConfig file " + clientConfigFile); UDDIClient client = new UDDIClient(clientConfigFile); if (client.getName() == null) { logger.warn("Deprecated, client name set to 'default', however it should be provided in the uddi.xml"); clientName = "default"; } if (client.getName() != null) { logger.info("Starting Client " + client.getName() + "..."); clientName = client.getName(); } else { throw new ConfigurationException("A client name needs to be specified in the client config file."); } client.start(); servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName); return client; } }  static UDDIClient getUDDIClient(ServletContext servletContext); static final Log logger; static final String UDDI_CLIENT_NAME; static final String UDDI_CLIENT_CONFIG_FILE; static final String JUDDI_CLIENT_NAME; static final String JUDDI_CLIENT_TRANSPORT; }