Discussion:
[picocontainer-dev] Decorator with 2.x ?
Grégory Joseph
2011-01-27 18:18:25 UTC
Permalink
Hi list,

Is there any way to use Decorated with 2.x without using Decorating ?
Point is, I want to use a certain adapter and a certain Decorator on
only a limited set of components I'm registering, and it seems like
creating my container with the Decorating factory will have all my
components decorated.

If org.picocontainer.behaviors.Decorated.Decorator was public, I guess
I could do what I want here, but maybe I'm look at it the wrong way,
and there's another method I could use ?

I'm essentially trying to decorate components, bean-style, based on an
existing mechanism (which loads those values of a JCR repository, if
you must know) - so while I know where those values come from at
registration time, I have no idea what they (add to that the fact that
I need to proxy those objects because said values can change over
time;))

Thanks for any hint,

-g

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Paul Hammant
2011-01-27 20:00:47 UTC
Permalink
One has to subclass Decorating and implement a Decorator I think.

You could easily bake conditional logic into your Decorating subclass that
would do what you want - right ?

See that I did some work on the site - http://picocontainer.github.com/ ?
Its almost ready to flip the switch. This weekend perhaps I'll merge from
2.x to 3.x where needed and address the outstanding questions.

- Paul
Post by Grégory Joseph
Hi list,
Is there any way to use Decorated with 2.x without using Decorating ?
Point is, I want to use a certain adapter and a certain Decorator on
only a limited set of components I'm registering, and it seems like
creating my container with the Decorating factory will have all my
components decorated.
If org.picocontainer.behaviors.Decorated.Decorator was public, I guess
I could do what I want here, but maybe I'm look at it the wrong way,
and there's another method I could use ?
I'm essentially trying to decorate components, bean-style, based on an
existing mechanism (which loads those values of a JCR repository, if
you must know) - so while I know where those values come from at
registration time, I have no idea what they (add to that the fact that
I need to proxy those objects because said values can change over
time;))
Thanks for any hint,
-g
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
Grégory Joseph
2011-01-28 08:14:24 UTC
Permalink
Hey,
Post by Paul Hammant
One has to subclass Decorating and implement a Decorator I think.
Yeah, after I sent the email and went out for a few minutes, I
realized I could do this:
final Decorating decorating = new Decorating() {
public void decorate(Object instance) {
System.out.println("HELLO " + instance);
}
};
pico.addAdapter(
decorating.createComponentAdapter(new
NullComponentMonitor(), new NullLifecycleStrategy(), new Properties(),
moduleClass, moduleClass, null)
);

... as you might guess, I'm not too happy about the CM and LCS bits,
I'd like to "get them" from my current pico.
Post by Paul Hammant
You could easily bake conditional logic into your Decorating subclass that
would do what you want - right ?
Not really (although I haven't given it much thought), the components
I'm decorating have no specific interface or annotation to
differentiate them, they're just registered from a different source...
Post by Paul Hammant
See that I did some work on the site - http://picocontainer.github.com/ ?
Ha cool, no more 404 images ;) Had been a while since I seen it. HA!
and I see the navigation changed. I'm still kind of missing a high
level navigation, either on the side or the top, though.
Post by Paul Hammant
Its almost ready to flip the switch.  This weekend perhaps I'll merge from
2.x to 3.x where needed and address the outstanding questions.
Excellent, thanks !

-g
Post by Paul Hammant
- Paul
Post by Grégory Joseph
Hi list,
Is there any way to use Decorated with 2.x without using Decorating ?
Point is, I want to use a certain adapter and a certain Decorator on
only a limited set of components I'm registering, and it seems like
creating my container with the Decorating factory will have all my
components decorated.
If org.picocontainer.behaviors.Decorated.Decorator was public, I guess
I could do what I want here, but maybe I'm look at it the wrong way,
and there's another method I could use ?
I'm essentially trying to decorate components, bean-style, based on an
existing mechanism (which loads those values of a JCR repository, if
you must know) - so while I know where those values come from at
registration time, I have no idea what they (add to that the fact that
I need to proxy those objects because said values can change over
time;))
Thanks for any hint,
-g
---------------------------------------------------------------------
   http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Loading...