Java Code Examples for javax.naming.InitialContext#unbind()

The following examples show how to use javax.naming.InitialContext#unbind() . 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: DataSourceRepository.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private void unregisterJNDI(DataSourceMetaInfo dsmInfo) {
		try {
//			PrivilegedCarbonContext.startTenantFlow();
//			PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(this.getTenantId());
			JNDIConfig jndiConfig = dsmInfo.getJndiConfig();
		    if (jndiConfig == null) {
			    return;
		    }
			try {
				InitialContext context = new InitialContext(jndiConfig.extractHashtableEnv());
				context.unbind(jndiConfig.getName());
		    } catch (NamingException e) {
			    log.error("Error in unregistering JNDI name: " +
		                jndiConfig.getName() + " - " + e.getMessage(), e);
		    }
		} finally {
//			PrivilegedCarbonContext.endTenantFlow();
		}
	}
 
Example 2
Source File: JndiServiceImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void unbind(String jndiName) {
	final InitialContext initialContext = buildInitialContext();
	final Name name = parseName( jndiName, initialContext );
	try {
		initialContext.unbind( name );
	}
	catch (Exception e) {
		throw new JndiException( "Error performing unbind [" + name + "]", e );
	}
	finally {
		cleanUp( initialContext );
	}
}
 
Example 3
Source File: ConfigurationBeanTest.java    From development with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalStateException.class)
public void testMissingBeanException() throws Exception {
    // Simulate missing EJB
    InitialContext context = new InitialContext();
    context.unbind(APPlatformService.JNDI_NAME);
    // And invoke internal EJB constructor
    new ConfigurationBean();
}
 
Example 4
Source File: RORControllerIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test(expected = RuntimeException.class)
public void initializeNoJndi() throws Exception {
    InitialContext context = new InitialContext();
    context.unbind(APPlatformService.JNDI_NAME);
    // when no platform service is available via JNDI, the controller cannot
    // work
    new RORController().initialize();
}
 
Example 5
Source File: RORControllerIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test(expected = RuntimeException.class)
public void initializeNoJndi_Communication() throws Exception {
    InitialContext context = new InitialContext();
    context.unbind(APPlatformService.JNDI_NAME);
    // when no platform service is available via JNDI, the controller cannot
    // work
    new ProcessManagerBean().initialize();
}
 
Example 6
Source File: MyRemoteServiceObject.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void stop() throws Exception
{
   if (m_running)
   {
      InitialContext ctx = new InitialContext();
      ctx.unbind(JNDI_NAME);
      UnicastRemoteObject.unexportObject(this, false);
      m_running = false;
      System.out.println("My remote service stopped successfully");
   }
}
 
Example 7
Source File: ManagerApiTestServer.java    From apiman with Apache License 2.0 5 votes vote down vote up
/**
 * Stop the server.
 * @throws Exception
 */
public void stop() throws Exception {
    if (node != null) {
        deleteAndFlush();
        node.stop();
        System.out.println("================ STOPPED ES ================ ");
    }
    server.stop();
    if (ds != null) {
        ds.close();
        InitialContext ctx = TestUtil.initialContext();
        ctx.unbind("java:comp/env/jdbc/ApiManagerDS");
    }
}
 
Example 8
Source File: DatabaseTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() throws NamingException {
  InitialContext ctx = new InitialContext();
  ctx.unbind( fullJndiName );
}
 
Example 9
Source File: SS7Service.java    From gmlc with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Unbounds object under specified name.
 *
 * @param jndiName
 *            the JNDI name of the object to be unbound.
 */
private void unbind(String jndiName) throws NamingException {
    InitialContext initialContext = new InitialContext();
    initialContext.unbind(jndiName);
}