package nl.tudelft.simulation.naming; import java.io.Serializable; import java.rmi.RemoteException; import java.util.Hashtable; import javax.naming.Binding; import javax.naming.Context; import javax.naming.Name; import javax.naming.NameClassPair; import javax.naming.NameParser; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.event.EventContext; import javax.naming.event.NamingListener; import nl.tudelft.simulation.naming.listener.ContextListenerInterface; import nl.tudelft.simulation.naming.listener.RemoteContextListener; /** * The FileContext as implementation of the Context interface. *
* (c) copyright 2002-2005 Delft University of Technology , the
* Netherlands.
* See for project information www.simulation.tudelft.nl
* License of use: Lesser General Public License (LGPL) , no
* warranty.
* @author Peter Jacobs
* @version 1.1 2004-03-24
* @since 1.5
*/
public class RemoteContextClient implements EventContext, Serializable
{
/** The default serial version UID for serializable classes. */
private static final long serialVersionUID = 1L;
/** the remoteContext on which all calls are passed. */
private RemoteContextInterface remoteContext = null;
/**
* constructs a new RemoteContextClient.
* @param remoteContext the remoteContext on which all calls are passed.
*/
public RemoteContextClient(final RemoteContextInterface remoteContext)
{
super();
this.remoteContext = remoteContext;
}
/** {@inheritDoc} */
@Override
public void addNamingListener(Name target, int scope, NamingListener l) throws NamingException
{
try
{
this.remoteContext
.addNamingListener(target, scope, new RemoteContextListener((ContextListenerInterface) l));
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public void addNamingListener(String target, int scope, NamingListener l) throws NamingException
{
try
{
this.remoteContext
.addNamingListener(target, scope, new RemoteContextListener((ContextListenerInterface) l));
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public void removeNamingListener(NamingListener l) throws NamingException
{
try
{
this.remoteContext.removeNamingListener(new RemoteContextListener((ContextListenerInterface) l));
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public boolean targetMustExist() throws NamingException
{
try
{
return this.remoteContext.targetMustExist();
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public Object addToEnvironment(String propName, Object propVal) throws NamingException
{
try
{
return this.remoteContext.addToEnvironment(propName, propVal);
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public void bind(Name name, Object obj) throws NamingException
{
try
{
this.remoteContext.bind(name, obj);
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public void bind(String name, Object obj) throws NamingException
{
try
{
this.remoteContext.bind(name, obj);
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public void close() throws NamingException
{
try
{
this.remoteContext.close();
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public Name composeName(Name name, Name prefix) throws NamingException
{
try
{
return this.remoteContext.composeName(name, prefix);
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public String composeName(String name, String prefix) throws NamingException
{
try
{
return this.remoteContext.composeName(name, prefix);
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public Context createSubcontext(Name name) throws NamingException
{
try
{
return new RemoteContextClient(this.remoteContext.createSubcontext(name));
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public Context createSubcontext(String name) throws NamingException
{
try
{
return new RemoteContextClient(this.remoteContext.createSubcontext(name));
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public void destroySubcontext(Name name) throws NamingException
{
try
{
this.remoteContext.destroySubcontext(name);
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public void destroySubcontext(String name) throws NamingException
{
try
{
this.remoteContext.destroySubcontext(name);
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public Hashtable, ?> getEnvironment() throws NamingException
{
try
{
return this.remoteContext.getEnvironment();
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public String getNameInNamespace() throws NamingException
{
try
{
return this.remoteContext.getNameInNamespace();
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public NameParser getNameParser(Name name) throws NamingException
{
try
{
return this.remoteContext.getNameParser(name);
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public NameParser getNameParser(String name) throws NamingException
{
try
{
return this.remoteContext.getNameParser(name);
}
catch (RemoteException remoteException)
{
throw new NamingException(remoteException.getMessage());
}
}
/** {@inheritDoc} */
@Override
public NamingEnumeration