Why not something like...

public class BasePageImplementation extends BasePage {
    private Log logger;

    public BasePageImplementation() {
        // Since all page classes are inherited Tapestry generated classes
        // we use the superclass to initialize the log
        logger = LogFactory.getLog(this.getClass().getSuperclass());
    }

    /**
     * @return Returns the logger.
     */
    public Log getLogger() {
        return logger;
    }
}

Works for me. :-)


On 4/9/06, Mark <[EMAIL PROTECTED]> wrote:
>
> Yes, that's what I have done.
> But still - let's assume I have something like
>
> public abstract class LogAwareBasePage extends BasePage implements
> PageBeginRenderListener {
>     Log log;
>     public void setLog(Log log) { ... }
>     public Log getLog() { ... }
> }
>
> I still don't have the log property initialized.
> Sure, I could do this:
>
> public abstract class LogAwareBasePage extends BasePage implements
> PageBeginRenderListener {
>     Log log = new SomeClassThatImplementsLog("param1", "param2", ...);
>     public void setLog(Log log) { ... }
>     public Log getLog() { ... }
> }
>
> But this is not runtime-configurable...
>
>
> Or I could do it in my .page file:
>
> <property name="log">ognl:Some OGNL expression</property>
>
> So I could plug it in the .page files, but that would have to be done in
> each .page file again and again. So if I want to switch the Log
> implementation, at least I don't have to modify my java code, but I will
> have to change every single .page file.
>
> So I am hoping that I could somehow use Hivemind instead to configure
> the injection of the Log implementation, but I don't know how.
>
>
> Also, as an additional challenge: My application architecture is using
> Spring for the configuration and property injection on all the other
> layers, so ideally, I would like to use Spring to initialize the log
> property, so that I do not have to define all the beans twice (once in
> Spring and once in Hivemind). Maybe the bridge from the tapestry-spring
> project can be used for that???
>
> Thanks for the help,
>
> MARK
>
>
>
>
>
>
>
> Sam Gendler wrote:
> > Define a MyBasePage which has all the properties you want, and then
> > make all your pages inherit from that.
> >
> > --sam
> >
> >
> > On 4/9/06, Mark <[EMAIL PROTECTED]> wrote:
> >
> >> Hello,
> >>
> >> is there a way to "globally" inject certain properties in a large
> number
> >> of pages, without having to do it in each page specification file?
> >> For example, I expect all my pages to have a "log" Property which is an
> >> implementation of the commons-logging Log interface.
> >> But I want to plug the particular implementation of the Log interface
> >> using injection at runtime, just like all the other page properties are
> >> plugged at runtime based on the .page specification file as well.
> >> However, I don't want to have to include the same property definition
> in
> >> every single page-descriptor, since it is not very well maintainable.
> >> Imagine I have 100 pages and now want to change the implementation of
> >> the Log interface - I have to change 100 different .page files.
> >>
> >> So is there a way to do this in a better way?
> >>
> >> Thanks,
> >>
> >> MARK
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
Pedro Viegas

Reply via email to