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 java.lang.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
TheServiceManager
class is an implementation of theServiceManager
the central class needed for implementing or using UNO components in Java.The Methods
queryInterface
andisSame
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
-
-
Constructor Summary
Constructors Constructor Description ServiceManager()
Creates a new instance of theServiceManager
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEventListener(com.sun.star.lang.XEventListener xListener)
Adds a newEventListener
.com.sun.star.container.XEnumeration
createContentEnumeration(java.lang.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.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 theServiceManager
and clears the list of the services.java.lang.String[]
getAvailableServiceNames()
Supplies a list of all available services names.Type
getElementType()
Provides the UNO type of theServiceManager
java.lang.String
getImplementationName()
Returns the implementation name of theServiceManager
component.java.lang.String[]
getSupportedServiceNames()
Supplies list of all supported services.boolean
has(java.lang.Object object)
Checks if a component is registered at theServiceManager
.boolean
hasElements()
Checks if the any components are registered.void
insert(java.lang.Object object)
Adds aSingleServiceFactory
to theServiceManager
.void
remove(java.lang.Object object)
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(java.lang.String serviceName)
Checks if theServiceManager
supports a service.
-
-
-
Method Detail
-
setDefaultContext
public void setDefaultContext(com.sun.star.uno.XComponentContext context)
-
createInstance
public java.lang.Object createInstance(java.lang.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 java.lang.Object createInstanceWithArguments(java.lang.String serviceSpecifier, java.lang.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
public java.lang.String[] getAvailableServiceNames() throws com.sun.star.uno.RuntimeException
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 java.lang.Object createInstanceWithContext(java.lang.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 java.lang.Object createInstanceWithArgumentsAndContext(java.lang.String rServiceSpecifier, java.lang.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.RuntimeException
Removes 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
public boolean has(java.lang.Object object) throws com.sun.star.uno.RuntimeException
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(java.lang.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(java.lang.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.RuntimeException
Provides 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
public Type getElementType() throws com.sun.star.uno.RuntimeException
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(java.lang.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
public java.lang.String getImplementationName() throws com.sun.star.uno.RuntimeException
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
public boolean supportsService(java.lang.String serviceName) throws com.sun.star.uno.RuntimeException
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
public java.lang.String[] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException
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
-
-