Add custom lifecycle management

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Add custom lifecycle management

Norman Maurer
Hi all,

I'm very new to Aries and wonder if its possible to add some kind of
"PostBeanProcessor" (this is how it get called in spring). We at JAMES
use spring at the moment to wire up our application as standalone
application. Now we are working on "osgify" JAMES. We need to
implement some kind of lifecycle methods. For example if a "service"
implements LogEnabled interface it need to get a Log injected. The
same is true for other dependencies.. We use JSR250 annotations, so we
would need to handle this kind of stuff. I did some tests with
spring-dm the last weeks and it seems to work but aries looks very
interesting too.

You know, Eat your own dogfood ;)


Thx,
Norman
Reply | Threaded
Open this post in threaded view
|

Re: Add custom lifecycle management

David Jencks
IIUC you want to scan the classes in the bundle (or at least those being used as blueprint beans) and alter the blueprint recipe as a result.  I did this in xbean-blueprint (in geronimo/xbean) using a (not-yet-standardized) blueprint namespace handler.

The problem with the current namespace handler API is that it doesn't give you access to the bundle at any point.  I got around that by initiializing an instance of the namepace handler with the bundle with the interesting classes.  However, I think the current namespace handler API is defective in that it does not give the namespace handler instance direct access to the bundle.  Unfortunately I haven't had time to propose an api change.

thanks
david jencks

On Jun 18, 2010, at 9:19 AM, Norman Maurer wrote:

> Hi all,
>
> I'm very new to Aries and wonder if its possible to add some kind of
> "PostBeanProcessor" (this is how it get called in spring). We at JAMES
> use spring at the moment to wire up our application as standalone
> application. Now we are working on "osgify" JAMES. We need to
> implement some kind of lifecycle methods. For example if a "service"
> implements LogEnabled interface it need to get a Log injected. The
> same is true for other dependencies.. We use JSR250 annotations, so we
> would need to handle this kind of stuff. I did some tests with
> spring-dm the last weeks and it seems to work but aries looks very
> interesting too.
>
> You know, Eat your own dogfood ;)
>
>
> Thx,
> Norman

Reply | Threaded
Open this post in threaded view
|

Re: Add custom lifecycle management

Lin Sun
In reply to this post by Norman Maurer
Hi

Aries already has this bean Interceptor concept that allows you to
specify precall before the method is invoked and specify postCall
after the method is invoked, see the Interceptor interface.

Aries also has an example in transaction-blueprint project where it
specifies a custom name space for transaction blueprint and allow
users to intercept attribute with certain transaction attribute on
bean method invocations.

for example -

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">
     <bean id="TestBeanImpl" class="org.apache.aries.simple.TestBeanImpl">
        <tx:transaction method="insertRow" value="required"/>
     </bean>

</blueprint>

basically asks the blueprint container to manage required transaction
attribute/strategy on insertRow method invocation.

Is this similar as what you want to do, except you want to do it with logging?

HTH

Lin


On Fri, Jun 18, 2010 at 12:19 PM, Norman Maurer <[hidden email]> wrote:

> Hi all,
>
> I'm very new to Aries and wonder if its possible to add some kind of
> "PostBeanProcessor" (this is how it get called in spring). We at JAMES
> use spring at the moment to wire up our application as standalone
> application. Now we are working on "osgify" JAMES. We need to
> implement some kind of lifecycle methods. For example if a "service"
> implements LogEnabled interface it need to get a Log injected. The
> same is true for other dependencies.. We use JSR250 annotations, so we
> would need to handle this kind of stuff. I did some tests with
> spring-dm the last weeks and it seems to work but aries looks very
> interesting too.
>
> You know, Eat your own dogfood ;)
>
>
> Thx,
> Norman
>
Reply | Threaded
Open this post in threaded view
|

Re: Add custom lifecycle management

Norman Maurer
Hi Lin,

not exactly. I want to implement 3 things..

1) LogEnabled.
Every component which is instanced by aries should get checked if it
implement LogEnabled. If so it has a setLog(Log logger) method which
should get called to inject a Log instance

2) Configurable.
Every component which is instanced by aries should get checked if it
implement Configurable. If so it need to get the "right" configuration
passed to its configure(HierachicalConfiguration config) methd.

3) JSR250
Check if the component which is instanced by aries has
@Resource(name="example"), @PostConstruct, @PreDestroy annotations on
methods. If so inject the service with name example to the setter.
Then call method which is annotated by @PostConstruct.  On shutdown /
undeploy etc the method annoted with @PreDestroy should get called.

I need to be sure that it is handled in the right order.

LogEnabled, Configurable, JSR250

