Author: alessio.soldano(a)jboss.com
Date: 2012-09-18 08:52:43 -0400 (Tue, 18 Sep 2012)
New Revision: 16737
Added:
api/trunk/src/main/java/org/jboss/ws/api/Log.java
api/trunk/src/main/java/org/jboss/ws/api/Messages.java
Removed:
api/trunk/src/main/java/org/jboss/ws/api/annotation/Message.properties
api/trunk/src/main/java/org/jboss/ws/api/handler/Message.properties
api/trunk/src/main/java/org/jboss/ws/api/tools/Message.properties
api/trunk/src/main/java/org/jboss/ws/api/util/Message.properties
api/trunk/src/test/java/org/jboss/ws/api/util/BundleUtilsTest.java
api/trunk/src/test/java/org/jboss/ws/api/util/Message_fr.properties
Modified:
api/trunk/pom.xml
api/trunk/src/main/java/org/jboss/ws/api/addressing/MAPBuilderFactory.java
api/trunk/src/main/java/org/jboss/ws/api/annotation/AuthMethod.java
api/trunk/src/main/java/org/jboss/ws/api/annotation/TransportGuarantee.java
api/trunk/src/main/java/org/jboss/ws/api/handler/GenericHandler.java
api/trunk/src/main/java/org/jboss/ws/api/monitoring/RecordGroupAssociation.java
api/trunk/src/main/java/org/jboss/ws/api/tools/SecurityActions.java
api/trunk/src/main/java/org/jboss/ws/api/util/DOMUtils.java
api/trunk/src/main/java/org/jboss/ws/api/util/ServiceLoader.java
Log:
[JBWS-3509] Converting JBossWS-API to latest JBoss Logging...
Modified: api/trunk/pom.xml
===================================================================
--- api/trunk/pom.xml 2012-09-18 10:19:01 UTC (rev 16736)
+++ api/trunk/pom.xml 2012-09-18 12:52:43 UTC (rev 16737)
@@ -24,7 +24,8 @@
</scm>
<properties>
- <jboss-logging-spi.version>2.0.5.GA</jboss-logging-spi.version>
+ <jboss-logging.version>3.1.2.GA</jboss-logging.version>
+
<jboss-logging-processor.version>1.0.3.Final</jboss-logging-processor.version>
<junit.version>3.8.2</junit.version>
</properties>
@@ -34,11 +35,18 @@
<!-- provided apis -->
<dependency>
<groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- <version>${jboss-logging-spi.version}</version>
+ <artifactId>jboss-logging</artifactId>
+ <version>${jboss-logging.version}</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-processor</artifactId>
+ <version>${jboss-logging-processor.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
@@ -46,7 +54,6 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
-
</dependencies>
<!-- Plugins -->
@@ -90,6 +97,16 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <!-- Optional if you wan to generate skeleton translation properties files
-->
+ <compilerArgument>
+
-AgeneratedTranslationFilesPath=${project.basedir}/target/generated-translation-files
+ </compilerArgument>
+ </configuration>
+ </plugin>
</plugins>
</build>
Added: api/trunk/src/main/java/org/jboss/ws/api/Log.java
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/Log.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/ws/api/Log.java 2012-09-18 12:52:43 UTC (rev 16737)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., 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.ws.api;
+
+import static org.jboss.logging.Logger.Level.ERROR;
+import static org.jboss.logging.Logger.Level.TRACE;
+import static org.jboss.logging.Logger.Level.WARN;
+
+import org.jboss.logging.BasicLogger;
+import org.jboss.logging.LogMessage;
+import org.jboss.logging.Message;
+import org.jboss.logging.MessageLogger;
+
+/**
+ * JBossWS API log messages
+ *
+ * @author alessio.soldano(a)jboss.com
+ */
+@MessageLogger(projectCode = "JBWS")
+public interface Log extends BasicLogger
+{
+ Log LOGGER = org.jboss.logging.Logger.getMessageLogger(Log.class,
"org.jboss.ws.api");
+
+ @LogMessage(level = TRACE)
+ @Message(id = 20003, value = "Ignore attribute: [uri=%s, qname=%s,
value=%s]")
+ void ignoringAttribute(String uri, String qname, String value);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 20005, value = "Cannnot parse: %s")
+ void cannotParse(String s);
+
+ @LogMessage(level = TRACE)
+ @Message(id = 20006, value = "createElement {%s}%s")
+ void creatingElement(String uri, String prefix);
+
+ @LogMessage(level = TRACE)
+ @Message(id = 20007, value = "createElement {%s}%s:%s")
+ void creatingElement(String uri, String prefix, String localPart);
+
+ @LogMessage(level = TRACE)
+ @Message(id = 20008, value = "pushGroupID: %s (%s)")
+ void pushGroupID(String groupId, String threadName);
+
+ @LogMessage(level = TRACE)
+ @Message(id = 20009, value = "peekGroupID: %s (%s)")
+ void peekGroupID(String groupId, String threadName);
+
+ @LogMessage(level = TRACE)
+ @Message(id = 20010, value = "popGroupID: %s (%s)")
+ void popGroupID(String groupId, String threadName);
+
+ @LogMessage(level = WARN)
+ @Message(id = 20012, value = "Non-standard method: %s")
+ void nonStandardMethod(String s);
+
+ @LogMessage(level = TRACE)
+ @Message(id = 20015, value = "Could not get %s module classloader: %s")
+ void couldNotGetModuleClassLoader(String module, Exception e);
+
+}
Added: api/trunk/src/main/java/org/jboss/ws/api/Messages.java
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/Messages.java (rev
0)
+++ api/trunk/src/main/java/org/jboss/ws/api/Messages.java 2012-09-18 12:52:43 UTC (rev
16737)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., 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.ws.api;
+
+import org.jboss.logging.Cause;
+import org.jboss.logging.Message;
+import org.jboss.logging.MessageBundle;
+
+/**
+ * JBossWS API exception messages
+ *
+ * @author alessio.soldano(a)jboss.com
+ */
+@MessageBundle(projectCode = "JBWS")
+public interface Messages {
+
+ Messages MESSAGES = org.jboss.logging.Messages.getBundle(Messages.class);
+
+ @Message(id = 20000, value = "Failed to load %s")
+ IllegalStateException failedToLoad(@Cause Throwable cause, Object objs);
+
+ @Message(id = 20001, value = "Cannot load properties: %s")
+ SecurityException cannotLoadProperties(@Cause Throwable cause, String s);
+
+ @Message(id = 20002, value = "Cannot find namespace uri for %s")
+ IllegalArgumentException cannotFindNamespaceURI(String qualifiedName);
+
+ @Message(id = 20004, value = "Source type not implemented: %s")
+ RuntimeException sourceTypeNotImplemented(Class<?> clazz);
+
+ @Message(id = 20011, value = "Cannot obtain required property: %s")
+ IllegalStateException cannotObtainRequiredProperty(String prop);
+
+ @Message(id = 20013, value = "Illegal auth method: %s")
+ IllegalArgumentException illegalAuthMethod(String method);
+
+ @Message(id = 20014, value = "Illegal transport guarantee: %s")
+ IllegalArgumentException illegalTransportGuarantee(String method);
+
+}
Modified: api/trunk/src/main/java/org/jboss/ws/api/addressing/MAPBuilderFactory.java
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/addressing/MAPBuilderFactory.java 2012-09-18
10:19:01 UTC (rev 16736)
+++ api/trunk/src/main/java/org/jboss/ws/api/addressing/MAPBuilderFactory.java 2012-09-18
12:52:43 UTC (rev 16737)
@@ -24,7 +24,7 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
-import org.jboss.logging.Logger;
+import org.jboss.ws.api.Log;
import org.jboss.ws.api.util.ServiceLoader;
/**
@@ -115,10 +115,8 @@
moduleClassLoader =
(ClassLoader)moduleClass.getMethod("getClassLoader").invoke(module);
} catch (Exception e) {
//ignore, JBoss Modules might not be available at all
- Logger log = Logger.getLogger(MAPBuilderFactory.class);
- if (log.isTraceEnabled())
- {
- log.trace("Could not get " + JBOSSWS_SPI_MODULE + " module
classloader: ", e);
+ if (Log.LOGGER.isTraceEnabled()) {
+ Log.LOGGER.couldNotGetModuleClassLoader(JBOSSWS_SPI_MODULE, e);
}
}
return moduleClassLoader;
Modified: api/trunk/src/main/java/org/jboss/ws/api/annotation/AuthMethod.java
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/annotation/AuthMethod.java 2012-09-18
10:19:01 UTC (rev 16736)
+++ api/trunk/src/main/java/org/jboss/ws/api/annotation/AuthMethod.java 2012-09-18
12:52:43 UTC (rev 16737)
@@ -21,11 +21,9 @@
*/
package org.jboss.ws.api.annotation;
-import java.util.ResourceBundle;
+import org.jboss.ws.api.Log;
+import org.jboss.ws.api.Messages;
-import org.jboss.logging.Logger;
-import org.jboss.ws.api.util.BundleUtils;
-
/**
* The authMethod is used to configure the authentication mechanism for the web service.
* As a prerequisite to gaining access to any web service which are protected by an
@@ -35,9 +33,6 @@
*/
public final class AuthMethod
{
- private static final Logger log = Logger.getLogger(AuthMethod.class);
- private static final ResourceBundle bundle = BundleUtils.getBundle(AuthMethod.class);
-
/**
* Basic authentication.
*/
@@ -59,7 +54,7 @@
* Returns string representing correct {@link org.jboss.ws.api.annotation.AuthMethod}
value.
* @param s string to convert.
* @return correct auth method value
- * @throws IllegalArgumentException if <b>s</b> is <b>null</b>
or contains unknown value.
+ * @throws IllegalArgumentException if <b>s</b> is
<b>null</b>.
*/
public static String valueOf(final String s)
{
@@ -77,11 +72,11 @@
{
return AuthMethod.CLIENT_CERT;
}
- log.warn(BundleUtils.getMessage(bundle, "NON_STANDARD_METHOD", s));
+ Log.LOGGER.nonStandardMethod(s);
return s;
}
- throw new IllegalArgumentException(BundleUtils.getMessage(bundle,
"ILLEGAL_AUTH_METHOD", s));
+ throw Messages.MESSAGES.illegalAuthMethod(s);
}
}
Deleted: api/trunk/src/main/java/org/jboss/ws/api/annotation/Message.properties
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/annotation/Message.properties 2012-09-18
10:19:01 UTC (rev 16736)
+++ api/trunk/src/main/java/org/jboss/ws/api/annotation/Message.properties 2012-09-18
12:52:43 UTC (rev 16737)
@@ -1,3 +0,0 @@
-ILLEGAL_TRANSPORT_GUARANTEE=Illegal transport guarantee value: {0}
-NON_STANDARD_METHOD=Non-standard auth method value : {0}
-ILLEGAL_AUTH_METHOD= Illegal auth method : {0}
Modified: api/trunk/src/main/java/org/jboss/ws/api/annotation/TransportGuarantee.java
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/annotation/TransportGuarantee.java 2012-09-18
10:19:01 UTC (rev 16736)
+++ api/trunk/src/main/java/org/jboss/ws/api/annotation/TransportGuarantee.java 2012-09-18
12:52:43 UTC (rev 16737)
@@ -21,10 +21,8 @@
*/
package org.jboss.ws.api.annotation;
-import java.util.ResourceBundle;
+import org.jboss.ws.api.Messages;
-import org.jboss.ws.api.util.BundleUtils;
-
/**
* The transportGuarantee specifies that the communication
* between client and server should be NONE, INTEGRAL, or
@@ -41,8 +39,6 @@
*/
public final class TransportGuarantee
{
- private static final ResourceBundle bundle =
BundleUtils.getBundle(TransportGuarantee.class);
-
/**
* Application does not require any transport guarantees.
*/
@@ -94,7 +90,7 @@
}
}
- throw new IllegalArgumentException(BundleUtils.getMessage(bundle,
"ILLEGAL_TRANSPORT_GUARANTEE", s));
+ throw Messages.MESSAGES.illegalTransportGuarantee(s);
}
}
Modified: api/trunk/src/main/java/org/jboss/ws/api/handler/GenericHandler.java
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/handler/GenericHandler.java 2012-09-18
10:19:01 UTC (rev 16736)
+++ api/trunk/src/main/java/org/jboss/ws/api/handler/GenericHandler.java 2012-09-18
12:52:43 UTC (rev 16737)
@@ -21,12 +21,10 @@
*/
package org.jboss.ws.api.handler;
-import java.util.ResourceBundle;
-
import javax.xml.ws.handler.Handler;
import javax.xml.ws.handler.MessageContext;
-import org.jboss.ws.api.util.BundleUtils;
+import org.jboss.ws.api.Messages;
/**
* A generic JAX-WS handler
@@ -36,7 +34,6 @@
*/
public abstract class GenericHandler implements Handler
{
- private static final ResourceBundle bundle =
BundleUtils.getBundle(GenericHandler.class);
private String handlerName;
public String getHandlerName()
@@ -53,7 +50,7 @@
{
Boolean outbound =
(Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outbound == null)
- throw new IllegalStateException(BundleUtils.getMessage(bundle,
"CANNOT_OBTAIN_REQUIRED_PROPERTY", MessageContext.MESSAGE_OUTBOUND_PROPERTY));
+ throw
Messages.MESSAGES.cannotObtainRequiredProperty(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
}
Deleted: api/trunk/src/main/java/org/jboss/ws/api/handler/Message.properties
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/handler/Message.properties 2012-09-18
10:19:01 UTC (rev 16736)
+++ api/trunk/src/main/java/org/jboss/ws/api/handler/Message.properties 2012-09-18
12:52:43 UTC (rev 16737)
@@ -1 +0,0 @@
-CANNOT_OBTAIN_REQUIRED_PROPERTY=Cannot obtain required property: {0}
Modified: api/trunk/src/main/java/org/jboss/ws/api/monitoring/RecordGroupAssociation.java
===================================================================
---
api/trunk/src/main/java/org/jboss/ws/api/monitoring/RecordGroupAssociation.java 2012-09-18
10:19:01 UTC (rev 16736)
+++
api/trunk/src/main/java/org/jboss/ws/api/monitoring/RecordGroupAssociation.java 2012-09-18
12:52:43 UTC (rev 16737)
@@ -21,10 +21,10 @@
*/
package org.jboss.ws.api.monitoring;
+import static org.jboss.ws.api.Log.LOGGER;
+
import java.util.Stack;
-import org.jboss.logging.Logger;
-
/**
* Associates the record group ID with the current thread. This is implemented
internally
* through a static ThreadLocal member.
@@ -36,9 +36,6 @@
{
private static ThreadLocal<Stack<String>> groupIDAssoc = new
ThreadLocal<Stack<String>>();
- // provide logging
- private static Logger log = Logger.getLogger(RecordGroupAssociation.class);
-
/**
* Associates the specified groupID to the current thread
*
@@ -46,7 +43,7 @@
*/
public static void pushGroupID(String groupID)
{
- if(log.isTraceEnabled()) log.trace("pushGroupID: " + groupID + "
(Thread " +Thread.currentThread().getName()+ ")");
+ if (LOGGER.isTraceEnabled()) LOGGER.pushGroupID(groupID,
Thread.currentThread().getName());
Stack<String> stack = groupIDAssoc.get();
if (stack == null)
{
@@ -69,7 +66,7 @@
{
groupID = stack.peek();
}
- if(log.isTraceEnabled()) log.trace("peekGroupID: " + groupID + "
(Thread " +Thread.currentThread().getName()+ ")");
+ if (LOGGER.isTraceEnabled()) LOGGER.peekGroupID(groupID,
Thread.currentThread().getName());
return groupID;
}
@@ -86,7 +83,7 @@
{
groupID = stack.pop();
}
- if(log.isTraceEnabled()) log.trace("popGroupID: " + groupID +"
(Thread " +Thread.currentThread().getName()+ ")");
+ if (LOGGER.isTraceEnabled()) LOGGER.popGroupID(groupID,
Thread.currentThread().getName());
return groupID;
}
Deleted: api/trunk/src/main/java/org/jboss/ws/api/tools/Message.properties
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/tools/Message.properties 2012-09-18 10:19:01
UTC (rev 16736)
+++ api/trunk/src/main/java/org/jboss/ws/api/tools/Message.properties 2012-09-18 12:52:43
UTC (rev 16737)
@@ -1,2 +0,0 @@
-ERROR_SETTING_CONTEXT_CLASSLOADER=Error setting context classloader
-ERROR_RUNNING_PRIVILEGED_ACTION=Error running privileged action
Modified: api/trunk/src/main/java/org/jboss/ws/api/tools/SecurityActions.java
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/tools/SecurityActions.java 2012-09-18
10:19:01 UTC (rev 16736)
+++ api/trunk/src/main/java/org/jboss/ws/api/tools/SecurityActions.java 2012-09-18
12:52:43 UTC (rev 16737)
@@ -25,10 +25,7 @@
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
-import java.util.ResourceBundle;
-import org.jboss.ws.api.util.BundleUtils;
-
/**
* Security actions for this package
*
@@ -38,7 +35,6 @@
*/
class SecurityActions
{
- private static final ResourceBundle bundle =
BundleUtils.getBundle(SecurityActions.class);
/**
* Get context classloader.
*
@@ -85,31 +81,16 @@
return AccessController.doPrivileged(new
PrivilegedExceptionAction<ClassLoader>() {
public ClassLoader run() throws Exception
{
- try
- {
- ClassLoader result =
Thread.currentThread().getContextClassLoader();
- if (cl != null)
- Thread.currentThread().setContextClassLoader(cl);
- return result;
- }
- catch (Exception e)
- {
- throw e;
- }
- catch (Error e)
- {
- throw e;
- }
- catch (Throwable e)
- {
- throw new RuntimeException(BundleUtils.getMessage(bundle,
"ERROR_SETTING_CONTEXT_CLASSLOADER"), e);
- }
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
}
});
}
catch (PrivilegedActionException e)
{
- throw new RuntimeException(BundleUtils.getMessage(bundle,
"ERROR_RUNNING_PRIVILEGED_ACTION"), e.getCause());
+ throw new RuntimeException(e);
}
}
}
Modified: api/trunk/src/main/java/org/jboss/ws/api/util/DOMUtils.java
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/util/DOMUtils.java 2012-09-18 10:19:01 UTC
(rev 16736)
+++ api/trunk/src/main/java/org/jboss/ws/api/util/DOMUtils.java 2012-09-18 12:52:43 UTC
(rev 16737)
@@ -21,6 +21,9 @@
*/
package org.jboss.ws.api.util;
+import static org.jboss.ws.api.Messages.MESSAGES;
+import static org.jboss.ws.api.Log.LOGGER;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -31,7 +34,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.ResourceBundle;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
@@ -45,7 +47,6 @@
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
-import org.jboss.logging.Logger;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -64,9 +65,6 @@
*/
public abstract class DOMUtils
{
- private static Logger log = Logger.getLogger(DOMUtils.class);
- private static ResourceBundle bundle = BundleUtils.getBundle(DOMUtils.class);
-
/** Get the qname of the given node.
*/
public static QName getElementQName(Element el)
@@ -111,7 +109,7 @@
}
if (namespaceURI.equals(""))
- throw new IllegalArgumentException(BundleUtils.getMessage(bundle,
"CANNOT_FIND_NAMESPACE_URI_FOR", qualifiedName));
+ throw MESSAGES.cannotFindNamespaceURI(qualifiedName);
}
else
{
@@ -244,8 +242,8 @@
// change an object in a way which is incorrect with regard to namespaces.
if (uri == null && qname.startsWith("xmlns"))
{
- if (log.isTraceEnabled())
- log.trace("Ignore attribute: [uri=" + uri + ",qname="
+ qname + ",value=" + value + "]");
+ if (LOGGER.isTraceEnabled())
+ LOGGER.ignoringAttribute(uri, qname, value);
}
else
{
@@ -553,7 +551,7 @@
}
else
{
- throw new RuntimeException(BundleUtils.getMessage(bundle,
"SOURCE_TYPE_NOT_IMPLEMENTED", source.getClass()));
+ throw MESSAGES.sourceTypeNotImplemented(source.getClass());
}
return retElement;
@@ -569,8 +567,7 @@
}
catch (IOException e)
{
- log.error(BundleUtils.getMessage(bundle, "CAN_NOT_PARSE",
xmlString));
- log.error("Cannot parse: " + xmlString);
+ LOGGER.cannotParse(xmlString);
throw e;
}
}
@@ -636,14 +633,14 @@
{
if (prefix == null || prefix.length() == 0)
{
- if (log.isTraceEnabled())
- log.trace("createElement {" + uri + "}" + localPart);
+ if (LOGGER.isTraceEnabled())
+ LOGGER.creatingElement(uri, prefix);
return doc.createElementNS(uri, localPart);
}
else
{
- if (log.isTraceEnabled())
- log.trace("createElement {" + uri + "}" + prefix +
":" + localPart);
+ if (LOGGER.isTraceEnabled())
+ LOGGER.creatingElement(uri, prefix, localPart);
return doc.createElementNS(uri, prefix + ":" + localPart);
}
}
Deleted: api/trunk/src/main/java/org/jboss/ws/api/util/Message.properties
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/util/Message.properties 2012-09-18 10:19:01
UTC (rev 16736)
+++ api/trunk/src/main/java/org/jboss/ws/api/util/Message.properties 2012-09-18 12:52:43
UTC (rev 16737)
@@ -1,5 +0,0 @@
-CANNOT_FIND_NAMESPACE_URI_FOR=Cannot find namespace uri for: {0}
-SOURCE_TYPE_NOT_IMPLEMENTED=Source type not implemented: {0}
-FAILED_TO_LOAD=Failed to load {0}: {1}
-CANNOT_LOAD_PROPERTIES=Cannot load properties: {0}
-CAN_NOT_PARSE = Cannot parse: {0}
Modified: api/trunk/src/main/java/org/jboss/ws/api/util/ServiceLoader.java
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/util/ServiceLoader.java 2012-09-18 10:19:01
UTC (rev 16736)
+++ api/trunk/src/main/java/org/jboss/ws/api/util/ServiceLoader.java 2012-09-18 12:52:43
UTC (rev 16737)
@@ -21,6 +21,8 @@
*/
package org.jboss.ws.api.util;
+import static org.jboss.ws.api.Messages.MESSAGES;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -32,7 +34,6 @@
import java.util.Collections;
import java.util.Map;
import java.util.Properties;
-import java.util.ResourceBundle;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
@@ -58,7 +59,6 @@
*/
public final class ServiceLoader
{
- private static final ResourceBundle bundle =
BundleUtils.getBundle(ServiceLoader.class);
/**
* A synchronized weak hash map that keeps factory names retrieved using Service API
(META-INF/services/*) for each classloader.
* Weak keys are used to remove entries when classloaders are garbage collected;
values are service-property-name -> factory name maps.
@@ -157,7 +157,7 @@
}
catch (Throwable t)
{
- throw new IllegalStateException(BundleUtils.getMessage(bundle,
"FAILED_TO_LOAD", new Object[]{ propertyName, factoryName}), t);
+ throw MESSAGES.failedToLoad(t, new Object[]{ propertyName, factoryName});
}
return factory;
@@ -207,7 +207,7 @@
}
catch (Throwable t)
{
- throw new IllegalStateException(BundleUtils.getMessage(bundle,
"FAILED_TO_LOAD", new Object[]{ propertyName , factoryName}), t);
+ throw MESSAGES.failedToLoad(t, new Object[]{ propertyName , factoryName});
}
}
@@ -250,7 +250,7 @@
}
catch (Throwable t)
{
- throw new IllegalStateException(BundleUtils.getMessage(bundle,
"FAILED_TO_LOAD", new Object[]{ propertyName , factoryName}), t);
+ throw MESSAGES.failedToLoad(t, new Object[]{ propertyName , factoryName});
}
}
@@ -271,7 +271,7 @@
}
catch (Throwable t)
{
- throw new IllegalStateException(BundleUtils.getMessage(bundle,
"FAILED_TO_LOAD", defaultFactory), t);
+ throw MESSAGES.failedToLoad(t, defaultFactory);
}
}
@@ -314,7 +314,7 @@
}
catch (IOException ex)
{
- throw new SecurityException(BundleUtils.getMessage(bundle,
"CANNOT_LOAD_PROPERTIES", filename), ex);
+ throw MESSAGES.cannotLoadProperties(ex, filename);
}
finally
{
Deleted: api/trunk/src/test/java/org/jboss/ws/api/util/BundleUtilsTest.java
===================================================================
--- api/trunk/src/test/java/org/jboss/ws/api/util/BundleUtilsTest.java 2012-09-18 10:19:01
UTC (rev 16736)
+++ api/trunk/src/test/java/org/jboss/ws/api/util/BundleUtilsTest.java 2012-09-18 12:52:43
UTC (rev 16737)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, 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.ws.api.util;
-
-import java.util.Locale;
-
-import junit.framework.TestCase;
-
-public class BundleUtilsTest extends TestCase
-{
- public void testI18NMessage() throws Exception
- {
- String message = BundleUtils.getMessage(BundleUtils.getBundle(this.getClass()),
"CAN_NOT_PARSE", "file");
- assertTrue("English error message is expected",
message.indexOf("Cannot parse") > -1);
- Locale.setDefault(java.util.Locale.FRANCE);
- message = BundleUtils.getMessage(BundleUtils.getBundle(this.getClass()),
"CAN_NOT_PARSE", "file");
- assertTrue("French error message is expected", message.contains("ne
peut pas analyser"));
- }
-}
Deleted: api/trunk/src/test/java/org/jboss/ws/api/util/Message_fr.properties
===================================================================
--- api/trunk/src/test/java/org/jboss/ws/api/util/Message_fr.properties 2012-09-18
10:19:01 UTC (rev 16736)
+++ api/trunk/src/test/java/org/jboss/ws/api/util/Message_fr.properties 2012-09-18
12:52:43 UTC (rev 16737)
@@ -1 +0,0 @@
-CAN_NOT_PARSE = ne peut pas analyser: {0}
\ No newline at end of file