Class JavaLoader
- java.lang.Object
-
- com.sun.star.comp.loader.JavaLoader
-
- All Implemented Interfaces:
com.sun.star.lang.XInitialization
,com.sun.star.lang.XServiceInfo
,com.sun.star.loader.XImplementationLoader
,com.sun.star.uno.XInterface
public class JavaLoader extends java.lang.Object implements com.sun.star.loader.XImplementationLoader, com.sun.star.lang.XServiceInfo, com.sun.star.lang.XInitialization
TheJavaLoader
class provides the functionality of thecom.sun.star.loader.Java
service.Therefore the
JavaLoader
activates external UNO components which are implemented in Java.The loader is used by the
ServiceManager
.- Since:
- UDK1.0
- See Also:
XImplementationLoader
,Java
,ServiceManager
-
-
Field Summary
Fields Modifier and Type Field Description protected com.sun.star.lang.XMultiServiceFactory
multiServiceFactory
-
Constructor Summary
Constructors Constructor Description JavaLoader()
Default constructor.JavaLoader(com.sun.star.lang.XMultiServiceFactory factory)
Creates a newJavaLoader
object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
activate(java.lang.String implementationName, java.lang.String implementationLoaderUrl, java.lang.String locationUrl, com.sun.star.registry.XRegistryKey xKey)
Provides a components factory.java.lang.String
getImplementationName()
Supplies the implementation name of the component.static com.sun.star.lang.XSingleServiceFactory
getServiceFactory(java.lang.String implName, com.sun.star.lang.XMultiServiceFactory multiFactory, com.sun.star.registry.XRegistryKey regKey)
Supplies the factory for theJavaLoader
.java.lang.String[]
getSupportedServiceNames()
Supplies a list of all service names supported by the component.void
initialize(java.lang.Object[] args)
Unlike the original intention, the method could be called every time a newcom.sun.star.lang.XMultiServiceFactory
should be set at the loader.boolean
supportsService(java.lang.String serviceName)
Verifies if a given service is supported by the component.boolean
writeRegistryInfo(com.sun.star.registry.XRegistryKey regKey, java.lang.String implementationLoaderUrl, java.lang.String locationUrl)
Registers the component in a registry under a given root key.static boolean
writeRegistryServiceInfo(com.sun.star.registry.XRegistryKey regKey)
Registers theJavaLoader
at the registry.
-
-
-
Constructor Detail
-
JavaLoader
public JavaLoader()
Default constructor.Creates a new instance of the
JavaLoader
class.
-
JavaLoader
public JavaLoader(com.sun.star.lang.XMultiServiceFactory factory)
Creates a newJavaLoader
object.The specified
com.sun.star.lang.XMultiServiceFactory
is theServiceManager
service which can be delivered to all components theJavaLoader
is loading.To set the
MultiServiceFactory
you can use thecom.sun.star.lang.XInitialization
interface, either.- Parameters:
factory
- theServiceManager
.- See Also:
ServiceManager
,XInitialization
-
-
Method Detail
-
initialize
public void initialize(java.lang.Object[] args) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException
Unlike the original intention, the method could be called every time a newcom.sun.star.lang.XMultiServiceFactory
should be set at the loader.- Specified by:
initialize
in interfacecom.sun.star.lang.XInitialization
- Parameters:
args
- - the first parameter (args[0]) specifies theServiceManager
.- Throws:
com.sun.star.uno.Exception
com.sun.star.uno.RuntimeException
- See Also:
XInitialization
,ServiceManager
-
getImplementationName
public java.lang.String getImplementationName() throws com.sun.star.uno.RuntimeException
Supplies the implementation name of the component.- Specified by:
getImplementationName
in interfacecom.sun.star.lang.XServiceInfo
- Returns:
- the implementation name - here the class name.
- Throws:
com.sun.star.uno.RuntimeException
- See Also:
XServiceInfo
-
supportsService
public boolean supportsService(java.lang.String serviceName) throws com.sun.star.uno.RuntimeException
Verifies if a given service is supported by the component.- Specified by:
supportsService
in interfacecom.sun.star.lang.XServiceInfo
- Parameters:
serviceName
- the name of the service that should be checked.- Returns:
- true,if 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 a list of all service names supported by the component.- Specified by:
getSupportedServiceNames
in interfacecom.sun.star.lang.XServiceInfo
- Returns:
- a String array with all supported services.
- Throws:
com.sun.star.uno.RuntimeException
- See Also:
XServiceInfo
-
activate
public java.lang.Object activate(java.lang.String implementationName, java.lang.String implementationLoaderUrl, java.lang.String locationUrl, com.sun.star.registry.XRegistryKey xKey) throws com.sun.star.loader.CannotActivateFactoryException, com.sun.star.uno.RuntimeException
Provides a components factory.The
JavaLoader
tries to load the class first. If a location URL is given the RegistrationClassFinder is used to load the class. Otherwise the class is loaded through the Class.forName method.To get the factory the inspects the class for the optional static member functions __getServiceFactory resp. getServiceFactory (DEPRECATED).
- Specified by:
activate
in interfacecom.sun.star.loader.XImplementationLoader
- Parameters:
implementationName
- the implementation (class) name of the component.implementationLoaderUrl
- the URL of the implementation loader. Not used.locationUrl
- points to an archive (JAR file) which contains a component.xKey
- registry key.- Returns:
- the factory for the component (@see com.sun.star.lang.XSingleServiceFactory)
- Throws:
com.sun.star.loader.CannotActivateFactoryException
com.sun.star.uno.RuntimeException
- See Also:
XImplementationLoader
,RegistrationClassFinder
-
writeRegistryInfo
public boolean writeRegistryInfo(com.sun.star.registry.XRegistryKey regKey, java.lang.String implementationLoaderUrl, java.lang.String locationUrl) throws com.sun.star.registry.CannotRegisterImplementationException, com.sun.star.uno.RuntimeException
Registers the component in a registry under a given root key.If the component supports the optional methods __writeRegistryServiceInfo, writeRegistryServiceInfo (DEPRECATED), the call is delegated to that method. Otherwise a default registration will be accomplished.
- Specified by:
writeRegistryInfo
in interfacecom.sun.star.loader.XImplementationLoader
- Parameters:
regKey
- the root key under that the component should be registered.implementationLoaderUrl
- specifies the loader, the component is loaded by.locationUrl
- points to an archive (JAR file) which contains a component.- Returns:
- true if registration is successfully - otherwise false.
- Throws:
com.sun.star.registry.CannotRegisterImplementationException
com.sun.star.uno.RuntimeException
-
getServiceFactory
public static com.sun.star.lang.XSingleServiceFactory getServiceFactory(java.lang.String implName, com.sun.star.lang.XMultiServiceFactory multiFactory, com.sun.star.registry.XRegistryKey regKey)
Supplies the factory for theJavaLoader
.- Parameters:
implName
- the name of the desired component.multiFactory
- theServiceManager
is delivered to the factory.regKey
- not used - can be null.- Returns:
- the factory for the
JavaLoader
.
-
writeRegistryServiceInfo
public static boolean writeRegistryServiceInfo(com.sun.star.registry.XRegistryKey regKey)
Registers theJavaLoader
at the registry.- Parameters:
regKey
- root key under which theJavaLoader
should be registered.- Returns:
- true if registration succeeded - otherwise false.
-
-