You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Luchesar Cekov <lu...@ontotext.com> on 2008/01/21 17:37:59 UTC

ServiceMix Spring BeanFactory hierarchy

Hi ServiceMix guys,

Can someone explain me how can I get an instance of a bean defined in my
Service Unit xbean.xml.

I have jsr181 service unit that simply deploys a POJO as a service and I
want to use it through a JBI NMR proxy. Then I instrument  another class
with the proxy service and I want to get an instance of it programmatically.  

I have something like this:
Service Unit xbean.xml

</beans>
    ....
       <bean id="deploymentService"
		class="org.ipsuper.ssb.DeploymentService">
		<property name="service">
			<jsr181:proxy service="deployment:DeploymentService"
				context="#context" type="org.ipsuper.ssb.IDeploymentService" />
		</property>
	</bean>
</beans>

How can I obtain an instance of this bean in my code? I succeeded in
injecting deploymentService bean as a property of another service but this
is not what I want. I also tried to get it from (SpringJBIContainer)
container but it wasn't there. I guess I should somehow get a ServiceUnit
specific BeanFactory but cannot find how.
Please anybody help.

Best,
Luchesar
-- 
View this message in context: http://www.nabble.com/ServiceMix-Spring-BeanFactory-hierarchy-tp15001268s12049p15001268.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix Spring BeanFactory hierarchy

Posted by Luchesar Cekov <lu...@ontotext.com>.
Finally I found a decision.

All my clients beans have super interface that implement Spring
InitializingBean, DisposableBean. When the bean is initialized I bind it to
the JNDI and when the bean is Disposed I unbind it from JNDI.

After that I could access it from wherever within ServiceMix.

Best,
Luchesar 
-- 
View this message in context: http://www.nabble.com/ServiceMix-Spring-BeanFactory-hierarchy-tp15001268s12049p15063745.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix Spring BeanFactory hierarchy

Posted by Luchesar Cekov <lu...@ontotext.com>.
I expose my POJOs to the bus with no problems through jsr181-se.  In fact my
problem is accessing exposed jsr181 services within ServiceMix. 

I want to access them via Java proxies rather then via messages (SM Client
API). That is why I am trying to define Java proxy clients to my jsr181
services as described at [1]. I can do this via spring injection (like in
the example), but this is not very convenient for me. I what to be able to
access those Java proxy clients from anywhere within ServiceMix.

[1] http://servicemix.apache.org/servicemix-jsr181.html



gnodet wrote:
> 
> If you want to expose your bean on the bus, you need to define  JBI
> endpoint
> using jsr181 or servicemix-cxf-se.
> There are examples of doing that in the distribution (wsdl-first and
> cxf-wsdl-first).  They use a wsdl first approch but
> you can simply use your pojo instead of the generated one.
> 
> On Jan 22, 2008 3:02 PM, Luchesar Cekov <lu...@ontotext.com>
> wrote:
> 
>>
>> Hi Guillaume,
>>
>> Thanks for the reply.
>> Is there any way I can expose a bean (In this case JBI NMR proxy client)
>> to
>> be globally available in the ESB? I want to be able to access it through
>> JBI
>> container (SpringJBIContainer.getBean()) or via JNDI?
>> My intention is to expose several services and to be able to access them
>> with JBI proxy clients from anywhere within ServiceMix.
>>
>> Best,
>> Luchesar
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/ServiceMix-Spring-BeanFactory-hierarchy-tp15001268s12049p15019050.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/ServiceMix-Spring-BeanFactory-hierarchy-tp15001268s12049p15019901.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix Spring BeanFactory hierarchy

Posted by Guillaume Nodet <gn...@gmail.com>.
If you want to expose your bean on the bus, you need to define  JBI endpoint
using jsr181 or servicemix-cxf-se.
There are examples of doing that in the distribution (wsdl-first and
cxf-wsdl-first).  They use a wsdl first approch but
you can simply use your pojo instead of the generated one.

On Jan 22, 2008 3:02 PM, Luchesar Cekov <lu...@ontotext.com> wrote:

>
> Hi Guillaume,
>
> Thanks for the reply.
> Is there any way I can expose a bean (In this case JBI NMR proxy client)
> to
> be globally available in the ESB? I want to be able to access it through
> JBI
> container (SpringJBIContainer.getBean()) or via JNDI?
> My intention is to expose several services and to be able to access them
> with JBI proxy clients from anywhere within ServiceMix.
>
> Best,
> Luchesar
>
>
> --
> View this message in context:
> http://www.nabble.com/ServiceMix-Spring-BeanFactory-hierarchy-tp15001268s12049p15019050.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/

Re: ServiceMix Spring BeanFactory hierarchy

Posted by Luchesar Cekov <lu...@ontotext.com>.
Hi Guillaume,

Thanks for the reply.
Is there any way I can expose a bean (In this case JBI NMR proxy client) to
be globally available in the ESB? I want to be able to access it through JBI
container (SpringJBIContainer.getBean()) or via JNDI?
My intention is to expose several services and to be able to access them
with JBI proxy clients from anywhere within ServiceMix.

Best,
Luchesar


-- 
View this message in context: http://www.nabble.com/ServiceMix-Spring-BeanFactory-hierarchy-tp15001268s12049p15019050.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix Spring BeanFactory hierarchy

Posted by Guillaume Nodet <gn...@gmail.com>.
You will only be able to easily retrieve an instance of this bean when
inside your SU.
To do that, there are several ways, the first one is to inject it using
spring, the next one
is to implement a BeanFactoryAware interface (iirc) so that you can access
the bean
factory and retrieve all the beans you want programmatically.
If you want to access your bean outside the SU, it becomes a bit trickier
imho
(and I'm not even sure this is possible right now).

On Jan 21, 2008 5:37 PM, Luchesar Cekov <lu...@ontotext.com> wrote:

>
> Hi ServiceMix guys,
>
> Can someone explain me how can I get an instance of a bean defined in my
> Service Unit xbean.xml.
>
> I have jsr181 service unit that simply deploys a POJO as a service and I
> want to use it through a JBI NMR proxy. Then I instrument  another class
> with the proxy service and I want to get an instance of it
> programmatically.
>
> I have something like this:
> Service Unit xbean.xml
>
> </beans>
>    ....
>       <bean id="deploymentService"
>                class="org.ipsuper.ssb.DeploymentService">
>                <property name="service">
>                        <jsr181:proxy
> service="deployment:DeploymentService"
>                                context="#context" type="
> org.ipsuper.ssb.IDeploymentService" />
>                </property>
>        </bean>
> </beans>
>
> How can I obtain an instance of this bean in my code? I succeeded in
> injecting deploymentService bean as a property of another service but this
> is not what I want. I also tried to get it from (SpringJBIContainer)
> container but it wasn't there. I guess I should somehow get a ServiceUnit
> specific BeanFactory but cannot find how.
> Please anybody help.
>
> Best,
> Luchesar
> --
> View this message in context:
> http://www.nabble.com/ServiceMix-Spring-BeanFactory-hierarchy-tp15001268s12049p15001268.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/