com.resilientedge.util.prefs
Class XMLPrefsContext

java.lang.Object
  |
  +--com.resilientedge.util.naming.AbstractCtx
        |
        +--com.resilientedge.util.naming.AbstractFederatedCtx
              |
              +--com.resilientedge.util.naming.FederatedHierCtx
                    |
                    +--com.resilientedge.util.prefs.XMLPrefsContext
All Implemented Interfaces:
javax.naming.Context, ContextAncestors, javax.naming.event.EventContext

public class XMLPrefsContext
extends FederatedHierCtx

Preferences is used to get application configuration parameters. Preferences supplied several methods to handle type conversion of the parameter requested. A default parameter may also be supplied for cases where the parameter requested is not found or there is some other error.

Missing parameters and type conversion failures will throw a PreferencesException except where a default is supplied in which case the default will be returned.

Call getInstance() to get an instance of Preferences.

Example:


  String myValue = Preferences.getInstance().getValueAsString("user.email.address");
  

This class requires a Context to be bound to the ApplicationCtx called "preference".

Author:
jgardner

Fields inherited from class com.resilientedge.util.naming.FederatedHierCtx
bindings_, nameParser_
 
Fields inherited from interface javax.naming.event.EventContext
OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE
 
Fields inherited from interface javax.naming.Context
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES
 
Constructor Summary
XMLPrefsContext(javax.naming.Context parent, java.util.Hashtable env)
           
XMLPrefsContext(java.lang.String XMLFileName)
          Use getInstance() to get an instance.
 
Method Summary
protected  javax.naming.Context createCtx(javax.naming.Context parent, java.util.Hashtable env)
           
protected  javax.naming.Context createCtx(javax.naming.Context parent, java.lang.String name, java.util.Hashtable env)
           
protected  javax.naming.NameParser getNameParser()
          Get the local NameParser.
 void load(java.lang.String XMLFileName)
           
static void main(java.lang.String[] args)
          The main program for the XMLPrefsContext class
 void store(java.lang.String XMLFileName)
           
 
Methods inherited from class com.resilientedge.util.naming.FederatedHierCtx
bind_internal, bind_nns, cloneCtx, createSubcontext, destroySubcontext, getNameParser_internal, getNameParser_nns, list_internal, list_nns, listBindings_internal, listBindings_nns, lookup_internal, lookup_nns, lookupLink, parseNameComponents, rebind_internal, rebind_nns, rename_internal, rename_nns, unbind_internal, unbind_nns
 
Methods inherited from class com.resilientedge.util.naming.AbstractFederatedCtx
bind, composeName, fillInCPE, getNameParser, isAllEmpty, list, listBindings, lookup, parseFederatedNameComponents, processJunction_nns, rebind, rename, resolveIntermediate_nns, resolveIntermediate_nns, unbind
 
Methods inherited from class com.resilientedge.util.naming.AbstractCtx
addNamingListener, addNamingListener, addToEnvironment, bind, close, composeName, createSubcontext, destroySubcontext, fireObjectChangeEvent, getEnvironment, getNameInNamespace, getNameParser, getParentContext, getRootContext, list, listBindings, lookup, lookupLink, rebind, removeFromEnvironment, removeNamingListener, rename, setParentContext, targetMustExist, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLPrefsContext

public XMLPrefsContext(java.lang.String XMLFileName)
                throws javax.naming.NamingException,
                       java.io.FileNotFoundException,
                       java.io.IOException,
                       XmlMappingException
Use getInstance() to get an instance.
Parameters:
XMLFileName - Parameter Description
Throws:
javax.naming.NamingException - Exception Description
java.io.FileNotFoundException - Exception Description
java.io.IOException - Exception Description
XmlMappingException - Exception Description

XMLPrefsContext

public XMLPrefsContext(javax.naming.Context parent,
                       java.util.Hashtable env)
                throws javax.naming.NamingException
Parameters:
parent - Parameter Description
env - Parameter Description
Throws:
javax.naming.NamingException - Exception Description
Method Detail

load

public void load(java.lang.String XMLFileName)
          throws javax.naming.NamingException,
                 java.io.FileNotFoundException,
                 java.io.IOException,
                 XmlMappingException
Parameters:
XMLFileName - Parameter Description
Throws:
javax.naming.NamingException - Exception Description
java.io.FileNotFoundException - Exception Description
java.io.IOException - Exception Description
XmlMappingException - Exception Description

store

public void store(java.lang.String XMLFileName)
           throws javax.naming.NamingException,
                  java.io.FileNotFoundException,
                  java.io.IOException,
                  XmlMappingException
Parameters:
XMLFileName - Parameter Description
Throws:
javax.naming.NamingException - Exception Description
java.io.FileNotFoundException - Exception Description
java.io.IOException - Exception Description
XmlMappingException - Exception Description

main

public static void main(java.lang.String[] args)
The main program for the XMLPrefsContext class
Parameters:
args - The command line arguments

getNameParser

protected javax.naming.NameParser getNameParser()
                                         throws javax.naming.NamingException
Description copied from class: FederatedHierCtx
Get the local NameParser.
Overrides:
getNameParser in class FederatedHierCtx
Returns:
The NameParser value
Throws:
javax.naming.NamingException - Exception Description

createCtx

protected javax.naming.Context createCtx(javax.naming.Context parent,
                                         java.util.Hashtable env)
                                  throws javax.naming.NamingException
Parameters:
parent - Parameter Description
env - Parameter Description
Returns:
Returned Value Description
Throws:
javax.naming.NamingException - Exception Description

createCtx

protected javax.naming.Context createCtx(javax.naming.Context parent,
                                         java.lang.String name,
                                         java.util.Hashtable env)
                                  throws javax.naming.NamingException
Overrides:
createCtx in class FederatedHierCtx
Parameters:
parent - Parameter Description
name - Parameter Description
env - Parameter Description
Returns:
Returned Value Description
Throws:
javax.naming.NamingException - Exception Description


Copyright © 2001 Resilient Edge, Inc. All Rights Reserved.