Пример #1
0
 /**
  * Sets a System property. This is also active in deployment mode because one might want to change
  * a System property at runtime. Synopsis:<br>
  * pw=<i>aPassword</i>&key=<i>someSystemPropertyKey</i>&value=<i>someSystemPropertyValue</i>
  *
  * @return either null when the password is wrong or a new page showing the System properties
  */
 public WOActionResults systemPropertyAction() {
   if (canPerformActionWithPasswordKey(
       "er.extensions.ERXDirectAction.ChangeSystemPropertyPassword")) {
     String key = request().stringFormValueForKey("key");
     ERXResponse r = new ERXResponse();
     if (ERXStringUtilities.stringIsNullOrEmpty(key)) {
       String user = request().stringFormValueForKey("user");
       Properties props = ERXConfigurationManager.defaultManager().defaultProperties();
       if (user != null) {
         System.setProperty("user.name", user);
         props = ERXConfigurationManager.defaultManager().applyConfiguration(props);
       }
       r.appendContentString(ERXProperties.logString(props));
     } else {
       String value = request().stringFormValueForKey("value");
       value = ERXStringUtilities.stringIsNullOrEmpty(value) ? "" : value;
       java.util.Properties p = System.getProperties();
       p.put(key, value);
       System.setProperties(p);
       ERXLogger.configureLoggingWithSystemProperties();
       for (java.util.Enumeration e = p.keys(); e.hasMoreElements(); ) {
         Object k = e.nextElement();
         if (k.equals(key)) {
           r.appendContentString(
               "<b>'" + k + "=" + p.get(k) + "'     <= you changed this</b><br>");
         } else {
           r.appendContentString("'" + k + "=" + p.get(k) + "'<br>");
         }
       }
       r.appendContentString("</body></html>");
     }
     return r;
   }
   return forbiddenResponse();
 }
Пример #2
0
  public ERClientApplication() {
    NSBundle mainBundle =
        NSBundle
            .mainBundle(); // causes the bundle to be loaded and evaluated (will load Properties)
    if (mainBundle == null) {
      throw new IllegalStateException("Main bundle not found");
    }

    userDefaults = Preferences.userNodeForPackage(getClass());

    ERXLogger.configureLoggingWithSystemProperties();
  }
Пример #3
0
 /**
  * Main entry point for getting an Logger for a given name. Calls getLogger to return the instance
  * of Logger from our custom Factory.
  *
  * <p>Note that if the log4j system has not been setup correctly, meaning the LoggerFactory
  * subclass has not been correctly put in place, then RuntimeException will be thrown.
  *
  * @param name to create the logger for
  * @return Logger for the given name.
  */
 public static ERXLogger getERXLogger(String name) {
   Logger logger = ERXLogger.getLogger(name);
   if (logger != null && !(logger instanceof ERXLogger)) {
     ERXLogger.configureLoggingWithSystemProperties();
     logger = ERXLogger.getLogger(name);
   }
   if (logger != null && !(logger instanceof ERXLogger)) {
     throw new RuntimeException(
         "Can't load Logger for \""
             + name
             + "\" because it is not of class ERXLogger but \""
             + logger.getClass().getName()
             + "\". Let your Application class inherit from ERXApplication or call ERXLog4j.configureLogging() statically the first thing in your app. \nAlso check if there is a \"log4j.loggerFactory=er.extensions.Logger$Factory\" line in your properties.");
   }
   return (ERXLogger) logger;
 }