Hope its now clear what I want todo :)

Thx,
Norman



2010/6/18 Lin Sun <[hidden email]>:

> Hi
>
> Aries already has this bean Interceptor concept that allows you to
> specify precall before the method is invoked and specify postCall
> after the method is invoked, see the Interceptor interface.
>
> Aries also has an example in transaction-blueprint project where it
> specifies a custom name space for transaction blueprint and allow
> users to intercept attribute with certain transaction attribute on
> bean method invocations.
>
> for example -
>
> <?xml version="1.0" encoding="UTF-8"?>
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>    xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">
>     <bean id="TestBeanImpl" class="org.apache.aries.simple.TestBeanImpl">
>        <tx:transaction method="insertRow" value="required"/>
>     </bean>
>
> </blueprint>
>
> basically asks the blueprint container to manage required transaction
> attribute/strategy on insertRow method invocation.
>
> Is this similar as what you want to do, except you want to do it with logging?
>
> HTH
>
> Lin
>
>
> On Fri, Jun 18, 2010 at 12:19 PM, Norman Maurer <[hidden email]> wrote:
>> Hi all,
>>
>> I'm very new to Aries and wonder if its possible to add some kind of
>> "PostBeanProcessor" (this is how it get called in spring). We at JAMES
>> use spring at the moment to wire up our application as standalone
>> application. Now we are working on "osgify" JAMES. We need to
>> implement some kind of lifecycle methods. For example if a "service"
>> implements LogEnabled interface it need to get a Log injected. The
>> same is true for other dependencies.. We use JSR250 annotations, so we
>> would need to handle this kind of stuff. I did some tests with
>> spring-dm the last weeks and it seems to work but aries looks very
>> interesting too.
>>
>> You know, Eat your own dogfood ;)
>>
>>
>> Thx,
>> Norman
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Add custom lifecycle management

Valentin Mahrwald
Hi Norman,

that sounds like quite a tall order :) Especially, ordering configuration and JSR250 (or blueprint) lifecycle callbacks sounds like something blueprint is unlikely to support out of the box.

By the sounds of it for the level of control you want, you might want to use the org.apache.aries.blueprint.BeanProcessor extension point. This allows you to intercept beans during creation where you could the instanceof checks against LogEnabled and Configurable as well as look at annotations (assuming no other BeanProcessor proxied the bean previously).

Now, the BeanProcessor is on the far end of supported extensions in that it is more likely to change or be completely redesigned :)

Regards,

Valentin



On 18 Jun 2010, at 18:20, Norman Maurer wrote:

> Hi Lin,
>
> not exactly. I want to implement 3 things..
>
> 1) LogEnabled.
> Every component which is instanced by aries should get checked if it
> implement LogEnabled. If so it has a setLog(Log logger) method which
> should get called to inject a Log instance
>
> 2) Configurable.
> Every component which is instanced by aries should get checked if it
> implement Configurable. If so it need to get the "right" configuration
> passed to its configure(HierachicalConfiguration config) methd.
>
> 3) JSR250
> Check if the component which is instanced by aries has
> @Resource(name="example"), @PostConstruct, @PreDestroy annotations on
> methods. If so inject the service with name example to the setter.
> Then call method which is annotated by @PostConstruct.  On shutdown /
> undeploy etc the method annoted with @PreDestroy should get called.
>
> I need to be sure that it is handled in the right order.
>
> LogEnabled, Configurable, JSR250
>
> Hope its now clear what I want todo :)
>
> Thx,
> Norman
>
>
>
> 2010/6/18 Lin Sun <[hidden email]>:
>> Hi
>>
>> Aries already has this bean Interceptor concept that allows you to
>> specify precall before the method is invoked and specify postCall
>> after the method is invoked, see the Interceptor interface.
>>
>> Aries also has an example in transaction-blueprint project where it
>> specifies a custom name space for transaction blueprint and allow
>> users to intercept attribute with certain transaction attribute on
>> bean method invocations.
>>
>> for example -
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>>    xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">
>>     <bean id="TestBeanImpl" class="org.apache.aries.simple.TestBeanImpl">
>>        <tx:transaction method="insertRow" value="required"/>
>>     </bean>
>>
>> </blueprint>
>>
>> basically asks the blueprint container to manage required transaction
>> attribute/strategy on insertRow method invocation.
>>
>> Is this similar as what you want to do, except you want to do it with logging?
>>
>> HTH
>>
>> Lin
>>
>>
>> On Fri, Jun 18, 2010 at 12:19 PM, Norman Maurer <[hidden email]> wrote:
>>> Hi all,
>>>
>>> I'm very new to Aries and wonder if its possible to add some kind of
>>> "PostBeanProcessor" (this is how it get called in spring). We at JAMES
>>> use spring at the moment to wire up our application as standalone
>>> application. Now we are working on "osgify" JAMES. We need to
>>> implement some kind of lifecycle methods. For example if a "service"
>>> implements LogEnabled interface it need to get a Log injected. The
>>> same is true for other dependencies.. We use JSR250 annotations, so we
>>> would need to handle this kind of stuff. I did some tests with
>>> spring-dm the last weeks and it seems to work but aries looks very
>>> interesting too.
>>>
>>> You know, Eat your own dogfood ;)
>>>
>>>
>>> Thx,
>>> Norman
>>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: Add custom lifecycle management

