You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Romain Manni-Bucau <rm...@gmail.com> on 2012/06/20 18:14:45 UTC
InitHooks
Hi,
i just pushed a new feature: InitHooks
the goal is to get a hook to execute code before the real container
startup. The idea was to run code working on config if needed but no more.
Why i didnt use services was to get a simpler API (you simply need to
implement a Runnable) and to be invocated earlier.
A sample is the updatechecker which is now no more integrated in the
lifecycle of the startup directly (the only link i added is an alias on the
qualified name to be a bit more user friendly)
Any issue with it?
- Romain
Re: InitHooks
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Yes. Simplr needs yo creaye the event and to fire it
Le 22 juin 2012 03:21, "Karan Malhi" <ka...@gmail.com> a écrit :
> This is nice stuff. Was wondering if there could be a possibility to extend
> it to a full-fledged event model for other events in the container.
> Examples could be "PreDeploy", "PostDeploy" , etc
>
> On Wed, Jun 20, 2012 at 5:03 PM, Romain Manni-Bucau
> <rm...@gmail.com>wrote:
>
> > both are on trunk
> >
> > observer have an alias, class name for observers defined in tomee.xml and
> > name of the file containing the class name in
> > META-INF/org.apache.opeenjb.observer for the ones found by scanning.
> >
> > One observer can be added only once (if one day we scan application too
> it
> > can avoid some weird stuff).
> >
> > - Romain
> >
> >
> > 2012/6/21 David Blevins <da...@gmail.com>
> >
> > >
> > > On Jun 20, 2012, at 4:16 PM, Romain Manni-Bucau wrote:
> > >
> > > > META-INF/ or Openejb but not both, no?
> > >
> > > Maybe we start with META-INF and see how far we get.
> > >
> > >
> > > -David
> > >
> > > >
> > > > 2012/6/21 David Blevins <da...@gmail.com>
> > > >
> > > >>
> > > >> On Jun 20, 2012, at 12:04 PM, David Blevins wrote:
> > > >>
> > > >>> Let me take a shot at a slightly different approach. Something
> like
> > > >> what we did the client with a CDI-like observer pattern. As I
> > > mentioned in
> > > >> that email, we might want to do it in the server as well. Sounds
> > like a
> > > >> good time to try it out.
> > > >>
> > > >> Updated the code so that SystemInstance has the observer
> functionality
> > > >> built-in.
> > > >>
> > > >> We have the following events now:
> > > >>
> > > >>
> > > >>
> > >
> >
> container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/event/AssemblerCreated.java
> > > >>
> > > >>
> > >
> >
> container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/event/AssemblerDestroyed.java
> > > >>
> > > >>
> > >
> >
> container/openejb-loader/src/main/java/org/apache/openejb/loader/event/ComponentAdded.java
> > > >>
> > > >>
> > >
> >
> container/openejb-loader/src/main/java/org/apache/openejb/loader/event/ComponentRemoved.java
> > > >>
> > > >>
> > >
> >
> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverAdded.java
> > > >>
> > > >>
> > >
> >
> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverFailed.java
> > > >>
> > > >>
> > >
> >
> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverRemoved.java
> > > >>
> > > >>
> > > >> Temporarily removed the code in the ConfigurationFactory where we
> were
> > > >> creating and installing observers. It's fine code to have, we just
> > > need to
> > > >> move that into the Assembler as that's it's job (to create the
> things
> > > >> defined in the openejb/tomee.xml file). We just need to update the
> > > >> FacilitiesInfo to have a collection of observerInfo. We should
> > probably
> > > >> allow the Observers to have dependency injection and just treat them
> > as
> > > >> another kind of ServiceInfo.
> > > >>
> > > >> Well probably want to add a META-INF/ loading mechanism as well.
> > > >>
> > > >>
> > > >> -David
> > > >>
> > > >>
> > >
> > >
> >
>
>
>
> --
>
> Karan Singh Malhi
> twitter.com/KaranSinghMalhi
>
Re: InitHooks
Posted by Karan Malhi <ka...@gmail.com>.
This is nice stuff. Was wondering if there could be a possibility to extend
it to a full-fledged event model for other events in the container.
Examples could be "PreDeploy", "PostDeploy" , etc
On Wed, Jun 20, 2012 at 5:03 PM, Romain Manni-Bucau
<rm...@gmail.com>wrote:
> both are on trunk
>
> observer have an alias, class name for observers defined in tomee.xml and
> name of the file containing the class name in
> META-INF/org.apache.opeenjb.observer for the ones found by scanning.
>
> One observer can be added only once (if one day we scan application too it
> can avoid some weird stuff).
>
> - Romain
>
>
> 2012/6/21 David Blevins <da...@gmail.com>
>
> >
> > On Jun 20, 2012, at 4:16 PM, Romain Manni-Bucau wrote:
> >
> > > META-INF/ or Openejb but not both, no?
> >
> > Maybe we start with META-INF and see how far we get.
> >
> >
> > -David
> >
> > >
> > > 2012/6/21 David Blevins <da...@gmail.com>
> > >
> > >>
> > >> On Jun 20, 2012, at 12:04 PM, David Blevins wrote:
> > >>
> > >>> Let me take a shot at a slightly different approach. Something like
> > >> what we did the client with a CDI-like observer pattern. As I
> > mentioned in
> > >> that email, we might want to do it in the server as well. Sounds
> like a
> > >> good time to try it out.
> > >>
> > >> Updated the code so that SystemInstance has the observer functionality
> > >> built-in.
> > >>
> > >> We have the following events now:
> > >>
> > >>
> > >>
> >
> container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/event/AssemblerCreated.java
> > >>
> > >>
> >
> container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/event/AssemblerDestroyed.java
> > >>
> > >>
> >
> container/openejb-loader/src/main/java/org/apache/openejb/loader/event/ComponentAdded.java
> > >>
> > >>
> >
> container/openejb-loader/src/main/java/org/apache/openejb/loader/event/ComponentRemoved.java
> > >>
> > >>
> >
> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverAdded.java
> > >>
> > >>
> >
> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverFailed.java
> > >>
> > >>
> >
> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverRemoved.java
> > >>
> > >>
> > >> Temporarily removed the code in the ConfigurationFactory where we were
> > >> creating and installing observers. It's fine code to have, we just
> > need to
> > >> move that into the Assembler as that's it's job (to create the things
> > >> defined in the openejb/tomee.xml file). We just need to update the
> > >> FacilitiesInfo to have a collection of observerInfo. We should
> probably
> > >> allow the Observers to have dependency injection and just treat them
> as
> > >> another kind of ServiceInfo.
> > >>
> > >> Well probably want to add a META-INF/ loading mechanism as well.
> > >>
> > >>
> > >> -David
> > >>
> > >>
> >
> >
>
--
Karan Singh Malhi
twitter.com/KaranSinghMalhi
Re: InitHooks
Posted by Romain Manni-Bucau <rm...@gmail.com>.
both are on trunk
observer have an alias, class name for observers defined in tomee.xml and
name of the file containing the class name in
META-INF/org.apache.opeenjb.observer for the ones found by scanning.
One observer can be added only once (if one day we scan application too it
can avoid some weird stuff).
- Romain
2012/6/21 David Blevins <da...@gmail.com>
>
> On Jun 20, 2012, at 4:16 PM, Romain Manni-Bucau wrote:
>
> > META-INF/ or Openejb but not both, no?
>
> Maybe we start with META-INF and see how far we get.
>
>
> -David
>
> >
> > 2012/6/21 David Blevins <da...@gmail.com>
> >
> >>
> >> On Jun 20, 2012, at 12:04 PM, David Blevins wrote:
> >>
> >>> Let me take a shot at a slightly different approach. Something like
> >> what we did the client with a CDI-like observer pattern. As I
> mentioned in
> >> that email, we might want to do it in the server as well. Sounds like a
> >> good time to try it out.
> >>
> >> Updated the code so that SystemInstance has the observer functionality
> >> built-in.
> >>
> >> We have the following events now:
> >>
> >>
> >>
> container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/event/AssemblerCreated.java
> >>
> >>
> container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/event/AssemblerDestroyed.java
> >>
> >>
> container/openejb-loader/src/main/java/org/apache/openejb/loader/event/ComponentAdded.java
> >>
> >>
> container/openejb-loader/src/main/java/org/apache/openejb/loader/event/ComponentRemoved.java
> >>
> >>
> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverAdded.java
> >>
> >>
> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverFailed.java
> >>
> >>
> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverRemoved.java
> >>
> >>
> >> Temporarily removed the code in the ConfigurationFactory where we were
> >> creating and installing observers. It's fine code to have, we just
> need to
> >> move that into the Assembler as that's it's job (to create the things
> >> defined in the openejb/tomee.xml file). We just need to update the
> >> FacilitiesInfo to have a collection of observerInfo. We should probably
> >> allow the Observers to have dependency injection and just treat them as
> >> another kind of ServiceInfo.
> >>
> >> Well probably want to add a META-INF/ loading mechanism as well.
> >>
> >>
> >> -David
> >>
> >>
>
>
Re: InitHooks
Posted by David Blevins <da...@gmail.com>.
On Jun 20, 2012, at 4:16 PM, Romain Manni-Bucau wrote:
> META-INF/ or Openejb but not both, no?
Maybe we start with META-INF and see how far we get.
-David
>
> 2012/6/21 David Blevins <da...@gmail.com>
>
>>
>> On Jun 20, 2012, at 12:04 PM, David Blevins wrote:
>>
>>> Let me take a shot at a slightly different approach. Something like
>> what we did the client with a CDI-like observer pattern. As I mentioned in
>> that email, we might want to do it in the server as well. Sounds like a
>> good time to try it out.
>>
>> Updated the code so that SystemInstance has the observer functionality
>> built-in.
>>
>> We have the following events now:
>>
>>
>> container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/event/AssemblerCreated.java
>>
>> container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/event/AssemblerDestroyed.java
>>
>> container/openejb-loader/src/main/java/org/apache/openejb/loader/event/ComponentAdded.java
>>
>> container/openejb-loader/src/main/java/org/apache/openejb/loader/event/ComponentRemoved.java
>>
>> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverAdded.java
>>
>> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverFailed.java
>>
>> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverRemoved.java
>>
>>
>> Temporarily removed the code in the ConfigurationFactory where we were
>> creating and installing observers. It's fine code to have, we just need to
>> move that into the Assembler as that's it's job (to create the things
>> defined in the openejb/tomee.xml file). We just need to update the
>> FacilitiesInfo to have a collection of observerInfo. We should probably
>> allow the Observers to have dependency injection and just treat them as
>> another kind of ServiceInfo.
>>
>> Well probably want to add a META-INF/ loading mechanism as well.
>>
>>
>> -David
>>
>>
Re: InitHooks
Posted by Romain Manni-Bucau <rm...@gmail.com>.
META-INF/ or Openejb but not both, no?
- Romain
2012/6/21 David Blevins <da...@gmail.com>
>
> On Jun 20, 2012, at 12:04 PM, David Blevins wrote:
>
> > Let me take a shot at a slightly different approach. Something like
> what we did the client with a CDI-like observer pattern. As I mentioned in
> that email, we might want to do it in the server as well. Sounds like a
> good time to try it out.
>
> Updated the code so that SystemInstance has the observer functionality
> built-in.
>
> We have the following events now:
>
>
> container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/event/AssemblerCreated.java
>
> container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/event/AssemblerDestroyed.java
>
> container/openejb-loader/src/main/java/org/apache/openejb/loader/event/ComponentAdded.java
>
> container/openejb-loader/src/main/java/org/apache/openejb/loader/event/ComponentRemoved.java
>
> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverAdded.java
>
> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverFailed.java
>
> container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverRemoved.java
>
>
> Temporarily removed the code in the ConfigurationFactory where we were
> creating and installing observers. It's fine code to have, we just need to
> move that into the Assembler as that's it's job (to create the things
> defined in the openejb/tomee.xml file). We just need to update the
> FacilitiesInfo to have a collection of observerInfo. We should probably
> allow the Observers to have dependency injection and just treat them as
> another kind of ServiceInfo.
>
> Well probably want to add a META-INF/ loading mechanism as well.
>
>
> -David
>
>
Re: InitHooks
Posted by David Blevins <da...@gmail.com>.
On Jun 20, 2012, at 12:04 PM, David Blevins wrote:
> Let me take a shot at a slightly different approach. Something like what we did the client with a CDI-like observer pattern. As I mentioned in that email, we might want to do it in the server as well. Sounds like a good time to try it out.
Updated the code so that SystemInstance has the observer functionality built-in.
We have the following events now:
container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/event/AssemblerCreated.java
container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/event/AssemblerDestroyed.java
container/openejb-loader/src/main/java/org/apache/openejb/loader/event/ComponentAdded.java
container/openejb-loader/src/main/java/org/apache/openejb/loader/event/ComponentRemoved.java
container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverAdded.java
container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverFailed.java
container/openejb-loader/src/main/java/org/apache/openejb/observer/event/ObserverRemoved.java
Temporarily removed the code in the ConfigurationFactory where we were creating and installing observers. It's fine code to have, we just need to move that into the Assembler as that's it's job (to create the things defined in the openejb/tomee.xml file). We just need to update the FacilitiesInfo to have a collection of observerInfo. We should probably allow the Observers to have dependency injection and just treat them as another kind of ServiceInfo.
Well probably want to add a META-INF/ loading mechanism as well.
-David
Re: InitHooks
Posted by David Blevins <da...@gmail.com>.
On Jun 20, 2012, at 9:14 AM, Romain Manni-Bucau wrote:
> Hi,
>
> i just pushed a new feature: InitHooks
>
> the goal is to get a hook to execute code before the real container
> startup. The idea was to run code working on config if needed but no more.
>
> Why i didnt use services was to get a simpler API (you simply need to
> implement a Runnable) and to be invocated earlier.
>
> A sample is the updatechecker which is now no more integrated in the
> lifecycle of the startup directly (the only link i added is an alias on the
> qualified name to be a bit more user friendly)
>
> Any issue with it?
Having more extensibility in the server is great. Let me take a shot at a slightly different approach. Something like what we did the client with a CDI-like observer pattern. As I mentioned in that email, we might want to do it in the server as well. Sounds like a good time to try it out.
-David