diff --git a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/dialogs/JdbcDriverManagerDialog.java b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/dialogs/JdbcDriverManagerDialog.java
index 77df2407034..8de3227ae1c 100644
--- a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/dialogs/JdbcDriverManagerDialog.java
+++ b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/dialogs/JdbcDriverManagerDialog.java
@@ -28,10 +28,10 @@
import org.eclipse.birt.report.data.oda.jdbc.ui.JdbcPlugin;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.DriverInfo;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.IHelpConstants;
-import org.eclipse.birt.report.data.oda.jdbc.ui.util.JDBCDriverInformation;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.JarFile;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.JdbcToolKit;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.Utility;
+import org.eclipse.birt.report.data.oda.jdbc.utils.JDBCDriverInformation;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/editors/SQLDataSetEditorPage.java b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/editors/SQLDataSetEditorPage.java
index b6ae72ed2ae..b04b8102789 100644
--- a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/editors/SQLDataSetEditorPage.java
+++ b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/editors/SQLDataSetEditorPage.java
@@ -222,7 +222,7 @@ private void setDefaultPereferencesIfNeed( )
private void prepareJDBCMetaDataProvider( DataSetDesign dataSetDesign )
{
- JdbcMetaDataProvider.createInstance( dataSetDesign );
+ JdbcMetaDataProvider.createInstance( dataSetDesign, this.getHostResourceIdentifiers( ) );
class TempThread extends Thread
{
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/profile/JDBCPropertyPage.java b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/profile/JDBCPropertyPage.java
index 1e14dcdd2ef..b5684453de5 100644
--- a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/profile/JDBCPropertyPage.java
+++ b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/profile/JDBCPropertyPage.java
@@ -67,6 +67,7 @@ protected void createAndInitCustomControl( Composite parent,
m_pageHelper.addBidiSettingsButton( content, profileProps );
this.setPingButtonVisible( false );
m_pageHelper.initCustomControl( profileProps );
+ m_pageHelper.setResourceIdentifier( this.getHostResourceIdentifiers( ) );
}
/*
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/profile/JDBCSelectionPageHelper.java b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/profile/JDBCSelectionPageHelper.java
index fb4f59b2a45..e296e67a251 100644
--- a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/profile/JDBCSelectionPageHelper.java
+++ b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/profile/JDBCSelectionPageHelper.java
@@ -29,14 +29,18 @@
import org.eclipse.birt.report.data.oda.jdbc.ui.util.DriverLoader;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.ExceptionHandler;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.IHelpConstants;
-import org.eclipse.birt.report.data.oda.jdbc.ui.util.JDBCDriverInfoManager;
-import org.eclipse.birt.report.data.oda.jdbc.ui.util.JDBCDriverInformation;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.JdbcToolKit;
-import org.eclipse.birt.report.data.oda.jdbc.ui.util.PropertyElement;
-import org.eclipse.birt.report.data.oda.jdbc.ui.util.PropertyGroup;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.Utility;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.bidi.profile.BidiSettingsSupport;
+import org.eclipse.birt.report.data.oda.jdbc.utils.DriverInfoConstants;
+import org.eclipse.birt.report.data.oda.jdbc.utils.JDBCDriverInfoManager;
+import org.eclipse.birt.report.data.oda.jdbc.utils.JDBCDriverInformation;
+import org.eclipse.birt.report.data.oda.jdbc.utils.PropertyElement;
+import org.eclipse.birt.report.data.oda.jdbc.utils.PropertyGroup;
+import org.eclipse.birt.report.data.oda.jdbc.utils.ResourceLocator;
import org.eclipse.datatools.connectivity.oda.OdaException;
+import org.eclipse.datatools.connectivity.oda.design.ResourceIdentifiers;
+import org.eclipse.datatools.connectivity.oda.design.ui.designsession.DesignSessionUtil;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.PreferencePage;
@@ -107,6 +111,7 @@ public class JDBCSelectionPageHelper
private final String ENCRYTPION_METHOD_DEFAULT_VALUE = "noEncryption"; //$NON-NLS-1$
private final String JDBC_EXTENSION_ID = "org.eclipse.birt.report.data.oda.jdbc"; //$NON-NLS-1$
+ private org.eclipse.datatools.connectivity.oda.util.ResourceIdentifiers resourceIdentifier;
JDBCSelectionPageHelper( WizardPage page )
{
@@ -152,7 +157,7 @@ Composite createCustomControl( Composite parent )
driverChooserCombo.getControl( ).setLayoutData( gridData );
List driverListTmp1 = JdbcToolKit.getJdbcDriversFromODADir( JDBC_EXTENSION_ID );
- JDBCDriverInformation[] driverListTmp2 = JDBCDriverInfoManager.getDrivers( );
+ JDBCDriverInformation[] driverListTmp2 = JDBCDriverInfoManager.getInstance( ).getDriversInfo( );
List driverList = new ArrayList( );
for ( Object driverInfo : driverListTmp1 )
{
@@ -277,17 +282,17 @@ private void drawPropertyGroups( final JDBCDriverInformation info )
for ( int i = 0; i < propertyList.size( ); i++ )
{
final String propertyName = propertyList.get( i )
- .getAttribute( Constants.DRIVER_INFO_PROPERTY_NAME );
+ .getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_NAME );
Label propertyParam = new Label( propertyGroup,
SWT.NONE );
String propertyParamDisplayName = propertyList.get( i )
- .getAttribute( Constants.DRIVER_INFO_PROPERTY_DISPLAYNAME );
+ .getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_DISPLAYNAME );
if ( propertyParamDisplayName == null )
{
propertyParamDisplayName = propertyName;
}
propertyParam.setText( propertyParamDisplayName );
- propertyParam.setToolTipText( propertyList.get( i ).getAttribute( Constants.DRIVER_INFO_PROPERTY_DEC ) );
+ propertyParam.setToolTipText( propertyList.get( i ).getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_DEC ) );
GridData gd = new GridData( );
gd.horizontalSpan = 2; // bidi_hcg
propertyParam.setLayoutData( gd );
@@ -299,8 +304,8 @@ private void drawPropertyGroups( final JDBCDriverInformation info )
propertyContent = getProfileproperty( propertyName );
}
- if ( Constants.DRIVER_INFO_PROPERTY_TYPE_BOOLEN.equalsIgnoreCase( propertyList.get( i )
- .getAttribute( Constants.DRIVER_INFO_PROPERTY_TYPE ) ) )
+ if ( DriverInfoConstants.DRIVER_INFO_PROPERTY_TYPE_BOOLEN.equalsIgnoreCase( propertyList.get( i )
+ .getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_TYPE ) ) )
{
drawPropertyCombo( propertyGroup,
propertyName,
@@ -309,7 +314,7 @@ private void drawPropertyGroups( final JDBCDriverInformation info )
else
{
if ( Boolean.valueOf( propertyList.get( i )
- .getAttribute( Constants.DRIVER_INFO_PROPERTY_ENCRYPT ) ) )
+ .getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_ENCRYPT ) ) )
{
drawPropertyText( propertyGroup,
propertyName,
@@ -340,7 +345,7 @@ private void drawPropertyText( Group propertyGroup,
propertyText = new Text( propertyGroup, SWT.BORDER );
}
- boolean isEncryptionMethod = Constants.DRIVER_INFO_PROPERTY_ENCRYPTION_METHOD.equals( propertyName );
+ boolean isEncryptionMethod = DriverInfoConstants.DRIVER_INFO_PROPERTY_ENCRYPTION_METHOD.equals( propertyName );
if ( propertyContent != null )
{
propertyText.setText( propertyContent );
@@ -982,6 +987,12 @@ else if ( m_propertyPage instanceof JDBCPropertyPage )
bidiSupportObj = ( (JDBCPropertyPage) m_propertyPage ).getBidiSupport( );
}
}
+
+ Properties privateProperties = collectSpecifiedProperties( );
+ Map appContext = new HashMap( );
+ appContext.put( org.eclipse.datatools.connectivity.oda.util.ResourceIdentifiers.ODA_APP_CONTEXT_KEY_CONSUMER_RESOURCE_IDS, this.resourceIdentifier );
+ ResourceLocator.resolveConnectionProperties( privateProperties, driverName, appContext );
+
if ( bidiSupportObj != null )
{
return DriverLoader.testConnection( driverName,
@@ -989,14 +1000,16 @@ else if ( m_propertyPage instanceof JDBCPropertyPage )
jndiNameValue,
userid,
passwd,
- bidiSupportObj.getMetadataBidiFormat( ).toString( ),collectSpecifiedProperties( ) );
+ bidiSupportObj.getMetadataBidiFormat( ).toString( ),
+ privateProperties );
}
return DriverLoader.testConnection( driverName,
url,
jndiNameValue,
userid,
- passwd,collectSpecifiedProperties( ) );
+ passwd,
+ privateProperties );
}
private Properties collectSpecifiedProperties( )
@@ -1239,4 +1252,11 @@ public void addBidiSettingsButton( Composite parent, Properties props )
bidiSupportObj.drawBidiSettingsButton( parent, props );
}
+ public void setResourceIdentifier( ResourceIdentifiers identifiers )
+ {
+ if ( identifiers != null )
+ {
+ this.resourceIdentifier = DesignSessionUtil.createRuntimeResourceIdentifiers( identifiers );
+ }
+ }
}
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/profile/JDBCSelectionWizardPage.java b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/profile/JDBCSelectionWizardPage.java
index 88d86a60370..6fad568e3e8 100644
--- a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/profile/JDBCSelectionWizardPage.java
+++ b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/profile/JDBCSelectionWizardPage.java
@@ -55,7 +55,7 @@ public void createPageCustomControl( Composite parent )
m_pageHelper.initCustomControl( m_folderProperties ); // in case init was called before create
//bidi_hcg: add "Bidi Settings..." button to "Edit Data Source dialog"
m_pageHelper.addBidiSettingsButton( content, m_folderProperties );
-
+ m_pageHelper.setResourceIdentifier( this.getHostResourceIdentifiers( ) );
this.setPingButtonVisible( false );
}
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/provider/JdbcMetaDataProvider.java b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/provider/JdbcMetaDataProvider.java
index 2f5d4b9b41e..c46d6f94090 100644
--- a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/provider/JdbcMetaDataProvider.java
+++ b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/provider/JdbcMetaDataProvider.java
@@ -17,7 +17,9 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -26,9 +28,11 @@
import org.eclipse.birt.report.data.bidi.utils.core.BidiTransform;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.Constants;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.DriverLoader;
+import org.eclipse.birt.report.data.oda.jdbc.utils.ResourceLocator;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.datatools.connectivity.oda.design.DataSetDesign;
import org.eclipse.datatools.connectivity.oda.design.DataSourceDesign;
+import org.eclipse.datatools.connectivity.oda.design.ResourceIdentifiers;
import org.eclipse.datatools.connectivity.oda.design.ui.designsession.DesignSessionUtil;
public class JdbcMetaDataProvider
@@ -69,7 +73,7 @@ private JdbcMetaDataProvider(String driverClass, String url, String userName, St
this.props = props;
}
- public static void createInstance( DataSetDesign dataSetDesign )
+ public static void createInstance( DataSetDesign dataSetDesign, ResourceIdentifiers resourceIdentifiers )
{
release( );
DataSourceDesign dataSourceDesign = dataSetDesign.getDataSourceDesign( );
@@ -88,6 +92,20 @@ public static void createInstance( DataSetDesign dataSetDesign )
String url = props.getProperty( Constants.ODAURL );
String driverClass = props.getProperty( Constants.ODADriverClass );
+ Map appContext = new HashMap( );
+ if ( resourceIdentifiers != null )
+ {
+ appContext.put( org.eclipse.datatools.connectivity.oda.util.ResourceIdentifiers.ODA_APP_CONTEXT_KEY_CONSUMER_RESOURCE_IDS,
+ DesignSessionUtil.createRuntimeResourceIdentifiers( resourceIdentifiers ) );
+ }
+ try
+ {
+ ResourceLocator.resolveConnectionProperties( props, driverClass, appContext );
+ }
+ catch ( OdaException e )
+ {
+ }
+
//bidi_hcg: if Bidi format is defined - perform required Bidi transformations
String metadataBidiFormatStr = props.getProperty(BidiConstants.METADATA_FORMAT_PROP_NAME);
if (metadataBidiFormatStr != null){
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/Constants.java b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/Constants.java
index 4acf6fe17c8..ffeac2c2bd1 100644
--- a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/Constants.java
+++ b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/Constants.java
@@ -14,19 +14,4 @@ public class Constants
org.eclipse.birt.report.data.oda.jdbc.Connection.Constants.ODAJndiName;
public static final String ODAResourceIdentiers =
org.eclipse.birt.report.data.oda.jdbc.Connection.Constants.ODAResourceIdentiers;
-
- public static final String DRIVER_INFO_PROPERTY_GROUP = "propertyGroup";
- public static final String DRIVER_INFO_PROPERTY_GROUP_NAME = "displayName";
- public static final String DRIVER_INFO_PROPERTY_GROUP_DEC = "description";
- public static final String DRIVER_INFO_PROPERTY_ENCRYPTION_METHOD = "EncryptionMethod";
-
- public static final String DRIVER_INFO_PROPERTY = "property";
- public static final String DRIVER_INFO_PROPERTY_NAME = "propertyName";
- public static final String DRIVER_INFO_PROPERTY_DISPLAYNAME = "displayName";
- public static final String DRIVER_INFO_PROPERTY_DEC = "description";
- public static final String DRIVER_INFO_PROPERTY_ENCRYPT= "encrypt";
- public static final String DRIVER_INFO_PROPERTY_TYPE= "type";
- public static final String DRIVER_INFO_PROPERTY_TYPE_BOOLEN= "boolean";
- public static final String DRIVER_INFO_PROPERTY_TYPE_STRING= "string";
- public static final String DRIVER_INFO_PROPERTY_TYPE_NUMBER= "number";
}
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/JDBCDriverInfoManager.java b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/JDBCDriverInfoManager.java
deleted file mode 100644
index 8bfff5bb6b9..00000000000
--- a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/JDBCDriverInfoManager.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 Actuate Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Actuate Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.birt.report.data.oda.jdbc.ui.util;
-
-import java.util.ArrayList;
-
-import org.eclipse.birt.report.data.oda.jdbc.OdaJdbcDriver;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * The JDBCDriverInfoManager manage the information of jdbc drivers read from the
- * org.eclipse.birt.report.data.oda.jdbc.driverInfo extensions. The
- * JDBCDriverInfoManager
instance can be retrieved using the
- * getInstance()
method.
- */
-
-public class JDBCDriverInfoManager
-{
- // prevents construction
- private JDBCDriverInfoManager( )
- {
- }
-
- /**
- * Returns a list of JDBC drivers discovered in the driverInfo extensions,
- * as an array of JDBCDriverInformation objects
- */
- static public JDBCDriverInformation[] getDrivers( )
- {
- ArrayList drivers = new ArrayList();
- IConfigurationElement[] configElements = Platform.getExtensionRegistry().
- getConfigurationElementsFor( OdaJdbcDriver.Constants.DRIVER_INFO_EXTENSION ) ;
- if ( configElements != null )
- {
- for ( int e = 0; e < configElements.length; e++ )
- {
- if ( configElements[e].getName( ).equals(
- OdaJdbcDriver.Constants.DRIVER_INFO_ELEM_JDBCDRIVER ) )
- {
- drivers.add( newJdbcDriverInfo( configElements[e] ) );
- }
- }
- }
- return (JDBCDriverInformation[])drivers.toArray( new JDBCDriverInformation[0]);
- }
-
- /**
- * Creates a new JDBCDriverInformation instance based on a driverInfo extension element
- * @param driverClass
- * @return
- */
- private static JDBCDriverInformation newJdbcDriverInfo(
- IConfigurationElement configElement )
- {
- JDBCDriverInformation driverInfo = JDBCDriverInformation.newInstance(
- configElement.getAttribute( OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_DRIVERCLASS ) );
- driverInfo.setDisplayName(
- configElement.getAttribute( OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_NAME ) );
- driverInfo.setUrlFormat(
- configElement.getAttribute( OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_URLTEMPL ) );
- driverInfo.setHide( configElement.getAttribute( "hide" ) );
- driverInfo.populateProperties( configElement );
- return driverInfo;
- }
-
-}
\ No newline at end of file
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/JdbcToolKit.java b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/JdbcToolKit.java
index b17e17d2d9c..ff582dec117 100644
--- a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/JdbcToolKit.java
+++ b/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/JdbcToolKit.java
@@ -31,6 +31,8 @@
import org.eclipse.birt.report.data.oda.jdbc.ui.JdbcPlugin;
import org.eclipse.birt.report.data.oda.jdbc.ui.dialogs.JdbcDriverManagerDialog;
+import org.eclipse.birt.report.data.oda.jdbc.utils.JDBCDriverInfoManager;
+import org.eclipse.birt.report.data.oda.jdbc.utils.JDBCDriverInformation;
import org.eclipse.ui.PlatformUI;
public class JdbcToolKit
@@ -132,7 +134,7 @@ public synchronized static List getJdbcDriversFromODADir( String driverName )
JDBCDriverInformation ODBCJDBCInfo = null;
// Merge drivers from the driverInfo extension point
- JDBCDriverInformation driverInfos[] = JDBCDriverInfoManager.getDrivers();
+ JDBCDriverInformation driverInfos[] = JDBCDriverInfoManager.getInstance( ).getDriversInfo( );
for (int i = 0; i < driverInfos.length; i++)
{
JDBCDriverInformation newInfo = driverInfos[i];
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc/schema/driverinfo.exsd b/data/org.eclipse.birt.report.data.oda.jdbc/schema/driverinfo.exsd
index 55846526984..54546c888b1 100644
--- a/data/org.eclipse.birt.report.data.oda.jdbc/schema/driverinfo.exsd
+++ b/data/org.eclipse.birt.report.data.oda.jdbc/schema/driverinfo.exsd
@@ -147,7 +147,7 @@ The extension class must implement interface org.eclipse.birt.report.data.oda.jd
- The type of property. It should be boolean, number or string. string is its default value.
+ The type of property. It should be boolean, number, resource or string. string is its default value. If it is resource, it means it will locate to file path.
@@ -158,6 +158,8 @@ The extension class must implement interface org.eclipse.birt.report.data.oda.jd
+
+
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/Connection.java b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/Connection.java
index 790bb934598..8698abf245e 100644
--- a/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/Connection.java
+++ b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/Connection.java
@@ -28,6 +28,7 @@
import org.eclipse.birt.report.data.oda.i18n.ResourceConstants;
import org.eclipse.birt.report.data.oda.jdbc.bidi.BidiCallStatement;
import org.eclipse.birt.report.data.oda.jdbc.bidi.BidiStatement;
+import org.eclipse.birt.report.data.oda.jdbc.utils.ResourceLocator;
import org.eclipse.datatools.connectivity.oda.IConnection;
import org.eclipse.datatools.connectivity.oda.IDataSetMetaData;
import org.eclipse.datatools.connectivity.oda.IQuery;
@@ -210,6 +211,7 @@ protected void connectByUrl( String url, Properties connProperties )
String driverClass = connProperties.getProperty( Constants.ODADriverClass );
String jndiNameUrl = connProperties.getProperty( Constants.ODAJndiName );
+ ResourceLocator.resolveConnectionProperties( props, driverClass, this.appContext );
try
{
if ( ( jndiNameUrl == null || jndiNameUrl.trim( ).length( ) == 0 )
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/DriverInfoConstants.java b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/DriverInfoConstants.java
new file mode 100644
index 00000000000..943bad97289
--- /dev/null
+++ b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/DriverInfoConstants.java
@@ -0,0 +1,21 @@
+package org.eclipse.birt.report.data.oda.jdbc.utils;
+
+
+public class DriverInfoConstants
+{
+ public static final String DRIVER_INFO_PROPERTY_GROUP = "propertyGroup";
+ public static final String DRIVER_INFO_PROPERTY_GROUP_NAME = "displayName";
+ public static final String DRIVER_INFO_PROPERTY_GROUP_DEC = "description";
+ public static final String DRIVER_INFO_PROPERTY_ENCRYPTION_METHOD = "EncryptionMethod";
+
+ public static final String DRIVER_INFO_PROPERTY = "property";
+ public static final String DRIVER_INFO_PROPERTY_NAME = "propertyName";
+ public static final String DRIVER_INFO_PROPERTY_DISPLAYNAME = "displayName";
+ public static final String DRIVER_INFO_PROPERTY_DEC = "description";
+ public static final String DRIVER_INFO_PROPERTY_ENCRYPT= "encrypt";
+ public static final String DRIVER_INFO_PROPERTY_TYPE= "type";
+ public static final String DRIVER_INFO_PROPERTY_TYPE_BOOLEN= "boolean";
+ public static final String DRIVER_INFO_PROPERTY_TYPE_STRING= "string";
+ public static final String DRIVER_INFO_PROPERTY_TYPE_NUMBER= "number";
+ public static final String DRIVER_INFO_PROPERTY_TYPE_RESOURCE= "resource";
+}
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/JDBCDriverInfoManager.java b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/JDBCDriverInfoManager.java
new file mode 100644
index 00000000000..5d2a711b9ec
--- /dev/null
+++ b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/JDBCDriverInfoManager.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Actuate Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Actuate Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.birt.report.data.oda.jdbc.utils;
+
+import java.util.ArrayList;
+
+import org.eclipse.birt.report.data.oda.jdbc.OdaJdbcDriver;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * The JDBCDriverInfoManager manage the information of jdbc drivers read from the
+ * org.eclipse.birt.report.data.oda.jdbc.driverInfo extensions. The
+ * JDBCDriverInfoManager
instance can be retrieved using the
+ * getInstance()
method.
+ */
+
+public class JDBCDriverInfoManager
+{
+ private JDBCDriverInformation[] jdbcDriverInfo = null;
+ private static JDBCDriverInfoManager instance = null;
+
+ // prevents construction
+ private JDBCDriverInfoManager( )
+ {
+ }
+
+ public synchronized static JDBCDriverInfoManager getInstance( )
+ {
+ if( instance== null )
+ instance = new JDBCDriverInfoManager( );
+ return instance;
+ }
+
+ /**
+ *
+ * @param driverClassName
+ * @return
+ */
+ public JDBCDriverInformation getDriversInfo( String driverClassName )
+ {
+ JDBCDriverInformation[] infos = getDriversInfo( );
+ for( JDBCDriverInformation info: infos )
+ {
+ if( driverClassName.equals( info.getDriverClassName( )) )
+ {
+ return info;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns a list of JDBC drivers discovered in the driverInfo extensions,
+ * as an array of JDBCDriverInformation objects
+ */
+ public JDBCDriverInformation[] getDriversInfo( )
+ {
+ if( jdbcDriverInfo!= null )
+ return jdbcDriverInfo;
+
+ synchronized( this )
+ {
+ if( jdbcDriverInfo!= null )
+ return jdbcDriverInfo;
+
+ IExtensionRegistry extReg = Platform.getExtensionRegistry();
+ IExtensionPoint extPoint =
+ extReg.getExtensionPoint( OdaJdbcDriver.Constants.DRIVER_INFO_EXTENSION );
+
+ if ( extPoint == null )
+ return new JDBCDriverInformation[0];
+
+ IExtension[] exts = extPoint.getExtensions();
+ if ( exts == null )
+ return new JDBCDriverInformation[0];
+
+ ArrayList drivers = new ArrayList( );
+
+ for ( int e = 0; e < exts.length; e++)
+ {
+ IConfigurationElement[] configElems = exts[e].getConfigurationElements();
+ if ( configElems == null )
+ continue;
+
+ for ( int i = 0; i < configElems.length; i++ )
+ {
+ if ( configElems[i].getName().equals(
+ OdaJdbcDriver.Constants.DRIVER_INFO_ELEM_JDBCDRIVER) )
+ {
+ drivers.add( newJdbcDriverInfo( configElems[i] ) );
+ }
+ }
+ }
+
+ jdbcDriverInfo = (JDBCDriverInformation[])drivers.toArray( new JDBCDriverInformation[0]);
+ }
+ return jdbcDriverInfo;
+ }
+
+ /**
+ * Creates a new JDBCDriverInformation instance based on a driverInfo extension element
+ * @param driverClass
+ * @return
+ */
+ private static JDBCDriverInformation newJdbcDriverInfo(
+ IConfigurationElement configElement )
+ {
+ JDBCDriverInformation driverInfo = JDBCDriverInformation.newInstance(
+ configElement.getAttribute( OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_DRIVERCLASS ) );
+ driverInfo.setDisplayName(
+ configElement.getAttribute( OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_NAME ) );
+ driverInfo.setUrlFormat(
+ configElement.getAttribute( OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_URLTEMPL ) );
+ driverInfo.setHide( configElement.getAttribute( OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_HIDE ) );
+ driverInfo.populateProperties( configElement );
+ return driverInfo;
+ }
+
+}
\ No newline at end of file
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/JDBCDriverInformation.java b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/JDBCDriverInformation.java
similarity index 86%
rename from data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/JDBCDriverInformation.java
rename to data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/JDBCDriverInformation.java
index 298fa055111..0b6f98d283b 100644
--- a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/JDBCDriverInformation.java
+++ b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/JDBCDriverInformation.java
@@ -9,7 +9,7 @@
* Actuate Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.birt.report.data.oda.jdbc.ui.util;
+package org.eclipse.birt.report.data.oda.jdbc.utils;
import java.sql.Driver;
import java.util.ArrayList;
@@ -152,7 +152,7 @@ public boolean hasProperty( )
/**
* @param urlFormat The urlFormat to set.
*/
- protected void setUrlFormat(String urlFormat)
+ public void setUrlFormat(String urlFormat)
{
this.urlFormat = urlFormat;
}
@@ -274,16 +274,16 @@ private PropertyElement populateProperty(
IConfigurationElement configElement )
{
PropertyElement element = new PropertyElement( );
- element.setAttribute( Constants.DRIVER_INFO_PROPERTY_NAME,
- configElement.getAttribute( Constants.DRIVER_INFO_PROPERTY_NAME ) );
- element.setAttribute( Constants.DRIVER_INFO_PROPERTY_DISPLAYNAME,
- configElement.getAttribute( Constants.DRIVER_INFO_PROPERTY_DISPLAYNAME ) );
- element.setAttribute( Constants.DRIVER_INFO_PROPERTY_DEC,
- configElement.getAttribute( Constants.DRIVER_INFO_PROPERTY_DEC ) );
- element.setAttribute( Constants.DRIVER_INFO_PROPERTY_ENCRYPT,
- configElement.getAttribute( Constants.DRIVER_INFO_PROPERTY_ENCRYPT ) );
- element.setAttribute( Constants.DRIVER_INFO_PROPERTY_TYPE,
- configElement.getAttribute( Constants.DRIVER_INFO_PROPERTY_TYPE ) );
+ element.setAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_NAME,
+ configElement.getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_NAME ) );
+ element.setAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_DISPLAYNAME,
+ configElement.getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_DISPLAYNAME ) );
+ element.setAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_DEC,
+ configElement.getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_DEC ) );
+ element.setAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_ENCRYPT,
+ configElement.getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_ENCRYPT ) );
+ element.setAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_TYPE,
+ configElement.getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_TYPE ) );
return element;
}
@@ -294,13 +294,13 @@ public List getPropertyGroup( )
public void populateProperties( IConfigurationElement configElement )
{
- IConfigurationElement[] elements = configElement.getChildren( Constants.DRIVER_INFO_PROPERTY_GROUP );
+ IConfigurationElement[] elements = configElement.getChildren( DriverInfoConstants.DRIVER_INFO_PROPERTY_GROUP );
for( IConfigurationElement element:elements )
{
- String name = element.getAttribute( Constants.DRIVER_INFO_PROPERTY_GROUP_NAME );
- String desc = element.getAttribute( Constants.DRIVER_INFO_PROPERTY_GROUP_DEC );
+ String name = element.getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_GROUP_NAME );
+ String desc = element.getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_GROUP_DEC );
PropertyGroup group = new PropertyGroup( name, desc );
- IConfigurationElement[] propertiesConfigurationElements = element.getChildren( Constants.DRIVER_INFO_PROPERTY );
+ IConfigurationElement[] propertiesConfigurationElements = element.getChildren( DriverInfoConstants.DRIVER_INFO_PROPERTY );
List list = new ArrayList( );
for ( IConfigurationElement prElement:propertiesConfigurationElements )
{
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/PropertyElement.java b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/PropertyElement.java
similarity index 90%
rename from data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/PropertyElement.java
rename to data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/PropertyElement.java
index b26548e6680..2340a3049e5 100644
--- a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/PropertyElement.java
+++ b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/PropertyElement.java
@@ -9,7 +9,7 @@
* Actuate Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.birt.report.data.oda.jdbc.ui.util;
+package org.eclipse.birt.report.data.oda.jdbc.utils;
import java.util.Properties;
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/PropertyGroup.java b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/PropertyGroup.java
similarity index 91%
rename from data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/PropertyGroup.java
rename to data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/PropertyGroup.java
index a390ad73401..c6fbff1a07f 100644
--- a/data/org.eclipse.birt.report.data.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/util/PropertyGroup.java
+++ b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/PropertyGroup.java
@@ -9,7 +9,7 @@
* Actuate Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.birt.report.data.oda.jdbc.ui.util;
+package org.eclipse.birt.report.data.oda.jdbc.utils;
import java.util.List;
diff --git a/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/ResourceLocator.java b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/ResourceLocator.java
new file mode 100644
index 00000000000..f2098b635ce
--- /dev/null
+++ b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/utils/ResourceLocator.java
@@ -0,0 +1,252 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Actuate Corporation. All rights reserved. This program and
+ * the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Actuate Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.birt.report.data.oda.jdbc.utils;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.datatools.connectivity.oda.OdaException;
+import org.eclipse.datatools.connectivity.oda.util.ResourceIdentifiers;
+import org.eclipse.datatools.connectivity.oda.util.ResourceIdentifiers.URILocator;
+
+
+public final class ResourceLocator
+{
+
+ private static Logger logger = Logger.getLogger( ResourceLocator.class.getName( ) );
+
+
+ public static void resolveConnectionProperties(
+ Properties connectionProperties, String driverClass, Map appContext )
+ throws OdaException
+ {
+ JDBCDriverInformation info = JDBCDriverInfoManager.getInstance( )
+ .getDriversInfo( driverClass );
+
+ if ( info != null )
+ {
+ List group = info.getPropertyGroup( );
+ for ( int i = 0; i < group.size( ); i++ )
+ {
+ List elements = group.get( i ).getProperties( );
+
+ for ( int j = 0; j < elements.size( ); j++ )
+ {
+ String propertyName = elements.get( j )
+ .getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_NAME );
+
+ if ( connectionProperties.containsKey( propertyName ) )
+ {
+ String type = elements.get( j )
+ .getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_TYPE );
+ if ( DriverInfoConstants.DRIVER_INFO_PROPERTY_TYPE_RESOURCE.equals( type ) )
+ {
+ String path = ResourceLocator.resolveResource( connectionProperties.getProperty( propertyName ),
+ appContext );
+ connectionProperties.setProperty( propertyName,
+ path );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static String resolveResource( String location, Map appContext ) throws OdaException
+ {
+ String absolutePath = null;
+ if ( location != null )
+ {
+ File docFile = null;
+ if ( appContext == null )
+ {
+ logger.warning( "No ResourceIdentifiers instance is provided from appContext" ); //$NON-NLS-1$
+ absolutePath = location;
+ }
+ else if ( ( new File( location ) ).isAbsolute( ) )
+ absolutePath = location;
+ else
+ {
+ Object obj = appContext.get( ResourceIdentifiers.ODA_APP_CONTEXT_KEY_CONSUMER_RESOURCE_IDS );
+ if ( obj != null )
+ {
+ try
+ {
+ absolutePath = getResourcePath( obj,
+ new URI( encode( location ) ) );
+ }
+ catch ( URISyntaxException e )
+ {
+ logger.log( Level.WARNING, "Failed to resolve path", e ); //$NON-NLS-1$
+ absolutePath = location;
+ }
+ }
+ else
+ {
+ logger.warning( "No ResourceIdentifiers instance is provided from appContext" ); //$NON-NLS-1$
+ absolutePath = location;
+ }
+ }
+
+ if ( absolutePath == null )
+ {
+ logger.logp( java.util.logging.Level.SEVERE,
+ location,
+ "open",
+ "cannot find file under location " + location );
+ throw new OdaException( "cannot find file " + location );
+ }
+
+ docFile = new File( absolutePath );
+ if ( docFile == null || !docFile.exists( ) )
+ {
+ throw new OdaException( "cannot find file under location "
+ + absolutePath );
+ }
+ }
+ return absolutePath;
+ }
+
+ /**
+ * Acquire the resource path.
+ * @param resourceIdentifiersObj
+ * @return
+ * @throws OdaException
+ */
+ private static String getResourcePath( Object resourceIdentifiersObj, URI path ) throws OdaException
+ {
+ if( resourceIdentifiersObj == null )
+ return null;
+
+ if ( resourceIdentifiersObj instanceof ResourceIdentifiers )
+ {
+ URILocator appLocator = ( (ResourceIdentifiers) resourceIdentifiersObj ).getApplResourceURILocator( );
+ URILocator designLocator = ( (ResourceIdentifiers) resourceIdentifiersObj ).getDesignResourceURILocator( );
+ if ( appLocator == null && designLocator == null )
+ {
+ throw new OdaException( "cannot find resource identifier" );
+ }
+ URI target = null;
+ if ( appLocator != null )
+ {
+ target = appLocator.resolve( path );
+ }
+ if ( target == null )
+ {
+ target = designLocator.resolve( path );
+ }
+ if ( target == null )
+ {
+ return null;
+ }
+ else
+ {
+ return target.getPath( );
+ }
+ }
+ else // probably different class loader was used; use reflective API instead
+ {
+ Method resolveAppResourceMethod = findMethod( resourceIdentifiersObj, "resolveApplResource", new Class[]{URI.class} ); //$NON-NLS-1$
+ Method resolveDesignResourceMethod = findMethod( resourceIdentifiersObj, "resolveDesignResource", new Class[]{URI.class} ); //$NON-NLS-1$
+
+ Object result = null;
+ if ( resolveAppResourceMethod != null )
+ {
+ result = invokeMethod( resourceIdentifiersObj, resolveAppResourceMethod, new Object[]{path});
+ }
+ if ( result == null || !(result instanceof URI) )
+ {
+ result = invokeMethod( resourceIdentifiersObj, resolveDesignResourceMethod, new Object[]{path});
+ }
+ if ( result instanceof URI )
+ {
+ return ((URI) result).getPath( );
+ }
+ return null;
+ }
+ }
+
+ private static Object invokeMethod( Object anObj, Method objMethod, Object[] arg )
+ {
+ Object returnValue = null;
+ try
+ {
+ returnValue = objMethod.invoke( anObj, arg );
+ }
+ catch( IllegalArgumentException ex )
+ {
+ // TODO - log warning
+ }
+ catch( IllegalAccessException ex )
+ {
+ // TODO - log warning
+ }
+ catch( InvocationTargetException ex )
+ {
+ // TODO - log warning
+ }
+ return returnValue;
+ }
+
+ private static Method findMethod( Object anObj, String methodName, Class[] argument )
+ {
+ Class clazz = anObj.getClass();
+ Method theMethod = null;
+ try
+ {
+ theMethod = clazz.getDeclaredMethod( methodName, argument );
+ }
+ catch( SecurityException ex )
+ {
+ // TODO - log warning
+ }
+ catch( NoSuchMethodException ex )
+ {
+ // TODO - log warning
+ }
+
+ return theMethod;
+ }
+
+ /**
+ *
+ * @param location
+ * @return
+ */
+ private static String encode( String location )
+ {
+ try
+ {
+ if ( File.separatorChar != '/' )
+ location = location.replace( File.separatorChar, '/' );
+ if( location.startsWith( "/" ) )
+ {
+ return new File( location ).toURI( )
+ .toASCIIString( )
+ .replace( new File( "/" ).toURI( ).toASCIIString( ), "/" );
+ }
+ else
+ return new File( location ).toURI( )
+ .toASCIIString( )
+ .replace( new File( "" ).toURI( ).toASCIIString( ), "" );
+ }
+ catch ( Exception e )
+ {
+ return location;
+ }
+ }
+}