According to the javadoc, m_componentContext will be passed to service implementations while looking up them through a servicemanager and m_context contains content such as info of loggermanager,metainformanager and so on. The question is,I passed the context of m_context to a FortressConfig by its setContainerConfiguration() and setMetaInfoManagerConfiguration() and so on and then use it to construct a ContainerManager and then get a Container, but I do want my Container have a different m_componentConext(by default,it has the same value of m_context), so I write my container class instead.

public class MyContainer extends DefaultContainer {
protected org.apache.avalon.framework.context.Context provideComponentContext(org.apache.avalon.framework.context.Context parent)
throws Exception


{
return wantedConext; }
}


the problem is, I have the wantedContext object in a class that has the container like this

class BootStrapClass
{

public static void main(String[] args)
{ Context wantedContext;
Configuration sysConfig = builder.build("system.xconf");
fConfig.setContainerConfiguration(sysConfig);


           Configuration roleConfig = builder.build("report.roles");
           fConfig.setRoleManagerConfiguration(roleConfig);
           //this is our own container
           fConfig.setContainerClass("MyContainer");

           ContainerManager cm = new
                   DefaultContainerManager(fConfig.getContext());
           ContainerUtil.initialize( cm );
           container = (DefaultContainer)cm.getContainer();
           rmanager = container.getServiceManager();

}
}

Before ContainerUtil.initialize( cm ), you get a null object using container = (DefaultContainer)cm.getContainer(); and after it, the m_componentContext has been set to all the service implementations contained in the container, so I guess the only way is to provide the "wantedContext" to MyContainer in class BootStrapClass, but how? since we use FortressConfig.setContainerClass(String) method, there isnt then a MyContainer object.

Anyone can help me?

Thanks
Mike

_________________________________________________________________
免费下载 MSN Explorer: http://explorer.msn.com/lccn/



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



Reply via email to