Java Code Examples for javax.naming.InitialContext#rebind()
The following examples show how to use
javax.naming.InitialContext#rebind() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WeldContainer.java From piranha with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Initialize the container. * * @param context the container context. */ @Override public void initialize(ContainerContext context) { try { CDI.setCDIProvider(new WeldProvider()); } catch (IllegalStateException ise) { } try { WeldManager manager = context.getManager(); WeldCDI cdi = new WeldCDI(); cdi.setWeldManager(manager); WeldProvider.setCDI(cdi); InitialContext initialContext = new InitialContext(); initialContext.rebind("java:comp/BeanManager", manager); } catch (NamingException ne) { throw new RuntimeException(ne); } }
Example 2
Source File: RMIConnectorServer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 3
Source File: RMIConnectorServer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 4
Source File: RMIConnectorServer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 5
Source File: JdbcWrapperHelper.java From javamelody with Apache License 2.0 | 5 votes |
static void rebindInitialDataSources(ServletContext servletContext) throws Throwable { try { final InitialContext initialContext = new InitialContext(); for (final Map.Entry<String, DataSource> entry : JNDI_DATASOURCES_BACKUP.entrySet()) { final String jndiName = entry.getKey(); final DataSource dataSource = entry.getValue(); final Object lock = changeContextWritable(servletContext, null); initialContext.rebind(jndiName, dataSource); changeContextWritable(servletContext, lock); } initialContext.close(); } finally { JNDI_DATASOURCES_BACKUP.clear(); } }
Example 6
Source File: JdbcWrapperHelper.java From javamelody with Apache License 2.0 | 5 votes |
static void rebindDataSource(ServletContext servletContext, String jndiName, DataSource dataSource, DataSource dataSourceProxy) throws Throwable { final Object lock = changeContextWritable(servletContext, null); final InitialContext initialContext = new InitialContext(); initialContext.rebind(jndiName, dataSourceProxy); JNDI_DATASOURCES_BACKUP.put(jndiName, dataSource); changeContextWritable(servletContext, lock); initialContext.close(); }
Example 7
Source File: MyRemoteServiceObject.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public void start() throws Exception { if (!m_running) { UnicastRemoteObject.exportObject(this); InitialContext ctx = new InitialContext(); ctx.rebind(JNDI_NAME, this); m_running = true; System.out.println("My remote service started successfully"); } }
Example 8
Source File: RMIConnectorServer.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 9
Source File: RMIConnectorServer.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 10
Source File: RMIConnectorServer.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 11
Source File: RMIConnectorServer.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 12
Source File: RMIConnectorServer.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 13
Source File: RMIConnectorServer.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 14
Source File: RMIConnectorServer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 15
Source File: RMIConnectorServer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 16
Source File: RMIConnectorServer.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 17
Source File: RMIConnectorServer.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 18
Source File: RMIConnectorServer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 19
Source File: RMIConnectorServer.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Bind a stub to a registry. * @param jndiUrl URL of the stub in the registry, extracted * from the <code>JMXServiceURL</code>. * @param attributes A Hashtable containing environment parameters, * built from the Map specified at this object creation. * @param rmiServer The object to bind in the registry * @param rebind true if the object must be rebound. **/ void bind(String jndiUrl, Hashtable<?, ?> attributes, RMIServer rmiServer, boolean rebind) throws NamingException, MalformedURLException { // if jndiURL is not null, we nust bind the stub to a // directory. InitialContext ctx = new InitialContext(attributes); if (rebind) ctx.rebind(jndiUrl, rmiServer); else ctx.bind(jndiUrl, rmiServer); ctx.close(); }
Example 20
Source File: JPA2DatabasesTest.java From piranha with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Test database. * * @throws Exception when a serious error occurs. */ @Test public void testJpaDatabase() throws Exception { System.getProperties().put("java.naming.factory.initial", "cloud.piranha.jndi.memory.DefaultInitialContextFactory"); InitialContext initialContext = new InitialContext(); JdbcDataSource dataSource = new JdbcDataSource(); dataSource.setURL("jdbc:h2:./target/JPADatabaseTest2"); initialContext.bind("java:/JPADatabaseTest2", dataSource); JdbcDataSource dataSource2 = new JdbcDataSource(); dataSource2.setURL("jdbc:h2:./target/JPADatabaseTest3"); initialContext.bind("java:/JPADatabaseTest3", dataSource2); DefaultTransactionManager transactionManager = new DefaultTransactionManager(); initialContext.rebind("java:/TransactionManager", transactionManager); EntityManagerFactory emf = Persistence.createEntityManagerFactory("JPADatabaseTest2"); EntityManagerFactory emf2 = Persistence.createEntityManagerFactory("JPADatabaseTest3"); transactionManager.begin(); EntityManager em = emf.createEntityManager(); JPATest jpaTest = new JPATest(); jpaTest.setId(1); em.persist(jpaTest); em.flush(); Transaction transaction = transactionManager.getTransaction(); assertEquals(transaction.getStatus(), 0); EntityManager em2 = emf2.createEntityManager(); JPATest jpaTest2 = new JPATest(); jpaTest2.setId(2); em2.persist(jpaTest2); em2.flush(); Transaction transaction2 = transactionManager.getTransaction(); assertEquals(transaction2.getStatus(), 0); transactionManager.commit(); assertEquals(transaction.getStatus(), 3); em = emf.createEntityManager(); JPATest jpaTestb = em.find(JPATest.class, 1); assertNotNull(jpaTestb); assertEquals(jpaTest.getId(), jpaTestb.getId()); assertEquals(transaction2.getStatus(), 3); em2 = emf2.createEntityManager(); JPATest jpaTest2b = em2.find(JPATest.class, 2); assertNotNull(jpaTest2b); assertEquals(jpaTest2b.getId(), jpaTest2.getId()); em.close(); emf.close(); em2.close(); emf2.close(); }