You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@aries.apache.org by Martin Lichtin <li...@yahoo.com> on 2011/11/16 15:18:57 UTC
Call OSGi services programmatically
Hi
With SpringDM/Gemini it is possible to call a service programmatically like this:
Class<ValueProcessor> cls = ValueProcessor.class;
OsgiServiceProxyFactoryBean factoryBean = new OsgiServiceProxyFactoryBean();
factoryBean.setBundleContext(bundleContext);
factoryBean.setInterfaces(new Class[] { cls });
factoryBean.setFilter(filter);
factoryBean.setContextClassLoader(ImportContextClassLoader.CLIENT);
factoryBean.setBeanClassLoader(cls.getClassLoader());
factoryBean.afterPropertiesSet();
ValueProcessor valueProcessor = (ValueProcessor) factoryBean.getObject();
How
can one create the proxy instance of the service with Aries?
Martin
Re: Call OSGi services programmatically
Posted by Toni Menzel <to...@okidokiteam.com>.
+1 on DM
The real beauty is DS/DM/BP/Peaberry etc all work on top of the service
registry, so you can mix higher level frameworks that fit best.
On Thu, Nov 17, 2011 at 8:17 AM, Felix Meschberger <fm...@adobe.com>wrote:
> Hi
>
> You might want to consider the Apache Felix DependencyManager [1]
>
> This of course has nothing to do with OSGi Blueprint or Spring/DM. It is
> just a programmatic front-end to simplify servie registration and DI.
>
> Regards
> Felix
>
> [1] http://felix.apache.org/site/apache-felix-dependency-manager.html
>
> Am 16.11.2011 um 15:18 schrieb Martin Lichtin:
>
> Hi
>
> With SpringDM/Gemini it is possible to call a service programmatically
> like this:
>
> Class<ValueProcessor> cls = ValueProcessor.class;
> OsgiServiceProxyFactoryBean factoryBean = new
> OsgiServiceProxyFactoryBean();
> factoryBean.setBundleContext(bundleContext);
> factoryBean.setInterfaces(new Class[] { cls });
> factoryBean.setFilter(filter);
> factoryBean.setContextClassLoader(ImportContextClassLoader.CLIENT);
> factoryBean.setBeanClassLoader(cls.getClassLoader());
> factoryBean.afterPropertiesSet();
> ValueProcessor valueProcessor = (ValueProcessor) factoryBean.getObject();
>
> How can one create the proxy instance of the service with Aries?
>
> Martin
>
>
>
--
Toni Menzel Source <http://tonimenzel.com>
Re: Call OSGi services programmatically
Posted by Felix Meschberger <fm...@adobe.com>.
Hi
You might want to consider the Apache Felix DependencyManager [1]
This of course has nothing to do with OSGi Blueprint or Spring/DM. It is just a programmatic front-end to simplify servie registration and DI.
Regards
Felix
[1] http://felix.apache.org/site/apache-felix-dependency-manager.html
Am 16.11.2011 um 15:18 schrieb Martin Lichtin:
Hi
With SpringDM/Gemini it is possible to call a service programmatically like this:
Class<ValueProcessor> cls = ValueProcessor.class;
OsgiServiceProxyFactoryBean factoryBean = new OsgiServiceProxyFactoryBean();
factoryBean.setBundleContext(bundleContext);
factoryBean.setInterfaces(new Class[] { cls });
factoryBean.setFilter(filter);
factoryBean.setContextClassLoader(ImportContextClassLoader.CLIENT);
factoryBean.setBeanClassLoader(cls.getClassLoader());
factoryBean.afterPropertiesSet();
ValueProcessor valueProcessor = (ValueProcessor) factoryBean.getObject();
How can one create the proxy instance of the service with Aries?
Martin
RE: Call OSGi services programmatically
Posted by Timothy Ward <ti...@apache.org>.
Hi Martin,
Aries doesn't have a programmatic API for creating blueprint managed beans, references or services. I assume that XML isn't appropriate for your use case?
Regards.
Tim Ward
-------------------
Apache Aries PMC member & Enterprise OSGi advocate
Enterprise OSGi in Action (http://www.manning.com/cummins)
-------------------
Date: Wed, 16 Nov 2011 06:18:57 -0800
From: lichtin@yahoo.com
Subject: Call OSGi services programmatically
To: user@aries.apache.org
Hi
With SpringDM/Gemini it is possible to call a service programmatically like this:
Class<ValueProcessor> cls = ValueProcessor.class;
OsgiServiceProxyFactoryBean factoryBean = new OsgiServiceProxyFactoryBean();
factoryBean.setBundleContext(bundleContext);
factoryBean.setInterfaces(new Class[] { cls });
factoryBean.setFilter(filter);
factoryBean.setContextClassLoader(ImportContextClassLoader.CLIENT);
factoryBean.setBeanClassLoader(cls.getClassLoader());
factoryBean.afterPropertiesSet();
ValueProcessor valueProcessor = (ValueProcessor) factoryBean.getObject();
How
can one create the proxy instance of the service with Aries?
Martin