[jboss-cvs] JBossAS SVN: r97198 - in projects/logging-service-metadata/trunk/src/main: resources/META-INF/schema and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Nov 30 23:23:03 EST 2009
Author: david.lloyd at jboss.com
Date: 2009-11-30 23:23:03 -0500 (Mon, 30 Nov 2009)
New Revision: 97198
Added:
projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/ClassLoaderRegistrationHelper.java
projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/DefineContextMetaData.java
Modified:
projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/LoggingMetaData.java
projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/LoggingMetaDataHelper.java
projects/logging-service-metadata/trunk/src/main/resources/META-INF/schema/jboss-logging_6_0.xsd
Log:
First whack at per-deployment-classloader log context
Added: projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/ClassLoaderRegistrationHelper.java
===================================================================
--- projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/ClassLoaderRegistrationHelper.java (rev 0)
+++ projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/ClassLoaderRegistrationHelper.java 2009-12-01 04:23:03 UTC (rev 97198)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.logging.metadata;
+
+import org.jboss.logmanager.LogContext;
+import org.jboss.logmanager.ClassLoaderLogContextSelector;
+
+/**
+ * A helper class which can be created and managed by the Microcontainer, which registers the associated classloader
+ * with the log context selector.
+ */
+public final class ClassLoaderRegistrationHelper {
+ private ClassLoader classLoader;
+ private LogContext logContext;
+ private ClassLoaderLogContextSelector selector;
+
+ public void start() {
+ selector.registerLogContext(classLoader, logContext);
+ }
+
+ public void stop() {
+ selector.unregisterLogContext(classLoader, logContext);
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public void setClassLoader(final ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+
+ public LogContext getLogContext() {
+ return logContext;
+ }
+
+ public void setLogContext(final LogContext logContext) {
+ this.logContext = logContext;
+ }
+
+ public ClassLoaderLogContextSelector getSelector() {
+ return selector;
+ }
+
+ public void setSelector(final ClassLoaderLogContextSelector selector) {
+ this.selector = selector;
+ }
+}
Added: projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/DefineContextMetaData.java
===================================================================
--- projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/DefineContextMetaData.java (rev 0)
+++ projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/DefineContextMetaData.java 2009-12-01 04:23:03 UTC (rev 97198)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.logging.metadata;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+ at XmlType(name = "defineContextType", propOrder = {})
+public class DefineContextMetaData {
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ @XmlAttribute
+ @XmlJavaTypeAdapter(PropertyReplaceAdapter.class)
+ public void setName(final String name) {
+ this.name = name;
+ }
+}
Modified: projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/LoggingMetaData.java
===================================================================
--- projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/LoggingMetaData.java 2009-12-01 02:10:52 UTC (rev 97197)
+++ projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/LoggingMetaData.java 2009-12-01 04:23:03 UTC (rev 97198)
@@ -51,6 +51,7 @@
private List<AbstractLoggerMetaData> loggerMetaDataList;
private List<AbstractHandlerMetaData> handlerMetaDataList;
private List<InstallHandlerMetaData> installHandlerMetaDataList;
+ private List<DefineContextMetaData> defineContextMetaDataList;
private String context = "system";
public List<AbstractLoggerMetaData> getLoggerMetaDataList() {
@@ -92,6 +93,15 @@
this.installHandlerMetaDataList = installHandlerMetaDataList;
}
+ public List<DefineContextMetaData> getDefineContextMetaDataList() {
+ return defineContextMetaDataList;
+ }
+
+ @XmlElement(name = "define-context")
+ public void setDefineContextMetaDataList(final List<DefineContextMetaData> defineContextMetaDataList) {
+ this.defineContextMetaDataList = defineContextMetaDataList;
+ }
+
public String getContext() {
return context;
}
Modified: projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/LoggingMetaDataHelper.java
===================================================================
--- projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/LoggingMetaDataHelper.java 2009-12-01 02:10:52 UTC (rev 97197)
+++ projects/logging-service-metadata/trunk/src/main/java/org/jboss/logging/metadata/LoggingMetaDataHelper.java 2009-12-01 04:23:03 UTC (rev 97198)
@@ -44,6 +44,7 @@
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
import org.jboss.dependency.spi.ControllerMode;
import org.jboss.logmanager.Logger;
+import org.jboss.logmanager.LogContext;
import org.jboss.logmanager.errormanager.OnlyOnceErrorManager;
import org.jboss.logmanager.filters.AcceptAllFilter;
import org.jboss.logmanager.filters.AllFilter;
@@ -77,6 +78,20 @@
// context should be "system" by default
throw new NullPointerException("context is null");
}
+ final List<DefineContextMetaData> defineContextMetaDataList = loggingMetaData.getDefineContextMetaDataList();
+ if (defineContextMetaDataList != null) for (DefineContextMetaData defineContextMetaData : defineContextMetaDataList) {
+ final String contextName = defineContextMetaData.getName();
+ final BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(getContextName(contextName == null ? context : contextName), LogContext.class.getName());
+ beanMetaDataList.add(builder.getBeanMetaData());
+ }
+ if (! context.equals("system")) {
+ // if it's "system", then nothing special needs to be done.
+ // Otherwise create a bean representing the registration of the deployment unit's classloader with a new log context.
+ final BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(new GetClassLoaderBeanMetaData(getAnonymousName(context, Kind.REGISTRATION), ClassLoaderRegistrationHelper.class.getName()));
+ builder.addPropertyMetaData("logContext", builder.createInject(getContextName(context)));
+ builder.addPropertyMetaData("selector", builder.createInject("JBossLogManagerContextSelectorService"));
+ beanMetaDataList.add(builder.getBeanMetaData());
+ }
final List<AbstractLoggerMetaData> abstractLoggerMetaDataList = loggingMetaData.getLoggerMetaDataList();
if (abstractLoggerMetaDataList != null) for (AbstractLoggerMetaData abstractLoggerMetaData : abstractLoggerMetaDataList) {
createLoggerBeanMetaData(beanMetaDataList, abstractLoggerMetaData, context);
@@ -124,7 +139,7 @@
builder.setFactoryMethod("getLogger");
builder.addConstructorParameter(String.class.getName(), name);
if (abstractLoggerMetaData instanceof LoggerMetaData) {
- builder.addPropertyMetaData("useParentHandlers", ((LoggerMetaData)abstractLoggerMetaData).isUseParentHandlers());
+ builder.addPropertyMetaData("useParentHandlers", Boolean.valueOf(((LoggerMetaData) abstractLoggerMetaData).isUseParentHandlers()));
}
final RefMetaData levelRef = abstractLoggerMetaData.getLevelMetaData();
if (levelRef != null) {
@@ -185,14 +200,14 @@
} else if (handlerMetaData instanceof SizeRotatingFileHandlerMetaData) {
final SizeRotatingFileHandlerMetaData sizeRotatingFileHandlerMetaData = (SizeRotatingFileHandlerMetaData) handlerMetaData;
builder.setBean(SizeRotatingFileHandler.class.getName());
- builder.addPropertyMetaData("maxBackupIndex", sizeRotatingFileHandlerMetaData.getMaxBackupIndex());
+ builder.addPropertyMetaData("maxBackupIndex", Integer.valueOf(sizeRotatingFileHandlerMetaData.getMaxBackupIndex()));
final String sizeString = sizeRotatingFileHandlerMetaData.getRotateSizeString();
- builder.addPropertyMetaData("rotateSize", parseSizeString(sizeString));
+ builder.addPropertyMetaData("rotateSize", Long.valueOf(parseSizeString(sizeString)));
} else {
builder.setBean(FileHandler.class.getName());
}
builder.addConstructorParameter(String.class.getName(), fileHandlerMetaData.getFileName());
- builder.addConstructorParameter(boolean.class.getName(), fileHandlerMetaData.isAppend());
+ builder.addConstructorParameter(boolean.class.getName(), Boolean.valueOf(fileHandlerMetaData.isAppend()));
} else if (handlerMetaData instanceof Log4jAppenderMetaData) {
builder.setBean(Log4jAppenderHandler.class.getName());
} else if (handlerMetaData instanceof NullHandlerMetaData) {
@@ -201,7 +216,7 @@
builder.setStop("close");
builder.setMode(ControllerMode.ON_DEMAND);
// autoflush
- builder.addPropertyMetaData("autoFlush", handlerMetaData.isAutoflush());
+ builder.addPropertyMetaData("autoFlush", Boolean.valueOf(handlerMetaData.isAutoflush()));
// encoding
final String encoding = handlerMetaData.getEncoding();
if (encoding != null) {
@@ -377,7 +392,7 @@
final ReplaceFilterMetaData metaData = (ReplaceFilterMetaData) value;
builder.addConstructorParameter(String.class.getName(), metaData.getPattern());
builder.addConstructorParameter(String.class.getName(), metaData.getReplacement());
- builder.addConstructorParameter(boolean.class.getName(), metaData.isReplaceAll());
+ builder.addConstructorParameter(boolean.class.getName(), Boolean.valueOf(metaData.isReplaceAll()));
final BeanMetaData beanMetaData = builder.getBeanMetaData();
beanMetaDataList.add(beanMetaData);
return beanMetaData;
@@ -392,9 +407,9 @@
final BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(beanName, LevelRangeFilter.class.getName());
final LevelRangeFilterMetaData metaData = (LevelRangeFilterMetaData) value;
builder.addConstructorParameter(Level.class.getName(), getLevelInjectValue(context, metaData.getMinLevel()));
- builder.addConstructorParameter(boolean.class.getName(), metaData.isMinInclusive());
+ builder.addConstructorParameter(boolean.class.getName(), Boolean.valueOf(metaData.isMinInclusive()));
builder.addConstructorParameter(Level.class.getName(), getLevelInjectValue(context, metaData.getMaxLevel()));
- builder.addConstructorParameter(boolean.class.getName(), metaData.isMaxInclusive());
+ builder.addConstructorParameter(boolean.class.getName(), Boolean.valueOf(metaData.isMaxInclusive()));
final BeanMetaData beanMetaData = builder.getBeanMetaData();
beanMetaDataList.add(beanMetaData);
return beanMetaData;
@@ -475,5 +490,6 @@
HANDLER,
FILTER,
LOGGER,
+ REGISTRATION,
}
}
Modified: projects/logging-service-metadata/trunk/src/main/resources/META-INF/schema/jboss-logging_6_0.xsd
===================================================================
--- projects/logging-service-metadata/trunk/src/main/resources/META-INF/schema/jboss-logging_6_0.xsd 2009-12-01 02:10:52 UTC (rev 97197)
+++ projects/logging-service-metadata/trunk/src/main/resources/META-INF/schema/jboss-logging_6_0.xsd 2009-12-01 04:23:03 UTC (rev 97198)
@@ -39,8 +39,8 @@
<xs:annotation>
<xs:documentation>
The logging configuration root type. Contains a list of named handlers, loggers, and formatters for
- this configuration. Use the "context" attribute to define a logging context which is separate from the
- default system context.
+ this configuration. Use the "context" attribute to depend upon a logging context which is separate
+ from the default system context.
</xs:documentation>
</xs:annotation>
<xs:choice minOccurs="0" maxOccurs="unbounded">
@@ -51,8 +51,10 @@
<xs:element name="root-logger" type="rootLoggerType"/>
<!-- install-handlers -->
<xs:element name="install-handler" type="installHandlerType"/>
+ <!-- contexts -->
+ <xs:element name="define-context" type="defineContextType"/>
</xs:choice>
- <xs:attribute name="context" type="xs:string" use="optional" default="system"/>
+ <xs:attribute name="context" type="xs:string" use="optional"/>
</xs:complexType>
<xs:complexType name="refType">
@@ -76,6 +78,18 @@
</xs:sequence>
</xs:complexType>
+ <!-- Log Context -->
+
+ <xs:complexType name="defineContextType">
+ <xs:annotation>
+ <xs:documentation>
+ A named log context. If the name is not specified, the context name of the enclosing
+ "logging" element is used, otherwise a log context of the given name will be created.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="name" type="xs:string" use="optional"/>
+ </xs:complexType>
+
<!-- Loggers -->
<xs:complexType name="loggersType">
More information about the jboss-cvs-commits
mailing list