Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.s1.options;
 
 
Options
public class Options {
    private static final Logger LOG = LoggerFactory.getLogger(OptionsStorage.class);
    private static OptionsStorage storage;

    

Returns:
    public static synchronized OptionsStorage getStorage() {
        if(==null){
            String cls = getParameter("OptionsStorage");
            try {
                if(!Objects.isNullOrEmpty(cls))
                     = (OptionsStorage)Class.forName(cls).newInstance();
            } catch (Exception e) {
                if(.isDebugEnabled())
                    .debug("Cannot instantiate OptionsStorage class "+cls+": "+e.getMessage());
            }
            if(==null)
                 = new OptionsStorage();
            .info("OptionsStorage: ("+cls+") initialized");
        }
        return ;
    }

    

Parameters:
storage
    public static synchronized void setStorage(OptionsStorage storage) {
        . = storage;
    }

    

Parameters:
name
Returns:
    static String getParameter(String name){
        String r = null;
        //then try system property
        if(!Objects.isNullOrEmpty(System.getProperty("s1."+name)))
            r = System.getProperty("s1."+name);
        //then try jndi
        if(r==null){
            try {
                Context initCtx = new InitialContext();
                Context envCtx = (ContextinitCtx.lookup("java:comp/env");
                r = (StringenvCtx.lookup("s1."+name);
            } catch (Exception e) {
            }
        }
        if(.isDebugEnabled())
            .debug("Read parameter "+name+": "+r);
        return r;
    }
New to GrepCode? Check out our FAQ X