Norman Maurer
Hi Valentin,

thanks for the response. I will try out the BeanProcessor stuff and
come back to you.. At the end maybe I can contribute something back ;)

BTW, would it be possible to publish the javadocs online ?

Bye,
Norman


2010/6/18 Valentin Mahrwald <[hidden email]>:

> Hi Norman,
>
> that sounds like quite a tall order :) Especially, ordering configuration and JSR250 (or blueprint) lifecycle callbacks sounds like something blueprint is unlikely to support out of the box.
>
> By the sounds of it for the level of control you want, you might want to use the org.apache.aries.blueprint.BeanProcessor extension point. This allows you to intercept beans during creation where you could the instanceof checks against LogEnabled and Configurable as well as look at annotations (assuming no other BeanProcessor proxied the bean previously).
>
> Now, the BeanProcessor is on the far end of supported extensions in that it is more likely to change or be completely redesigned :)
>
> Regards,
>
> Valentin
>
>
>
> On 18 Jun 2010, at 18:20, Norman Maurer wrote:
>
>> Hi Lin,
>>
>> not exactly. I want to implement 3 things..
>>
>> 1) LogEnabled.
>> Every component which is instanced by aries should get checked if it
>> implement LogEnabled. If so it has a setLog(Log logger) method which
>> should get called to inject a Log instance
>>
>> 2) Configurable.
>> Every component which is instanced by aries should get checked if it
>> implement Configurable. If so it need to get the "right" configuration
>> passed to its configure(HierachicalConfiguration config) methd.
>>
>> 3) JSR250
>> Check if the component which is instanced by aries has
>> @Resource(name="example"), @PostConstruct, @PreDestroy annotations on
>> methods. If so inject the service with name example to the setter.
>> Then call method which is annotated by @PostConstruct.  On shutdown /
>> undeploy etc the method annoted with @PreDestroy should get called.
>>
>> I need to be sure that it is handled in the right order.
>>
>> LogEnabled, Configurable, JSR250
>>
>> Hope its now clear what I want todo :)
>>
>> Thx,
>> Norman
>>
>>
>>
>> 2010/6/18 Lin Sun <[hidden email]>:
>>> Hi
>>>
>>> Aries already has this bean Interceptor concept that allows you to
>>> specify precall before the method is invoked and specify postCall
>>> after the method is invoked, see the Interceptor interface.
>>>
>>> Aries also has an example in transaction-blueprint project where it
>>> specifies a custom name space for transaction blueprint and allow
>>> users to intercept attribute with certain transaction attribute on
>>> bean method invocations.
>>>
>>> for example -
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>>>    xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">
>>>     <bean id="TestBeanImpl" class="org.apache.aries.simple.TestBeanImpl">
>>>        <tx:transaction method="insertRow" value="required"/>
>>>     </bean>
>>>
>>> </blueprint>
>>>
>>> basically asks the blueprint container to manage required transaction
>>> attribute/strategy on insertRow method invocation.
>>>
>>> Is this similar as what you want to do, except you want to do it with logging?
>>>
>>> HTH
>>>
>>> Lin
>>>
>>>
>>> On Fri, Jun 18, 2010 at 12:19 PM, Norman Maurer <[hidden email]> wrote:
>>>> Hi all,
>>>>
>>>> I'm very new to Aries and wonder if its possible to add some kind of
>>>> "PostBeanProcessor" (this is how it get called in spring). We at JAMES
>>>> use spring at the moment to wire up our application as standalone
>>>> application. Now we are working on "osgify" JAMES. We need to
>>>> implement some kind of lifecycle methods. For example if a "service"
>>>> implements LogEnabled interface it need to get a Log injected. The
>>>> same is true for other dependencies.. We use JSR250 annotations, so we
>>>> would need to handle this kind of stuff. I did some tests with
>>>> spring-dm the last weeks and it seems to work but aries looks very
>>>> interesting too.
>>>>
>>>> You know, Eat your own dogfood ;)
>>>>
>>>>
>>>> Thx,
>>>> Norman
>>>>
>>>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Add custom lifecycle management

