This is my main class file
public class TestFortress {
public static void main( String[] args ) throws Exception {
final FortressConfig config = new FortressConfig(); config.setContextDirectory(""); config.setWorkDirectory(""); config.setContainerConfiguration("systemTRY.xconf"); ContainerManager cm = new DefaultContainerManager(config.getContext()); ContainerUtil.initialize( cm ); DefaultContainer container = (DefaultContainer) cm.getContainer(); ServiceManager manager = container.getServiceManager(); Runner service=(Runner)manager.lookup(Runner.ROLE); System.out.println(service.getName()); container.getServiceManager().release(service); org.apache.avalon.framework.container.ContainerUtil.dispose( cm ); } }
This is my service interface public interface Runner { public static final String ROLE="Runner"; public String getName(); }
This is my service implementaion class
/** * @(#) AnotherRunner * * @avalon.component * @avalon.service type="Runner" * @x-avalon.info name="AnotherRunner" * @x-avalon.lifestyle type="pooled" */ public class AnotherRunner extends AbstractRunner{ public String getName() { try{ return configuration.getAttribute("name"); }catch (Exception e) { return null; } }
and This is my systemTRY.xconf
<my-system> <AnotherRunner id="AnotherRunner" name="I M ANOTHER RUNNER"/> </my-system>
and This is the meta file produced using the ant task provided by fortress, it is placed in the same directory as that of the class
#Meta information for com.achievo.AnotherRunner #Sat Jan 17 16:59:09 CST 2004 x-avalon.lifestyle=pooled x-avalon.name=AnotherRunner
and This is the ServiceList file which is in the root directory of my class directory
com.achievo.Runner
I ran the main class TestFortress, but it told me
org.apache.avalon.framework.service.ServiceException: Unable to provide implementation for Runner (Key='Runner')
any one can help?
Thanks Mike
_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]