What you need to do is to get Log interface into the initial classloader that is created by the jvm. For the moment you will need to update the script that runs merlin (change -jar to -classpath, include a jar containing the Log interface, add the main cli jar, and include the Main class as a parameter).


I've been thinking about this question of customization of the initial classloader and I think we need a specific property containing a list of jars that should be loaded before loading merlin. This could be added to the repository package so that the generated classloader chain would look like:

    SystemClassLoader
        ^
        |
    Common API ClassLoader <---- this would contain you Log interface
        ^
        |
    Repository Generated ClassLoader

Using this approach we guarantee that the supplementary API classes are in a parent classloader relative to both 'system' and 'application' classloaders.

Hope that helps.

Cheers, Stephen.



Maksimenko Alexander wrote:
Hi!
I try to describe my problem. I have to use instance of org.apache.commons.logging.Log in my components instead of Logger. So I've created my implementation of org.apache.avalon.logging.provider.LoggingManager. This implementation instantiates another LoggingManager implementation and wraps produced Logger instance. My wrapper implements both Logger and Log interfaces:


public class LogLogger implements Log, Logger{
  protected Logger logger = null;

  public LogLogger(Logger logger) {
    this.logger = logger;
  }

  public boolean isTraceEnabled() {
    return logger.isDebugEnabled();
  }

  public boolean isDebugEnabled() {
    return logger.isDebugEnabled();
  }
.....
}

So I can cast it to Log in my component:
  Log myLogger;
  public void enableLogging(Logger logger) {
    myLogger = (Log)logger;
  }

But unfortunately a get the following exception:

java.lang.ClassCastException
net.softwarium.commons.logger.avalon.TestComponent.enableLogging(TestComponent.java:47)


org.apache.avalon.activation.appliance.impl.DefaultAppliance.applyLogger(DefaultAppliance.java:545)


I discoved the cause of the exception is that Log class for LoggingManager and Log class for Component lay in distinct classloaders:


LoggingManager ClassLoader ---> Log ClassLoader ---> Merlin Impl ClassLoader --->.....
MyComponent ClassLoader ---> LogClassLoader ---> Merlin Impl ClassLoader --> ....


but I can't imagine how I can reapir this situation :(


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




--

|------------------------------------------------|
| Magic by Merlin                                |
| Production by Avalon                           |
|                                                |
| http://avalon.apache.org/merlin                |
| http://dpml.net/merlin/distributions/latest    |
|------------------------------------------------|

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to