/**
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();
}
}
java类org.apache.log4j.spi.OptionHandler的实例源码
SMTPAppender.java 文件源码
项目:cacheonix-core
阅读 25
收藏 0
点赞 0
评论 0
EmailAppender.java 文件源码
项目:log4j-collector
阅读 24
收藏 0
点赞 0
评论 0
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();
}
}
RewriteAppender.java 文件源码
项目:daq-eclipse
阅读 23
收藏 0
点赞 0
评论 0
/**
* {@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;
}
AppenderDynamicMBean.java 文件源码
项目:daq-eclipse
阅读 23
收藏 0
点赞 0
评论 0
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;
}
SMTPAppender.java 文件源码
项目:daq-eclipse
阅读 30
收藏 0
点赞 0
评论 0
/**
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();
}
}
AppenderDynamicMBean.java 文件源码
项目:nabs
阅读 22
收藏 0
点赞 0
评论 0
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;
}
LayoutDynamicMBean.java 文件源码
项目:cacheonix-core
阅读 24
收藏 0
点赞 0
评论 0
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;
}
AppenderDynamicMBean.java 文件源码
项目:cacheonix-core
阅读 23
收藏 0
点赞 0
评论 0
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;
}
EmailDailyRollingFileAppender.java 文件源码
项目:log4j-collector
阅读 22
收藏 0
点赞 0
评论 0
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();
}
}
LayoutDynamicMBean.java 文件源码
项目:daq-eclipse
阅读 28
收藏 0
点赞 0
评论 0
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;
}
LayoutDynamicMBean.java 文件源码
项目:nabs
阅读 22
收藏 0
点赞 0
评论 0
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;
}
Log4jAppenderHandler.java 文件源码
项目:wildfly-core
阅读 29
收藏 0
点赞 0
评论 0
/**
* 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());
}
}
}
SMTPAppender.java 文件源码
项目:au-log4j
阅读 28
收藏 0
点赞 0
评论 0
/**
* 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();
}
}
PropertyConfigurator.java 文件源码
项目:cacheonix-core
阅读 27
收藏 0
点赞 0
评论 0
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;
}
PropertySetter.java 文件源码
项目:cacheonix-core
阅读 24
收藏 0
点赞 0
评论 0
public
void activate() {
if (obj instanceof OptionHandler) {
((OptionHandler) obj).activateOptions();
}
}
PropertyConfigurator.java 文件源码
项目:daq-eclipse
阅读 25
收藏 0
点赞 0
评论 0
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;
}
PropertySetter.java 文件源码
项目:daq-eclipse
阅读 20
收藏 0
点赞 0
评论 0
public
void activate() {
if (obj instanceof OptionHandler) {
((OptionHandler) obj).activateOptions();
}
}
PropertyConfigurator.java 文件源码
项目:nabs
阅读 32
收藏 0
点赞 0
评论 0
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;
}
PropertySetter.java 文件源码
项目:nabs
阅读 24
收藏 0
点赞 0
评论 0
public
void activate() {
if (obj instanceof OptionHandler) {
((OptionHandler) obj).activateOptions();
}
}