Lin Sun
Hi Norma

Yep I agree with Valentin that I don't think the standardized
blueprint container spec provides what you want.

Regarding annotation, I have done some limited work on it, but it is
mostly based on the blueprint XML definition file.  What you are
attempting to do isn't configurable from the configuration of
blueprint XML file.

Lin

On Fri, Jun 18, 2010 at 1:49 PM, Norman Maurer <[hidden email]> wrote:

> Hi Valentin,
>
> thanks for the response. I will try out the BeanProcessor stuff and
> come back to you.. At the end maybe I can contribute something back ;)
>
> BTW, would it be possible to publish the javadocs online ?
>
> Bye,
> Norman
>
>
> 2010/6/18 Valentin Mahrwald <[hidden email]>:
>> Hi Norman,
>>
>> that sounds like quite a tall order :) Especially, ordering configuration and JSR250 (or blueprint) lifecycle callbacks sounds like something blueprint is unlikely to support out of the box.
>>
>> By the sounds of it for the level of control you want, you might want to use the org.apache.aries.blueprint.BeanProcessor extension point. This allows you to intercept beans during creation where you could the instanceof checks against LogEnabled and Configurable as well as look at annotations (assuming no other BeanProcessor proxied the bean previously).
>>
>> Now, the BeanProcessor is on the far end of supported extensions in that it is more likely to change or be completely redesigned :)
>>
>> Regards,
>>
>> Valentin
>>
>>
>>
>> On 18 Jun 2010, at 18:20, Norman Maurer wrote:
>>
>>> Hi Lin,
>>>
>>> not exactly. I want to implement 3 things..
>>>
>>> 1) LogEnabled.
>>> Every component which is instanced by aries should get checked if it
>>> implement LogEnabled. If so it has a setLog(Log logger) method which
>>> should get called to inject a Log instance
>>>
>>> 2) Configurable.
>>> Every component which is instanced by aries should get checked if it
>>> implement Configurable. If so it need to get the "right" configuration
>>> passed to its configure(HierachicalConfiguration config) methd.
>>>
>>> 3) JSR250
>>> Check if the component which is instanced by aries has
>>> @Resource(name="example"), @PostConstruct, @PreDestroy annotations on
>>> methods. If so inject the service with name example to the setter.
>>> Then call method which is annotated by @PostConstruct.  On shutdown /
>>> undeploy etc the method annoted with @PreDestroy should get called.
>>>
>>> I need to be sure that it is handled in the right order.
>>>
>>> LogEnabled, Configurable, JSR250
>>>
>>> Hope its now clear what I want todo :)
>>>
>>> Thx,
>>> Norman
>>>
>>>
>>>
>>> 2010/6/18 Lin Sun <[hidden email]>:
>>>> Hi
>>>>
>>>> Aries already has this bean Interceptor concept that allows you to
>>>> specify precall before the method is invoked and specify postCall
>>>> after the method is invoked, see the Interceptor interface.
>>>>
>>>> Aries also has an example in transaction-blueprint project where it
>>>> specifies a custom name space for transaction blueprint and allow
>>>> users to intercept attribute with certain transaction attribute on
>>>> bean method invocations.
>>>>
>>>> for example -
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>>>>    xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">
>>>>     <bean id="TestBeanImpl" class="org.apache.aries.simple.TestBeanImpl">
>>>>        <tx:transaction method="insertRow" value="required"/>
>>>>     </bean>
>>>>
>>>> </blueprint>
>>>>
>>>> basically asks the blueprint container to manage required transaction
>>>> attribute/strategy on insertRow method invocation.
>>>>
>>>> Is this similar as what you want to do, except you want to do it with logging?
>>>>
>>>> HTH
>>>>
>>>> Lin
>>>>
>>>>
>>>> On Fri, Jun 18, 2010 at 12:19 PM, Norman Maurer <[hidden email]> wrote:
>>>>> Hi all,
>>>>>
>>>>> I'm very new to Aries and wonder if its possible to add some kind of
>>>>> "PostBeanProcessor" (this is how it get called in spring). We at JAMES
>>>>> use spring at the moment to wire up our application as standalone
>>>>> application. Now we are working on "osgify" JAMES. We need to
>>>>> implement some kind of lifecycle methods. For example if a "service"
>>>>> implements LogEnabled interface it need to get a Log injected. The
>>>>> same is true for other dependencies.. We use JSR250 annotations, so we
>>>>> would need to handle this kind of stuff. I did some tests with
>>>>> spring-dm the last weeks and it seems to work but aries looks very
>>>>> interesting too.
>>>>>
>>>>> You know, Eat your own dogfood ;)
>>>>>
>>>>>
>>>>> Thx,
>>>>> Norman
>>>>>
>>>>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Add custom lifecycle management

