Listening for EJBs appearing / JNDI registrations

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

Listening for EJBs appearing / JNDI registrations

David Bosschaert
Hi,

I have a piece of code that needs to kick into action when a particular
EJB is registered. What would be the best way to do this? The code is in
user-space, it's an OSGi bundle that needs to do something once the EJB
is available...

So I thought about the following:
* register a DeploymentUnitProcessor, however this is a bit heavyweight
to ask a EJB/OSGi developer to do...
* maybe register an MSC service that waits for an MSC service registered
by the EJB to appear? this is also a bit heavyweight and I don't think
the MSC services registered by the EJB are documented/part of the public
API...
* It would be nice if I could simply listen for the JNDI registration...
is that possible?

As a workaround, I also thought about this:
* If I deploy my artifacts in a certain order, will the appserver deploy
them again in the same order on a restart?

Thanks,

David
_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: Listening for EJBs appearing / JNDI registrations

Brian Stansberry
On 7/18/11 3:04 AM, David Bosschaert wrote:

> Hi,
>
> I have a piece of code that needs to kick into action when a particular
> EJB is registered. What would be the best way to do this? The code is in
> user-space, it's an OSGi bundle that needs to do something once the EJB
> is available...
>
> So I thought about the following:
> * register a DeploymentUnitProcessor, however this is a bit heavyweight
> to ask a EJB/OSGi developer to do...
> * maybe register an MSC service that waits for an MSC service registered
> by the EJB to appear? this is also a bit heavyweight and I don't think
> the MSC services registered by the EJB are documented/part of the public
> API...
> * It would be nice if I could simply listen for the JNDI registration...
> is that possible?
>
> As a workaround, I also thought about this:
> * If I deploy my artifacts in a certain order, will the appserver deploy
> them again in the same order on a restart?
>

It should invoke the management operations to deploy them in the same
order, yes. However, those management operations install all sorts of
services, and those services' start() methods are called asynchronously
with no guaranteed order and no guarantee that everything for deployment
A is done before deployment B starts. So I doubt a solution based on the
initial order would be robust.

> Thanks,
>
> David
> _______________________________________________
> jboss-as7-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev


--
Brian Stansberry
Principal Software Engineer
JBoss by Red Hat
_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: Listening for EJBs appearing / JNDI registrations

Carlo de Wolf
In reply to this post by David Bosschaert
Vica-versa? Let a @Singleton fire off an OSGi service. You can inject
the EJB into the singleton and pass it onwards.

Carlo

On 07/18/2011 10:04 AM, David Bosschaert wrote:

> Hi,
>
> I have a piece of code that needs to kick into action when a particular
> EJB is registered. What would be the best way to do this? The code is in
> user-space, it's an OSGi bundle that needs to do something once the EJB
> is available...
>
> So I thought about the following:
> * register a DeploymentUnitProcessor, however this is a bit heavyweight
> to ask a EJB/OSGi developer to do...
> * maybe register an MSC service that waits for an MSC service registered
> by the EJB to appear? this is also a bit heavyweight and I don't think
> the MSC services registered by the EJB are documented/part of the public
> API...
> * It would be nice if I could simply listen for the JNDI registration...
> is that possible?
>
> As a workaround, I also thought about this:
> * If I deploy my artifacts in a certain order, will the appserver deploy
> them again in the same order on a restart?
>
> Thanks,
>
> David
> _______________________________________________
> jboss-as7-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev

_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: Listening for EJBs appearing / JNDI registrations

David Bosschaert
Thanks Carlo, that makes sense. Let me play with that!

Cheers,

David

On 18/07/2011 16:06, Carlo de Wolf wrote:

> Vica-versa? Let a @Singleton fire off an OSGi service. You can inject
> the EJB into the singleton and pass it onwards.
>
> Carlo
>
> On 07/18/2011 10:04 AM, David Bosschaert wrote:
>> Hi,
>>
>> I have a piece of code that needs to kick into action when a particular
>> EJB is registered. What would be the best way to do this? The code is in
>> user-space, it's an OSGi bundle that needs to do something once the EJB
>> is available...
>>
>> So I thought about the following:
>> * register a DeploymentUnitProcessor, however this is a bit heavyweight
>> to ask a EJB/OSGi developer to do...
>> * maybe register an MSC service that waits for an MSC service registered
>> by the EJB to appear? this is also a bit heavyweight and I don't think
>> the MSC services registered by the EJB are documented/part of the public
>> API...
>> * It would be nice if I could simply listen for the JNDI registration...
>> is that possible?
>>
>> As a workaround, I also thought about this:
>> * If I deploy my artifacts in a certain order, will the appserver deploy
>> them again in the same order on a restart?
>>
>> Thanks,
>>
>> David
>> _______________________________________________
>> jboss-as7-dev mailing list
>> [hidden email]
>> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
>

_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: Listening for EJBs appearing / JNDI registrations

David Bosschaert
In reply to this post by Brian Stansberry
On 18/07/2011 15:52, Brian Stansberry wrote:

> On 7/18/11 3:04 AM, David Bosschaert wrote:
>> Hi,
>>
>> I have a piece of code that needs to kick into action when a particular
>> EJB is registered. What would be the best way to do this? The code is in
>> user-space, it's an OSGi bundle that needs to do something once the EJB
>> is available...
>>
>> So I thought about the following:
>> * register a DeploymentUnitProcessor, however this is a bit heavyweight
>> to ask a EJB/OSGi developer to do...
>> * maybe register an MSC service that waits for an MSC service registered
>> by the EJB to appear? this is also a bit heavyweight and I don't think
>> the MSC services registered by the EJB are documented/part of the public
>> API...
>> * It would be nice if I could simply listen for the JNDI registration...
>> is that possible?
>>
>> As a workaround, I also thought about this:
>> * If I deploy my artifacts in a certain order, will the appserver deploy
>> them again in the same order on a restart?
>>
> It should invoke the management operations to deploy them in the same
> order, yes. However, those management operations install all sorts of
> services, and those services' start() methods are called asynchronously
> with no guaranteed order and no guarantee that everything for deployment
> A is done before deployment B starts. So I doubt a solution based on the
> initial order would be robust.
>
Thanks Brian. I agree that it's not a great idea.

Best regards,

David
_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev