Cool, thanks for the quick work.
I'll take a look at it.
MARK
James Carman wrote:
Okay. I've got the auto-wire thing working. It's in my tapernate-example
application. The source for it can be found here:
http://www.carmanconsulting.com/svn/public/tapernate-example/trunk/src/java/
com/carmanconsulting/tapernate/example/web/enhance/HiveMindAutowireWorker.ja
va
I had to create a custom factory, since I wanted the Module injected into
me:
http://www.carmanconsulting.com/svn/public/tapernate-example/trunk/src/java/
com/carmanconsulting/tapernate/example/web/enhance/HiveMindAutowireWorkerFac
tory.java
You have to do a bit of configuration in the hivemodule.xml file (at the
bottom):
http://www.carmanconsulting.com/svn/public/tapernate-example/trunk/src/templ
ates/WEB-INF/hivemodule.xml
If you ask for something to be injected via an annotation or xml file, it
won't override that. This only happens on read-only properties which
haven't been injected by other means. If the tapestry team likes this
(Jesse?), feel free to go ahead and include it in the core library. It's
Apache v2.0 licensed. Do you want me to create a JIRA issue and attach a
patch to it?
-----Original Message-----
From: James Carman [mailto:[EMAIL PROTECTED]
Sent: Saturday, April 22, 2006 4:17 PM
To: 'Tapestry users'
Subject: RE: What to do if annotations are not available?
What we really need is the ability to "autowire" services into our
components/pages. Maybe we should set something up that does that? So, if
a page has a setPersonDao() method, it would automatically have the proxy
for the service that implements the PersonDao interface injected into it. I
can look into this. It shouldn't be that difficult.
-----Original Message-----
From: Mark [mailto:[EMAIL PROTECTED]
Sent: Saturday, April 22, 2006 11:39 AM
To: Tapestry users
Subject: Re: What to do if annotations are not available?
Hi Raul,
thanks for the response.
Inject doesn't scale because you need to do it in every single .page
file. If you have a large application, you have lots of those. I have
not a lot of experience but I think you can even have many pages that do
not require .page files, so all of those now need to have one as well.
Now imagine you want to add a new property to your VlibPage class. Now
you need to run through all of the .page files again and put the new
inject tag in everywhere.
I'm not sure if I understand your 3rd option. If I have a custom
service, I still need to use either 1. or 2. to inject the service into
the page, don't I?
I had an idea last night, but don't know if it is viable:
- Create a VlibBasePageComponent that handles all that stuff, inject
everything into the component via .jwc file
- have my VlibPage implement PageAttachListener.pageAttached().
- In pageAttached() call "getNestedComponent()" to access the component
and then get all the injected stuff from there.
The advantage would be that all the services, beans, etc can be injected
into the component, which means I only need to add them into one .jwc
file rather than all .page files.
Not sure if I still need to inject the component itself into each .page
file, but even if I do - at least adding new services or beans can be
done in the .jwc once.
2 questions regarding this idea:
1. Would it work at all?
2. Will it work for high-traffic applications, meaning be thread-save,
so that one user does not end up with properties that came from some
other user's session...
Thanks,
MARK
Raul Raja wrote:
Why <inject/> doesn't scale?
As far as I know there are three ways to access your registry ASO's
and services:
1. annotations
2. <inject>
3. Creating a custom engine service and injecting the object via
setter based dependency using their interfaces as parameters for the
setter, which in my opinion is even a heavier and a more complicated
solution.
Are there other ways?
best regards.
Raul Raja.
Mark wrote:
Hello everybody,
attached below is an excerpt of the code from the VLib sample project
- the VlibPage Class to be more exact.
I assume this is the BasePage subclass that is used for most (if not
all) pages of the Vlib application.
It uses annotations to access all the required beans, objects and
services that are defined in Hivemind.
How can I get to those objects and services if I use JDK 1.4 and do
not have annotations?
Please don't say "use <Inject> in the .page files" - I know that, but
that doesn't scale at all... There has to be some better way, no?!
Thanks a lot for your help!
MARK
====================================================
public abstract class VlibPage extends BasePage implements
IErrorProperty, IMessageProperty,
PageValidateListener, OperationsUser
{
@Bean(VirtualLibraryDelegate.class)
public abstract IValidationDelegate getValidationDelegate();
@InjectState("visit")
public abstract Visit getVisitState();
@InjectStateFlag("visit")
public abstract boolean getVisitStateExists();
@InjectPage("Login")
public abstract Login getLogin();
@InjectMeta("anonymous-access")
public abstract boolean getAllowAnonymousAccess();
@InjectMeta("admin-page")
public abstract boolean isAdminPage();
@InjectObject("service:vlib.ModelSource")
public abstract ModelSource getModelSource();
====================================================
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
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]