well, I have traced into the fortress sourcode to find
in ComponentFactory.java, the method


public ComponentFactory( final Class componentClass,
                            final Configuration configuration,
                            final ServiceManager serviceManager,
                            final Context context,
                            final LoggerManager loggerManager,
                            final LifecycleExtensionManager extManager )

has this statement

m_context =new DefaultContext( context )

while the context passed in is the value I set by provideComponentContext() method in my Container class, and in the same java file, there is another method

public Object newInstance()

and in it a statement: ContainerUtil.contextualize( component, m_context );

that is, my expected context is not passed to the service implementaition I need, the actullay passed context is a DefaultContext which is contstructed by taking my expected context as a parent, so I wonder in such a way, how can my expected context be passed to looked up service implementaions while looking up?








From: "Mu Mike" <[EMAIL PROTECTED]>
Reply-To: "Avalon framework users" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Fortress: why is  this
Date: Fri, 16 Jan 2004 03:12:14 +0000

I read the javadoc, it tells that the m_componentContext is the context object passed to your service implementation object while looking up it by a ServiceManager of a container,it suggests override provideComponentContext method to change the context passed.
So I did this:


public class MyContainer extends DefaultContainer {
protected org.apache.avalon.framework.context.Context provideComponentContext(org.apache.avalon.framework.context.Context parent)
{
MyContext myContext=new MyContext();
m_componentContext=myContext;/I guess this statement is useless, but I put it anyway
return myContext;
}


}

then I have this code

           FortressConfig fConfig=new FortressConfig();
           ........
           ........
           FortressConfig fConfig.setContainerClass("MyContainer");
           ContainerManager cm = new
                   DefaultContainerManager(fConfig.getContext());
           ContainerUtil.initialize( cm );
           container = (DefaultContainer)cm.getContainer();
           ServiceManager manager = container.getServiceManager();

and then I looked up mySpecialService like this:
          mySpecialService=manager.lookup(mySpecialService.role);

yet the context of the mySpecialService object I got is still of org.apache.avalon.framework.context.DefaultContext type, why isnt it a MyContext object?

_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。  http://www.hotmail.com


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


_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn



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



Reply via email to