Jon Elson-Green wrote:

Jon Elson-Green wrote:

Hi all,

I have made a Selector which creates a number of selectable components based on it's configuration (DefaultFileHandlerSelector).
These selectable components depend on another component (a DataSourceSelector named datasources).
I have supplied a DataSourceSelector to my Selector during service() and attempt to create my selectable components during initialize() (DAFStoreFileHandler)


When I create a selectable component I pass my servicemanager to it so that it can access my DataSourceSelector however I get an exception:

Exception: org.apache.avalon.framework.service.ServiceException
Message: Unknown key: datasources (Key='datasources')
---- stack trace ------------------------------------------------------------
org.apache.avalon.framework.service.ServiceException: Unknown key: datasources (Key='datasources')
org.apache.avalon.activation.appliance.impl.DefaultServiceManager.lookup(DefaultServiceManager.java:110)


au.com.wcmgroup.liberty.blocks.filehandler.DAFStoreFileHandler.service(DAFStoreFileHandler.java:102)

au.com.wcmgroup.liberty.blocks.filehandler.DefaultFileHandlerSelector.initialize(DefaultFileHandlerSelector.java:122)

org.apache.avalon.activation.appliance.impl.DefaultAppliance.applyInitialization(DefaultAppliance.java:917)



My understanding of the lifecycle and automatic dependency resolving clearly needs work, without posting a bunch of sources could someone suggest where I have gone wrong.


More investigation leads me to believe the custom selector doesn't have a dependency on DataSourceSelector so it's not in the servicemanager.
As the components are dynamically created their dependencies aren't resolved by merlin.

If you define a component that happens to provide selection semantics then the component needs to define statically the service dependencies it has statically at the type level.


E.g.:

  /**
   * @avalon.component name="my-selector"
   */
   public class WidgetSelector
   {
      /**
       * @avalon.dependency type="Widget" key="widget-one"
       * @avalon.dependency type="Widget" key="widget-two"
       */
       public void service( ServiceManager manager )
       {
            // setup the widgets from which client of
            // this component can select between widget-one
            // and widget-two
       }

       public Widget select( String whichWidget )
       {
            // select the appropriate widget
       }
   }

Any suggestions about how to provide dependencies to dynamically created components? Especially where I don't want to declare the DataSourceSelector as a dependency of my Custom Selector, (although I tried this with manual dependency resolution and still didn't get an instance in the service manager).

Track and/or contribute to what is going on under the facilities subject because this is where you will be able to link in privileged components that have access the entire container side view of the world.


Cheers, Stephen.


Jon


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




--

|------------------------------------------------|
| Magic by Merlin                                |
| Production by Avalon                           |
|                                                |
| http://avalon.apache.org/merlin                |
| http://dpml.net/merlin/distributions/latest    |
|------------------------------------------------|

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



Reply via email to