|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean
public class OsgiServiceFactoryBean
FactoryBean that transparently publishes other beans in the same application context as OSGi services returning the ServiceRegistration for the given object. Also known as an exporter this class handle the registration and unregistration of an OSGi service for the backing/target object.
The service properties used when publishing the service are determined by the OsgiServicePropertiesResolver. The default implementation usessetContextClassLoader(ExportContextClassLoader)
,
since proxying is required, the target class has to meet certain criterion
described in the Spring AOP documentation. In short, final classes are not
supported when class enhancement is used.
Field Summary |
---|
Fields inherited from interface org.springframework.core.Ordered |
---|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
Constructor Summary | |
---|---|
OsgiServiceFactoryBean()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
|
void |
destroy()
|
String |
getBeanName()
Returns the bean name of this class when configured inside a Spring container. |
Class[] |
getInterfaces()
Returns the interfaces that will be considered when exporting the target as an OSGi service. |
Object |
getObject()
Returns a ServiceRegistration to the OSGi service for the
target object. |
Class |
getObjectType()
|
int |
getOrder()
|
int |
getRanking()
Returns the OSGi ranking used when publishing the service. |
OsgiServicePropertiesResolver |
getResolver()
Returns the property resolver used for publishing the service. |
Map |
getServiceProperties()
Returns the properties used when exporting the target as an OSGi service. |
Object |
getTarget()
Returns the object exported as an OSGi service. |
String |
getTargetBeanName()
Returns the target bean name. |
boolean |
isSingleton()
|
void |
setAutoExport(AutoExport classExporter)
Sets the strategy used for automatically publishing classes. |
void |
setBeanClassLoader(ClassLoader classLoader)
|
void |
setBeanFactory(BeanFactory beanFactory)
|
void |
setBeanName(String name)
|
void |
setBundleContext(BundleContext context)
Set the BundleContext that this bean runs in. |
void |
setContextClassLoader(ExportContextClassLoader ccl)
Sets the context class loader management strategy to use when invoking operations on the exposed target bean. |
void |
setInterfaces(Class[] interfaces)
Sets the interfaces advertised by the service.These will be advertised in the OSGi space and are considered when looking for a service. |
void |
setListeners(OsgiServiceRegistrationListener[] listeners)
Sets the listeners interested in registration and unregistration events. |
void |
setOrder(int order)
Set the ordering which will apply to this class's implementation of Ordered, used when applying multiple BeanPostProcessors. |
void |
setRanking(int ranking)
Shortcut for setting the ranking property of the published service. |
void |
setRegisterService(boolean register)
Controls whether the service actually gets published or not. |
void |
setResolver(OsgiServicePropertiesResolver resolver)
Sets the property resolver used when publishing the bean as an OSGi service. |
void |
setServiceProperties(Map serviceProperties)
Sets the properties used when exposing the target as an OSGi service. |
void |
setTarget(Object target)
Sets the given object to be export as an OSGi service. |
void |
setTargetBeanName(String name)
Sets the name of the bean managed by the Spring container, which will be exported as an OSGi service. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OsgiServiceFactoryBean()
Method Detail |
---|
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
public void setBeanClassLoader(ClassLoader classLoader)
setBeanClassLoader
in interface BeanClassLoaderAware
public Object getObject() throws Exception
ServiceRegistration
to the OSGi service for the
target object.
getObject
in interface FactoryBean
Exception
public Class getObjectType()
getObjectType
in interface FactoryBean
public boolean isSingleton()
isSingleton
in interface FactoryBean
public void setContextClassLoader(ExportContextClassLoader ccl)
ExportContextClassLoader.UNMANAGED
is used.
Note: Since proxying is required for context class
loader manager, the target class has to meet certain criterias described
in the Spring AOP documentation. In short, final classes are not
supported when class enhancement is used.
ccl
- context class loader strategy to useExportContextClassLoader
public Object getTarget()
public void setTarget(Object target)
setTargetBeanName(String)
is used.
target
- the object to be exported as an OSGi servicepublic String getTargetBeanName()
public void setTargetBeanName(String name)
setTarget(Object)
.
name
- target bean namepublic void setAutoExport(AutoExport classExporter)
AutoExport.DISABLED
.
classExporter
- class exporter used for automatically publishing
service classes.AutoExport
public Map getServiceProperties()
public void setServiceProperties(Map serviceProperties)
serviceProperties
- properties used for exporting the target as an
OSGi servicepublic int getRanking()
public void setRanking(int ranking)
ranking
- service rankingConstants.SERVICE_RANKING
public void setRegisterService(boolean register)
register
- whether to register the service or not. The default is
true.public void setBeanFactory(BeanFactory beanFactory) throws BeansException
setBeanFactory
in interface BeanFactoryAware
BeansException
public void setBundleContext(BundleContext context)
BundleContextAware
BundleContext
that this bean runs in. Normally this can
be used to initialize an object.
setBundleContext
in interface BundleContextAware
context
- the BundleContext
object to be used
by this objectpublic OsgiServicePropertiesResolver getResolver()
public void setResolver(OsgiServicePropertiesResolver resolver)
resolver
- service property resolverpublic Class[] getInterfaces()
public void setInterfaces(Class[] interfaces)
interfaces
- array of classes to advertisepublic int getOrder()
getOrder
in interface Ordered
public void setOrder(int order)
Default value is Integer.MAX_VALUE
, meaning that it's
non-ordered.
order
- ordering valuepublic String getBeanName()
public void setBeanName(String name)
setBeanName
in interface BeanNameAware
public void setListeners(OsgiServiceRegistrationListener[] listeners)
listeners
- registration/unregistration listeners.public void destroy()
destroy
in interface DisposableBean
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |