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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to