mx4j/src/core/mx4j/remote ProviderFactory.java,1.5,1.6
Simone Bordet <[email protected]> Thu, 17 Feb 2005 05:33:06 +0000
| Newsgroups | gmane.comp.java.mx4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mx4j/mx4j/src/core/mx4j/remote
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3994/src/core/mx4j/remote
Modified Files:
ProviderFactory.java
Log Message:
Fixed behavior of provider loading: the protocol is checked with the class name in order to return the correct provider
Index: ProviderFactory.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/core/mx4j/remote/ProviderFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ProviderFactory.java 16 Feb 2005 15:29:57 -0000 1.5
--- ProviderFactory.java 17 Feb 2005 05:33:04 -0000 1.6
***************
*** 147,151 ****
catch (ClassNotFoundException x)
{
! if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Provider class " + providerClassName + " not found, continuing with next package");
continue;
}
--- 147,151 ----
catch (ClassNotFoundException x)
{
! if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Provider class " + providerClassName + " not found, " + (tokenizer.hasMoreTokens() ? "continuing with next package" : "no more packages to try"));
continue;
}
***************
*** 169,173 ****
try
{
! Object[] serviceProviders = fromServiceProviders(providerType, loader);
// For now, return the first instance; later we may add some way to prefer one instance or the other
if (serviceProviders.length > 0) return serviceProviders[0];
--- 169,173 ----
try
{
! Object[] serviceProviders = fromServiceProviders(providerType, protocol, className, loader);
// For now, return the first instance; later we may add some way to prefer one instance or the other
if (serviceProviders.length > 0) return serviceProviders[0];
***************
*** 183,187 ****
}
! public static Object[] fromServiceProviders(Class providerType, ClassLoader loader) throws IOException
{
String services = "META-INF/services/";
--- 183,187 ----
}
! public static Object[] fromServiceProviders(Class providerType, String protocol, String className, ClassLoader loader) throws IOException
{
String services = "META-INF/services/";
***************
*** 228,244 ****
line = line.trim();
if (line.length() == 0) continue;
! try
{
! if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Found provider '" + line + "' in " + providerURL);
! Class providerClass = loader.loadClass(line);
! if (providerType.isAssignableFrom(providerClass))
{
! Object providerInstance = providerClass.newInstance();
! providers.add(providerInstance);
}
}
! catch (Exception ignored)
{
! // Skip this line and continue
}
}
--- 228,253 ----
line = line.trim();
if (line.length() == 0) continue;
! if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Found provider '" + line + "' in " + providerURL);
! // We assume the classes defined by service providers follow the style defined by JSR 160
! if (line.endsWith(protocol + "." + className))
{
! if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Provider '" + line + "' matches protocol " + protocol);
! try
{
! Class providerClass = loader.loadClass(line);
! if (providerType.isAssignableFrom(providerClass))
! {
! Object providerInstance = providerClass.newInstance();
! providers.add(providerInstance);
! }
! }
! catch (Exception ignored)
! {
! // Skip this line and continue
}
}
! else
{
! if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Provider '" + line + "' does not match protocol " + protocol + ", ignoring");
}
}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click