Keep null service manager throw a DeploymentException

...rather than a general RuntimeException, for consistency with existing service
ctor code.

Change-Id: Ia9ac14a1b5bcecb24394e7b9cade369f3f9303f0
This commit is contained in:
Stephan Bergmann 2012-09-17 19:12:34 +02:00
parent 1b699e5c20
commit d2092dc56b
4 changed files with 10 additions and 7 deletions

View File

@ -19,6 +19,7 @@
package test.codemaker.javamaker.java15; package test.codemaker.javamaker.java15;
import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.DeploymentException;
import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XComponentContext;
import complexlib.ComplexTestCase; import complexlib.ComplexTestCase;
@ -68,18 +69,18 @@ public final class Test extends ComplexTestCase {
} }
public XMultiComponentFactory getServiceManager() { public XMultiComponentFactory getServiceManager() {
throw new com.sun.star.uno.RuntimeException(); throw new DeploymentException();
} }
}; };
try { try {
Service.create(context); Service.create(context);
failed(); failed();
} catch (com.sun.star.uno.RuntimeException e) {} } catch (DeploymentException e) {}
try { try {
Service.create( Service.create(
context, false, (byte) 1, (short) 2, Integer.valueOf(4)); context, false, (byte) 1, (short) 2, Integer.valueOf(4));
failed(); failed();
} catch (com.sun.star.uno.RuntimeException e) {} } catch (DeploymentException e) {}
} }
private static final class Ifc implements XIfc { private static final class Ifc implements XIfc {

View File

@ -60,6 +60,7 @@
#include <com/sun/star/lang/XMultiComponentFactory.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
#include "com/sun/star/uno/DeploymentException.hpp"
#include "com/sun/star/uno/RuntimeException.hpp" #include "com/sun/star/uno/RuntimeException.hpp"
#include <memory> #include <memory>
@ -674,7 +675,7 @@ Reference< lang::XMultiComponentFactory > ComponentContext::getServiceManager()
{ {
if ( !m_xSMgr.is() ) if ( !m_xSMgr.is() )
{ {
throw RuntimeException( throw DeploymentException(
"null component context service manager", "null component context service manager",
static_cast<OWeakObject *>(this) ); static_cast<OWeakObject *>(this) );
} }

View File

@ -20,6 +20,7 @@ package com.sun.star.comp.helper;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.Any; import com.sun.star.uno.Any;
import com.sun.star.uno.DeploymentException;
import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XComponentContext;
import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lang.XSingleComponentFactory; import com.sun.star.lang.XSingleComponentFactory;
@ -209,7 +210,7 @@ public class ComponentContext implements XComponentContext, XComponent
{ {
if (m_xSMgr == null) if (m_xSMgr == null)
{ {
throw new com.sun.star.uno.RuntimeException( throw new DeploymentException(
"null component context service manager" ); "null component context service manager" );
} }
return m_xSMgr; return m_xSMgr;

View File

@ -49,8 +49,8 @@ published interface XComponentContext : XInterface
service manager is used very often. service manager is used very often.
@return @return
service manager; throws RuntimeException in case service manager service manager; throws DeploymentException in case service
is null manager is null
*/ */
com::sun::star::lang::XMultiComponentFactory getServiceManager(); com::sun::star::lang::XMultiComponentFactory getServiceManager();
}; };