Top Description Inners Fields Constructors Methods
com.sun.star.comp.servicemanager

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
Class Inheritance
Imports
java.util.ArrayList, .Collections, com.sun.star.container.XContentEnumerationAccess, com.sun.star.container.XEnumeration, com.sun.star.container.XSet, com.sun.star.lang.XComponent, com.sun.star.lang.XEventListener, com.sun.star.lang.XMultiComponentFactory, com.sun.star.lang.XMultiServiceFactory, com.sun.star.lang.XServiceInfo, com.sun.star.lang.XSingleComponentFactory, com.sun.star.lang.XSingleServiceFactory, com.sun.star.uno.UnoRuntime, com.sun.star.uno.XComponentContext

The 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.

Since
UDK1.0
See Also
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

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
ServiceManager.ServiceEnumerationImpl

The ServiceEnumerationImpl class provides an implementation of the @see com.sun.star.container.XEnumeration interface.

Field Summary

Modifier and TypeField and Description
private static final boolean
pack-priv ArrayList<com.sun.star.lang.XEventListener>
pack-priv HashMap<String, Object>
pack-priv HashMap<String, ArrayList<Object>>
private com.sun.star.uno.XComponentContext
pack-priv static String[]
private static Type

Constructor Summary

AccessConstructor and Description
public
ServiceManager()

Creates a new instance of the ServiceManager.

Method Summary

Modifier and TypeMethod and Description
public void
addEventListener(com.sun.star.lang.XEventListener
the new listener which should been added.
xListener
)

Adds a new EventListener.

public com.sun.star.container.XEnumeration

Returns:

an enumeration for service name.
createContentEnumeration
(String
name of the requested service.
serviceName
)

Provides an enumeration of all factories for a specified service.

public com.sun.star.container.XEnumeration

Returns:

an enumeration of all available services.
createEnumeration
()

Provides an enumeration of all registered services.

public Object

Returns:

newly created component.
createInstance
(String
indicates the service or component name.
serviceSpecifier
)

Creates a new instance of a specified service.

public Object

Returns:

newly created component.
createInstanceWithArguments
(String
indicates the service or component name.
serviceSpecifier
,
Object[] args)

Creates a new instance of a specified service with the given parameters.

public Object

Returns:

service instance.
createInstanceWithArgumentsAndContext
(String
service name.
rServiceSpecifier
,
Object[]
arguments.
rArguments
,
com.sun.star.uno.XComponentContext
context.
xContext
)

Create a service instance with given context and arguments.

public Object

Returns:

service instance.
createInstanceWithContext
(String
service name.
rServiceSpecifier
,
com.sun.star.uno.XComponentContext
context.
xContext
)

Create a service instance with given context.

private static final void
public void
dispose()

Removes all listeners from the ServiceManager and clears the list of the services.

public String[]

Returns:

list of Strings of all service names.
getAvailableServiceNames
()

Supplies a list of all available services names.

public Type

Returns:

the UNO type of the ServiceManager.
getElementType
()

Provides the UNO type of the ServiceManager

public String

Returns:

the class name of the ServiceManager.
getImplementationName
()

Returns the implementation name of the ServiceManager component.

public String[]

Returns:

a list of all supported service names.
getSupportedServiceNames
()

Supplies list of all supported services.

public boolean

Returns:

true if the component is registered otherwise false.
has
(Object
object which provides a XServiceInfo interface.
object
)

Checks if a component is registered at the ServiceManager.

public boolean

Returns:

true - if the list of the registered components is not empty - otherwise false.
hasElements
()

Checks if the any components are registered.

public void
insert(Object
factory which should be added.
object
)

Adds a SingleServiceFactory to the ServiceManager.

private Object

Returns:

the factory of the service / implementation.
queryServiceFactory
(String
indicates the service or implementation name.
serviceName
)

Look up the factory for a given service or implementation name.

public void
remove(Object
factory which should be removed.
object
)

Removes a SingleServiceFactory from the ServiceManager.

public void
removeEventListener(com.sun.star.lang.XEventListener
the new listener which should been removed.
xListener
)

Removes a EventListener from the ServiceManager.

public void
setDefaultContext(com.sun.star.uno.XComponentContext context)

public boolean

Returns:

true if the service is supported - otherwise false.
supportsService
(String
service name which should be checked.
serviceName
)

