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


Java OptionConverter.instantiateByClassName方法代码示例

本文整理汇总了Java中org.apache.log4j.helpers.OptionConverter.instantiateByClassName方法的典型用法代码示例。如果您正苦于以下问题:Java OptionConverter.instantiateByClassName方法的具体用法?Java OptionConverter.instantiateByClassName怎么用?Java OptionConverter.instantiateByClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.log4j.helpers.OptionConverter的用法示例。


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

示例1: invoke

import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的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

示例2: addRenderer

import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
/**
    Add a renderer to a hierarchy passed as parameter.
 */
 static
 public
 void addRenderer(RendererSupport repository, String renderedClassName,
	   String renderingClassName) {
   LogLog.debug("Rendering class: ["+renderingClassName+"], Rendered class: ["+
	 renderedClassName+"].");
   ObjectRenderer renderer = (ObjectRenderer)
            OptionConverter.instantiateByClassName(renderingClassName,
					    ObjectRenderer.class,
					    null);
   if(renderer == null) {
     LogLog.error("Could not instantiate renderer ["+renderingClassName+"].");
     return;
   } else {
     try {
Class renderedClass = Loader.loadClass(renderedClassName);
repository.setRenderer(renderedClass, renderer);
     } catch(ClassNotFoundException e) {
LogLog.error("Could not find class ["+renderedClassName+"].", e);
     }
   }
 }
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:26,代码来源:RendererMap.java

示例3: configureLoggerFactory

import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
/**
   Check the provided <code>Properties</code> object for a
   {@link org.apache.log4j.spi.LoggerFactory LoggerFactory}
   entry specified by {@link #LOGGER_FACTORY_KEY}.  If such an entry
   exists, an attempt is made to create an instance using the default
   constructor.  This instance is used for subsequent Category creations
   within this configurator.

   @see #parseCatsAndRenderers
 */
protected void configureLoggerFactory(Properties props) {
  String factoryClassName = OptionConverter.findAndSubst(LOGGER_FACTORY_KEY,
					   props);
  if(factoryClassName != null) {
    LogLog.debug("Setting category factory to ["+factoryClassName+"].");
    loggerFactory = (LoggerFactory)
         OptionConverter.instantiateByClassName(factoryClassName,
					 LoggerFactory.class,
					 loggerFactory);
    PropertySetter.setProperties(loggerFactory, props, FACTORY_PREFIX + ".");
  }
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:23,代码来源:PropertyConfigurator.java

示例4: addAppender

import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
void addAppender(String appenderClass, String appenderName) {
  cat.debug("addAppender called with "+appenderClass+", "+appenderName);
  Appender appender = (Appender)
     OptionConverter.instantiateByClassName(appenderClass,
			      org.apache.log4j.Appender.class,
			      null);
  appender.setName(appenderName);
  logger.addAppender(appender);

  //appenderMBeanRegistration();

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:13,代码来源:LoggerDynamicMBean.java

示例5: parseFilters

import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
/**
    Used internally to parse a filter element.
  */
 protected
 void parseFilters(Element element, Appender appender) {
   String clazz = subst(element.getAttribute(CLASS_ATTR));
   Filter filter = (Filter) OptionConverter.instantiateByClassName(clazz,
                                               Filter.class, null);
   
   if(filter != null) {
     PropertySetter propSetter = new PropertySetter(filter);
     NodeList children = element.getChildNodes();
     final int length 	= children.getLength();

     for (int loop = 0; loop < length; loop++) {
Node currentNode = children.item(loop);
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
  Element currentElement = (Element) currentNode;
  String tagName = currentElement.getTagName();
  if(tagName.equals(PARAM_TAG)) {
           setParameter(currentElement, propSetter);
  } else {
           quietParseUnrecognizedElement(filter, currentElement, props);
     }
}
     }
     propSetter.activate();
     LogLog.debug("Adding filter of type ["+filter.getClass()
	   +"] to appender named ["+appender.getName()+"].");
     appender.addFilter(filter);
   }    
 }
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:33,代码来源:DOMConfigurator.java

示例6: parseCategoryFactory

import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
/**
    Used internally to parse the category factory element.
 */
 protected
 void parseCategoryFactory(Element factoryElement) {
   String className = subst(factoryElement.getAttribute(CLASS_ATTR));

   if(EMPTY_STR.equals(className)) {
     LogLog.error("Category Factory tag " + CLASS_ATTR + " attribute not found.");
     LogLog.debug("No Category Factory configured.");
   }
   else {
     LogLog.debug("Desired category factory: ["+className+']');
     Object factory = OptionConverter.instantiateByClassName(className,
                                                                LoggerFactory.class, 
                                                                null);
     if (factory instanceof LoggerFactory) {
         catFactory = (LoggerFactory) factory;
     } else {
         LogLog.error("Category Factory class " + className + " does not implement org.apache.log4j.LoggerFactory");
     }
     PropertySetter propSetter = new PropertySetter(factory);

     Element  currentElement = null;
     Node     currentNode    = null;
     NodeList children       = factoryElement.getChildNodes();
     final int length        = children.getLength();

     for (int loop=0; loop < length; loop++) {
       currentNode = children.item(loop);
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
  currentElement = (Element)currentNode;
  if (currentElement.getTagName().equals(PARAM_TAG)) {
    setParameter(currentElement, propSetter);
  } else {
          quietParseUnrecognizedElement(factory, currentElement, props);
     }
}
     }
   }
 }
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:42,代码来源:DOMConfigurator.java

