summaryrefslogtreecommitdiff
path: root/javaunohelper
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-10-14 09:37:20 +0200
committerNoel Grandin <noel@peralex.com>2015-10-14 09:55:17 +0200
commit7e7014ba139dbcb192b21fc1a28178ef35e1fdc4 (patch)
tree282a2b2efd8f10564564f846fbbe12e96533c5b8 /javaunohelper
parentec0c4ce0a02ed72459de1fcaf3f2f7713bf67b5d (diff)
use early returns to make method easier to read
Change-Id: Iabaedbd51d3832eff8e7470fd586132c38e1d039
Diffstat (limited to 'javaunohelper')
-rw-r--r--javaunohelper/com/sun/star/comp/helper/ComponentContext.java147
1 files changed, 73 insertions, 74 deletions
diff --git a/javaunohelper/com/sun/star/comp/helper/ComponentContext.java b/javaunohelper/com/sun/star/comp/helper/ComponentContext.java
index 9d327ec8a8ce..67579f95bae8 100644
--- a/javaunohelper/com/sun/star/comp/helper/ComponentContext.java
+++ b/javaunohelper/com/sun/star/comp/helper/ComponentContext.java
@@ -121,94 +121,93 @@ public class ComponentContext implements XComponentContext, XComponent
public Object getValueByName( String rName )
{
Object o = m_table.get( rName );
- if (o != null)
+ if (o == null)
{
- if (o instanceof ComponentContextEntry)
+ if (m_xDelegate != null)
{
- ComponentContextEntry entry = (ComponentContextEntry)o;
- if (entry.m_lateInit != null)
- {
- Object xInstance = null;
+ return m_xDelegate.getValueByName( rName );
+ }
+ else
+ {
+ return Any.VOID;
+ }
+ }
- try
- {
- String serviceName = (String)entry.m_lateInit;
- if (serviceName != null)
- {
- if (m_xSMgr != null)
- {
- xInstance = m_xSMgr.createInstanceWithContext( serviceName, this );
- }
- else
- {
- if (DEBUG)
- System.err.println( "### no service manager instance for late init of singleton instance \"" + rName + "\"!" );
- }
- }
- else
- {
- XSingleComponentFactory xCompFac =
- UnoRuntime.queryInterface(
- XSingleComponentFactory.class, entry.m_lateInit );
- if (xCompFac != null)
- {
- xInstance = xCompFac.createInstanceWithContext( this );
- }
- else
- {
- if (DEBUG)
- System.err.println( "### neither service name nor service factory given for late init of singleton instance \"" + rName + "\"!" );
- }
- }
- }
- catch (com.sun.star.uno.Exception exc)
- {
- if (DEBUG)
- System.err.println( "### exception occurred on late init of singleton instance \"" + rName + "\": " + exc.getMessage() );
- }
+ if (!(o instanceof ComponentContextEntry))
+ {
+ // direct value in map
+ return o;
+ }
- if (xInstance != null)
- {
- synchronized (entry)
- {
- if (entry.m_lateInit != null)
- {
- entry.m_value = xInstance;
- entry.m_lateInit = null;
- }
- else // inited in the meantime
- {
- // dispose fresh service instance
- XComponent xComp = UnoRuntime.queryInterface(
- XComponent.class, xInstance );
- if (xComp != null)
- {
- xComp.dispose();
- }
- }
- }
- }
- else
- {
- if (DEBUG)
- System.err.println( "### failed late init of singleton instance \"" + rName + "\"!" );
- }
+ ComponentContextEntry entry = (ComponentContextEntry)o;
+ if (entry.m_lateInit == null)
+ {
+ return entry.m_value;
+ }
+
+ Object xInstance = null;
+ try
+ {
+ String serviceName = (String)entry.m_lateInit;
+ if (serviceName != null)
+ {
+ if (m_xSMgr != null)
+ {
+ xInstance = m_xSMgr.createInstanceWithContext( serviceName, this );
+ }
+ else
+ {
+ if (DEBUG)
+ System.err.println( "### no service manager instance for late init of singleton instance \"" + rName + "\"!" );
}
- return entry.m_value;
}
- else // direct value in map
+ else
{
- return o;
+ XSingleComponentFactory xCompFac = UnoRuntime.queryInterface( XSingleComponentFactory.class, entry.m_lateInit );
+ if (xCompFac != null)
+ {
+ xInstance = xCompFac.createInstanceWithContext( this );
+ }
+ else
+ {
+ if (DEBUG)
+ System.err.println( "### neither service name nor service factory given for late init of singleton instance \"" + rName + "\"!" );
+ }
}
}
- else if (m_xDelegate != null)
+ catch (com.sun.star.uno.Exception exc)
+ {
+ if (DEBUG)
+ System.err.println( "### exception occurred on late init of singleton instance \"" + rName + "\": " + exc.getMessage() );
+ }
+
+ if (xInstance != null)
{
- return m_xDelegate.getValueByName( rName );
+ synchronized (entry)
+ {
+ if (entry.m_lateInit != null)
+ {
+ entry.m_value = xInstance;
+ entry.m_lateInit = null;
+ }
+ else // inited in the meantime
+ {
+ // dispose fresh service instance
+ XComponent xComp = UnoRuntime.queryInterface(
+ XComponent.class, xInstance );
+ if (xComp != null)
+ {
+ xComp.dispose();
+ }
+ }
+ }
}
else
{
- return Any.VOID;
+ if (DEBUG)
+ System.err.println( "### failed late init of singleton instance \"" + rName + "\"!" );
}
+ return entry.m_value;
}
public XMultiComponentFactory getServiceManager()