Norman Maurer
I think I could write a jsr250 BeanProcessor by myself.. Are you
interested in such a contribution ?

Thx,
Norman


2010/6/18 Lin Sun <[hidden email]>:

> Hi Norma
>
> Yep I agree with Valentin that I don't think the standardized
> blueprint container spec provides what you want.
>
> Regarding annotation, I have done some limited work on it, but it is
> mostly based on the blueprint XML definition file.  What you are
> attempting to do isn't configurable from the configuration of
> blueprint XML file.
>
> Lin
>
> On Fri, Jun 18, 2010 at 1:49 PM, Norman Maurer <[hidden email]> wrote:
>> Hi Valentin,
>>
>> thanks for the response. I will try out the BeanProcessor stuff and
>> come back to you.. At the end maybe I can contribute something back ;)
>>
>> BTW, would it be possible to publish the javadocs online ?
>>
>> Bye,
>> Norman
>>
>>
>> 2010/6/18 Valentin Mahrwald <[hidden email]>:
>>> Hi Norman,
>>>
>>> that sounds like quite a tall order :) Especially, ordering configuration and JSR250 (or blueprint) lifecycle callbacks sounds like something blueprint is unlikely to support out of the box.
>>>
>>> By the sounds of it for the level of control you want, you might want to use the org.apache.aries.blueprint.BeanProcessor extension point. This allows you to intercept beans during creation where you could the instanceof checks against LogEnabled and Configurable as well as look at annotations (assuming no other BeanProcessor proxied the bean previously).
>>>
>>> Now, the BeanProcessor is on the far end of supported extensions in that it is more likely to change or be completely redesigned :)
>>>
>>> Regards,
>>>
>>> Valentin
>>>
>>>
>>>
>>> On 18 Jun 2010, at 18:20, Norman Maurer wrote:
>>>
>>>> Hi Lin,
>>>>
>>>> not exactly. I want to implement 3 things..
>>>>
>>>> 1) LogEnabled.
>>>> Every component which is instanced by aries should get checked if it
>>>> implement LogEnabled. If so it has a setLog(Log logger) method which
>>>> should get called to inject a Log instance
>>>>
>>>> 2) Configurable.
>>>> Every component which is instanced by aries should get checked if it
>>>> implement Configurable. If so it need to get the "right" configuration
>>>> passed to its configure(HierachicalConfiguration config) methd.
>>>>
>>>> 3) JSR250
>>>> Check if the component which is instanced by aries has
>>>> @Resource(name="example"), @PostConstruct, @PreDestroy annotations on
>>>> methods. If so inject the service with name example to the setter.
>>>> Then call method which is annotated by @PostConstruct.  On shutdown /
>>>> undeploy etc the method annoted with @PreDestroy should get called.
>>>>
>>>> I need to be sure that it is handled in the right order.
>>>>
>>>> LogEnabled, Configurable, JSR250
>>>>
>>>> Hope its now clear what I want todo :)
>>>>
>>>> Thx,
>>>> Norman
>>>>
>>>>
>>>>
>>>> 2010/6/18 Lin Sun <[hidden email]>:
>>>>> Hi
>>>>>
>>>>> Aries already has this bean Interceptor concept that allows you to
>>>>> specify precall before the method is invoked and specify postCall
>>>>> after the method is invoked, see the Interceptor interface.
>>>>>
>>>>> Aries also has an example in transaction-blueprint project where it
>>>>> specifies a custom name space for transaction blueprint and allow
>>>>> users to intercept attribute with certain transaction attribute on
>>>>> bean method invocations.
>>>>>
>>>>> for example -
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>>>>>    xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">
>>>>>     <bean id="TestBeanImpl" class="org.apache.aries.simple.TestBeanImpl">
>>>>>        <tx:transaction method="insertRow" value="required"/>
>>>>>     </bean>
>>>>>
>>>>> </blueprint>
>>>>>
>>>>> basically asks the blueprint container to manage required transaction
>>>>> attribute/strategy on insertRow method invocation.
>>>>>
>>>>> Is this similar as what you want to do, except you want to do it with logging?
>>>>>
>>>>> HTH
>>>>>
>>>>> Lin
>>>>>
>>>>>
>>>>> On Fri, Jun 18, 2010 at 12:19 PM, Norman Maurer <[hidden email]> wrote:
>>>>>> Hi all,
>>>>>>
>>>>>> I'm very new to Aries and wonder if its possible to add some kind of
>>>>>> "PostBeanProcessor" (this is how it get called in spring). We at JAMES
>>>>>> use spring at the moment to wire up our application as standalone
>>>>>> application. Now we are working on "osgify" JAMES. We need to
>>>>>> implement some kind of lifecycle methods. For example if a "service"
>>>>>> implements LogEnabled interface it need to get a Log injected. The
>>>>>> same is true for other dependencies.. We use JSR250 annotations, so we
>>>>>> would need to handle this kind of stuff. I did some tests with
>>>>>> spring-dm the last weeks and it seems to work but aries looks very
>>>>>> interesting too.
>>>>>>
>>>>>> You know, Eat your own dogfood ;)
>>>>>>
>>>>>>
>>>>>> Thx,
>>>>>> Norman
>>>>>>
>>>>>
>>>
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Add custom lifecycle management

