avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 22931] New: - ExcaliburComponentManagerCreator does not recognize ROLE+"Selector"
Date Thu, 04 Sep 2003 13:12:12 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22931>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22931

ExcaliburComponentManagerCreator does not recognize ROLE+"Selector"

           Summary: ExcaliburComponentManagerCreator does not recognize
                    ROLE+"Selector"
           Product: Avalon
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Excalibur
        AssignedTo: dev@avalon.apache.org
        ReportedBy: dcmoeller@gmx.de


Hi guys,

I've found that ExcaliburComponentManagerCreator does not recognize a role 
configuration with added "Selector" to configure a component/service selector. 
He throws a ClassNotFoundException.

I'll give you some sample code:
-----------------------------------------------------------------
A) Client:
package component2;

import java.io.ByteArrayInputStream;

import org.apache.avalon.excalibur.component.ExcaliburComponentManagerCreator;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.commons.lang.ArrayUtils;

public class TestServiceSelector {

	public static final String ROLE_CONFIG =
		"<role-list>"
			+ "\n  <role shorthand='selector' name='component2.ServiceSelector' 
default-class='org.apache.avalon.excalibur.component.
ExcaliburComponentSelector'>"
		//+"\n  <role shorthand='selector' name='component2.Service' 
default-class='org.apache.avalon.framework.service.DefaultServiceSelector'>"
	+"\n    <hint shorthand='i1' class='component2.impl.Service1'/>" + "\n  
</role>" + "\n</role-list>";
	public static final String COMPONENT_CONFIG =
		"<test>" + "\n  <selector>" + "\n    <i1 name='select1'/>" + "\n  
</selector>" + "\n</test>";
	public static final String LOG_CONFIG =
		"<logkit>"
			+ "\n  <factories>"
			+ "\n    <factory type='sysout' class='org.apache.avalon.excalibur.
logger.factory.StreamTargetFactory'/>"
			+ "\n  </factories>"
			+ "\n  <targets>"
			+ "\n    <sysout id='root'>"
			+ "\n      <stream>System.out</stream>"
			+ "\n      <format type='pattern'>%6.6{priority} %19.19{time:
yyyy-MM-dd HH:mm:ss}: %{message}\n%{throwable}</format>"
			+ "\n    </sysout>"
			+ "\n  </targets>"
			+ "\n  <categories>"
			+ "\n    <category name='system' log-level='INFO'>"
			+ "\n      <log-target id-ref='root'/>"
			+ "\n    </category>"
			+ "\n  </categories>"
			+ "\n</logkit>";

	public TestServiceSelector() {
		super();
	}

	public static final void main(String[] args) {
		System.out.println("### ROLE:\n" + ROLE_CONFIG);
		System.out.println("### COMPONENT:\n" + COMPONENT_CONFIG);
		ExcaliburComponentManagerCreator creator = null;
		try {
			creator =
				new ExcaliburComponentManagerCreator(
					null,
					new ByteArrayInputStream(LOG_CONFIG.getBytes()),
					new ByteArrayInputStream(ROLE_CONFIG.getBytes()),
					new ByteArrayInputStream(COMPONENT_CONFIG.getBytes()),
					null);
			ServiceManager manager = creator.getServiceManager();
			Object object = manager.lookup(Service.ROLE + "Selector");
			System.out.println("Got instance of: " + object);
			System.out.println("Interfaces: " + ArrayUtils.toString(object.
getClass().getInterfaces()));
			ServiceSelector selector = (ServiceSelector) object;
			Service select1 = (Service) selector.select("select1");
			System.out.println("Got instance of: " + select1);
			selector.release(select1);
			manager.release(selector);
		}
		catch (Throwable e) {
			e.printStackTrace();
		}
		finally {
			creator.dispose();
		}
	}

}
-----------------------------------------------------------------
B) Service interface (as simple as possible):
package component2;

public interface Service {

	public static final String ROLE = Service.class.getName();

}
-----------------------------------------------------------------
C) Service implementation:
package component2.impl;

import org.apache.avalon.framework.thread.ThreadSafe;

import component.Service;

public class Service1 implements Service, ThreadSafe {

	public Service1() {
		super();
	}

	public String toString() {
		return this.getClass().getName();
	}

}
-----------------------------------------------------------------

Running the client results in this stack trace:
java.lang.ClassNotFoundException: component2.ServiceSelector
      [...]
      at component2.TestServiceSelector.main(TestServiceSelector.java:48)

Working without "Selector" in configuration XML as well as when requesting the 
component/service works.
BUT all documentation I've found states that the above code should work!

I'm working with following versions of Avalon/Excalibur JAR files:
- avalon-framework-4.1.4.jar
- excalibur-component-1.1.jar
- excalibur-i18n-1.0.jar
- excalibur-instrument-1.0.jar
- excalibur-logger-1.0.1.jar
- excalibur-pool-1.2.jar
- logkit-1.2.jar

- commons-collections.jar
- commons-lang-2.0.jar

Greetings

Christian

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


Mime
View raw message