On Thu, 2004-01-08 at 08:45, æ è wrote:

> When I use ECM,  I do this:
> 
> ExcaliburComponentManager manager=new 
> ExcaliburComponentManager(this.getClass().getClassLoader());
> manager.setLogger(mylogger);
> DefaultRoleManager roleManager=new DefaultRoleManager();
> roleManager.configure(myRolesConfiguration);
> manager.setRoleManager(roleManagre);

and when you use Fortress you would do somehing like this:

package org.apache.avalon.example;

import org.apache.avalon.fortress.impl.DefaultContainerManager;
import org.apache.avalon.fortress.impl.DefaultContainer;
import org.apache.avalon.fortress.util.FortressConfig;
import org.apache.avalon.fortress.ContainerManager;
import org.apache.avalon.framework.container.ContainerUtil;


public class Main {

  public static void main( String[] args )
        throws Exception
  {

    // get directory which contains our configuration files
    String confDir = args[0];

    // Set up all the preferences for Fortress
    final FortressConfig config = new FortressConfig();
        
    config.setContainerConfiguration( confDir+"/system.xconf" );
    config.setRoleManagerConfiguration( confDir+"/roles.xconf" );
    config.setLoggerManagerConfiguration( confDir+"/logkit.xconf");

    // Get the root container initialized
     ContainerManager cm = new
              DefaultContainerManager(config.getContext());
    
    ContainerUtil.initialize( cm );
 
    DefaultContainer container = (DefaultContainer) cm.getContainer();

    ServiceManager manager = container.getServiceManager();

    MyService service = (MyService) manager.lookup(MyService.ROLE);

    System.out.println("Hello "+service.getName());

    container.getServiceManager().release(service);

    // Properly clean up when we are done
    org.apache.avalon.framework.container.ContainerUtil.dispose( cm );

  }
}

Now, you don't need to configure a RoleManager like that anymore since
Fortress can use embedded meta-data, but for ECM-based applications,
this is often easier, especially if you want to keep your old 'roles'
files.

> 
> First, the interface  Container in fortress confuses me, I dont know what 
> it is for, it doesn not exist in Excalibur, and there is an implementation 
> of this interface: DefaultContainer and also there are ContainerManager and 
> DefaultContainerManager, what are they for? how to use them?

Containers basically setup everything for you so you don't have to. 
When I say everything I mean your ServiceManager, RoleManager
(MetaInfoManager) and your basic Context, etc.


> is that how a ServiceManager is got? and after got the ServiceManager, I 
> will be able to lookup a Service as I look up a Component in ECM?

This is ONE way to get the ServiceManager.  It's certainly a valid way.
However, in many case you may not even need the ServiceManager.

> And, what do these two statements do?  the API doc doest give explaination.
> 
> config.setContextDirectory( context.getRealPath("./") );
> config.setWorkDirectory( context.getRealPath("./") );

If you're components use Contextualize and need to get a Context
Directory or a Working Directory from the context, you can set it in the
configuration.  Otherwise certain default values are given (which I once
knew off the top of my head but would have to look up now).

> Thank you very much
> 
> Mike

ææåé
 
-- 
 jaaron  <http://jadetower.org>


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

Reply via email to