Hi Berin,
Attached is an example of the kind of thing I'm looking for, either
as a separate class or part of the existing infrastructure. Thoughts ?
Cheers,
Marcus
On Wed, Apr 17, 2002 at 05:15:12PM +0200, Marcus Crafter wrote:
> On Wed, Apr 17, 2002 at 10:37:47AM -0400, Berin Loritsch wrote:
> > Marcus Crafter wrote:
> > >
> > > Quick question, I'm wondering if there is any way to be able to
> > > dynamically find out all the possible selectables within a component
> > > selector?
> >
> > No there isn't
>
> ok.
>
> > > From the API this doesn't look like it's possible - if so, was there
> > > a reason not to provide this functionality, or hasn't it brought
> > > up till now ?
> >
> > It hasn't been brought up till now. Generally, the logic for which
> > component to return should be in the Container, not the client. As a
> > result, you either work with a known system (ala Cocoon), or you have
> > a really smart container (ala Phoenix).
> >
> > What is the problem you want to solve with this apprach?
>
> I'd like to be able to offer the user a choice of options in some
> situations.
>
> For example, in our application, the user can select which database
> they can log into. Previously on our login page we had a list of
> databases that they could choose from.
>
> I've since integrated the Avalon excalibur data sources into our
> application and would like to do the same, ie. supply the user with a
> list of configured databases at login time based on what's been
> specified between the <datasources>...</datasources> section
> of our config file.
>
> I was hoping there might have been a way to get a list of configured
> datasources from the DataSourceSelector, which I could iterate
> over when creating the login page.
>
> There are a few other cases, but the idea is the same - find out
> what's been configured so the user can choose.
>
> Cheers,
>
> Marcus
>
> --
> .....
> ,,$$$$$$$$$, Marcus Crafter
> ;$' '$$$$: Computer Systems Engineer
> $: $$$$: ManageSoft GmbH
> $ o_)$$$: 82-84 Mainzer Landstrasse
> ;$, _/\ &&:' 60327 Frankfurt Germany
> ' /( &&&
> \_&&&&'
> &&&&.
> &&&&&&&:
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
--
.....
,,$$$$$$$$$, Marcus Crafter
;$' '$$$$: Computer Systems Engineer
$: $$$$: ManageSoft GmbH
$ o_)$$$: 82-84 Mainzer Landstrasse
;$, _/\ &&:' 60327 Frankfurt Germany
' /( &&&
\_&&&&'
&&&&.
&&&&&&&:
/*
* Package definition
*/
//package some.package.yet.to.be.named;
/*
* Standard imports
*/
import java.util.List;
import java.util.ArrayList;
import org.apache.avalon.excalibur.component.ExcaliburComponentSelector;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.configuration.Configuration;
/**
* ChoosableComponentSelector.
*
* This ComponentSelector includes extra functionality allowing a developer to
* access during runtime the hints that this ComponentSelector manages.
*
* This allows one to iterate over the list of registered hints for example
* when runtime interaction is required to ascertain which Component should be
* selected.
*
* REVISIT: Implement as a Decorator or Subclass ?
* REVISIT: Find a better name!
*/
public class ChoosableComponentSelector extends ExcaliburComponentSelector
{
/**
* Add a new component to the manager.
*
* @param hint the hint name for the new component
* @param component the class of this component
* @param configuration the configuration of this component
*/
public void addComponent(
Object hint, Class component, Configuration configuration
)
throws ComponentException
{
super.addComponent(hint, component, configuration);
m_hints.add(hint);
}
/**
* Returns an array containing all hints registered with this
* ComponentSelector.
*
* @return <code>String[]</code> array containing all hints
* registered with this ComponentSelector
*/
public String[] hints()
{
String[] hints_a = new String[m_hints.size()];
return (String[]) m_hints.toArray(hints_a);
}
// local store of hints registered with this selector
private List m_hints = new ArrayList();
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>