示例#1
0
  /**
   * Creates a sub-context in the parent context with the provided name.
   *
   * @param context The start context
   * @throws StartException If any problems occur creating the context
   */
  public synchronized void start(final StartContext context) throws StartException {
    store = new InMemoryNamingStore();

    try {
      final Reference globalReference =
          GlobalNamespaceObjectFactory.createReference(
              name, (Context) store.lookup(new CompositeName()));
      final NamingStore javaContext = this.javaContext.getValue();
      javaContext.rebind(
          null, NameParser.INSTANCE.parse(name), globalReference, Reference.class.getName());
    } catch (NamingException e) {
      throw new StartException("Failed to bind EE context: java:" + name, e);
    }
  }
示例#2
0
 /**
  * Unbinds the context from the parent.
  *
  * @param context The stop context
  */
 public synchronized void stop(StopContext context) {
   final NamingStore javaContext = this.javaContext.getValue();
   try {
     javaContext.unbind(null, NameParser.INSTANCE.parse(name));
   } catch (NamingException e) {
     throw new IllegalStateException("Failed to unbind EE context: java:" + name, e);
   } finally {
     try {
       store.close();
       store = null;
     } catch (NamingException e) {
       throw new IllegalStateException("Failed to destroy root context", e);
     }
   }
 }