Checks if the ServiceManager supports a service.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEBUGback to summary
private static final boolean DEBUG
eventListenerback to summary
pack-priv ArrayList<com.sun.star.lang.XEventListener> eventListener
factoriesByImplNamesback to summary
pack-priv HashMap<String, Object> factoriesByImplNames
factoriesByServiceNamesback to summary
pack-priv HashMap<String, ArrayList<Object>> factoriesByServiceNames
m_xDefaultContextback to summary
private com.sun.star.uno.XComponentContext m_xDefaultContext
supportedServiceNamesback to summary
pack-priv static String[] supportedServiceNames
UNO_TYPEback to summary
private static Type UNO_TYPE

Constructor Detail

ServiceManagerback to summary
public ServiceManager()

Creates a new instance of the ServiceManager.

Method Detail

addEventListenerback to summary
public void addEventListener(com.sun.star.lang.XEventListener xListener) throws com.sun.star.uno.RuntimeException

Adds a new EventListener.

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.

Parameters
xListener:com.sun.star.lang.XEventListener

the new listener which should been added.

See Also
com.sun.star.lang.XComponent
createContentEnumerationback to summary
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.

Parameters
serviceName:String

name of the requested service.

Returns:com.sun.star.container.XEnumeration

an enumeration for service name.

See Also
com.sun.star.container.XContentEnumerationAccess
createEnumerationback to summary
public com.sun.star.container.XEnumeration createEnumeration() throws com.sun.star.uno.RuntimeException

Provides an enumeration of all registered services.

Returns:com.sun.star.container.XEnumeration

an enumeration of all available services.

See Also
com.sun.star.container.XEnumerationAccess
createInstanceback to summary
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.

Parameters
serviceSpecifier:String

indicates the service or component name.

Returns:Object

newly created component.

See Also
com.sun.star.lang.XMultiServiceFactory
createInstanceWithArgumentsback to summary
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.

Parameters
serviceSpecifier:String

indicates the service or component name.

Returns:Object

newly created component.

See Also
com.sun.star.lang.XMultiServiceFactory
createInstanceWithArgumentsAndContextback to summary
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.

Parameters
rServiceSpecifier:String

service name.

rArguments:Object[]

arguments.

xContext:com.sun.star.uno.XComponentContext

context.

Returns:Object

service instance.

createInstanceWithContextback to summary
public Object createInstanceWithContext(String rServiceSpecifier, com.sun.star.uno.XComponentContext xContext) throws com.sun.star.uno.Exception

Create a service instance with given context.

Parameters
rServiceSpecifier:String

service name.

xContext:com.sun.star.uno.XComponentContext

context.

Returns:Object

service instance.

DEBUGback to summary
private static final void DEBUG(String dbg)
disposeback to summary
public void dispose() throws com.sun.star.uno.RuntimeException

Removes all listeners from the ServiceManager and clears the list of the services.

See Also
com.sun.star.lang.XComponent
getAvailableServiceNamesback to summary
public String[] getAvailableServiceNames() throws com.sun.star.uno.RuntimeException

Supplies a list of all available services names.

Returns:String[]

list of Strings of all service names.

See Also
com.sun.star.container.XContentEnumerationAccess
getElementTypeback to summary
public Type getElementType() throws com.sun.star.uno.RuntimeException

Provides the UNO type of the ServiceManager

Returns:Type

the UNO type of the ServiceManager.

See Also
com.sun.star.container.XElementAccess, com.sun.star.uno.TypeClass
getImplementationNameback to summary
public String getImplementationName() throws com.sun.star.uno.RuntimeException

Returns the implementation name of the ServiceManager component.

Returns:String

the class name of the ServiceManager.

See Also
com.sun.star.lang.XServiceInfo
getSupportedServiceNamesback to summary
public String[] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException

Supplies list of all supported services.

Returns:String[]

a list of all supported service names.

See Also
com.sun.star.lang.XServiceInfo
hasback to summary
public boolean has(Object object) throws com.sun.star.uno.RuntimeException

Checks if a component is registered at the ServiceManager.

The given object argument must provide a XServiceInfo interface.

Parameters
object:Object

object which provides a XServiceInfo interface.

Returns:boolean

true if the component is registered otherwise false.

See Also
com.sun.star.container.XSet, com.sun.star.lang.XServiceInfo
hasElementsback to summary
public boolean hasElements()

Checks if the any components are registered.

Returns:boolean

true - if the list of the registered components is not empty - otherwise false.

See Also
com.sun.star.container.XElementAccess
insertback to summary
public void insert(Object object) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.ElementExistException, com.sun.star.uno.RuntimeException

Adds a SingleServiceFactory to the ServiceManager.

Parameters
object:Object

factory which should be added.

See Also
com.sun.star.container.XSet, com.sun.star.lang.XSingleServiceFactory
queryServiceFactoryback to summary
private Object queryServiceFactory(String serviceName) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException

Look up the factory for a given service or implementation name.

First the requested service name is search in the list of available services. If it can not be found the name is looked up in the implementation list.

Parameters
serviceName:String

indicates the service or implementation name.

Returns:Object

the factory of the service / implementation.

See Also
com.sun.star.lang.XMultiServiceFactory
removeback to summary
public void remove(Object object) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.NoSuchElementException, com.sun.star.uno.RuntimeException

Removes a SingleServiceFactory from the ServiceManager.

Parameters
object:Object

factory which should be removed.

See Also
com.sun.star.container.XSet, com.sun.star.lang.XSingleServiceFactory
removeEventListenerback to summary
public void removeEventListener(com.sun.star.lang.XEventListener xListener) throws com.sun.star.uno.RuntimeException

Removes a EventListener from the ServiceManager.

If the listener is not registered a com.sun.star.uno.RuntimeException will be thrown.

Parameters
xListener:com.sun.star.lang.XEventListener

the new listener which should been removed.

See Also
com.sun.star.lang.XComponent
setDefaultContextback to summary
public void setDefaultContext(com.sun.star.uno.XComponentContext context)
supportsServiceback to summary
public boolean supportsService(String serviceName) throws com.sun.star.uno.RuntimeException

Checks if the ServiceManager supports a service.

Parameters
serviceName:String

service name which should be checked.

Returns:boolean

true if the service is supported - otherwise false.

See Also
com.sun.star.lang.XServiceInfo
com.sun.star.comp.servicemanager back to summary

pack-priv Class ServiceManager.ServiceEnumerationImpl

extends Object
implements com.sun.star.container.XEnumeration
Class Inheritance
  • java.lang.Object
  • com.sun.star.comp.servicemanager.ServiceManager.ServiceEnumerationImpl

The ServiceEnumerationImpl class provides an implementation of the @see com.sun.star.container.XEnumeration interface.

It is an inner wrapper for a java.util.Enumeration object.

Since
UDK1.0
See Also
com.sun.star.lang.XSingleServiceFactory, com.sun.star.lang.XServiceInfo

Field Summary

Modifier and TypeField and Description
pack-priv Iterator<Object>

Constructor Summary

AccessConstructor and Description
public
ServiceEnumerationImpl()

Constructs a new empty instance.

public
ServiceEnumerationImpl(Enumeration<Object>
is the enumeration which should been wrapped.
enumer
)

Constructs a new instance with a given enumeration.

public
ServiceEnumerationImpl(Iterator<Object>
is the enumeration which should been wrapped.
enumer
)

Constructs a new instance with a given enumeration.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if more elements are available - otherwise false.
hasMoreElements
()

Checks if the enumeration contains more elements.

public Object

Returns:

the next element.
nextElement
()

Returns the next element of the enumeration.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

enumerationback to summary
pack-priv Iterator<Object> enumeration

Constructor Detail

ServiceEnumerationImplback to summary
public ServiceEnumerationImpl()

Constructs a new empty instance.

ServiceEnumerationImplback to summary
public ServiceEnumerationImpl(Enumeration<Object> enumer)

Constructs a new instance with a given enumeration.

Parameters
enumer:Enumeration<Object>

is the enumeration which should been wrapped.

See Also
com.sun.star.container.XEnumeration
ServiceEnumerationImplback to summary
public ServiceEnumerationImpl(Iterator<Object> enumer)

Constructs a new instance with a given enumeration.

Parameters
enumer:Iterator<Object>

is the enumeration which should been wrapped.

See Also
com.sun.star.container.XEnumeration

Method Detail

hasMoreElementsback to summary
public boolean hasMoreElements() throws com.sun.star.uno.RuntimeException

Checks if the enumeration contains more elements.

Returns:boolean

true if more elements are available - otherwise false.

See Also
com.sun.star.container.XEnumeration
nextElementback to summary
public Object nextElement() throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException, com.sun.star.uno.RuntimeException

Returns the next element of the enumeration.

If no further elements available a com.sun.star.container.NoSuchElementException exception will be thrown.

Returns:Object

the next element.

See Also
com.sun.star.container.XEnumeration