public class ServiceManager
extends java.lang.Object
ServiceManager
class is an implmentation of the ServiceManager
the 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.
|
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.ServicManager
multiFactory
- references 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.Exception
com.sun.star.uno.RuntimeException
com.sun.star.lang.XInitialization
,
com.sun.star.lang.RegistryServiceManager
,
com.sun.star.lang.XSimpleRegistry
public 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.Exception
com.sun.star.uno.RuntimeException
com.sun.star.lang.XMultiServiceFactory
public 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.Exception
com.sun.star.uno.RuntimeException
com.sun.star.lang.XMultiServiceFactory
public java.lang.String[] getAvailableServiceNames() throws com.sun.star.uno.RuntimeException
com.sun.star.uno.RuntimeException
com.sun.star.container.XContentEnumerationAccess
public 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.Exception
public 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.Exception
public void dispose() throws com.sun.star.uno.RuntimeException
ServiceManager
and clears the list of the services.
com.sun.star.uno.RuntimeException
com.sun.star.lang.XComponent
public 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.RuntimeException
com.sun.star.lang.XComponent
public 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.RuntimeException
com.sun.star.lang.XComponent
public 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.RuntimeException
com.sun.star.container.XSet
,
com.sun.star.lang.XServiceInfo
public 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.IllegalArgumentException
com.sun.star.container.ElementExistException
com.sun.star.uno.RuntimeException
com.sun.star.container.XSet
,
com.sun.star.lang.XSingleServiceFactory
public 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.IllegalArgumentException
com.sun.star.container.NoSuchElementException
com.sun.star.uno.RuntimeException
com.sun.star.container.XSet
,
com.sun.star.lang.XSingleServiceFactory
public XEnumeration createEnumeration() throws com.sun.star.uno.RuntimeException
com.sun.star.uno.RuntimeException
com.sun.star.conatiner.XEnumerationAccess
public Type getElementType() throws com.sun.star.uno.RuntimeException
ServiceManager
ServiceManager
.com.sun.star.uno.RuntimeException
com.sun.star.container.XElementAccess
,
com.sun.star.uno.TypeClass
public boolean hasElements()
com.sun.star.container.XElementAccess
public XEnumeration createContentEnumeration(java.lang.String serviceName) throws com.sun.star.uno.RuntimeException
serviceName
- name of the requested servicecom.sun.star.uno.RuntimeException
com.sun.star.container.XContentEnumerationAccess
public java.lang.String getImplementationName() throws com.sun.star.uno.RuntimeException
ServiceManager
component.
ServiceManager
.com.sun.star.uno.RuntimeException
com.sun.star.lang.XServiceInfo
public 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.RuntimeException
com.sun.star.lang.XServiceInfo
public java.lang.String[] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException
com.sun.star.uno.RuntimeException
com.sun.star.lang.XServiceInfo