Hi,

Yeah, you can do it with several ways, but it's not the best practice in OSGi world.

Take a look at[1] to get more details

[1]http://forum.springsource.org/archive/index.php/t-56255.html

Freeman
On 2010-10-19, at 下午7:19, Tim Dellas wrote:

Hi there! Sorry for answering back that late. Yes I want to access the beans from the same bundle. I have no code to access the beans, as it's my question how to implement it. All spring tutorials need me to define an .xml file where the beans are defined, but the beans.xml file seems to be loaded by ServiceMix.

So my question is: how can I grab the reference to the spring application context (that's already instantiated by ServiceMix) in my code, so that I can get the beans?

The following is the beans.xml file I use:

<beans xmlns="http://www.springframework.org/schema/beans";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns:jaxws="http://cxf.apache.org/jaxws";
        xsi:schemaLocation="
                http://www.springframework.org/schema/beans
                http://www.springframework.org/schema/beans/spring-beans.xsd
                http://cxf.apache.org/jaxws
                http://cxf.apache.org/schemas/jaxws.xsd
                http://www.springframework.org/schema/osgi
                http://www.springframework.org/schema/osgi/spring-osgi.xsd";>

   <import resource="classpath:META-INF/cxf/cxf.xml" />
   <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
   <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
<import resource="classpath:META-INF/cxf/osgi/cxf-extension- osgi.xml" />

        <!--  ServiceBeans -->
<bean id="sambaMessageService" class="de.samba.message.MessageImpl" /> <bean id="auditingProxyService" class="de.samba.message.proxies.AuditingProxyImpl" /> <bean id="helloWorldProxyService" class="de.samba.message.proxies.HelloWorldCommonsImpl" />

        <jaxws:endpoint id="SambaMessageEndpoint"
                implementorClass="de.samba.message.MessageImpl"
            implementor="#sambaMessageService"
            address="/MessageService"/>

        <jaxws:endpoint id="AuditingProxyEndpoint"
                implementorClass="de.samba.message.proxies.AuditingProxyImpl"
            implementor="#auditingProxyService"
            address="/AuditingProxy"/>
        
        <jaxws:endpoint id="HelloWorldProxyEndpoint"
                
implementorClass="de.samba.message.proxies.HelloWorldCommonsImpl"
            implementor="#helloWorldProxyService"
            address="/HelloWorldProxy"/>
        
</beans>

Best Regards,

Tim


__________________________________________________

-----Ursprüngliche Nachricht-----
Von: Freeman Fang [mailto:[email protected]]
Gesendet: Mittwoch, 13. Oktober 2010 03:17
An: [email protected]
Betreff: Re: Spring newbie question

Hi Tim,
Are your code and beans.xml in same bundle?
Could you please show me the method how you reference the beans.xml from your code?

Freeman
On 2010-10-12, at 下午6:41, Tim Dellas wrote:

Hey there!

I have the beans.xml file under src/main/resources/META-INF/spring/
of my cxf bundle and use it to define <jaxws:endpoint>s. Everything
works to far, but as I’m not familiar with Spring so far, I wonder how
I can get these beans and define more beans that I can somehow reach
in the bundle’s code. In all examples I found, I need to define the
location of the XML file, and I don’t know how to do that. The
generated bundle contains the META-INF/spring/beans.xml file, but I
can’t reference it via “classpath:META-INF/spring/ beans.xml” or
“file: META-INF/spring/beans.xml”. I want to be able to get the
endpoints and other beans in my code.

Hope someone can point me in the right direction.


Best Regards,

Tim

__________________________________________________
Ascora GmbH


Dipl. Inform. Tim Dellas
[email protected]
http://www.ascora.de
__________________________________________________


__________________________________________________



--
Freeman Fang

------------------------
blog: http://freemanfang.blogspot.com
twitter: http://twitter.com/freemanfang
Open Source SOA: http://fusesource.com
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org




--
Freeman Fang

------------------------
blog: http://freemanfang.blogspot.com
twitter: http://twitter.com/freemanfang
Open Source SOA: http://fusesource.com
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org

Reply via email to