Wow great job Igor. Thanks for doing it. I think that's the proper way to go.

Regarding cglib I think you should use spring AOP (it is already a dependency and generalization can wait a bit). Spring AOP handles all that and a bit more and is easy to use. Ie for cglib like in the current implementation you would also have to do something for serializing the proxy (http://cglib.sourceforge.net/howto.html) and maybe there are other things. With spring AOP:


final Class proxyClass = //class/interface needed to inject
ProxyFactory fact = new ProxyFactory();
fact.setTargetSource(new TargetSource(){
    private transient _target;
    public Class getTargetClass(){return proxyClass;}
    public boolean isStatic(){return false;}
    public Object getTarget() throws Exception
    {
       if(_target == null)
            _target = loadTheTarget();
       return _target;
    }
    public void releaseTarget(Object arg0) throws Exception{}
});

if(!proxyClass.isInterface())
   fact.setProxyTargetClass(true); //will use cglib

Object proxy = fact.getProxy();
//inject the proxy (done)

Just of my head two further suggestions:
1.) If a field is not null than do not inject anything. This way custom injections could be done 2.) If a Compnoent implements Initializable than call init(). So setter injection can be done and the componetn can do its full setup in the init method - basically like in the constructor.

What I'm working on now is an ApplicationContext which wrapps the 'real' ApplicationContext and does create for getBean() etc automatically the proxies. I think this way I'll never have to worry about the serialization problem for such beans.

Christian




On Tue, 8 Nov 2005 00:07:30 -0800, Igor Vaynberg <[EMAIL PROTECTED]> wrote:

heh
why do i only get to work on this stuff when i can barely keep my eyes open?

works great when i use a dynamic proxy - ie the dependency is an interface.
there is some class cast exception with cglib when the dependency is a
concrete class, maybe someone can take a look.

basically what this is does is this:
traverses the class hierarchy and looks for any fields that are annotated
with a SpringBean annotation, for any field it creates a proxy that will
load the dependency on first method invocation and sets the proxy as the
field value. the proxy does not replace the field value with the dependency
when its loaded, but instead forwards the invocations itself. this allows
the proxy to remain as the field value and be serialized and deserialized
instead of the dependency and thus solves the deserialization problem
because the proxy keeps enough information to be able to lookup the
dependency on its own.

this approach allows pages or components to carry spring references and
there is very low overhead because everything is lazy, and the hierarchy is
only traversed once.

right now the impl is jdk5 because that's the easiest, but this will work
just fine with jdk4, just need a way to store the metadata elsewhere - like
wicket metadata store in 1.2. it can also be easily extended to pull out
dependencies from places other then spring - the principle is the same.

the code (which needs to be refactored a lot) is in wicket-contrib-spring
project in wicket-stuff. see the wicket.contrib.spring.injection for code
and tests (examples :) )

this can work automatically for pages, just create a constructor like this:

SpringEnabledPage extends WebPage {
public SpringEnabledPage() {
super();
SpringInitailizer.initialize(this, getSpringContextLocator());
}
}

and then any page that extends the current page gets the proxies created
automatically

does this sound good to people and will any one actually use it? or is this
"not ioc enough" and i am just wasting my time?

Good night,
-Igor



On 11/7/05, Igor Vaynberg <[EMAIL PROTECTED]> wrote:

or a JNDIAnnotation, anything is possible with this approach.

Let me try and get some of it going tonight and we can move from there.

-Igor


