summaryrefslogtreecommitdiff
path: root/jurt/com
diff options
context:
space:
mode:
authorDaniel Boelzle <dbo@openoffice.org>2002-06-14 12:09:52 +0000
committerDaniel Boelzle <dbo@openoffice.org>2002-06-14 12:09:52 +0000
commitc28dcca32eeaf1ae3451da315bc8d2237fbfd780 (patch)
tree74a5b346dfe5761e191420650bda9b334a1d6edb /jurt/com
parentae6d9541ba3927bcbf2ec0c2d21ef66806924b03 (diff)
#100075# using macro expander singleton handling macrofied urls
Diffstat (limited to 'jurt/com')
-rw-r--r--jurt/com/sun/star/comp/loader/JavaLoader.java70
1 files changed, 65 insertions, 5 deletions
diff --git a/jurt/com/sun/star/comp/loader/JavaLoader.java b/jurt/com/sun/star/comp/loader/JavaLoader.java
index aa424370feb4..44a0e04bf02b 100644
--- a/jurt/com/sun/star/comp/loader/JavaLoader.java
+++ b/jurt/com/sun/star/comp/loader/JavaLoader.java
@@ -2,9 +2,9 @@
*
* $RCSfile: JavaLoader.java,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: kr $ $Date: 2001-02-19 10:01:01 $
+ * last change: $Author: dbo $ $Date: 2002-06-14 13:09:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,6 +67,8 @@ import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
+import java.net.URLDecoder;
+
import com.sun.star.loader.CannotActivateFactoryException;
import com.sun.star.loader.XImplementationLoader;
@@ -85,9 +87,16 @@ import com.sun.star.lang.ServiceNotRegisteredException;
import com.sun.star.lang.WrappedTargetException;
import com.sun.star.lang.XInitialization;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.util.XMacroExpander;
+
import com.sun.star.uno.XInterface;
+import com.sun.star.uno.Type;
import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+
import java.io.IOException;
import java.net.MalformedURLException;
@@ -96,7 +105,7 @@ import java.net.MalformedURLException;
* service. Therefor the <code>JavaLoader</code> activates external UNO components which are implemented in Java.
* The loader is used by the <code>ServiceManger</code>.
* <p>
- * @version $Revision: 1.3 $ $ $Date: 2001-02-19 10:01:01 $
+ * @version $Revision: 1.4 $ $ $Date: 2002-06-14 13:09:52 $
* @author Markus Herzog
* @see com.sun.star.loader.XImplementationLoader
* @see com.sun.star.loader.Java
@@ -108,7 +117,7 @@ public class JavaLoader implements XImplementationLoader,
XServiceInfo,
XInitialization
{
- private static final boolean DEBUG = false;
+ private static final boolean DEBUG = true;
private static final void DEBUG(String dbg) {
if (DEBUG) System.err.println( dbg );
@@ -120,6 +129,53 @@ public class JavaLoader implements XImplementationLoader,
protected XMultiServiceFactory multiServiceFactory = null;
+ private XMacroExpander m_xMacroExpander = null;
+ private static final String EXPAND_PROTOCOL_PREFIX = "vnd.sun.star.expand:";
+
+ /** Expands macrofied url using the macro expander singleton.
+ */
+ private String expand_url( String url ) throws RuntimeException
+ {
+ if (url != null && url.startsWith( EXPAND_PROTOCOL_PREFIX ))
+ {
+ try
+ {
+ if (m_xMacroExpander == null)
+ {
+ XPropertySet xProps = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, multiServiceFactory );
+ if (xProps == null)
+ {
+ throw new com.sun.star.uno.RuntimeException(
+ "service manager does not support XPropertySet!", this );
+ }
+ XComponentContext xContext = (XComponentContext)AnyConverter.toObject(
+ new Type( XComponentContext.class ),
+ xProps.getPropertyValue( "DefaultContext" ) );
+ m_xMacroExpander = (XMacroExpander)AnyConverter.toObject(
+ new Type( XMacroExpander.class ),
+ xContext.getValueByName( "/singletons/com.sun.star.util.theMacroExpander" ) );
+ // decode uric class chars
+ String macro = URLDecoder.decode(
+ url.substring( EXPAND_PROTOCOL_PREFIX.length() ) /* cut protocol */ );
+ // expand macro string
+ String ret = m_xMacroExpander.expandMacros( macro );
+ if (DEBUG)
+ {
+ System.err.println(
+ "JavaLoader.expand_url(): " + url + " => " + macro + " => " + ret );
+ }
+ return ret;
+ }
+ }
+ catch (com.sun.star.uno.Exception exc)
+ {
+ throw new com.sun.star.uno.RuntimeException( exc.getMessage(), this );
+ }
+ }
+ return url;
+ }
+
/** default constructor
*/
@@ -234,6 +290,8 @@ public class JavaLoader implements XImplementationLoader,
throws CannotActivateFactoryException,
com.sun.star.uno.RuntimeException
{
+ locationUrl = expand_url( locationUrl );
+
boolean needFactoryWrapper = false;
Object returnObject = null;
Class clazz = null;
@@ -349,6 +407,8 @@ public class JavaLoader implements XImplementationLoader,
throws CannotRegisterImplementationException,
com.sun.star.uno.RuntimeException
{
+ locationUrl = expand_url( locationUrl );
+
boolean success = false;
try {
@@ -425,7 +485,7 @@ public class JavaLoader implements XImplementationLoader,
* the registration at a registry in a default manner. The class is used by the <code>JavaLoader</code> if the
* a component does not comes with its own methods for creating a factory or for the registration.
* <p>
- * @version $Revision: 1.3 $ $ $Date: 2001-02-19 10:01:01 $
+ * @version $Revision: 1.4 $ $ $Date: 2002-06-14 13:09:52 $
* @author Markus Herzog
* @since UDK1.0
*/