FileDocCategorySizeDatePackage
Repository.javaAPI DocGlassfish v2 API6399Fri May 04 22:35:10 BST 2007com.sun.enterprise.repository

Repository

public class Repository extends Object

Fields Summary
private static Logger
_logger
private Context
ctx
private String
name
Constructors Summary
public Repository(String repositoryName)
Constructor.....

        Properties env = new Properties();
        env.put("java.naming.factory.initial", 
                "com.sun.enterprise.repository.RepositoryInitContextFactory");
        env.put("com.sun.enterprise.repository.name", repositoryName);
	name = repositoryName;
	init(env);
    
public Repository(String repositoryName, String repositoryDir)
Constructor.....

        Properties env = new Properties();
        env.put("java.naming.factory.initial", 
                "com.sun.enterprise.repository.RepositoryInitContextFactory");
        env.put("com.sun.enterprise.repository.name", repositoryName);
        env.put("com.sun.enterprise.repository.dir", repositoryDir);
	name = repositoryName;
	init(env);
    
Methods Summary
public booleanadd(java.lang.String name, java.lang.String value)
Adds a value corresponding to a name within this Repository.

return
A value true indicates that the value was successfully added to the repository.

        try {
            ctx.rebind(name, value);
            // System.out.println("Added " + name + ", " + value);
// START OF IASRI 4660742
	    //if(_logger.isLoggable(Level.FINE))
                 // _logger.log(Level.FINE,"Added " + name + ", " + value);
// END OF IASRI 4660742
            return true;
	} catch (NamingException ne) {
// IASRI 4660742	    ne.printStackTrace();
// START OF IASRI 4660742
             _logger.log(Level.SEVERE,"enterprise.addinrepository_exception",ne);
// END OF IASRI 4660742
            return false;
	}
    
public java.lang.Stringfind(java.lang.String name)
Finds a value corresponding to a name stored within this Repository.

return
A string Value corresponding to the name within the repository or null if no such value exists.

    
       _logger=LogDomains.getLogger(LogDomains.ROOT_LOGGER);
        
        try {
            String value = (String) ctx.lookup(name);
            // System.out.println(name + " is bound to " + value);
// START OF IASRI 4660742
            // _logger.log(Level.FINE,name + " is bound to " + value);
// END OF IASRI 4660742
            return value;
        } catch (Exception e) {
      //      e.printStackTrace();
// START OF IASRI 4660742
            // _logger.log(Level.SEVERE,"enterprise.findinrepository_exception",e);
// END OF IASRI 4660742
            return null;
        }
    
public java.lang.StringgetName()

        return RepositoryContext.getRepositoryName(name);
	
private voidinit(java.util.Properties env)
Initializing the context...

        try {
            ctx = new InitialContext(env);
        } catch (NamingException ne) {
// IASRI 4660742            ne.printStackTrace();
// START OF IASRI 4660742
             _logger.log(Level.SEVERE,"enterprise.naming_exception",ne);
// END OF IASRI 4660742
            ctx = null;
        }
    
public java.lang.String[]keys()

		Vector v = new Vector(10);
		Enumeration e = null;
        try {
            e = ctx.listBindings("");
		} catch (NamingException ne) {
// IASRI 4660742	   		 ne.printStackTrace();
// START OF IASRI 4660742
             _logger.log(Level.SEVERE,"enterprise.naming_exception",ne);
// END OF IASRI 4660742
		}

		while((e != null) && e.hasMoreElements())
		{
			Binding b = (Binding) e.nextElement();
			v.add(b.getName());
		}

		String[] keynames = new String[v.size()];
		v.copyInto(keynames);

		return keynames;
	
public booleanremove(java.lang.String name)

    try {
        ctx.unbind(name);
        // System.out.println("Added " + name + ", " + value);
// START OF IASRI 4660742
	    //if(_logger.isLoggable(Level.FINE))
                 // _logger.log(Level.FINE,"Added " + name + ", " + value);
// END OF IASRI 4660742
        return true;
	} catch (NamingException ne) {
// IASRI 4660742	    ne.printStackTrace();
// START OF IASRI 4660742
             _logger.log(Level.SEVERE,"enterprise.delinrepository_exception",ne);
// END OF IASRI 4660742
        return false;
	}