Package com.sun.star.comp.servicemanager
Class ServiceManager
java.lang.Object
com.sun.star.comp.servicemanager.ServiceManager
- All Implemented Interfaces:
com.sun.star.container.XContentEnumerationAccess
,com.sun.star.container.XElementAccess
,com.sun.star.container.XEnumerationAccess
,com.sun.star.container.XSet
,com.sun.star.lang.XComponent
,com.sun.star.lang.XMultiComponentFactory
,com.sun.star.lang.XMultiServiceFactory
,com.sun.star.lang.XServiceInfo
,com.sun.star.uno.XInterface
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
The
ServiceManager
class is an implementation 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.
- Since:
- UDK1.0
- See Also:
-
XMultiServiceFactory
XSet
XContentEnumerationAccess
XComponent
XServiceInfo
-
Field Summary
Fields inherited from interface com.sun.star.lang.XComponent
UNOTYPEINFO
Fields inherited from interface com.sun.star.container.XContentEnumerationAccess
UNOTYPEINFO
Fields inherited from interface com.sun.star.lang.XMultiComponentFactory
UNOTYPEINFO
Fields inherited from interface com.sun.star.lang.XMultiServiceFactory
UNOTYPEINFO
Fields inherited from interface com.sun.star.lang.XServiceInfo
UNOTYPEINFO
Fields inherited from interface com.sun.star.container.XSet
UNOTYPEINFO
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEventListener
(com.sun.star.lang.XEventListener xListener) Adds a newEventListener
.com.sun.star.container.XEnumeration
createContentEnumeration
(String serviceName) Provides an enumeration of all factories for a specified service.com.sun.star.container.XEnumeration
Provides an enumeration of all registered services.createInstance
(String serviceSpecifier) Creates a new instance of a specified service.createInstanceWithArguments
(String serviceSpecifier, Object[] args) Creates a new instance of a specified service with the given parameters.createInstanceWithArgumentsAndContext
(String rServiceSpecifier, Object[] rArguments, com.sun.star.uno.XComponentContext xContext) Create a service instance with given context and arguments.createInstanceWithContext
(String rServiceSpecifier, com.sun.star.uno.XComponentContext xContext) Create a service instance with given context.void
dispose()
Removes all listeners from theServiceManager
and clears the list of the services.String[]
Supplies a list of all available services names.Provides the UNO type of theServiceManager
Returns the implementation name of theServiceManager
component.String[]
Supplies list of all supported services.boolean
Checks if a component is registered at theServiceManager
.boolean
Checks if the any components are registered.void
Adds aSingleServiceFactory
to theServiceManager
.void
Removes aSingleServiceFactory
from theServiceManager
.void
removeEventListener
(com.sun.star.lang.XEventListener xListener) Removes aEventListener
from theServiceManager
.void
setDefaultContext
(com.sun.star.uno.XComponentContext context) boolean
supportsService
(String serviceName) Checks if theServiceManager
supports a service.
-
Constructor Details
-
ServiceManager
public ServiceManager()Creates a new instance of theServiceManager
.
-
-
Method Details
-
setDefaultContext
public void setDefaultContext(com.sun.star.uno.XComponentContext context) -
createInstance
public Object createInstance(String serviceSpecifier) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException Creates a new instance of a specified service.Therefore the associated factory of the service is looked up and used to instantiate a new component.
- Specified by:
createInstance
in interfacecom.sun.star.lang.XMultiServiceFactory
- Parameters:
serviceSpecifier
- indicates the service or component name.- Returns:
- newly created component.
- Throws:
com.sun.star.uno.Exception
com.sun.star.uno.RuntimeException
- See Also:
-
XMultiServiceFactory
-
createInstanceWithArguments
public Object createInstanceWithArguments(String serviceSpecifier, Object[] args) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException Creates a new instance of a specified service with the given parameters.Therefore the associated factory of the service is looked up and used to instantiate a new component.
- Specified by:
createInstanceWithArguments
in interfacecom.sun.star.lang.XMultiServiceFactory
- Parameters:
serviceSpecifier
- indicates the service or component name.- Returns:
- newly created component.
- Throws:
com.sun.star.uno.Exception
com.sun.star.uno.RuntimeException
- See Also:
-
XMultiServiceFactory
-
getAvailableServiceNames
Supplies a list of all available services names.- Specified by:
getAvailableServiceNames
in interfacecom.sun.star.container.XContentEnumerationAccess
- Specified by:
getAvailableServiceNames
in interfacecom.sun.star.lang.XMultiComponentFactory
- Specified by:
getAvailableServiceNames
in interfacecom.sun.star.lang.XMultiServiceFactory
- Returns:
- list of Strings of all service names.
- Throws:
com.sun.star.uno.RuntimeException
- See Also:
-
XContentEnumerationAccess
-
createInstanceWithContext
public Object createInstanceWithContext(String rServiceSpecifier, com.sun.star.uno.XComponentContext xContext) throws com.sun.star.uno.Exception Create a service instance with given context.- Specified by:
createInstanceWithContext
in interfacecom.sun.star.lang.XMultiComponentFactory
- Parameters:
rServiceSpecifier
- service name.xContext
- context.- Returns:
- service instance.
- Throws:
com.sun.star.uno.Exception
-
createInstanceWithArgumentsAndContext
public Object createInstanceWithArgumentsAndContext(String rServiceSpecifier, Object[] rArguments, com.sun.star.uno.XComponentContext xContext) throws com.sun.star.uno.Exception Create a service instance with given context and arguments.- Specified by:
createInstanceWithArgumentsAndContext
in interfacecom.sun.star.lang.XMultiComponentFactory
- Parameters:
rServiceSpecifier
- service name.rArguments
- arguments.xContext
- context.- Returns:
- service instance.
- Throws:
com.sun.star.uno.Exception
-
dispose
public void dispose() throws com.sun.star.uno.RuntimeExceptionRemoves all listeners from theServiceManager
and clears the list of the services.- Specified by:
dispose
in interfacecom.sun.star.lang.XComponent
- Throws:
com.sun.star.uno.RuntimeException
- See Also:
-
XComponent
-
addEventListener
public void addEventListener(com.sun.star.lang.XEventListener xListener) throws com.sun.star.uno.RuntimeException Adds a newEventListener
.The listener is notified when a service is added (removed) to (from) the
ServiceManager
.If the listener is already registered a
com.sun.star.uno.RuntimeException
will be thrown.- Specified by:
addEventListener
in interfacecom.sun.star.lang.XComponent
- Parameters:
xListener
- the new listener which should been added.- Throws:
com.sun.star.uno.RuntimeException
- See Also:
-
XComponent
-
removeEventListener
public void removeEventListener(com.sun.star.lang.XEventListener xListener) throws com.sun.star.uno.RuntimeException Removes aEventListener
from theServiceManager
.If the listener is not registered a
com.sun.star.uno.RuntimeException
will be thrown.- Specified by:
removeEventListener
in interfacecom.sun.star.lang.XComponent
- Parameters:
xListener
- the new listener which should been removed.- Throws:
com.sun.star.uno.RuntimeException
- See Also:
-
XComponent
-
has
Checks if a component is registered at theServiceManager
.The given object argument must provide a
XServiceInfo
interface.- Specified by:
has
in interfacecom.sun.star.container.XSet
- Parameters:
object
- object which provides aXServiceInfo
interface.- Returns:
- true if the component is registered otherwise false.
- Throws:
com.sun.star.uno.RuntimeException
- See Also:
-
XSet
XServiceInfo
-
insert
public void insert(Object object) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.ElementExistException, com.sun.star.uno.RuntimeException Adds aSingleServiceFactory
to theServiceManager
.- Specified by:
insert
in interfacecom.sun.star.container.XSet
- Parameters:
object
- factory which should be added.- Throws:
com.sun.star.lang.IllegalArgumentException
com.sun.star.container.ElementExistException
com.sun.star.uno.RuntimeException
- See Also:
-
XSet
XSingleServiceFactory
-
remove
public void remove(Object object) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.NoSuchElementException, com.sun.star.uno.RuntimeException Removes aSingleServiceFactory
from theServiceManager
.- Specified by:
remove
in interfacecom.sun.star.container.XSet
- Parameters:
object
- factory which should be removed.- Throws:
com.sun.star.lang.IllegalArgumentException
com.sun.star.container.NoSuchElementException
com.sun.star.uno.RuntimeException
- See Also:
-
XSet
XSingleServiceFactory
-
createEnumeration
public com.sun.star.container.XEnumeration createEnumeration() throws com.sun.star.uno.RuntimeExceptionProvides an enumeration of all registered services.- Specified by:
createEnumeration
in interfacecom.sun.star.container.XEnumerationAccess
- Returns:
- an enumeration of all available services.
- Throws:
com.sun.star.uno.RuntimeException
- See Also:
-
XEnumerationAccess
-
getElementType
Provides the UNO type of theServiceManager
- Specified by:
getElementType
in interfacecom.sun.star.container.XElementAccess
- Returns:
- the UNO type of the
ServiceManager
. - Throws:
com.sun.star.uno.RuntimeException
- See Also:
-
XElementAccess
TypeClass
-
hasElements
public boolean hasElements()Checks if the any components are registered.- Specified by:
hasElements
in interfacecom.sun.star.container.XElementAccess
- Returns:
- true - if the list of the registered components is not empty - otherwise false.
- See Also:
-
XElementAccess
-
createContentEnumeration
public com.sun.star.container.XEnumeration createContentEnumeration(String serviceName) throws com.sun.star.uno.RuntimeException Provides an enumeration of all factories for a specified service.- Specified by:
createContentEnumeration
in interfacecom.sun.star.container.XContentEnumerationAccess
- Parameters:
serviceName
- name of the requested service.- Returns:
- an enumeration for service name.
- Throws:
com.sun.star.uno.RuntimeException
- See Also:
-
XContentEnumerationAccess
-
getImplementationName
Returns the implementation name of theServiceManager
component.- Specified by:
getImplementationName
in interfacecom.sun.star.lang.XServiceInfo
- Returns:
- the class name of the
ServiceManager
. - Throws:
com.sun.star.uno.RuntimeException
- See Also:
-
XServiceInfo
-
supportsService
Checks if theServiceManager
supports a service.- Specified by:
supportsService
in interfacecom.sun.star.lang.XServiceInfo
- Parameters:
serviceName
- service name which should be checked.- Returns:
- true if the service is supported - otherwise false.
- Throws:
com.sun.star.uno.RuntimeException
- See Also:
-
XServiceInfo
-
getSupportedServiceNames
Supplies list of all supported services.- Specified by:
getSupportedServiceNames
in interfacecom.sun.star.lang.XServiceInfo
- Returns:
- a list of all supported service names.
- Throws:
com.sun.star.uno.RuntimeException
- See Also:
-
XServiceInfo
-