/** * {@inheritDoc} */ public String browse() throws DSBWebServiceException { String result = null; try { InitialContext initialContext = this.jndiService.getInitialContext(); result = JNDIUtil.browseJNDI(initialContext, null, 0); System.out.println(result); } catch (NamingException e) { throw new DSBWebServiceException(e.getMessage()); } return result; }
/** * Browse the JNDI server. * * @param initialContext * The InitialContext connected to the JNDI server * @param host * The JNDI host. Can be {@code null} * @param port * The JNDI port * @return * @throws NamingException */ public static String browseJNDI(InitialContext initialContext, String host, int port) throws NamingException { StringBuilder result = new StringBuilder(); if (host == null) { result.append("JNDI directory local \n<== / ==>\n"); } else { result.append("JNDI directory on " + host + ":" + port + "\n<== / ==>\n"); } recurseBindings(initialContext, initialContext.listBindings("/"), "\t", result); return result.toString().replaceAll("&47;", "/"); }
result.append("\n" + tabs + "<=" + binding.getName() + "=>\n"); try { recurseBindings((Context) object, context.listBindings(binding.getName()), tabs + "\t", result); } catch (Exception e) { recurseNames((Context) object, context.list(binding.getName()), tabs + "\t", result);
public String browseJNDI() throws PetalsException { if (this.containerConfiguration == null) { throw new PetalsException("The container configuration is not properly set"); } String result = null; Component jndiComponent = FractalHelper.getRecursiveComponentByName( this.petalsContentController, FractalHelper.JNDI_COMPONENT); try { JNDIService jndiService = (JNDIService) jndiComponent.getFcInterface("service"); InitialContext initialContext = jndiService.getInitialContext(); if (this.domainConfiguration.getJndiConfiguration() == null) { result = JNDIUtil.browseJNDI(initialContext, (String) null, 0); } else { URI providerUrl = this.domainConfiguration.getJndiConfiguration() .getJndiProviderUrl(); result = JNDIUtil.browseJNDI(initialContext, providerUrl.getHost(), providerUrl .getPort()); } } catch (NoSuchInterfaceException e) { throw new PetalsException(e); } catch (NamingException e) { throw new PetalsException(e); } return result; }
@Override public String browseJNDI() throws PetalsException { if (this.containerConfiguration == null) { throw new PetalsException("The container configuration is not properly set"); } String result = null; Component jndiComponent = FractalHelper.getRecursiveComponentByName( this.petalsContentController, FractalHelper.JNDI_COMPONENT); try { JNDIService jndiService = (JNDIService) jndiComponent.getFcInterface("service"); InitialContext initialContext = jndiService.getInitialContext(); if (this.domainConfiguration.getJndiConfiguration() == null) { result = JNDIUtil.browseJNDI(initialContext, (String) null, 0); } else { URI providerUrl = this.domainConfiguration.getJndiConfiguration() .getJndiProviderUrl(); result = JNDIUtil.browseJNDI(initialContext, providerUrl.getHost(), providerUrl .getPort()); } } catch (NoSuchInterfaceException e) { throw new PetalsException(e); } catch (NamingException e) { throw new PetalsException(e); } return result; }