Lin Sun
Sure.  The annotation work in blueprint is at very early stage.  We
are collecting inputs and requirement from community.

The existing work we have is based on standardized blueprint container
spec, but we do want to use common annotation specs that are already
defined if possible (like jsr 250 or 330, etc).

And if possible, I'd like to keep anything add on to the standardized
blueprint container as optional project/packages, in case people don't
want it, which is where all blueprint annotation related projects are.

Lin

On Fri, Jun 18, 2010 at 2:16 PM, Norman Maurer <[hidden email]> wrote:

> I think I could write a jsr250 BeanProcessor by myself.. Are you
> interested in such a contribution ?
>
> Thx,
> Norman
>
>
> 2010/6/18 Lin Sun <[hidden email]>:
>> Hi Norma
>>
>> Yep I agree with Valentin that I don't think the standardized
>> blueprint container spec provides what you want.
>>
>> Regarding annotation, I have done some limited work on it, but it is
>> mostly based on the blueprint XML definition file.  What you are
>> attempting to do isn't configurable from the configuration of
>> blueprint XML file.
>>
>> Lin
>>
>> On Fri, Jun 18, 2010 at 1:49 PM, Norman Maurer <[hidden email]> wrote:
>>> Hi Valentin,
>>>
>>> thanks for the response. I will try out the BeanProcessor stuff and
>>> come back to you.. At the end maybe I can contribute something back ;)
>>>
>>> BTW, would it be possible to publish the javadocs online ?
>>>
>>> Bye,
>>> Norman
>>>
>>>
>>> 2010/6/18 Valentin Mahrwald <[hidden email]>:
>>>> Hi Norman,
>>>>
>>>> that sounds like quite a tall order :) Especially, ordering configuration and JSR250 (or blueprint) lifecycle callbacks sounds like something blueprint is unlikely to support out of the box.
>>>>
>>>> By the sounds of it for the level of control you want, you might want to use the org.apache.aries.blueprint.BeanProcessor extension point. This allows you to intercept beans during creation where you could the instanceof checks against LogEnabled and Configurable as well as look at annotations (assuming no other BeanProcessor proxied the bean previously).
>>>>
>>>> Now, the BeanProcessor is on the far end of supported extensions in that it is more likely to change or be completely redesigned :)
>>>>
>>>> Regards,
>>>>
>>>> Valentin
>>>>
>>>>
>>>>
>>>> On 18 Jun 2010, at 18:20, Norman Maurer wrote:
>>>>
>>>>> Hi Lin,
>>>>>
>>>>> not exactly. I want to implement 3 things..
>>>>>
>>>>> 1) LogEnabled.
>>>>> Every component which is instanced by aries should get checked if it
>>>>> implement LogEnabled. If so it has a setLog(Log logger) method which
>>>>> should get called to inject a Log instance
>>>>>
>>>>> 2) Configurable.
>>>>> Every component which is instanced by aries should get checked if it
>>>>> implement Configurable. If so it need to get the "right" configuration
>>>>> passed to its configure(HierachicalConfiguration config) methd.
>>>>>
>>>>> 3) JSR250
>>>>> Check if the component which is instanced by aries has
>>>>> @Resource(name="example"), @PostConstruct, @PreDestroy annotations on
>>>>> methods. If so inject the service with name example to the setter.
>>>>> Then call method which is annotated by @PostConstruct.  On shutdown /
>>>>> undeploy etc the method annoted with @PreDestroy should get called.
>>>>>
>>>>> I need to be sure that it is handled in the right order.
>>>>>
>>>>> LogEnabled, Configurable, JSR250
>>>>>
>>>>> Hope its now clear what I want todo :)
>>>>>
>>>>> Thx,
>>>>> Norman
>>>>>
>>>>>
>>>>>
>>>>> 2010/6/18 Lin Sun <[hidden email]>:
>>>>>> Hi
>>>>>>
>>>>>> Aries already has this bean Interceptor concept that allows you to
>>>>>> specify precall before the method is invoked and specify postCall
>>>>>> after the method is invoked, see the Interceptor interface.
>>>>>>
>>>>>> Aries also has an example in transaction-blueprint project where it
>>>>>> specifies a custom name space for transaction blueprint and allow
>>>>>> users to intercept attribute with certain transaction attribute on
>>>>>> bean method invocations.
>>>>>>
>>>>>> for example -
>>>>>>
>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>>>>>>    xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">
>>>>>>     <bean id="TestBeanImpl" class="org.apache.aries.simple.TestBeanImpl">
>>>>>>        <tx:transaction method="insertRow" value="required"/>
>>>>>>     </bean>
>>>>>>
>>>>>> </blueprint>
>>>>>>
>>>>>> basically asks the blueprint container to manage required transaction
>>>>>> attribute/strategy on insertRow method invocation.
>>>>>>
>>>>>> Is this similar as what you want to do, except you want to do it with logging?
>>>>>>
>>>>>> HTH
>>>>>>
>>>>>> Lin
>>>>>>
>>>>>>
>>>>>> On Fri, Jun 18, 2010 at 12:19 PM, Norman Maurer <[hidden email]> wrote:
>>>>>>> Hi all,
>>>>>>>
>>>>>>> I'm very new to Aries and wonder if its possible to add some kind of
>>>>>>> "PostBeanProcessor" (this is how it get called in spring). We at JAMES
>>>>>>> use spring at the moment to wire up our application as standalone
>>>>>>> application. Now we are working on "osgify" JAMES. We need to
>>>>>>> implement some kind of lifecycle methods. For example if a "service"
>>>>>>> implements LogEnabled interface it need to get a Log injected. The
>>>>>>> same is true for other dependencies.. We use JSR250 annotations, so we
>>>>>>> would need to handle this kind of stuff. I did some tests with
>>>>>>> spring-dm the last weeks and it seems to work but aries looks very
>>>>>>> interesting too.
>>>>>>>
>>>>>>> You know, Eat your own dogfood ;)
>>>>>>>
>>>>>>>
>>>>>>> Thx,
>>>>>>> Norman
>>>>>>>
>>>>>>
>>>>
>>>>
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Add custom lifecycle management