On 11/7/05, Christian Essl <[EMAIL PROTECTED]> wrote:
>
> I think there should be both of your implementations.
>
> IMO the constructor based impl should have the protected doInject
> method,
> because to me it seems to be the easiest way to inject manually services
> in the constructor without the need to manually proxy them.
>
> Yes with cglib we'll hit the final problem. I think - don't know - we'll
> need also a default constructor. Anyway spring runs into the same
> problem
> if it uses ie transaction proxies because spring does also use cglib for
>
> non interface based AOP. Maybe use spring AOP directly, which is well
> tested and performend.
>
> To me it would be fine to only use interfaces, because in the end those
> things are services I want to replace for mocking, remoting or
> whatsoever.
> So interfaces are a good (recomended) practice.
>
> By the way we could also create an EJBInjection annotation.
>
> Christian
>
>
>
> On Mon, 7 Nov 2005 16:22:02 -0800, Igor Vaynberg <[EMAIL PROTECTED]
> >
> wrote:
>
> > but using that same idea, there is nothing stopping you from creating
> a
> > subclass that calls the decorating factory from the constructor.
> >
> > So some of these init proxies are going to have to be cglib proxies?
> We
> > can
> > check if the field's type is an interface, and if so we can create a
> > regular
> > proxy, but if its not we try to create a cglib proxy? Do we hit the
> same
> > final method drawbacks?
> >
> > -Igor
> >
> >
> > On 11/7/05, Christian Essl <[EMAIL PROTECTED]> wrote:
> >>
> >> That's right. That's propably the cleanest way and you can use it on
> >> each
> >> component.
> >>
> >> The problem why I came up with the constructor aproach initially was
> >> that
> >> generally all the subcomponents are created and setup in the
> >> constructor.
> >> And it would than be IMO more wicket like if you can also inject the > >> services directly in the constructor, witout breaking up the setup of
> >> the
> >> subcomponents between the constructor and some setters.
> >>
> >> IMO this is a general problem with setter based DI and hierarchical
> >> structures.
> >>
> >> Christian
> >>
> >> On Mon, 7 Nov 2005 15:16:53 -0800, Igor Vaynberg
> >> <[EMAIL PROTECTED]>
> >> wrote:
> >>
> >> > but why not replace every references thats annotated as a bean with
> a
> >> > proxy
> >> > that only initializes itself as opposed to the entire class? that
> way
> >> you
> >> > dont even need the doinjection() method in the class and its a lot
> >> safer.
> >> >
> >> > I would even put this "decoration" into a separate factory so that
> the
> >> > page
> >> > stays a simple dumb pojo with some annotations on it.That way you
> can
> >> > have a
> >> > factory that pulls dependencies out of spring, or out of our
> builtin
> >> > metadata system, or out of somewhere else.
> >> >
> >> > code would look something like this:
> >> >
> >> > MyPage page=SpringDecorator.decorate(new MyPage(a,b,c));
> >> >
> >> > this would look like this:
> >> >
> >> > SpringDecorator.decorate (Page page) {
> >> > for each field with SpringBean annotation in page
> >> > set value to a new SpringDepdencyProxy
> >> > end
> >> > return page;
> >> > }
> >> >
> >> > and the SpringDependencyProxy would look like this:
> >> >
> >> > transient targetobject;
> >> >
> >> > if (targetobject is null) {
> >> > locate spring context and set targetobject to the lookup
> >> > }
> >> > forward call to targetobject;
> >> >
> >> >
> >> > this way the class need not be aware of the fact that its decorated
> >> with
> >> > proxies or implement anything special. the proxies get serialized
> and
> >> > deserialized normally.
> >> >
> >> > -Igor
> >> >
> >> >
> >> > On 11/7/05, Christian Essl <[EMAIL PROTECTED] > wrote:
> >> >>
> >> >> Unfortunately I think this does not work.
> >> >>
> >> >> Actually cglib creates at runtime a subclass where you can
> override
> >> >> methods and as with any java code you can not override final (or
> >> >> private)
> >> >> methods. So when a non overridable method is called on the proxy
> it
> >> is
> >> >> not
> >> >> possible to delegate it and any state changes will only happen in
> the
> >> >> proxy and not in the proxied (real) page. On the other hand if the
> >> >> proxied
> >> >> instance calls one of its methods they will only effect its state
> and
> >> >> not
> >> >> the state of the proxy.
> >> >>
> >> >> Because of this and because the cglib proxy as a subclass also
> >> carries
> >> >> everything constructed in the cunstructor of the superclass I do
> not
> >> >> realy
> >> >> like cglib proxies.
> >> >>
> >> >> But why not make it something like this (pseudo code - not
> tested):
> >> >>
> >> >> public class AbstractSpringAwarePage extends WebPage
> >> >> {
> >> >> public AbstractSpringAwarePage()
> >> >> {
> >> >> super();
> >> >> doInjection();
> >> >> }
> >> >>
> >> >> private final void readObject( java.io.ObjectInputStream in)
> throws
> >> >> IOException,
> >> >> ClassNotFoundException
> >> >> {
> >> >> in.defaultReadObject();
> >> >> //do for fields only now
> >> >> Class cl = this.getClass();
> >> >> while(cl != null && !AbstractSpringAwarePage.class.equals(cl)){
> >> >> Field[] fields = cl.getDeclaredFields();
> >> >> for(final Field field:fields){
> >> >> //if field has spring annotation and it has a declaring class as
> >> >> interface
> >> >>
> >> >> //create a proxy
> >> >> InvocationHandler iH = new InvocationHandler(){
> >> >> private transient Object _target;
> >> >> public Object invoke(Object proxy, Method method, Object[]
> >> >> args) throws Throwable
> >> >> {
> >> >> if(_target == null){
> >> >> doInjection();
> >> >> _target = field.get(AbstractSpringAwarePage.this);
> >> >> }
> >> >> return method.invoke(_target, args);
> >> >> }
> >> >> };
> >> >> Class proxyClass = field.getDeclaringClass();
> >> >> Object serviceProxy = Proxy.newProxyInstance(
> >> >> Thread.currentThread().getContextClassLoader(),
> >> >> new Class[]{proxyClass}, iH);
> >> >> ///////////////
> >> >> //assign serviceProxy to field
> >> >> }
> >> >> cl = cl.getSuperclass();
> >> >> }
> >> >> }
> >> >>
> >> >> /**
> >> >> * Override to load and assign custom beans. WARNING IS CALLED FROM
> >> THE
> >> >> CONSTRUCTOR
> >> >> * DO NOT DEPEND ON STATE SET IN THE CONSTRUCTOR. DO NOT CALL
> METHODS
> >> >> WHICH DEPEND
> >> >> * ON INSTANCE STATE. DO NOT LET LEAK A REFERNCE TO THIS INSTANCE
> OUT.
> >> >> */
> >> >> protected void doInjection()
> >> >> {
> >> >> // Default implementation as Igor has.
> >> >> }
> >> >> }
> >> >>
> >> >>
> >> >> Sure this is not DI. It also does not provide AOP,
> >> livecylcle-management
> >> >> etc as a container does. It is also not elegant with the
> constructor
> >> >> calling the doInjection() method and it's magic.
> >> >>
> >> >> However it is sugar for lookup. ie:
> >> >>
> >> >> class MyPage(){
> >> >> @SpringBean("customerdao")
> >> >> protected CustomerDAO _customerDao; //no getter/setter
> >> >>
> >> >> public void someWhere(){
> >> >> _mydao.getCustomer("id");
> >> >> }
> >> >> }
> >> >>
> >> >> during testing:
> >> >>
> >> >> MyPage page = new MyPage(){
> >> >> protected void doInjection(){
> >> >> _customerDao = new MockDAO();
> >> >> }
> >> >> };
> >> >>
> >> >> And you have the service ready in the constructor in case you want
> to
> >> >> give
> >> >> it further to a component you construct in the constructor.
> >> >>
> >> >>
> >> >>
> >> >> On Mon, 7 Nov 2005 12:27:12 -0800, Igor Vaynberg
> >> >> <[EMAIL PROTECTED]>
> >> >> wrote:
> >> >>
> >> >> > yes. but instead of doing the injection right away the proxy
> would
> >> do
> >> >> > injection-on-first-access.
> >> >> > that way you get lazy injection and strongly typed pages.
> >> >> >
> >> >> > so you would annotate getter functions with the @SpringBean
> annot,
> >> and
> >> >> > the
> >> >> > proxy would first call the getter ... if the getter returns null
> >> the
> >> >> > proxy
> >> >> > would then look for the setter and invoke the setter with the
> >> >> dependency,
> >> >> > and then forward the call to the getter again.
> >> >> >
> >> >> > sound like a good idea?
> >> >> >
> >> >> > its not as elegant as being able to simply create the page and
> go,
> >> but
> >> >> it
> >> >> > does give us the benefit of lazy dependency lookups and solves
> >> >> > deserialization issues.
> >> >> >
> >> >> > i guess of course if you want to use aop you can intercept new
> >> >> operator
> >> >> > on a
> >> >> > subclass of WebPage and do the wrapping automatically.
> >> >> >
> >> >> > Or make the constructors of the page protected and create public
>
> >> >> static
> >> >> > factory methods. MyPage page=MyPage.construct(user,
> >> securitycontext);
> >> >> >
> >> >> > -Igor
> >> >> >
> >> >> >
> >> >> > On 11/7/05, Christian Essl <[EMAIL PROTECTED]> wrote:
> >> >> >>
> >> >> >> Do you mean when you construct the page you do something like
> >> >> >>
> >> >> >> MyPage page = (MyPage) wrapInProxy(new MyPage(..));
> >> >> >>
> >> >> >> and wrapInProxy does create the Proxy and does all the
> injection?
> >> >> >>
> >> >> >>
> >> >> >> On Mon, 7 Nov 2005 11:56:23 -0800, Igor Vaynberg
> >> >> >> <[EMAIL PROTECTED] >
> >> >> >> wrote:
> >> >> >>
> >> >> >> > yeah, i was thinking cglib and extract at runtime
> >> >> >> > never used cglib before though
> >> >> >> >
> >> >> >> > that way you just wrap the page with the proxy after you
> create
> >> it
> >> >> and
> >> >> >> > there
> >> >> >> > is no need to worry about serialization/deserialiation
> garbage
> >> >> >> >
> >> >> >> > -Igor
> >> >> >> >
> >> >> >> >
> >> >> >> > On 11/7/05, Christian Essl < [EMAIL PROTECTED]> wrote:
> >> >> >> >>
> >> >> >> >> The interface of the setter parameter or of the field type.
> Of
> >> >> >> course a
> >> >> >> >> restriction. If you want more you could use cglib (or spring
> >> aop).
> >> >> >> Don't
> >> >> >> >> know.
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> On Mon, 7 Nov 2005 11:27:28 -0800, Igor Vaynberg
> >> >> >> >> < [EMAIL PROTECTED]>
> >> >> >> >> wrote:
> >> >> >> >>
> >> >> >> >> > what interface would you use for the proxy though?
> >> >> >> >> > -Igor
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> > On 11/7/05, Christian Essl <[EMAIL PROTECTED] >
> wrote:
> >> >> >> >> >>
> >> >> >> >> >> Thanks for the clarification and sorry for the confusion.
> So
> >> >> >> >> >> readObject()
> >> >> >> >> >> as you have it in your code is fine.
> >> >> >> >> >>
> >> >> >> >> >> > To get the bean context i simply make my
> applicationbean
> >> >> >> implement
> >> >> >> >> >> > applicationcontextaware and then i use
> >> >> >> >> >> > ((MyApplication)Application.get()).getBeanContext()
> static
> >> >> >> lookup
> >> >> >> >> >> which
> >> >> >> >> >> > works because application object is always present.
> >> >> >> >> >>
> >> >> >> >> >> Still one question. The threadlocal used in
> >> Application.get()
> >> >> is
> >> >> >> set
> >> >> >> >> at
> >> >> >> >> >> the beginning of a request - on the request thread. I do
> not
> >> >> know
> >> >> >> but
> >> >> >> >> >> maybe the deserialization of the session could happen
> >> outside
> >> >> of
> >> >> a
> >> >> >> >> >> request
> >> >> >> >> >> - even in a totally different thread?
> >> >> >> >> >>
> >> >> >> >> >> Maybe in readObject() a dynamic proxy could be injected
> >> which
> >> >> >> >> triggers
> >> >> >> >> >> on
> >> >> >> >> >> first access the onInject() method.
> >> >> >> >> >>
> >> >> >> >> >> Christian
> >> >> >> >> >>
> >> >> >> >> >> >
> >> >> >> >> >> > -Igor
> >> >> >> >> >> >
> >> >> >> >> >> >
> >> >> >> >> >> > On 11/7/05, Christian Essl <[EMAIL PROTECTED]>
> wrote:
> >> >> >> >> >> >>
> >> >> >> >> >> >> On Mon, 7 Nov 2005 15:25:29 +0100, Johan Compagner
> >> >> >> >> >> >> <[EMAIL PROTECTED]>
> >> >> >> >> >> >> wrote:
> >> >> >> >> >> >>
> >> >> >> >> >> >> > And there is also a thing like XML Serialization
> >> >> >> >> >> >> > Which also doesn't use the java read/write object at
>
> >> all.
> >> >> >> >> >> >> >
> >> >> >> >> >> >>
> >> >> >> >> >> >> Does this mean that the readObject is guaranteed to be
>
> >> >> called
> >> >> >> on
> >> >> >> >> Page
> >> >> >> >> >> >> because it is serialized through the PageMap and is
> not a
> >> >> >> direct
> >> >> >> >> >> session
> >> >> >> >> >> >> attribute?
> >> >> >> >> >> >>
> >> >> >> >> >> >> I don't get realy clear with 'Serializable closure' in
>
> >> the
> >> >> >> spec:
> >> >> >> >> >> >>
> >> >> >> >> >> >> "Developers are not guaranteed that containers will
> call
> >> >> >> >> readObject
> >> >> >> >> >> and
> >> >> >> >> >> >> writeObject methods on
> >> >> >> >> >> >> session attributes if they implement them, but are
> >> >> guaranteed
> >> >> >> that
> >> >> >> >> >> the
> >> >> >> >> >> >> Serializable closure of their attributes will be
> >> preserved."
> >> >> >> >> >> >>
> >> >> >> >> >> >> And if readObject() gets called on Pages can I than
> acess
> >> >> >> somehow
> >> >> >> >> the
> >> >> >> >> >> >> ApplicationContext to get to the BeanContext?
> >> >> >> >> >> >>
> >> >> >> >> >> >> Please help.
> >> >> >> >> >> >>
> >> >> >> >> >> >> Thanks,
> >> >> >> >> >> >> Christian
> >> >> >> >> >> >>
> >> >> >> >> >> >> >
> >> >> >> >> >> >> > On 11/7/05, Christian Essl <[EMAIL PROTECTED] >
> >> wrote:
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >> Hi Igor,
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >> I looked through your code. Thanks for implementing
> >> it.
> >> I
> >> >> am
> >> >> >> >> not
> >> >> >> >> >> sure
> >> >> >> >> >> >> >> wheter readObject() is the right place to do the
> >> >> >> (re)injection.
> >> >> >> >> >> >> >> According
> >> >> >> >> >> >> >> to the servlet-spec in SVR 7.7.2 readObject() is
> not
> >> >> >> guaranteed
> >> >> >> >> to
> >> >> >> >> >> be
> >> >> >> >> >> >> >> called on session-attributes. (Instead session
> >> attributes
> >> >> >> which
> >> >> >> >> >> >> >> implement
> >> >> >> >> >> >> >> HttpSessionActiviationListeners are informed on
> >> >> >> >> deserialization).
> >> >> >> >> >> >> Even
> >> >> >> >> >> >> >> if
> >> >> >> >> >> >> >> readObject is called I am not sure wheter there is
> an
> >> >> >> >> >> >> ApplicationContext
> >> >> >> >> >> >> >> to get to the BeanContext.
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >> I don't know wheter wicket has a mean to propogate
> >> these
> >> >> >> >> >> >> >> HttpSessionEvents
> >> >> >> >> >> >> >> on deserialization or a similar callback? If so I
> >> guess
> >> >> you
> >> >> >> >> could
> >> >> >> >> >> do
> >> >> >> >> >> >> the
> >> >> >> >> >> >> >> (re)injection there.
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >> Christian
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >> On Mon, 7 Nov 2005 01:13:31 -0800, Igor Vaynberg
> >> >> >> >> >> >> >> <[EMAIL PROTECTED]>
> >> >> >> >> >> >> >> wrote:
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >> > here is something i threw together that solves
> the
> >> >> >> >> >> deserialization
> >> >> >> >> >> >> and
> >> >> >> >> >> >> >> > ability to use the new operator to create pages.
> >> >> atleast
> >> >> i
> >> >> >> >> think
> >> >> >> >> >> it
> >> >> >> >> >> >> >> > does....its really late here and all i really
> know
> >> so
> >> >> far
> >> >> >> is
> >> >> >> >> >> that
> >> >> >> >> >> >> it
> >> >> >> >> >> >> >> > compiles :)
> >> >> >> >> >> >> >> >
> >> >> >> >> >> >> >> > the idea is pretty simple, do the injection in
> the
> >> >> default
> >> >> >> >> >> >> >> constructor,
> >> >> >> >> >> >> >> > and
> >> >> >> >> >> >> >> > then do it anytime the object is deserialized.
> you
> >> use
> >> >> a
> >> >> >> >> >> >> @SpringBean
> >> >> >> >> >> >> >> > annotation to denote the dependency. it can
> either
> >> be
> >> >> used
> >> >> >> >> on a
> >> >> >> >> >> >> field
> >> >> >> >> >> >> >> or
> >> >> >> >> >> >> >> > on
> >> >> >> >> >> >> >> > a setter. If you specify the bean name it will be
> >> used
> >> >> to
> >> >> >> >> find
> >> >> >> >> >> the
> >> >> >> >> >> >> >> bean,
> >> >> >> >> >> >> >> > if
> >> >> >> >> >> >> >> > you dont then the field's type or the setters
> >> argument
> >> >> >> type
> >> >> >> >> will
> >> >> >> >> >> be
> >> >> >> >> >> >> >> used
> >> >> >> >> >> >> >> > for
> >> >> >> >> >> >> >> > the lookup.
> >> >> >> >> >> >> >> >
> >> >> >> >> >> >> >> > -Igor
> >> >> >> >> >> >> >> >
> >> >> >> >> >> >> >> >
> >> >> >> >> >> >> >> > On 11/7/05, Igor Vaynberg <
> [EMAIL PROTECTED]>
> >> >> wrote:
> >> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >> >> and you have to have the pages defined as beans
> in
> >> the
> >> >> >> >> >> application
> >> >> >> >> >> >> >> >> context? with their properties specified?
> >> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >> >> -Igor
> >> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >> >> On 11/7/05, Igor Vaynberg <
> [EMAIL PROTECTED]>
> >> >> >> wrote:
> >> >> >> >> >> >> >> >> >
> >> >> >> >> >> >> >> >> > but how does the above handle deserealization
> of
> >> >> pages?
> >> >> >> >> there
> >> >> >> >> >> is
> >> >> >> >> >> >> >> >> nothing
> >> >> >> >> >> >> >> >> > to reinject the dependencies.
> >> >> >> >> >> >> >> >> >
> >> >> >> >> >> >> >> >> > -Igor
> >> >> >> >> >> >> >> >> >
> >> >> >> >> >> >> >> >> >
> >> >> >> >> >> >> >> >> > On 11/7/05, [EMAIL PROTECTED] < [EMAIL PROTECTED]>
> >> >> wrote:
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > IMHO pages are standing on the borderline
> >> between
> >> >> a
> >> >> >> >> >> stateful
> >> >> >> >> >> >> GUI
> >> >> >> >> >> >> >> and
> >> >> >> >> >> >> >> >> > > the rest of the application in form of
> >> stateless
> >> >> >> >> services.
> >> >> >> >> >> >> >> >> > > DI should be done by the IoC container,
> >> creating
> >> >> the
> >> >> >> >> pages
> >> >> >> >> >> can
> >> >> >> >> >> >> >> >> better
> >> >> >> >> >> >> >> >> > > be done the standard Wicket way ( e.g. with
> >> >> >> >> PageParameters).
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > As described before I'm using a custom page
> >> >> factory
> >> >> >> that
> >> >> >> >> >> >> >> cooperates
> >> >> >> >> >> >> >> >> > > with a wrapped page factory and the
> containing
> >> >> bean
> >> >> >> >> >> factory:
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > public class SpringInjectingPageFactory
> >> implements
> >> >> >> >> >> >> IPageFactory,
> >> >> >> >> >> >> >> >> > > BeanFactoryAware {
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > private AutowireCapableBeanFactory
> beanFactory;
> >> >> >> >> >> >> >> >> > > private IPageFactory pageFactory;
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > public void setPageFactory(IPageFactory
> >> >> pageFactory)
> >> >> >> {
> >> >> >> >> >> >> >> >> > > this.pageFactory = pageFactory;
> >> >> >> >> >> >> >> >> > > }
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > public void setBeanFactory(BeanFactory
> >> >> beanFactory)
> >> >> >> >> throws
> >> >> >> >> >> >> >> >> > > BeansException {
> >> >> >> >> >> >> >> >> > > this.beanFactory =
> >> >> >> >> (AutowireCapableBeanFactory)beanFactory;
> >> >> >> >> >> >> >> >> > > }
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > public Page newPage(Class pageClass) {
> >> >> >> >> >> >> >> >> > > Page page =
> >> this.pageFactory.newPage(pageClass);
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > injectDependencies(page, pageClass.getName());
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > return page;
> >> >> >> >> >> >> >> >> > > }
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > public Page newPage(Class pageClass,
> >> >> PageParameters
> >> >> >> >> >> >> parameters)
> >> >> >> >> >> >> {
> >> >> >> >> >> >> >> >> > > Page page = this.pageFactory.newPage
> (pageClass,
> >> >> >> >> >> parameters);
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > injectDependencies(page, pageClass.getName());
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > return page;
> >> >> >> >> >> >> >> >> > > }
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > private void injectDependencies(Page page,
> >> String
> >> >> >> >> >> beanName) {
> >> >> >> >> >> >> >> >> > > if (this.beanFactory.containsBean(beanName))
> {
> >> >> >> >> >> >> >> >> > > this.beanFactory.applyBeanPropertyValues
> (page,
> >> >> >> >> beanName);
> >> >> >> >> >> >> >> >> > > }
> >> >> >> >> >> >> >> >> > > }
> >> >> >> >> >> >> >> >> > > }
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > Note that if you don't specify a name or id
> >> >> attribute
> >> >> >> >> for
> >> >> >> >> >> >> beans,
> >> >> >> >> >> >> >> >> they
> >> >> >> >> >> >> >> >> > > will be registered under their classname in
> >> >> Spring.
> >> >> >> >> >> >> >> >> > > And NO, I don't use autowiring:
> >> >> >> >> applyBeanPropertyValues()
> >> >> >> >> >> does
> >> >> >> >> >> >> >> not
> >> >> >> >> >> >> >> >> > > autowire although it is located in
> >> >> >> >> >> AutowireCapableBeanFactory.
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > Sven
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > > >you are right, this is not ioc. but are
> >> >> >> >> pages/components
> >> >> >> >> >> >> managed
> >> >> >> >> >> >> >> by
> >> >> >> >> >> >> >> >> > > an ioc
> >> >> >> >> >> >> >> >> > > >container?
> >> >> >> >> >> >> >> >> > > >-Igor
> >> >> >> >> >> >> >> >> > > >
> >> >> >> >> >> >> >> >> > > >
> >> >> >> >> >> >> >> >> > > >On 11/6/05, Alexandru Popescu <
> >> >> >> >> >> >> >> >> [EMAIL PROTECTED]>
> >> >> >> >> >> >> >> >> > > wrote:
> >> >> >> >> >> >> >> >> > > >>
> >> >> >> >> >> >> >> >> > > >> #: Igor Vaynberg changed the world a bit
> at
> >> a
> >> >> time
> >> >> >> by
> >> >> >> >> >> >> saying
> >> >> >> >> >> >> >> on
> >> >> >> >> >> >> >> >> > > 11/6/2005
> >> >> >> >> >> >> >> >> > > >> 7:06 PM :#
> >> >> >> >> >> >> >> >> > > >> > Or how about a simple solution:
> >> >> >> >> >> >> >> >> > > >> >
> >> >> >> >> >> >> >> >> > > >> > public MyApplication extends
> >> WebApplication
> >> {
> >> >> >> >> >> >> >> >> > > >> > public Object lookup(String name) {
> >> >> >> >> >> >> >> >> > > >> > Object=...do a lookup from somewhere
> like
> >> >> spring
> >> >> >> >> >> context
> >> >> >> >> >> >> or
> >> >> >> >> >> >> >> app
> >> >> >> >> >> >> >> >> > > >> object...;
> >> >> >> >> >> >> >> >> > > >> > return object;
> >> >> >> >> >> >> >> >> > > >> > }
> >> >> >> >> >> >> >> >> > > >> > }
> >> >> >> >> >> >> >> >> > > >> >
> >> >> >> >> >> >> >> >> > > >> > public MyPage extends Page {
> >> >> >> >> >> >> >> >> > > >> > public transient SomeService service;
> >> >> >> >> >> >> >> >> > > >> >
> >> >> >> >> >> >> >> >> > > >> > public SomeService getService() {
> >> >> >> >> >> >> >> >> > > >> > if (service==null) {
> >> >> >> >> >> >> >> >> > > >> >
> >> >> >> >> >> >> >>
> >> >> >> service=getApplication().lookup(SomeService.class.getName());
> >> >> >> >> >> >> >> >> > > >> > }
> >> >> >> >> >> >> >> >> > > >> > return service;
> >> >> >> >> >> >> >> >> > > >> > }
> >> >> >> >> >> >> >> >> > > >> >
> >> >> >> >> >> >> >> >> > > >> > I know its not quiete as elegant as ioc
> >> but
> >> >> it
> >> >> >> has
> >> >> >> >> >> none
> >> >> >> >> >> >> of
> >> >> >> >> >> >> >> the
> >> >> >> >> >> >> >> >> > > >> performance
> >> >> >> >> >> >> >> >> > > >> > hits an automatic injection would cause
> if
> >> it
> >> >> >> would
> >> >> >> >> be
> >> >> >> >> >> >> done
> >> >> >> >> >> >> >> on
> >> >> >> >> >> >> >> >> > > >> > deserialization of every component.
> Also
> >> its
> >> >> a
> >> >> >> lazy
> >> >> >> >> >> >> lookup
> >> >> >> >> >> >> >> so
> >> >> >> >> >> >> >> >> you
> >> >> >> >> >> >> >> >> > > dont
> >> >> >> >> >> >> >> >> > > >> do it
> >> >> >> >> >> >> >> >> > > >> > until its needed, and its only done
> once
> >> per
> >> >> >> page
> >> >> >> >> >> (until
> >> >> >> >> >> >> it
> >> >> >> >> >> >> >> >> gets
> >> >> >> >> >> >> >> >> > > >> > deserialized).
> >> >> >> >> >> >> >> >> > > >> >
> >> >> >> >> >> >> >> >> > > >> > -Igor
> >> >> >> >> >> >> >> >> > > >> >
> >> >> >> >> >> >> >> >> > > >>
> >> >> >> >> >> >> >> >> > > >> But this was exactly what I was
> suggesting
> >> to
> >> >> >> avoid
> >> >> >> >> ;-).
> >> >> >> >> >> >> >> Lookups
> >> >> >> >> >> >> >> >> > > and
> >> >> >> >> >> >> >> >> > > >> factories are not ioc/di.
> >> >> >> >> >> >> >> >> > > >>
> >> >> >> >> >> >> >> >> > > >> ./alex
> >> >> >> >> >> >> >> >> > > >> --
> >> >> >> >> >> >> >> >> > > >> .w( the_mindstorm )p.
> >> >> >> >> >> >> >> >> > > >>
> >> >> >> >> >> >> >> >> > > >>
> >> >> >> >> >> >> >> >> > > >>
> >> >> >> >> >> >> >> >> > > >>
> >> >> >> >> -------------------------------------------------------
> >> >> >> >> >> >> >> >> > > >> SF.Net email is sponsored by:
> >> >> >> >> >> >> >> >> > > >> Tame your development challenges with
> >> Apache's
> >> >> >> >> Geronimo
> >> >> >> >> >> App
> >> >> >> >> >> >> >> >> Server.
> >> >> >> >> >> >> >> >> > > >> Download
> >> >> >> >> >> >> >> >> > > >> it for free - -and be entered to win a
> 42"
> >> >> plasma
> >> >> >> tv
> >> >> >> >> or
> >> >> >> >> >> >> your
> >> >> >> >> >> >> >> very
> >> >> >> >> >> >> >> >> > > own
> >> >> >> >> >> >> >> >> > > >> Sony(tm)PSP. Click here to play:
> >> >> >> >> >> >> >> >> > > http://sourceforge.net/geronimo.php
> >> >> >> >> >> >> >> >> > > >>
> >> _______________________________________________
> >> >> >> >> >> >> >> >> > > >> Wicket-user mailing list
> >> >> >> >> >> >> >> >> > > >> Wicket-user@lists.sourceforge.net
> >> >> >> >> >> >> >> >> > > >>
> >> >> >> >> https://lists.sourceforge.net/lists/listinfo/wicket-user
> >> >> >> >> >> >> >> >> > > >>
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> > >
> >> >> >> -------------------------------------------------------
> >> >> >> >> >> >> >> >> > > SF.Net email is sponsored by:
> >> >> >> >> >> >> >> >> > > Tame your development challenges with
> Apache's
> >> >> >> Geronimo
> >> >> >> >> App
> >> >> >> >> >> >> >> Server.
> >> >> >> >> >> >> >> >> > > Download
> >> >> >> >> >> >> >> >> > > it for free - -and be entered to win a 42"
> >> plasma
> >> >> tv
> >> >> >> or
> >> >> >> >> >> your
> >> >> >> >> >> >> very
> >> >> >> >> >> >> >> >> own
> >> >> >> >> >> >> >> >> > > Sony(tm)PSP. Click here to play:
> >> >> >> >> >> >> >> http://sourceforge.net/geronimo.php
> >> >> >> >> >> >> >> >> > >
> _______________________________________________
> >> >> >> >> >> >> >> >> > > Wicket-user mailing list
> >> >> >> >> >> >> >> >> > > Wicket-user@lists.sourceforge.net
> >> >> >> >> >> >> >> >> > >
> >> >> >> https://lists.sourceforge.net/lists/listinfo/wicket-user
> >> >> >> >> >> >> >> >> > >
> >> >> >> >> >> >> >> >> >
> >> >> >> >> >> >> >> >> >
> >> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >> --
> >> >> >> >> >> >> >> Christian Essl
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >>
> >> >> ___________________________________________________________
> >> >> >> >> >> >> >> Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher
> >> >> kostenlos
> >> >> >> -
> >> >> >> >> Hier
> >> >> >> >> >> >> >> anmelden: http://mail.yahoo.de
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >>
> >> >> >> >> >> >> >>
> >> -------------------------------------------------------
> >> >> >> >> >> >> >> SF.Net email is sponsored by:
> >> >> >> >> >> >> >> Tame your development challenges with Apache's
> >> Geronimo
> >> >> App
> >> >> >> >> >> Server.
> >> >> >> >> >> >> >> Download
> >> >> >> >> >> >> >> it for free - -and be entered to win a 42" plasma
> tv
> >> or
> >> >> your
> >> >> >> >> very
> >> >> >> >> >> own
> >> >> >> >> >> >> >> Sony(tm)PSP. Click here to play:
> >> >> >> >> >> http://sourceforge.net/geronimo.php
> >> >> >> >> >> >> >> _______________________________________________
> >> >> >> >> >> >> >> Wicket-user mailing list
> >> >> >> >> >> >> >> Wicket-user@lists.sourceforge.net
> >> >> >> >> >> >> >>
> >> https://lists.sourceforge.net/lists/listinfo/wicket-user
> >> >> >> >> >> >> >>
> >> >> >> >> >> >>
> >> >> >> >> >> >>
> >> >> >> >> >> >>
> >> >> >> >> >> >> --
> >> >> >> >> >> >> Christian Essl
> >> >> >> >> >> >>
> >> >> >> >> >> >>
> >> >> >> >> >> >>
> >> >> >> >> >> >>
> >> >> >> >> >> >>
> >> >> >> >> >> >>
> >> ___________________________________________________________
> >> >> >> >> >> >> Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher
> >> kostenlos
> >> >> -
> >> >> >> Hier
> >> >> >> >> >> >> anmelden: http://mail.yahoo.de
> >> >> >> >> >> >>
> >> >> >> >> >> >>
> >> >> >> >> >> >>
> >> >> >> >> >> >>
> -------------------------------------------------------
> >> >> >> >> >> >> SF.Net email is sponsored by:
> >> >> >> >> >> >> Tame your development challenges with Apache's
> Geronimo
> >> App
> >> >> >> >> Server.
> >> >> >> >> >> >> Download
> >> >> >> >> >> >> it for free - -and be entered to win a 42" plasma tv
> or
> >> your
> >> >> >> very
> >> >> >> >> own
> >> >> >> >> >> >> Sony(tm)PSP. Click here to play:
> >> >> >> >> http://sourceforge.net/geronimo.php
> >> >> >> >> >> >> _______________________________________________
> >> >> >> >> >> >> Wicket-user mailing list
> >> >> >> >> >> >> Wicket-user@lists.sourceforge.net
> >> >> >> >> >> >>
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> >> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >> --
> >> >> >> >> >> Christian Essl
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> ___________________________________________________________
> >> >> >> >> >> Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher
> kostenlos
> >> -
> >> >> Hier
> >> >> >> >> >> anmelden: http://mail.yahoo.de
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >> -------------------------------------------------------
> >> >> >> >> >> SF.Net email is sponsored by:
> >> >> >> >> >> Tame your development challenges with Apache's Geronimo
> App
> >> >> >> Server.
> >> >> >> >> >> Download
> >> >> >> >> >> it for free - -and be entered to win a 42" plasma tv or
> your
> >> >> very
> >> >> >> own
> >> >> >> >> >> Sony(tm)PSP. Click here to play:
> >> >> >> http://sourceforge.net/geronimo.php
> >> >> >> >> >> _______________________________________________
> >> >> >> >> >> Wicket-user mailing list
> >> >> >> >> >> Wicket-user@lists.sourceforge.net
> >> >> >> >> >> https://lists.sourceforge.net/lists/listinfo/wicket-user
> >> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> --
> >> >> >> >> Christian Essl
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> ___________________________________________________________ > >> >> >> >> Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos
> -
> >> Hier
> >> >> >> >> anmelden: http://mail.yahoo.de
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> -------------------------------------------------------
> >> >> >> >> SF.Net email is sponsored by:
> >> >> >> >> Tame your development challenges with Apache's Geronimo App
> >> >> Server.
> >> >> >> >> Download
> >> >> >> >> it for free - -and be entered to win a 42" plasma tv or your
>
> >> very
> >> >> own
> >> >> >> >> Sony(tm)PSP. Click here to play:
> >> >> http://sourceforge.net/geronimo.php
> >> >> >> >> _______________________________________________
> >> >> >> >> Wicket-user mailing list
> >> >> >> >> Wicket-user@lists.sourceforge.net
> >> >> >> >> https://lists.sourceforge.net/lists/listinfo/wicket-user
> >> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> --
> >> >> >> Christian Essl
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> ___________________________________________________________
> >> >> >> Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos -
> Hier
> >> >> >> anmelden: http://mail.yahoo.de
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> -------------------------------------------------------
> >> >> >> SF.Net email is sponsored by:
> >> >> >> Tame your development challenges with Apache's Geronimo App
> >> Server.
> >> >> >> Download
> >> >> >> it for free - -and be entered to win a 42" plasma tv or your
> very
> >> own
> >> >> >> Sony(tm)PSP. Click here to play:
> >> http://sourceforge.net/geronimo.php
> >> >> >> _______________________________________________
> >> >> >> Wicket-user mailing list
> >> >> >> Wicket-user@lists.sourceforge.net
> >> >> >> https://lists.sourceforge.net/lists/listinfo/wicket-user
> >> >> >>
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> Christian Essl
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> ___________________________________________________________
> >> >> Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier
>
> >> >> anmelden: http://mail.yahoo.de
> >> >>
> >> >>
> >> >>
> >> >> -------------------------------------------------------
> >> >> SF.Net email is sponsored by:
> >> >> Tame your development challenges with Apache's Geronimo App
> Server.
> >> >> Download
> >> >> it for free - -and be entered to win a 42" plasma tv or your very
> own
> >> >> Sony(tm)PSP. Click here to play:
> http://sourceforge.net/geronimo.php
> >> >> _______________________________________________
> >> >> Wicket-user mailing list
> >> >> Wicket-user@lists.sourceforge.net
> >> >> https://lists.sourceforge.net/lists/listinfo/wicket-user
> >> >>
> >>
> >>
> >>
> >> --
> >> Christian Essl
> >>
> >>
> >>
> >>
> >>
> >> ___________________________________________________________
> >> Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier
> >> anmelden: http://mail.yahoo.de
> >>
> >>
> >>
> >> -------------------------------------------------------
> >> SF.Net email is sponsored by:
> >> Tame your development challenges with Apache's Geronimo App Server.
> >> Download
> >> it for free - -and be entered to win a 42" plasma tv or your very own
>
> >> Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
> >> _______________________________________________
> >> Wicket-user mailing list
> >> Wicket-user@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/wicket-user
> >>
>
>
>
> --
> Christian Essl
>
>
>
>
>
> ___________________________________________________________
> Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier
> anmelden: http://mail.yahoo.de
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server.
> Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>





--
Christian Essl
        

        
                
___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to