Author: alessio.soldano(a)jboss.com
Date: 2012-12-14 19:19:33 -0500 (Fri, 14 Dec 2012)
New Revision: 17078
Modified:
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/Loggers.java
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/deployment/ResourceResolver.java
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/deployment/UnifiedVirtualFile.java
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/metadata/webservices/JBossWebservicesFactory.java
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/util/URLLoaderAdapter.java
Log:
New dailsafe methods
Modified: spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/Loggers.java
===================================================================
--- spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/Loggers.java 2012-12-15 00:18:36
UTC (rev 17077)
+++ spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/Loggers.java 2012-12-15 00:19:33
UTC (rev 17078)
@@ -21,8 +21,9 @@
*/
package org.jboss.wsf.spi;
+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 static org.jboss.logging.Logger.Level.ERROR;
import java.net.URL;
import java.util.Collection;
@@ -32,7 +33,6 @@
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Cause;
import org.jboss.logging.LogMessage;
-import org.jboss.logging.Logger.Level;
import org.jboss.logging.Message;
import org.jboss.logging.MessageLogger;
@@ -71,4 +71,8 @@
@Message(id = 21018, value = "Cannot get name for resource %s")
void cannotGetNameForResource(@Cause Throwable cause, URL url);
+ @LogMessage(level = TRACE)
+ @Message(id = 21019, value = "Cannot get URL for %s")
+ void cannotGetURLFor(String path);
+
}
Modified:
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/deployment/ResourceResolver.java
===================================================================
---
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/deployment/ResourceResolver.java 2012-12-15
00:18:36 UTC (rev 17077)
+++
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/deployment/ResourceResolver.java 2012-12-15
00:19:33 UTC (rev 17078)
@@ -41,4 +41,13 @@
*/
public URL resolve(String resourcePath) throws IOException;
+ /**
+ * Same as resolve(String resourcePath) except it does not throw exception
+ * when resource is not found, simply returns null.
+ *
+ * @param resourcePath
+ * @return
+ */
+ public URL resolveFailSafe(String resourcePath);
+
}
Modified:
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/deployment/UnifiedVirtualFile.java
===================================================================
---
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/deployment/UnifiedVirtualFile.java 2012-12-15
00:18:36 UTC (rev 17077)
+++
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/deployment/UnifiedVirtualFile.java 2012-12-15
00:19:33 UTC (rev 17078)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2012, 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.
*
@@ -27,16 +27,24 @@
import java.util.List;
/**
- * An adaptor to a VirtualFile from jboss-vfs.jar
- * jboss-vfs cannot be used in jboss-4.x because of its dependeny on
jboss-common-core.jar
*
* @author Thomas.Diesler(a)jboss.org
+ * @author alessio.soldano(a)jboss.com
* @since 05-May-2006
*/
public interface UnifiedVirtualFile extends Serializable
{
UnifiedVirtualFile findChild(String child) throws IOException;
+ /**
+ * Same as findChild(String child) but does not throw any exception
+ * on child not found, simply returns null.
+ *
+ * @param child
+ * @return
+ */
+ UnifiedVirtualFile findChildFailSafe(String child);
+
List<UnifiedVirtualFile> getChildren() throws IOException;
String getName();
Modified:
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/metadata/webservices/JBossWebservicesFactory.java
===================================================================
---
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/metadata/webservices/JBossWebservicesFactory.java 2012-12-15
00:18:36 UTC (rev 17077)
+++
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/metadata/webservices/JBossWebservicesFactory.java 2012-12-15
00:19:33 UTC (rev 17078)
@@ -86,20 +86,11 @@
public static JBossWebservicesMetaData loadFromVFSRoot(final UnifiedVirtualFile root)
{
JBossWebservicesMetaData webservices = null;
- UnifiedVirtualFile wsdd = null;
- try {
- wsdd = root.findChild("META-INF/jboss-webservices.xml");
- } catch (IOException e) {
- //
- }
+ UnifiedVirtualFile wsdd =
root.findChildFailSafe("META-INF/jboss-webservices.xml");
// Maybe a web application deployment?
if (null == wsdd) {
- try {
- wsdd = root.findChild("WEB-INF/jboss-webservices.xml");
- } catch (IOException e) {
- //
- }
+ wsdd = root.findChildFailSafe("WEB-INF/jboss-webservices.xml");
}
// the descriptor is optional
Modified:
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java
===================================================================
---
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java 2012-12-15
00:18:36 UTC (rev 17077)
+++
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java 2012-12-15
00:19:33 UTC (rev 17078)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2012, 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.
*
@@ -96,27 +96,12 @@
{
WebservicesMetaData webservices = null;
- UnifiedVirtualFile wsdd = null;
- try
- {
- wsdd = root.findChild("META-INF/webservices.xml");
- }
- catch (IOException e)
- {
- //
- }
+ UnifiedVirtualFile wsdd =
root.findChildFailSafe("META-INF/webservices.xml");
// Maybe a web application deployment?
if (null == wsdd)
{
- try
- {
- wsdd = root.findChild("WEB-INF/webservices.xml");
- }
- catch (IOException e)
- {
- //
- }
+ wsdd = root.findChildFailSafe("WEB-INF/webservices.xml");
}
// the descriptor is optional
Modified:
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/util/URLLoaderAdapter.java
===================================================================
---
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/util/URLLoaderAdapter.java 2012-12-15
00:18:36 UTC (rev 17077)
+++
spi/branches/JBWS3551/src/main/java/org/jboss/wsf/spi/util/URLLoaderAdapter.java 2012-12-15
00:19:33 UTC (rev 17078)
@@ -69,7 +69,7 @@
this.loader = loader;
}
- public UnifiedVirtualFile findChild(String resourcePath) throws IOException
+ private UnifiedVirtualFile findChild(String resourcePath, boolean
throwExceptionIfNotFound) throws IOException
{
URL resourceURL = null;
if (resourcePath != null)
@@ -114,11 +114,38 @@
}
if (resourceURL == null)
- throw Messages.MESSAGES.cannotGetURLFor(resourcePath);
+ {
+ if (throwExceptionIfNotFound)
+ {
+ throw Messages.MESSAGES.cannotGetURLFor(resourcePath);
+ }
+ else
+ {
+ if (ROOT_LOGGER.isTraceEnabled()) ROOT_LOGGER.cannotGetURLFor(resourcePath);
+ return null;
+ }
+ }
return new URLLoaderAdapter(rootURL, loader, resourceURL);
}
+ public UnifiedVirtualFile findChild(String resourcePath) throws IOException
+ {
+ return findChild(resourcePath, true);
+ }
+
+ public UnifiedVirtualFile findChildFailSafe(String resourcePath)
+ {
+ try
+ {
+ return findChild(resourcePath, false);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
public URL toURL()
{
if (resourceURL != null)
Show replies by date