当前位置: 首页>>代码示例>>Java>>正文


Java OptionHandler类代码示例

本文整理汇总了Java中org.apache.log4j.spi.OptionHandler的典型用法代码示例。如果您正苦于以下问题:Java OptionHandler类的具体用法?Java OptionHandler怎么用?Java OptionHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OptionHandler类属于org.apache.log4j.spi包,在下文中一共展示了OptionHandler类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: activateOptions

import org.apache.log4j.spi.OptionHandler; //导入依赖的package包/类
/**
   Activate the specified options, such as the smtp host, the
   recipient, from, etc. */
public
void activateOptions() {
  Session session = createSession();
  msg = new MimeMessage(session);

   try {
      addressMessage(msg);
      if(subject != null) {
      msg.setSubject(subject);
   }
   } catch(MessagingException e) {
     LogLog.error("Could not activate SMTPAppender options.", e );
   }

   if (evaluator instanceof OptionHandler) {
       ((OptionHandler) evaluator).activateOptions();
   }
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:22,代码来源:SMTPAppender.java

示例2: activateOptions

import org.apache.log4j.spi.OptionHandler; //导入依赖的package包/类
public
void activateOptions() {
    super.activateOptions();
    Session session = createSession();
    msg = new MimeMessage(session);
    try {
        addressMessage(msg);
        if(subject != null) {
            try {
                msg.setSubject(MimeUtility.encodeText(subject, "UTF-8", null));
            } catch(UnsupportedEncodingException ex) {
                LogLog.error("Unable to encode SMTP subject", ex);
            }
        }
    } catch(MessagingException e) {
        LogLog.error("Could not activate SMTPAppender options.", e );
    }

    if (evaluator!=null && evaluator instanceof OptionHandler) {
        ((OptionHandler) evaluator).activateOptions();
    }
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:23,代码来源:EmailAppender.java

示例3: parseUnrecognizedElement

import org.apache.log4j.spi.OptionHandler; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public boolean parseUnrecognizedElement(final Element element,
                                        final Properties props) throws Exception {
    final String nodeName = element.getNodeName();
    if ("rewritePolicy".equals(nodeName)) {
        Object rewritePolicy =
                org.apache.log4j.xml.DOMConfigurator.parseElement(
                        element, props, RewritePolicy.class);
        if (rewritePolicy != null) {
            if (rewritePolicy instanceof OptionHandler) {
                ((OptionHandler) rewritePolicy).activateOptions();
            }
            this.setRewritePolicy((RewritePolicy) rewritePolicy);
        }
        return true;
    }
    return false;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:21,代码来源:RewriteAppender.java

示例4: invoke

import org.apache.log4j.spi.OptionHandler; //导入依赖的package包/类
public
Object invoke(String operationName, Object params[], String signature[])
  throws MBeanException,
  ReflectionException {

  if(operationName.equals("activateOptions") &&
                   appender instanceof OptionHandler) {
    OptionHandler oh = (OptionHandler) appender;
    oh.activateOptions();
    return "Options activated.";
  } else if (operationName.equals("setLayout")) {
    Layout layout = (Layout) OptionConverter.instantiateByClassName((String)
						      params[0],
						      Layout.class,
						      null);
    appender.setLayout(layout);
    registerLayoutMBean(layout);
  }
  return null;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:21,代码来源:AppenderDynamicMBean.java

示例5: activateOptions

import org.apache.log4j.spi.OptionHandler; //导入依赖的package包/类
/**
   Activate the specified options, such as the smtp host, the
   recipient, from, etc. */
public
void activateOptions() {
  Session session = createSession();
  msg = new MimeMessage(session);

   try {
      addressMessage(msg);
      if(subject != null) {
         try {
              msg.setSubject(MimeUtility.encodeText(subject, "UTF-8", null));
         } catch(UnsupportedEncodingException ex) {
              LogLog.error("Unable to encode SMTP subject", ex);
         }
      }
   } catch(MessagingException e) {
     LogLog.error("Could not activate SMTPAppender options.", e );
   }

   if (evaluator instanceof OptionHandler) {
       ((OptionHandler) evaluator).activateOptions();
   }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:26,代码来源:SMTPAppender.java

示例6: invoke

import org.apache.log4j.spi.OptionHandler; //导入依赖的package包/类
public
Object invoke(String operationName, Object params[], String signature[])
  throws MBeanException,
  ReflectionException {

  if(operationName.equals("activateOptions") &&
                   layout instanceof OptionHandler) {
    OptionHandler oh = (OptionHandler) layout;
    oh.activateOptions();
    return "Options activated.";
  }
  return null;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:14,代码来源:LayoutDynamicMBean.java

示例7: activateOptions

import org.apache.log4j.spi.OptionHandler; //导入依赖的package包/类
public
void activateOptions() {
    super.activateOptions();
    if(datePattern != null && fileName != null) {
        now.setTime(System.currentTimeMillis());
        sdf = new SimpleDateFormat(datePattern);
        int type = computeCheckPeriod();
        printPeriodicity(type);
        rc.setType(type);
        File file = new File(fileName);
        scheduledFilename = fileName+sdf.format(new Date(file.lastModified()));

    } else {
        LogLog.error("Either File or DatePattern options are not set for appender ["
                +name+"].");
    }

    Session session = createSession();
    msg = new MimeMessage(session);

    try {
        addressMessage(msg);
        if(subject != null) {
            try {
                msg.setSubject(MimeUtility.encodeText(subject, "UTF-8", null));
            } catch(UnsupportedEncodingException ex) {
                LogLog.error("Unable to encode SMTP subject", ex);
            }
        }
    } catch(MessagingException e) {
        LogLog.error("Could not activate SMTPAppender options.", e );
    }

    if (evaluator!=null && evaluator instanceof OptionHandler) {
        ((OptionHandler) evaluator).activateOptions();
    }
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:38,代码来源:EmailDailyRollingFileAppender.java

示例8: activate

import org.apache.log4j.spi.OptionHandler; //导入依赖的package包/类
/**
 * Activates the appender only if it's an {@link OptionHandler option handler}.
 */
public void activate() {
    if (appender instanceof OptionHandler) {
        ((OptionHandler) appender).activateOptions();
        if (LoggingLogger.ROOT_LOGGER.isDebugEnabled()) {
            LoggingLogger.ROOT_LOGGER.debugf("Invoking OptionHandler.activateOptions() on appender %s (%s)", appender.getName(), appender.getClass().getCanonicalName());
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:12,代码来源:Log4jAppenderHandler.java

示例9: activateOptions

import org.apache.log4j.spi.OptionHandler; //导入依赖的package包/类
/**
 * Activate the specified options, such as the smtp host, the recipient,
 * from, etc.
 */
public void activateOptions()
{
    super.activateOptions();
    final Session session = createSession();
    msg = new MimeMessage(session);

    if (evaluator instanceof OptionHandler)
    {
        ((OptionHandler) evaluator).activateOptions();
    }
}
 
开发者ID:AthabascaUniversity,项目名称:au-log4j,代码行数:16,代码来源:SMTPAppender.java

示例10: parseAppender

import org.apache.log4j.spi.OptionHandler; //导入依赖的package包/类
Appender parseAppender(Properties props, String appenderName) {
   Appender appender = registryGet(appenderName);
   if((appender != null)) {
     LogLog.debug("Appender \"" + appenderName + "\" was already parsed.");
     return appender;
   }
   // Appender was not previously initialized.
   String prefix = APPENDER_PREFIX + appenderName;
   String layoutPrefix = prefix + ".layout";

   appender = (Appender) OptionConverter.instantiateByKey(props, prefix,
				      org.apache.log4j.Appender.class,
				      null);
   if(appender == null) {
     LogLog.error(
             "Could not instantiate appender named \"" + appenderName+"\".");
     return null;
   }
   appender.setName(appenderName);

   if(appender instanceof OptionHandler) {
     if(appender.requiresLayout()) {
Layout layout = (Layout) OptionConverter.instantiateByKey(props,
							  layoutPrefix,
							  Layout.class,
							  null);
if(layout != null) {
  appender.setLayout(layout);
  LogLog.debug("Parsing layout options for \"" + appenderName +"\".");
  //configureOptionHandler(layout, layoutPrefix + ".", props);
         PropertySetter.setProperties(layout, props, layoutPrefix + ".");
  LogLog.debug("End of parsing for \"" + appenderName +"\".");
}
     }
     //configureOptionHandler((OptionHandler) appender, prefix + ".", props);
     PropertySetter.setProperties(appender, props, prefix + ".");
     LogLog.debug("Parsed \"" + appenderName +"\" options.");
   }
   registryPut(appender);
   return appender;
 }
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:42,代码来源:PropertyConfigurator.java

示例11: activate

import org.apache.log4j.spi.OptionHandler; //导入依赖的package包/类
public
void activate() {
  if (obj instanceof OptionHandler) {
    ((OptionHandler) obj).activateOptions();
  }
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:7,代码来源:PropertySetter.java

示例12: parseAppender

import org.apache.log4j.spi.OptionHandler; //导入依赖的package包/类
Appender parseAppender(Properties props, String appenderName) {
   Appender appender = registryGet(appenderName);
   if((appender != null)) {
     LogLog.debug("Appender \"" + appenderName + "\" was already parsed.");
     return appender;
   }
   // Appender was not previously initialized.
   String prefix = APPENDER_PREFIX + appenderName;
   String layoutPrefix = prefix + ".layout";

   appender = (Appender) OptionConverter.instantiateByKey(props, prefix,
				      org.apache.log4j.Appender.class,
				      null);
   if(appender == null) {
     LogLog.error(
             "Could not instantiate appender named \"" + appenderName+"\".");
     return null;
   }
   appender.setName(appenderName);

   if(appender instanceof OptionHandler) {
     if(appender.requiresLayout()) {
Layout layout = (Layout) OptionConverter.instantiateByKey(props,
							  layoutPrefix,
							  Layout.class,
							  null);
if(layout != null) {
  appender.setLayout(layout);
  LogLog.debug("Parsing layout options for \"" + appenderName +"\".");
  //configureOptionHandler(layout, layoutPrefix + ".", props);
         PropertySetter.setProperties(layout, props, layoutPrefix + ".");
  LogLog.debug("End of parsing for \"" + appenderName +"\".");
}
     }
     final String errorHandlerPrefix = prefix + ".errorhandler";
     String errorHandlerClass = OptionConverter.findAndSubst(errorHandlerPrefix, props);
     if (errorHandlerClass != null) {
   		ErrorHandler eh = (ErrorHandler) OptionConverter.instantiateByKey(props,
				  errorHandlerPrefix,
				  ErrorHandler.class,
				  null);
   		if (eh != null) {
   			  appender.setErrorHandler(eh);
   			  LogLog.debug("Parsing errorhandler options for \"" + appenderName +"\".");
   			  parseErrorHandler(eh, errorHandlerPrefix, props, repository);
   			  final Properties edited = new Properties();
   			  final String[] keys = new String[] { 
   					  errorHandlerPrefix + "." + ROOT_REF,
   					  errorHandlerPrefix + "." + LOGGER_REF,
   					  errorHandlerPrefix + "." + APPENDER_REF_TAG
   			  };
   			  for(Iterator iter = props.entrySet().iterator();iter.hasNext();) {
   				  Map.Entry entry = (Map.Entry) iter.next();
   				  int i = 0;
   				  for(; i < keys.length; i++) {
   					  if(keys[i].equals(entry.getKey())) break;
   				  }
   				  if (i == keys.length) {
   					  edited.put(entry.getKey(), entry.getValue());
   				  }
   			  }
   		      PropertySetter.setProperties(eh, edited, errorHandlerPrefix + ".");
   			  LogLog.debug("End of errorhandler parsing for \"" + appenderName +"\".");
   		}
   	  
     }
     //configureOptionHandler((OptionHandler) appender, prefix + ".", props);
     PropertySetter.setProperties(appender, props, prefix + ".");
     LogLog.debug("Parsed \"" + appenderName +"\" options.");
   }
   parseAppenderFilters(props, appenderName, appender);
   registryPut(appender);
   return appender;
 }
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:75,代码来源:PropertyConfigurator.java


注:本文中的org.apache.log4j.spi.OptionHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。