Re: XML configuration not complete?

Konstantin Priblouda <kpriblouda-/[email protected]> Thu, 5 Feb 2004 01:03:56 -0800 (PST)
Newsgroups gmane.comp.java.nanocontainer.devel
Message-ID <[email protected]>
--- Paul Hammant <[email protected]> wrote:
> Konstantin,
> 
> Can you send in a (failing) test case? It will help
> us understand thing 
> you are proposing.
> 

Well, it may be not bug, but my ignorance and lack of
documentation preventing me from achieving what I
like. 

But after  looking into nano code, it seems that 
only constant parameters are implemented  by 
picoextras reflection. 

In short, I would like to be able to specify not only
constant dependencies ( which are covered by 
<parameter> pretty well ) , but also component
dependency ( by name ).


While testdriving, I did following in my java code:
---------%<------------------
       // register outgoing mail service
       
_container.registerComponentImplementation(MailServer.class,
SmtpServer.class,
            new Parameter[]{new
ComponentParameter("emailConfig")});
        // regiter velocity rendering engine
       
_container.registerComponentImplementation(VelocityComponent.class);
        // email propertry configurator
       
_container.registerComponentImplementation("emailConfig",
ClasspathProperties.class,
            new Parameter[]{new
ConstantParameter("/mail.properties")});
        // user registration notificator
       
_container.registerComponentImplementation(UserRegistrationNotification.class,
UserRegistrationNotification.class,
            new Parameter[]{new
ComponentParameter(MailServer.class),
            new
ComponentParameter(VelocityComponent.class)});
        // password recovery  notificator
       
_container.registerComponentImplementation(PasswordRecoveryNotification.class,
PasswordRecoveryNotification.class,
            new Parameter[]{new
ComponentParameter(MailServer.class),
            new
ComponentParameter(VelocityComponent.class)});
---------%<------------------

And now I would like to move it into external XML 
config file ( well, bsh is also there but for yout
internal puproses xml is better )

So I tried this:
---%<---------------------
<container>
    <component key="emailConfig"
class="com.infodesire.webgui.pico.ClasspathProperties">
        <parameter
class="java.lang.String">/mail.properties</parameter>
    </component>
    <component key="com.infodesire.mail.MailServer"
class="com.infodesire.mail.server.SmtpServer">
        <parameter
class="java.lang.String">emailConfig</parameter>
    </component>
    
    <component
class="com.infodesire.webgui.velocity.VelocityComponent"/>
    
    <component
class="com.infodesire.webgui.email.UserRegistrationNotification">
    <!--
        <parameter
class="org.picocontainer.defaults.ComponentParameter">com.infodesire.mail.MailServer</parameter>
        <parameter
class="org.picocontainer.defaults.ComponentParameter">com.infodesire.webgui.velocity.VelocityComponent</parameter>
        -->
    </component>
    
    <component
class="com.infodesire.webgui.email.PasswordRecoveryNotification">
    <!--
        <parameter
class="org.picocontainer.defaults.ComponentParameter">com.infodesire.mail.MailServer</parameter>
        <parameter
class="org.picocontainer.defaults.ComponentParameter">com.infodesire.webgui.velocity.VelocityComponent</parameter>
        -->
    </component>
</container>
---%<---------------------
I was able to specify constant parameter ( for
classpath properties ) , but not those properties by
name to email component - well,automatic wiring works
fine in this case, because there is only one instance
of ClassPathProperties there...  

But tag like <componentParameter (class|key)> would be
nice ( though "class" parameter may be not necessary )

regards,

=====
----[ Konstantin Pribluda ( ko5tik ) ]----------------
Zu Verstärkung meines Teams suche ich ab Sofort einen
Softwareentwickler[In] für die Festanstellung. 
Arbeitsort: Mainz 
Skills:  Programieren, Kentnisse in OpenSource-Bereich
----[ http://www.pribluda.de ]------------------------

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html