Re deserialization:
You can use getter-based dependency injection to solve this problem.
Every time, a dependency-injected field is accessed (or corresponding
getter method is executed -- your choice), an advise can re-inject the
dependencies. See
http://www.ibm.com/developerworks/java/library/j-aopwork13.html for
more details.
Re configuring too many objects:
You can use annotations (such as @Configured available with Spring
2.0), and then you can just define a prototype configuration in the
bean configuration file. You can implement the same functionality with
classes implementing an interface, if you prefer it over annotations.
For example, here are a few beans that need an emailer as an injected
dependency:
@Configurable("emailClient")
public class OrderProcessor {
private Emailer emailer; // property with getter and setter
... use emailer
}
@Configurable("emailClient")
public class ShipmentProcessor {
private Emailer emailer; // property with getter and setter
... use emailer
}
You need only the following prototype definition in XML:
<bean id="emailClient" lazy-init="true">
<property name="emailer" ref="smtpEmailer"/>
</bean>
This works out of box for constructor-based DI; but it is not hard to
write a getter-based implementation either.
-Ramnivas
===
Ramnivas Laddad,
Author, AspectJ in Action
http://ramnivas.com
Igor Vaynberg wrote:
no it wont be the solution. havent you guys been following
any of the other spring threads? injecting a component is not enough
because you never want those dependencies serialized - thus the whole
thing about wicket proxying the dependencies it injects.
you inject a service into a page's member variable. that page gets
serialized, the service gets serialized, the hibernate dao the service
references gets serialized, the hibernate session factory the dao
references gets serialized - now you have a huge mess. or worse, the
service is not serializable - you get an exception - the page never
makes it into session - nothing on the page works.
besides, the way i see it you have to declare the dependencies inside
the application context just like you would for any other bean, this
will get tedios. in the project i work on now we probably have more
then 100 components that get injected, i wouldnt want to have 100 bean
definitions in my application context. and maintainin @SpringBean
wicket annotations is a lot simpler.
-Igor
On 6/16/06, Tom van Zummeren <[EMAIL PROTECTED]> wrote:
Hey,
I was there
as well, and I agree with you.
This could be the solution to all wicket-spring integration problems.
Now for
someone to actually try it…
Tom
Hey everybody,
I've followed a few
discussions here on dependency
injection and when I was visiting the Spring 2.0 presentation at
J-Spring in
the Netherlands
there was one new feature that really drew my attention.
Spring 2.0 offers support
for dependency injection into
domain objects using AspectJ, and when I read the description (http://static.springframework.org/spring/docs/2.0-m5/spring-reference.pdf
, section 7.7.1) it sounds like this would be the perfect way to
implement
dependency injection with Wicket.
I hope that solves all
our problems …
Kind regards,
Michiel Trimpe
Michiel
Trimpe
| Java Developer| TomTom | [EMAIL PROTECTED]
| +31
(0)6 41482341mobile
This e-mail message contains information
which is confidential and may
be privileged. It is intended for use by the addressee only. If you are
not the
intended addressee, we request that you notify the sender immediately
and
delete or destroy this e-mail message and any attachment(s), without
copying,
saving, forwarding, disclosing or using its contents in any other way.
TomTom
N.V., TomTom International BV
or any other company belonging to the TomTom group of companies will
not be
liable for damage relating to the communication by e-mail of data,
documents or
any other information.
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.0/366 - Release Date: 6/15/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.0/366 - Release Date: 6/15/2006
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
|