Example usage for org.springframework.mock.jndi SimpleNamingContextBuilder clear

List of usage examples for org.springframework.mock.jndi SimpleNamingContextBuilder clear

Introduction

In this page you can find the example usage for org.springframework.mock.jndi SimpleNamingContextBuilder clear.

Prototype

public void clear() 

Source Link

Document

Clear all bindings in this context builder, while keeping it active.

Usage

From source file:example.app.config.support.NamingContextBuilderFactoryBean.java

@Override
public void destroy() throws Exception {
    SimpleNamingContextBuilder namingContextBuilder = SimpleNamingContextBuilder.getCurrentContextBuilder();

    if (namingContextBuilder != null) {
        namingContextBuilder.clear();
        namingContextBuilder.deactivate();
    }/*from  ww w.ja  va 2 s .c  o  m*/
}

From source file:org.springframework.mock.jndi.SimpleNamingContextBuilder.java

/**
 * If no SimpleNamingContextBuilder is already configuring JNDI,
 * create and activate one. Otherwise take the existing activate
 * SimpleNamingContextBuilder, clear it and return it.
 * <p>This is mainly intended for test suites that want to
 * reinitialize JNDI bindings from scratch repeatedly.
 * @return an empty SimpleNamingContextBuilder that can be used
 * to control JNDI bindings/*from   w  w w.  j  ava  2  s . co m*/
 */
public static SimpleNamingContextBuilder emptyActivatedContextBuilder() throws NamingException {
    SimpleNamingContextBuilder builder = activated;
    if (builder != null) {
        // Clear already activated context builder.
        builder.clear();
    } else {
        // Create and activate new context builder.
        builder = new SimpleNamingContextBuilder();
        // The activate() call will cause an assignment to the activated variable.
        builder.activate();
    }
    return builder;
}