Jaaron,

Unless you are migrating from ECM, you do not need to use the "Selector" post-fix method. Certainly, for the example case it is not needed.

What I have found to work is this:

After you get the service as an Object, always check if the object returned is a ServiceSelector. If so, lookup the desired service from it by supplying the hint/shorthand. Fortress will return the service directly if there is only one defined in the roles-config file, if there are multiple it returns a ServiceSelector. Also, as long as you don't have a hint called "default", supplying a hint of "default" (soon to change to "*"?) to the lookup method returns the first service listed in the roles-config file.

Shash





From: J Aaron Farr <[EMAIL PROTECTED]>
Reply-To: "Avalon framework users" <[EMAIL PROTECTED]>
To: avalon <[EMAIL PROTECTED]>
Subject: Using ServiceSelector in Fortress
Date: Tue, 4 Feb 2003 08:19:42 -0800 (PST)

Hello.

I'm having a bit of trouble using the FortressServiceSelector. Let me put it
in the context of the current Fortress Swing example:

Suppose we have two translator components: translator1 and transator2 listed in
the SwingContainer.xconf file. For simplicity they're exactly the same except
for the 'id' attribute. Nothing else in the xconf file is changed.
Additionally, the .roles file is not touched either.

If I add a line or two in the SwingContainer.java class to check what class is
now returned from

m_serviceManager.lookup( ...Translator.ROLE ),

I get this:

DEBUG 2003-02-04 11:14:08.777 [fortress ] (): Object =
org.apache.avalon.fortress.impl.lookup.FortressServiceSelector

Now, I thought I had to do something like

m_serviceManager.lookup( ...Translator.ROLE + "Selector")

to get the ServiceSelector. On top of that, if I do use the ROLE + "Selector"
method, then I get an error regardless of whether I add a "TranslatorSelector"
entry in the SwingContainer.role file:

org.apache.avalon.fortress.InitializationException: Cannot set up impl. Startup
lifecycle failure
at
org.apache.avalon.fortress.impl.DefaultContainerManager.createContain
er(DefaultContainerManager.java:219)
....
Caused by: org.apache.avalon.framework.service.ServiceException: Unable to
provi
de implementation for
org.apache.avalon.fortress.examples.components.TranslatorS
elector
(Key='org.apache.avalon.fortress.examples.components.TranslatorSelector'
)
at
org.apache.avalon.framework.service.DefaultServiceManager.lookup(Defa
ultServiceManager.java:117)
....

I'm not sure if I'm just misunderstanding how to use the ServiceSelector or if
it has to do with the difference between ECM and Fortress, or what. Anyone
have any insight?

Thanks,
jaaron

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail


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

Reply via email to