public class ServiceManager extends Object implements com.sun.star.lang.XMultiServiceFactory, com.sun.star.lang.XMultiComponentFactory, com.sun.star.container.XSet, com.sun.star.container.XContentEnumerationAccess, com.sun.star.lang.XComponent, com.sun.star.lang.XServiceInfo
ServiceManager class is an implementation of the
ServiceManagerthe central class needed for implementing or using
UNO components in Java.
The Methods queryInterface and isSame delegate
calls to the implementing objects and are used instead of casts and identity
comparisons.
XMultiServiceFactory,
XSet,
XContentEnumerationAccess,
XComponent,
XServiceInfo| Constructor and Description |
|---|
ServiceManager()
Creates a new instance of the
ServiceManager. |
| Modifier and Type | Method and Description |
|---|---|
void |
addEventListener(com.sun.star.lang.XEventListener xListener)
Adds a new
EventListener. |
com.sun.star.container.XEnumeration |
createContentEnumeration(String serviceName)
Provides an enumeration of all factories for a specified service.
|
com.sun.star.container.XEnumeration |
createEnumeration()
Provides an enumeration of all registered services.
|
Object |
createInstance(String serviceSpecifier)
Creates a new instance of a specified service.
|
Object |
createInstanceWithArguments(String serviceSpecifier,
Object[] args)
Creates a new instance of a specified service with the given parameters.
|
Object |
createInstanceWithArgumentsAndContext(String rServiceSpecifier,
Object[] rArguments,
com.sun.star.uno.XComponentContext xContext)
Create a service instance with given context and arguments.
|
Object |
createInstanceWithContext(String rServiceSpecifier,
com.sun.star.uno.XComponentContext xContext)
Create a service instance with given context.
|
void |
dispose()
Removes all listeners from the
ServiceManager and clears the
list of the services. |
String[] |
getAvailableServiceNames()
Supplies a list of all avialable services names.
|
com.sun.star.uno.Type |
getElementType()
Provides the UNO type of the
ServiceManager |
String |
getImplementationName()
Returns the implementation name of the
ServiceManager component. |
String[] |
getSupportedServiceNames()
Supplies list of all supported services.
|
boolean |
has(Object object)
Checks if a component is registered at the
ServiceManager. |
boolean |
hasElements()
Checks if the any components are registered.
|
void |
insert(Object object)
Adds a
SingleServiceFactory to the ServiceManager. |
void |
remove(Object object)
Removes a
SingleServiceFactory from the ServiceManager. |
void |
removeEventListener(com.sun.star.lang.XEventListener xListener)
Removes a
EventListener from the ServiceManager. |
void |
setDefaultContext(com.sun.star.uno.XComponentContext context) |
boolean |
supportsService(String serviceName)
Checks if the
ServiceManager supports a service. |
public ServiceManager()
ServiceManager.public void setDefaultContext(com.sun.star.uno.XComponentContext context)
public Object createInstance(String serviceSpecifier) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException
Therefore the associated factory of the service is looked up and used to instanciate a new component.
createInstance in interface com.sun.star.lang.XMultiServiceFactoryserviceSpecifier - indicates the service or component name.com.sun.star.uno.Exceptioncom.sun.star.uno.RuntimeExceptionXMultiServiceFactorypublic Object createInstanceWithArguments(String serviceSpecifier, Object[] args) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException
Therefore the associated factory of the service is looked up and used to instanciate a new component.
createInstanceWithArguments in interface com.sun.star.lang.XMultiServiceFactoryserviceSpecifier - indicates the service or component name.com.sun.star.uno.Exceptioncom.sun.star.uno.RuntimeExceptionXMultiServiceFactorypublic String[] getAvailableServiceNames() throws com.sun.star.uno.RuntimeException
getAvailableServiceNames in interface com.sun.star.container.XContentEnumerationAccessgetAvailableServiceNames in interface com.sun.star.lang.XMultiComponentFactorygetAvailableServiceNames in interface com.sun.star.lang.XMultiServiceFactorycom.sun.star.uno.RuntimeExceptionXContentEnumerationAccesspublic Object createInstanceWithContext(String rServiceSpecifier, com.sun.star.uno.XComponentContext xContext) throws com.sun.star.uno.Exception
createInstanceWithContext in interface com.sun.star.lang.XMultiComponentFactoryrServiceSpecifier - service name.xContext - context.com.sun.star.uno.Exceptionpublic Object createInstanceWithArgumentsAndContext(String rServiceSpecifier, Object[] rArguments, com.sun.star.uno.XComponentContext xContext) throws com.sun.star.uno.Exception
createInstanceWithArgumentsAndContext in interface com.sun.star.lang.XMultiComponentFactoryrServiceSpecifier - service name.rArguments - arguments.xContext - context.com.sun.star.uno.Exceptionpublic void dispose()
throws com.sun.star.uno.RuntimeException
ServiceManager and clears the
list of the services.dispose in interface com.sun.star.lang.XComponentcom.sun.star.uno.RuntimeExceptionXComponentpublic void addEventListener(com.sun.star.lang.XEventListener xListener)
throws com.sun.star.uno.RuntimeException
EventListener.
The listener is notified when a service is added (removed) to (from)
the ServiceManager.
If the listener is already registred a
com.sun.star.uno.RuntimeException will be thrown.
addEventListener in interface com.sun.star.lang.XComponentxListener - the new listener which should been added.com.sun.star.uno.RuntimeExceptionXComponentpublic void removeEventListener(com.sun.star.lang.XEventListener xListener)
throws com.sun.star.uno.RuntimeException
EventListener from the ServiceManager.
If the listener is not registered a com.sun.star.uno.RuntimeException
will be thrown.
removeEventListener in interface com.sun.star.lang.XComponentxListener - the new listener which should been removed.com.sun.star.uno.RuntimeExceptionXComponentpublic boolean has(Object object) throws com.sun.star.uno.RuntimeException
ServiceManager.
The given object argument must provide a XServiceInfo
interface.
has in interface com.sun.star.container.XSetobject - object which provides a XServiceInfo interface.com.sun.star.uno.RuntimeExceptionXSet,
XServiceInfopublic void insert(Object object) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.ElementExistException, com.sun.star.uno.RuntimeException
SingleServiceFactory to the ServiceManager.insert in interface com.sun.star.container.XSetobject - factory which should be added.com.sun.star.lang.IllegalArgumentExceptioncom.sun.star.container.ElementExistExceptioncom.sun.star.uno.RuntimeExceptionXSet,
XSingleServiceFactorypublic void remove(Object object) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.NoSuchElementException, com.sun.star.uno.RuntimeException
SingleServiceFactory from the ServiceManager.remove in interface com.sun.star.container.XSetobject - factory which should be removed.com.sun.star.lang.IllegalArgumentExceptioncom.sun.star.container.NoSuchElementExceptioncom.sun.star.uno.RuntimeExceptionXSet,
XSingleServiceFactorypublic com.sun.star.container.XEnumeration createEnumeration()
throws com.sun.star.uno.RuntimeException
createEnumeration in interface com.sun.star.container.XEnumerationAccesscom.sun.star.uno.RuntimeExceptionXEnumerationAccesspublic com.sun.star.uno.Type getElementType()
throws com.sun.star.uno.RuntimeException
ServiceManagergetElementType in interface com.sun.star.container.XElementAccessServiceManager.com.sun.star.uno.RuntimeExceptionXElementAccess,
TypeClasspublic boolean hasElements()
hasElements in interface com.sun.star.container.XElementAccessXElementAccesspublic com.sun.star.container.XEnumeration createContentEnumeration(String serviceName) throws com.sun.star.uno.RuntimeException
createContentEnumeration in interface com.sun.star.container.XContentEnumerationAccessserviceName - name of the requested service.com.sun.star.uno.RuntimeExceptionXContentEnumerationAccesspublic String getImplementationName() throws com.sun.star.uno.RuntimeException
ServiceManager component.getImplementationName in interface com.sun.star.lang.XServiceInfoServiceManager.com.sun.star.uno.RuntimeExceptionXServiceInfopublic boolean supportsService(String serviceName) throws com.sun.star.uno.RuntimeException
ServiceManager supports a service.supportsService in interface com.sun.star.lang.XServiceInfoserviceName - service name which should be checked.com.sun.star.uno.RuntimeExceptionXServiceInfopublic String[] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException
getSupportedServiceNames in interface com.sun.star.lang.XServiceInfocom.sun.star.uno.RuntimeExceptionXServiceInfo