示例7: parseElement

import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
/**
 * Creates an object and processes any nested param elements
 * but does not call activateOptions.  If the class also supports
 * UnrecognizedElementParser, the parseUnrecognizedElement method
 * will be call for any child elements other than param.
 *
 * @param element       element, may not be null.
 * @param props         properties
 * @param expectedClass interface or class expected to be implemented
 *                      by created class
 * @return created class or null.
 * @throws Exception thrown if the contain object should be abandoned.
 * @since 1.2.15
 */
public static Object parseElement(final Element element,
                                         final Properties props,
                                         final Class expectedClass) throws Exception {
    String clazz = subst(element.getAttribute("class"), props);
    Object instance = OptionConverter.instantiateByClassName(clazz,
            expectedClass, null);

    if (instance != null) {
        PropertySetter propSetter = new PropertySetter(instance);
        NodeList children = element.getChildNodes();
        final int length = children.getLength();

        for (int loop = 0; loop < length; loop++) {
            Node currentNode = children.item(loop);
            if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
                Element currentElement = (Element) currentNode;
                String tagName = currentElement.getTagName();
                if (tagName.equals("param")) {
                    setParameter(currentElement, propSetter, props);
                } else {
                     parseUnrecognizedElement(instance, currentElement, props);
                }
            }
        }
        return instance;
    }
    return null;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:43,代码来源:DOMConfigurator.java

示例8: setEvaluatorClass

import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
/**
   The <b>EvaluatorClass</b> option takes a string value
   representing the name of the class implementing the {@link
   TriggeringEventEvaluator} interface. A corresponding object will
   be instantiated and assigned as the triggering event evaluator
   for the SMTPAppender.
 */
public
void setEvaluatorClass(String value) {
    evaluator = (TriggeringEventEvaluator)
              OptionConverter.instantiateByClassName(value,
			   TriggeringEventEvaluator.class,
				       evaluator);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:15,代码来源:SMTPAppender.java

示例9: convertArg

import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
/**
   Convert <code>val</code> a String parameter to an object of a
   given type.
*/
protected
Object convertArg(String val, Class type) {
  if(val == null)
    return null;

  String v = val.trim();
  if (String.class.isAssignableFrom(type)) {
    return val;
  } else if (Integer.TYPE.isAssignableFrom(type)) {
    return new Integer(v);
  } else if (Long.TYPE.isAssignableFrom(type)) {
    return new Long(v);
  } else if (Boolean.TYPE.isAssignableFrom(type)) {
    if ("true".equalsIgnoreCase(v)) {
      return Boolean.TRUE;
    } else if ("false".equalsIgnoreCase(v)) {
      return Boolean.FALSE;
    }
  } else if (Priority.class.isAssignableFrom(type)) {
    return OptionConverter.toLevel(v, (Level) Level.DEBUG);
  } else if (ErrorHandler.class.isAssignableFrom(type)) {
    return OptionConverter.instantiateByClassName(v, 
 ErrorHandler.class, null);
  }
  return null;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:31,代码来源:PropertySetter.java

示例10: setFileRollEventListener

import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
/**
 * @param className
 *            The name of the class that implements the
 *            {@link FileRollEventListener} interface; implementors must be
 *            declared public and have a default constructor.
 */
public void setFileRollEventListener(String className) {
	if (className != null) {
		className = className.trim();
		final FileRollEventListener fileRollEventListener = (FileRollEventListener) OptionConverter.instantiateByClassName(className, FileRollEventListener.class, null);
		if (fileRollEventListener != null) {
			this.initGuestFileRollEventListener(fileRollEventListener);
		}
	}
}
 
开发者ID:foundation-runtime,项目名称:logging,代码行数:16,代码来源:FoundationFileRollingAppender.java

示例11: setLogFileScavenger

import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
public void setLogFileScavenger(String className) {
	if (className != null) {
		className = className.trim();
		final LogFileScavenger logFileScavenger = (LogFileScavenger) OptionConverter.instantiateByClassName(className, LogFileScavenger.class, null);
		if (logFileScavenger != null) {
			this.initLogFileScavenger(logFileScavenger);
		}
	}
}
 
开发者ID:foundation-runtime,项目名称:logging,代码行数:10,代码来源:FoundationFileRollingAppender.java

示例12: setEvaluatorClass

import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
/**
 * The <b>EvaluatorClass</b> option takes a string value representing the
 * name of the class implementing the {@link TriggeringEventEvaluator}
 * interface. A corresponding object will be instantiated and assigned as
 * the triggering event evaluator for the SMTPAppender.
 */
public void setEvaluatorClass(final String value)
{
    evaluator =
        (TriggeringEventEvaluator) OptionConverter.instantiateByClassName(
            value, TriggeringEventEvaluator.class, evaluator);
}
 
开发者ID:AthabascaUniversity,项目名称:au-log4j,代码行数:13,代码来源:SMTPAppender.java

示例13: parseErrorHandler

import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
/**
    Used internally to parse an {@link ErrorHandler} element.
  */
 protected
 void parseErrorHandler(Element element, Appender appender) {
   ErrorHandler eh = (ErrorHandler) OptionConverter.instantiateByClassName(
                                      subst(element.getAttribute(CLASS_ATTR)),
                                      org.apache.log4j.spi.ErrorHandler.class, 
				       null);
   
   if(eh != null) {
     eh.setAppender(appender);

     PropertySetter propSetter = new PropertySetter(eh);
     NodeList children = element.getChildNodes();
     final int length 	= children.getLength();

     for (int loop = 0; loop < length; loop++) {
Node currentNode = children.item(loop);
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
  Element currentElement = (Element) currentNode;
  String tagName = currentElement.getTagName();
  if(tagName.equals(PARAM_TAG)) {
           setParameter(currentElement, propSetter);
  } else if(tagName.equals(APPENDER_REF_TAG)) {
    eh.setBackupAppender(findAppenderByReference(currentElement));
  } else if(tagName.equals(LOGGER_REF)) {
    String loggerName = currentElement.getAttribute(REF_ATTR);	    
    Logger logger = (catFactory == null) ? repository.getLogger(loggerName)
               : repository.getLogger(loggerName, catFactory);
    eh.setLogger(logger);
  } else if(tagName.equals(ROOT_REF)) {
    Logger root = repository.getRootLogger();
    eh.setLogger(root);
  } else {
         quietParseUnrecognizedElement(eh, currentElement, props);
     }
}
     }
     propSetter.activate();
     appender.setErrorHandler(eh);
   }
 }
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:44,代码来源:DOMConfigurator.java

示例14: setEvaluatorClass

import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
/**
 * The <b>EvaluatorClass </b> option takes a string value representing the name of the class implementing the {@linkTriggeringEventEvaluator} interface. A
 * corresponding object will be instantiated and assigned as the triggering event evaluator for the SMTPAppender.
 */
public void setEvaluatorClass(final String value) {
    evaluator = (TriggeringEventEvaluator) OptionConverter.instantiateByClassName(value, TriggeringEventEvaluator.class, evaluator);
}
 
开发者ID:huihoo,项目名称:olat,代码行数:8,代码来源:IMAppender.java


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