Norman Maurer
sure.. I will have a look and come back to you later again..

Bye,
Norman

2010/6/18 Lin Sun <[hidden email]>:

> Sure.  The annotation work in blueprint is at very early stage.  We
> are collecting inputs and requirement from community.
>
> The existing work we have is based on standardized blueprint container
> spec, but we do want to use common annotation specs that are already
> defined if possible (like jsr 250 or 330, etc).
>
> And if possible, I'd like to keep anything add on to the standardized
> blueprint container as optional project/packages, in case people don't
> want it, which is where all blueprint annotation related projects are.
>
> Lin
>
> On Fri, Jun 18, 2010 at 2:16 PM, Norman Maurer <[hidden email]> wrote:
>> I think I could write a jsr250 BeanProcessor by myself.. Are you
>> interested in such a contribution ?
>>
>> Thx,
>> Norman
>>
>>
>> 2010/6/18 Lin Sun <[hidden email]>:
>>> Hi Norma
>>>
>>> Yep I agree with Valentin that I don't think the standardized
>>> blueprint container spec provides what you want.
>>>
>>> Regarding annotation, I have done some limited work on it, but it is
>>> mostly based on the blueprint XML definition file.  What you are
>>> attempting to do isn't configurable from the configuration of
>>> blueprint XML file.
>>>
>>> Lin
>>>
>>> On Fri, Jun 18, 2010 at 1:49 PM, Norman Maurer <[hidden email]> wrote:
>>>> Hi Valentin,
>>>>
>>>> thanks for the response. I will try out the BeanProcessor stuff and
>>>> come back to you.. At the end maybe I can contribute something back ;)
>>>>
>>>> BTW, would it be possible to publish the javadocs online ?
>>>>
>>>> Bye,
>>>> Norman
>>>>
>>>>
>>>> 2010/6/18 Valentin Mahrwald <[hidden email]>:
>>>>> Hi Norman,
>>>>>
>>>>> that sounds like quite a tall order :) Especially, ordering configuration and JSR250 (or blueprint) lifecycle callbacks sounds like something blueprint is unlikely to support out of the box.
>>>>>
>>>>> By the sounds of it for the level of control you want, you might want to use the org.apache.aries.blueprint.BeanProcessor extension point. This allows you to intercept beans during creation where you could the instanceof checks against LogEnabled and Configurable as well as look at annotations (assuming no other BeanProcessor proxied the bean previously).
>>>>>
>>>>> Now, the BeanProcessor is on the far end of supported extensions in that it is more likely to change or be completely redesigned :)
>>>>>
>>>>> Regards,
>>>>>
>>>>> Valentin
>>>>>
>>>>>
>>>>>
>>>>> On 18 Jun 2010, at 18:20, Norman Maurer wrote:
>>>>>
>>>>>> Hi Lin,
>>>>>>
>>>>>> not exactly. I want to implement 3 things..
>>>>>>
>>>>>> 1) LogEnabled.
>>>>>> Every component which is instanced by aries should get checked if it
>>>>>> implement LogEnabled. If so it has a setLog(Log logger) method which
>>>>>> should get called to inject a Log instance
>>>>>>
>>>>>> 2) Configurable.
>>>>>> Every component which is instanced by aries should get checked if it
>>>>>> implement Configurable. If so it need to get the "right" configuration
>>>>>> passed to its configure(HierachicalConfiguration config) methd.
>>>>>>
>>>>>> 3) JSR250
>>>>>> Check if the component which is instanced by aries has
>>>>>> @Resource(name="example"), @PostConstruct, @PreDestroy annotations on
>>>>>> methods. If so inject the service with name example to the setter.
>>>>>> Then call method which is annotated by @PostConstruct.  On shutdown /
>>>>>> undeploy etc the method annoted with @PreDestroy should get called.
>>>>>>
>>>>>> I need to be sure that it is handled in the right order.
>>>>>>
>>>>>> LogEnabled, Configurable, JSR250
>>>>>>
>>>>>> Hope its now clear what I want todo :)
>>>>>>
>>>>>> Thx,
>>>>>> Norman
>>>>>>
>>>>>>
>>>>>>
>>>>>> 2010/6/18 Lin Sun <[hidden email]>:
>>>>>>> Hi
>>>>>>>
>>>>>>> Aries already has this bean Interceptor concept that allows you to
>>>>>>> specify precall before the method is invoked and specify postCall
>>>>>>> after the method is invoked, see the Interceptor interface.
>>>>>>>
>>>>>>> Aries also has an example in transaction-blueprint project where it
>>>>>>> specifies a custom name space for transaction blueprint and allow
>>>>>>> users to intercept attribute with certain transaction attribute on
>>>>>>> bean method invocations.
>>>>>>>
>>>>>>> for example -
>>>>>>>
>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>>>>>>>    xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">
>>>>>>>     <bean id="TestBeanImpl" class="org.apache.aries.simple.TestBeanImpl">
>>>>>>>        <tx:transaction method="insertRow" value="required"/>
>>>>>>>     </bean>
>>>>>>>
>>>>>>> </blueprint>
>>>>>>>
>>>>>>> basically asks the blueprint container to manage required transaction
>>>>>>> attribute/strategy on insertRow method invocation.
>>>>>>>
>>>>>>> Is this similar as what you want to do, except you want to do it with logging?
>>>>>>>
>>>>>>> HTH
>>>>>>>
>>>>>>> Lin
>>>>>>>
>>>>>>>
>>>>>>> On Fri, Jun 18, 2010 at 12:19 PM, Norman Maurer <[hidden email]> wrote:
>>>>>>>> Hi all,
>>>>>>>>
>>>>>>>> I'm very new to Aries and wonder if its possible to add some kind of
>>>>>>>> "PostBeanProcessor" (this is how it get called in spring). We at JAMES
>>>>>>>> use spring at the moment to wire up our application as standalone
>>>>>>>> application. Now we are working on "osgify" JAMES. We need to
>>>>>>>> implement some kind of lifecycle methods. For example if a "service"
>>>>>>>> implements LogEnabled interface it need to get a Log injected. The
>>>>>>>> same is true for other dependencies.. We use JSR250 annotations, so we
>>>>>>>> would need to handle this kind of stuff. I did some tests with
>>>>>>>> spring-dm the last weeks and it seems to work but aries looks very
>>>>>>>> interesting too.
>>>>>>>>
>>>>>>>> You know, Eat your own dogfood ;)
>>>>>>>>
>>>>>>>>
>>>>>>>> Thx,
>>>>>>>> Norman
>>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>