commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dennis Lundberg <denn...@apache.org>
Subject Re: Patch for Logging 1.1 to run in applets.
Date Mon, 12 Mar 2007 21:12:33 GMT
The upcoming 1.1.1 release has fixed these issues.

Pavel Vlasov wrote:
> Hello,
> 
> Today I tried to use HttpClient from an applet and I run into a quite a
> number of problems with commons logging version 1.1. Searching internet and
> Commons Wiki didn't yield any valuable result.
> 
> Thus, I had to modify LogFactory.java around line 320, I added a catch block
> for SecurityException, which was missing. Please find code below:
> 
>         String storeImplementationClass;
>         try {
>         	storeImplementationClass =
> System.getProperty(HASHTABLE_IMPLEMENTATION_PROPERTY);
>         } catch (SecurityException e) {
>         	storeImplementationClass = null;
>         }
> 
> Also I had to create my own implementation of LogFactory because default
> implementation invokes getClasLoader() method, which is prohibited in
> Applets.
> 
> Here is the no-op implementation:
> 
> public class NoOpLogFactory extends LogFactory {
> 	
> 	private Log log = new NoOpLog();
> 	
> 	private Map attributes = new HashMap();
> 
> 	public Object getAttribute(String name) {
> 		return attributes.get(name);
> 	}
> 
> 	public String[] getAttributeNames() {
> 		return (String[]) new
> ArrayList(attributes.keySet()).toArray(new String[attributes.size()]);
> 	}
> 
> 	public Log getInstance(Class clazz) throws LogConfigurationException
> {
> 		return log;
> 	}
> 
> 	public Log getInstance(String name) throws LogConfigurationException
> {
> 		return log;
> 	}
> 
> 	public void release() {
> 		// Nothing to release
> 	}
> 
> 	public void removeAttribute(String name) {
> 		attributes.remove(name);
> 	}
> 
> 	public void setAttribute(String name, Object value) {
> 		attributes.put(name, value);
> 	}
> 
> }
> 
> I've installed it by specifying class name in a configuration file in
> META-INF/services in one of my jars
> 
> Please review these changes and incorporate into the library if appropriate.
> Also please let me know if there is another way to make commons logging work
> in applets.
> ---
> Best regards, Pavel.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


-- 
Dennis Lundberg

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message