/*
 * JBoss, the OpenSource J2EE webOS
 * 
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.test.kernel.deployment.jboss.beans;

import java.io.Serializable;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.jboss.naming.Util;

public class POJOJNDIBinder
{
   private String jndiName;
   
   public POJOJNDIBinder(String jndiName)
   {
      this.jndiName = jndiName;
   }
   
   public void setPojo(Serializable pojo) throws NamingException
   {
      InitialContext ctx = new InitialContext();
      if (pojo == null)
         Util.unbind(ctx, jndiName);
      else
         Util.rebind(ctx, jndiName, pojo);
   }
}
