public class ServiceManager
extends java.lang.Object
ServiceManager class is an implmentation 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.
com.sun.star.lang.XMultiServiceFactory,
com.sun.star.container.XSet,
com.sun.star.container.XContentEnumerationAccess,
com.sun.star.lang.XComponent,
com.sun.star.lang.XServiceInfo,
com.sun.star.lang.XInitialization| Constructor and Description |
|---|
ServiceManager()
Creates a new instance of the
ServiceManager. |
ServiceManager(XComponentContext xContext)
Creates a new instance of the
ServiceManager. |
| Modifier and Type | Method and Description |
|---|---|
void |
addEventListener(XEventListener xListener)
Adds a new
EventListener. |
XEnumeration |
createContentEnumeration(java.lang.String serviceName)
Provides an enumeration of of all factorys for a specified service.
|
XEnumeration |
createEnumeration()
Provides an enumeration of all registred services.
|
java.lang.Object |
createInstance(java.lang.String serviceSpecifier)
Creates a new instance of a specified service.
|
java.lang.Object |
createInstanceWithArguments(java.lang.String serviceSpecifier,
java.lang.Object[] args)
Creates a new instance of a specified service with the given parameters.
|
java.lang.Object |
createInstanceWithArgumentsAndContext(java.lang.String rServiceSpecifier,
java.lang.Object[] rArguments,
com.sun.star.uno.XComponentContext xContext)
Create a service instance with given context and arguments.
|
java.lang.Object |
createInstanceWithContext(java.lang.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. |
java.lang.String[] |
getAvailableServiceNames()
Supplies a list of all avialable services names.
|
com.sun.star.uno.Type |
getElementType()
Provides the UNO type of the
ServiceManager |
java.lang.String |
getImplementationName()
Returns the implementation name of the
ServiceManager component. |
static XSingleServiceFactory |
getServiceFactory(java.lang.String implName,
XMultiServiceFactory multiFactory,
XRegistryKey regKey)
Returns the service factory for the
ServiceManager. |
java.lang.String[] |
getSupportedServiceNames()
Supplies list of all supported services.
|
boolean |
has(java.lang.Object object)
Checks if a component is registered at the
ServiceManager. |
boolean |
hasElements()
Checks if the any componets are registered.
|
void |
initialize(java.lang.Object[] args)
The method is used to add components to the
ServiceManager. |
void |
insert(java.lang.Object object)
Adds a
SingleServiceFactory to the ServiceManager. |
void |
remove(java.lang.Object object)
Removes a
SingleServiceFactory from the ServiceManager. |
void |
removeEventListener(XEventListener xListener)
Removes a
EventListener from the ServiceManager. |
boolean |
supportsService(java.lang.String serviceName)
Checks if the
ServiceManager supports a service. |
public ServiceManager()
ServiceManager.public ServiceManager(XComponentContext xContext)
ServiceManager.public static XSingleServiceFactory getServiceFactory(java.lang.String implName,
XMultiServiceFactory multiFactory,
XRegistryKey regKey)
ServiceManager. If the given implementation name
does not equal to the ServiceManagers class name null will be returned.
implName - the implementation name of the of the service.
Must be equal to com.sun.star.comp.servicemanager.ServicManagermultiFactory - refernce of the MultiServiceFactory. This parameter will be ignored.regKey - the root key of the registry. This parameter will be ignored.ServiceManager.public void initialize(java.lang.Object[] args)
throws com.sun.star.uno.Exception,
com.sun.star.uno.RuntimeException
ServiceManager. The first argument indicates a SimpleRegistry.
The components which should be added will be searched under the Implementations key in the registry.
args - the first argument ( args[0] ) specifices the SimpleRegistry objectcom.sun.star.uno.Exceptioncom.sun.star.uno.RuntimeExceptioncom.sun.star.lang.XInitialization,
com.sun.star.lang.RegistryServiceManager,
com.sun.star.lang.XSimpleRegistrypublic java.lang.Object createInstance(java.lang.String serviceSpecifier)
throws com.sun.star.uno.Exception,
com.sun.star.uno.RuntimeException
serviceSpecifier - indicates the service or component namecom.sun.star.uno.Exceptioncom.sun.star.uno.RuntimeExceptioncom.sun.star.lang.XMultiServiceFactorypublic java.lang.Object createInstanceWithArguments(java.lang.String serviceSpecifier,
java.lang.Object[] args)
throws com.sun.star.uno.Exception,
com.sun.star.uno.RuntimeException
serviceSpecifier - indicates the service or component namecom.sun.star.uno.Exceptioncom.sun.star.uno.RuntimeExceptioncom.sun.star.lang.XMultiServiceFactorypublic java.lang.String[] getAvailableServiceNames()
throws com.sun.star.uno.RuntimeException
com.sun.star.uno.RuntimeExceptioncom.sun.star.container.XContentEnumerationAccesspublic java.lang.Object createInstanceWithContext(java.lang.String rServiceSpecifier,
com.sun.star.uno.XComponentContext xContext)
throws com.sun.star.uno.Exception
rServiceSpecifier - service namexContext - contextcom.sun.star.uno.Exceptionpublic java.lang.Object createInstanceWithArgumentsAndContext(java.lang.String rServiceSpecifier,
java.lang.Object[] rArguments,
com.sun.star.uno.XComponentContext xContext)
throws com.sun.star.uno.Exception
rServiceSpecifier - service namerArguments - argumentsxContext - contextcom.sun.star.uno.Exceptionpublic void dispose()
throws com.sun.star.uno.RuntimeException
ServiceManager and clears the list of the services.
com.sun.star.uno.RuntimeExceptioncom.sun.star.lang.XComponentpublic void addEventListener(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.
xListener - the new listener which should been added.com.sun.star.uno.RuntimeExceptioncom.sun.star.lang.XComponentpublic void removeEventListener(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.
xListener - the new listener which should been removed.com.sun.star.uno.RuntimeExceptioncom.sun.star.lang.XComponentpublic boolean has(java.lang.Object object)
throws com.sun.star.uno.RuntimeException
ServiceManager. The given object argument must
provide a XServiceInfo interface.
object - object which provides a XServiceInfo interface.com.sun.star.uno.RuntimeExceptioncom.sun.star.container.XSet,
com.sun.star.lang.XServiceInfopublic void insert(java.lang.Object object)
throws com.sun.star.lang.IllegalArgumentException,
com.sun.star.container.ElementExistException,
com.sun.star.uno.RuntimeException
SingleServiceFactory to the ServiceManager.
object - factory which should be added.com.sun.star.lang.IllegalArgumentExceptioncom.sun.star.container.ElementExistExceptioncom.sun.star.uno.RuntimeExceptioncom.sun.star.container.XSet,
com.sun.star.lang.XSingleServiceFactorypublic void remove(java.lang.Object object)
throws com.sun.star.lang.IllegalArgumentException,
com.sun.star.container.NoSuchElementException,
com.sun.star.uno.RuntimeException
SingleServiceFactory from the ServiceManager.
object - factory which should be removed.com.sun.star.lang.IllegalArgumentExceptioncom.sun.star.container.NoSuchElementExceptioncom.sun.star.uno.RuntimeExceptioncom.sun.star.container.XSet,
com.sun.star.lang.XSingleServiceFactorypublic XEnumeration createEnumeration()
throws com.sun.star.uno.RuntimeException
com.sun.star.uno.RuntimeExceptioncom.sun.star.conatiner.XEnumerationAccesspublic com.sun.star.uno.Type getElementType()
throws com.sun.star.uno.RuntimeException
ServiceManager
ServiceManager.com.sun.star.uno.RuntimeExceptioncom.sun.star.container.XElementAccess,
com.sun.star.uno.TypeClasspublic boolean hasElements()
com.sun.star.container.XElementAccesspublic XEnumeration createContentEnumeration(java.lang.String serviceName)
throws com.sun.star.uno.RuntimeException
serviceName - name of the requested servicecom.sun.star.uno.RuntimeExceptioncom.sun.star.container.XContentEnumerationAccesspublic java.lang.String getImplementationName()
throws com.sun.star.uno.RuntimeException
ServiceManager component.
ServiceManager.com.sun.star.uno.RuntimeExceptioncom.sun.star.lang.XServiceInfopublic boolean supportsService(java.lang.String serviceName)
throws com.sun.star.uno.RuntimeException
ServiceManager supports a service.
serviceName - service name which should be checked.com.sun.star.uno.RuntimeExceptioncom.sun.star.lang.XServiceInfopublic java.lang.String[] getSupportedServiceNames()
throws com.sun.star.uno.RuntimeException
com.sun.star.uno.RuntimeExceptioncom.sun.star.lang.XServiceInfo