List of usage examples for javax.naming InitialContext lookup
public Object lookup(Name name) throws NamingException
From source file:com.sapito.db.config.PersistenceConfig.java
@Bean public DataSource dataSource() { try {/*from w w w . j ava 2 s. co m*/ InitialContext context = new InitialContext(); return (DataSource) context.lookup("jdbc/sapito"); } catch (NamingException ex) { System.err.println("Exception getting jdbc/sapito from jndi"); ex.getExplanation(); return null; } }
From source file:com.francetelecom.clara.cloud.commons.JasyptPrerequisites.java
private void assertJasyptPrerequisites(String passPhraseEnvName, String passPhraseJndiName) { Validate.notEmpty(passPhraseEnvName, "passPhraseEnvName cannot be empty, neither null"); String passPhrase = System.getenv(passPhraseEnvName); if (!isPassPhraseCorrect(passPhrase)) { try {/*w ww . j a v a 2s .c om*/ InitialContext ctx = new InitialContext(); String jndiValue = (String) ctx.lookup(passPhraseJndiName); passPhrase = jndiValue; } catch (NamingException e) { logger.info("No Jndi jasypt secret named " + passPhraseJndiName, e); } } if (!isPassPhraseCorrect(passPhrase)) { throw new TechnicalException( "Jasypt require pass phrase into environment or jndi variables : '" + passPhraseEnvName + "'"); } }
From source file:org.jboss.adminclient.connection.AbstractProfileServiceConnectionProvider.java
protected Object lookup(InitialContext initialContext, String name) { try {// ww w. j a v a 2s. c o m return initialContext.lookup(name); } catch (NamingException e) { throw new RuntimeException("Failed to lookup JNDI name '" + name + "' from InitialContext.", e); } }
From source file:org.pepstock.jem.junit.test.jppf.java.RunnableReaderWriter.java
@Override public void run() { try {// w w w .j a v a 2 s .c o m InitialContext ic = UniqueInitialContext.getContext(); Object oI = (Object) ic.lookup("INPUT"); InputStream is = (InputStream) oI; Object oO = (Object) ic.lookup("OUTPUT"); OutputStream os = (OutputStream) oO; IOUtils.copy(is, os); IOUtils.closeQuietly(is); IOUtils.closeQuietly(os); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:Main.java
private Connection getConnection() { Connection connection = null; try {// w w w . j ava 2 s . c o m InitialContext context = new InitialContext(); DataSource dataSource = (DataSource) context.lookup("jdbc/DataSource"); connection = dataSource.getConnection(); } catch (NamingException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return connection; }
From source file:TransformServlet.java
/** * Servlet initializer - look up the bean's home interface *///from w w w .j av a 2 s. c om public void init(ServletConfig config) throws ServletException { try { InitialContext context = new InitialContext(); Object transformRef = context.lookup("transform"); transformer = (TransformHome) PortableRemoteObject.narrow(transformRef, TransformHome.class); } catch (Exception NamingException) { NamingException.printStackTrace(); } }
From source file:org.rhq.plugins.jbossas5.connection.AbstractProfileServiceConnectionProvider.java
protected Object lookup(InitialContext initialContext, String name) { try {//from w w w .ja v a 2 s . c o m Object found = initialContext.lookup(name); return found; } catch (NamingException e) { throw new RuntimeException("Failed to lookup JNDI name '" + name + "' from InitialContext.", e); } }
From source file:ar.com.zauber.commons.web.proxy.impl.dao.properties.provider.JndiPropertiesProvider.java
/** * Creates the JndiPropertiesProvider./* w w w .java 2s.c om*/ * * @param jndiVariable * @param resourceLoader * @param fallback * @throws IOException . */ public JndiPropertiesProvider(final String jndiVariable, final ResourceLoader resourceLoader, final PropertiesProvider fallback) throws IOException { Validate.notEmpty(jndiVariable); Validate.notNull(resourceLoader); Validate.notNull(fallback); try { final InitialContext initCtx = new InitialContext(); final Context envCtx = (Context) initCtx.lookup("java:comp/env"); final Resource resource = resourceLoader.getResource((String) envCtx.lookup(jndiVariable)); target = new ResourcePropertiesProvider(resource); } catch (final NamingException e) { target = fallback; } }
From source file:io.apiman.gateway.engine.ispn.AbstractInfinispanComponent.java
/** * @return gets the cache/*from ww w. j a v a 2s.c o m*/ */ protected Cache<Object, Object> getCache() { if (cache != null) { return cache; } try { InitialContext ic = new InitialContext(); CacheContainer container = (CacheContainer) ic.lookup(cacheContainer); cache = container.getCache(cacheName); return cache; } catch (NamingException e) { throw new RuntimeException(e); } }
From source file:com.comcast.cats.service.settop.command.SettopServiceBaseCommand.java
public void lookupSettopCatalog() { try {/* ww w . jav a2 s .c om*/ InitialContext ctx = new InitialContext(); catalog = (SettopCatalog) ctx.lookup("cats/services/SettopCatalog"); } catch (NamingException e) { throw new RuntimeException(e); } }