Skip to content

Commit 41ac366

Browse files
committed
Update with master
2 parents ac844a3 + 7b156fb commit 41ac366

File tree

187 files changed

+4014
-9459
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+4014
-9459
lines changed

core/pom.xml

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
<!--
2+
~ JBoss, Home of Professional Open Source.
3+
~
4+
~ Copyright 2014 Red Hat, Inc., and individual contributors
5+
~ as indicated by the @author tags.
6+
~
7+
~ Licensed under the Apache License, Version 2.0 (the "License");
8+
~ you may not use this file except in compliance with the License.
9+
~ You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing, software
14+
~ distributed under the License is distributed on an "AS IS" BASIS,
15+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
~ See the License for the specific language governing permissions and
17+
~ limitations under the License.
18+
-->
19+
20+
<project xmlns="http://maven.apache.org/POM/4.0.0"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<name>JBoss Log Manager (Core)</name>
27+
<description>An implementation of java.util.logging.LogManager</description>
28+
29+
<artifactId>jboss-logmanager</artifactId>
30+
<packaging>jar</packaging>
31+
32+
<parent>
33+
<groupId>org.jboss.logmanager</groupId>
34+
<artifactId>jboss-logmanager-parent</artifactId>
35+
<version>3.0.0.Final-SNAPSHOT</version>
36+
</parent>
37+
38+
<dependencies>
39+
<dependency>
40+
<groupId>org.jboss.modules</groupId>
41+
<artifactId>jboss-modules</artifactId>
42+
<scope>provided</scope>
43+
<optional>true</optional>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.kohsuke.metainf-services</groupId>
47+
<artifactId>metainf-services</artifactId>
48+
<!-- Optional and provided as this is only a compile-time dependency -->
49+
<optional>true</optional>
50+
<scope>provided</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.wildfly.common</groupId>
54+
<artifactId>wildfly-common</artifactId>
55+
</dependency>
56+
57+
<!-- test dependencies -->
58+
59+
<!-- Used in a test formatter -->
60+
<dependency>
61+
<groupId>javax.json</groupId>
62+
<artifactId>javax.json-api</artifactId>
63+
<scope>test</scope>
64+
</dependency>
65+
<!-- JSON implementation -->
66+
<dependency>
67+
<groupId>org.glassfish</groupId>
68+
<artifactId>javax.json</artifactId>
69+
<scope>test</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>junit</groupId>
73+
<artifactId>junit</artifactId>
74+
<scope>test</scope>
75+
</dependency>
76+
</dependencies>
77+
78+
<build>
79+
<plugins>
80+
<plugin>
81+
<artifactId>maven-compiler-plugin</artifactId>
82+
</plugin>
83+
<plugin>
84+
<artifactId>maven-javadoc-plugin</artifactId>
85+
<configuration>
86+
<doclint>none</doclint>
87+
</configuration>
88+
</plugin>
89+
<plugin>
90+
<artifactId>maven-source-plugin</artifactId>
91+
</plugin>
92+
<plugin>
93+
<artifactId>maven-surefire-plugin</artifactId>
94+
<configuration>
95+
<includes>
96+
<include>**/*Tests.java</include>
97+
</includes>
98+
<argLine>-Djava.util.logging.manager=org.jboss.logmanager.LogManager</argLine>
99+
<systemPropertyVariables>
100+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
101+
</systemPropertyVariables>
102+
<trimStackTrace>false</trimStackTrace>
103+
</configuration>
104+
</plugin>
105+
<plugin>
106+
<artifactId>maven-enforcer-plugin</artifactId>
107+
</plugin>
108+
<!-- Adding OSGI metadata to the JAR without changing the packaging type. -->
109+
<plugin>
110+
<artifactId>maven-jar-plugin</artifactId>
111+
<configuration>
112+
<archive>
113+
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
114+
<manifestEntries>
115+
<Multi-Release>true</Multi-Release>
116+
</manifestEntries>
117+
</archive>
118+
</configuration>
119+
</plugin>
120+
<plugin>
121+
<groupId>org.apache.felix</groupId>
122+
<artifactId>maven-bundle-plugin</artifactId>
123+
<extensions>true</extensions>
124+
<dependencies>
125+
<dependency>
126+
<groupId>biz.aQute.bnd</groupId>
127+
<artifactId>biz.aQute.bndlib</artifactId>
128+
<version>3.5.0</version>
129+
</dependency>
130+
</dependencies>
131+
<configuration>
132+
<instructions>
133+
<_fixupmessages>"Classes found in the wrong directory";is:=warning</_fixupmessages>
134+
<Export-Package>
135+
${project.groupId}.*;version=${project.version};-split-package:=error
136+
</Export-Package>
137+
</instructions>
138+
</configuration>
139+
<executions>
140+
<execution>
141+
<id>bundle-manifest</id>
142+
<phase>process-classes</phase>
143+
<goals>
144+
<goal>manifest</goal>
145+
</goals>
146+
</execution>
147+
</executions>
148+
</plugin>
149+
</plugins>
150+
</build>
151+
152+
<profiles>
153+
<profile>
154+
<id>java9-tests</id>
155+
<activation>
156+
<jdk>[9,</jdk>
157+
</activation>
158+
<build>
159+
<plugins>
160+
<plugin>
161+
<artifactId>maven-compiler-plugin</artifactId>
162+
<executions>
163+
<execution>
164+
<id>test-compile-java9</id>
165+
<phase>test-compile</phase>
166+
<goals>
167+
<goal>testCompile</goal>
168+
</goals>
169+
<configuration>
170+
<release>9</release>
171+
<buildDirectory>${project.build.directory}</buildDirectory>
172+
<compileSourceRoots>${project.basedir}/src/test/java9</compileSourceRoots>
173+
</configuration>
174+
</execution>
175+
</executions>
176+
</plugin>
177+
<plugin>
178+
<artifactId>maven-failsafe-plugin</artifactId>
179+
<configuration>
180+
<systemPropertyVariables>
181+
<java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
182+
</systemPropertyVariables>
183+
</configuration>
184+
<executions>
185+
<execution>
186+
<phase>package</phase>
187+
<goals>
188+
<goal>integration-test</goal>
189+
<goal>verify</goal>
190+
</goals>
191+
</execution>
192+
</executions>
193+
</plugin>
194+
</plugins>
195+
</build>
196+
</profile>
197+
</profiles>
198+
</project>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* JBoss, Home of Professional Open Source.
3+
*
4+
* Copyright 2018 Red Hat, Inc., and individual contributors
5+
* as indicated by the @author tags.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
package org.jboss.logmanager;
21+
22+
/**
23+
* Used to create a {@link LogContextConfigurator}. The {@linkplain #priority() priority} is used to determine which
24+
* factory should be used. The lowest priority factory is used. If two factories have the same priority the second
25+
* factory will not be used. The order of loading the factories for determining priority is done via the
26+
* {@link java.util.ServiceLoader#load(Class, ClassLoader)}.
27+
*
28+
* @author <a href="mailto:[email protected]">James R. Perkins</a>
29+
*/
30+
public interface ConfiguratorFactory {
31+
32+
/**
33+
* Creates the {@link LogContextConfigurator}.
34+
*
35+
* @return the log context configurator
36+
*/
37+
LogContextConfigurator create();
38+
39+
/**
40+
* The priority for the factory which is used to determine which factory should be used to create a
41+
* {@link LogContextConfigurator}. The lowest priority factory will be used.
42+
*
43+
* @return the priority for this factory
44+
*/
45+
int priority();
46+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package org.jboss.logmanager;
2+
3+
import java.util.logging.ErrorManager;
4+
5+
/**
6+
* An extended error manager, which contains additional useful utilities for error managers.
7+
*/
8+
public abstract class ExtErrorManager extends ErrorManager {
9+
10+
/**
11+
* Get the name corresponding to the given error code.
12+
*
13+
* @param code the error code
14+
* @return the corresponding name (not {@code null})
15+
*/
16+
protected String nameForCode(int code) {
17+
switch (code) {
18+
case CLOSE_FAILURE: return "CLOSE_FAILURE";
19+
case FLUSH_FAILURE: return "FLUSH_FAILURE";
20+
case FORMAT_FAILURE: return "FORMAT_FAILURE";
21+
case GENERIC_FAILURE: return "GENERIC_FAILURE";
22+
case OPEN_FAILURE: return "OPEN_FAILURE";
23+
case WRITE_FAILURE: return "WRITE_FAILURE";
24+
default: return "INVALID (" + code + ")";
25+
}
26+
}
27+
28+
public void error(final String msg, final Exception ex, final int code) {
29+
super.error(msg, ex, code);
30+
}
31+
32+
/**
33+
* Convert the given error to a log record which can be published to handler(s) or stored. Care should
34+
* be taken not to publish the log record to a logger that writes to the same handler that produced the error.
35+
*
36+
* @param msg the error message (possibly {@code null})
37+
* @param ex the error exception (possibly {@code null})
38+
* @param code the error code
39+
* @return the log record (not {@code null})
40+
*/
41+
protected ExtLogRecord errorToLogRecord(String msg, Exception ex, int code) {
42+
final ExtLogRecord record = new ExtLogRecord(Level.ERROR, "Failed to publish log record (%s[%d]): %s", ExtLogRecord.FormatStyle.PRINTF, getClass().getName());
43+
final String codeStr = nameForCode(code);
44+
record.setParameters(new Object[] {
45+
codeStr,
46+
Integer.valueOf(code),
47+
msg,
48+
});
49+
record.setThrown(ex);
50+
record.setLoggerName("");
51+
return record;
52+
}
53+
}

src/main/java/org/jboss/logmanager/ExtFormatter.java renamed to core/src/main/java/org/jboss/logmanager/ExtFormatter.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,34 @@
2323
import java.util.MissingResourceException;
2424
import java.util.ResourceBundle;
2525
import java.util.logging.Formatter;
26+
import java.util.logging.Handler;
2627
import java.util.logging.LogRecord;
2728

2829
/**
2930
* A formatter which handles {@link org.jboss.logmanager.ExtLogRecord ExtLogRecord} instances.
3031
*/
3132
public abstract class ExtFormatter extends Formatter {
33+
/**
34+
* Construct a new instance.
35+
*/
36+
public ExtFormatter() {
37+
}
38+
39+
/**
40+
* Wrap an existing formatter with an {@link ExtFormatter}, optionally replacing message formatting with
41+
* the default extended message formatting capability.
42+
*
43+
* @param formatter the formatter to wrap (must not be {@code null})
44+
* @param formatMessages {@code true} to replace message formatting, {@code false} to let the original formatter do it
45+
* @return the extended formatter (not {@code null})
46+
*/
47+
public static ExtFormatter wrap(Formatter formatter, boolean formatMessages) {
48+
if (formatter instanceof ExtFormatter && ! formatMessages) {
49+
return (ExtFormatter) formatter;
50+
} else {
51+
return new WrappedFormatter(formatter, formatMessages);
52+
}
53+
}
3254

3355
/** {@inheritDoc} */
3456
public final String format(final LogRecord record) {
@@ -120,4 +142,34 @@ protected String formatMessageLegacy(LogRecord record) {
120142
protected String formatMessagePrintf(LogRecord record) {
121143
return String.format(record.getMessage(), record.getParameters());
122144
}
145+
146+
static class WrappedFormatter extends ExtFormatter {
147+
private final Formatter formatter;
148+
private final boolean formatMessages;
149+
150+
WrappedFormatter(Formatter formatter, boolean formatMessages) {
151+
this.formatter = formatter;
152+
this.formatMessages = formatMessages;
153+
}
154+
155+
@Override
156+
public String format(ExtLogRecord record) {
157+
return formatter.format(record);
158+
}
159+
160+
@Override
161+
public String formatMessage(LogRecord record) {
162+
return formatMessages ? super.formatMessage(record) : formatter.formatMessage(record);
163+
}
164+
165+
@Override
166+
public String getHead(Handler h) {
167+
return formatter.getHead(h);
168+
}
169+
170+
@Override
171+
public String getTail(Handler h) {
172+
return formatter.getTail(h);
173+
}
174+
}
123175
}

0 commit comments

Comments
 (0)