/** Create an instance of the {@link APIConfiguration} object to setup the framework etc.. */ private APIConfigurationImpl createDefaultAPIConfiguration(LocalConnectorInfoImpl localInfo) { // setup classloader since we are going to construct the config bean ThreadClassLoaderManager.getInstance() .pushClassLoader(localInfo.getConnectorClass().getClassLoader()); try { Class<? extends Connector> connectorClass = localInfo.getConnectorClass(); APIConfigurationImpl rv = new APIConfigurationImpl(); Configuration config = localInfo.getConnectorConfigurationClass().newInstance(); boolean pooling = PoolableConnector.class.isAssignableFrom(connectorClass); rv.setConnectorPoolingSupported(pooling); rv.setConfigurationProperties(JavaClassProperties.createConfigurationProperties(config)); rv.setConnectorInfo(localInfo); rv.setSupportedOperations(FrameworkUtil.getDefaultSupportedOperations(connectorClass)); return rv; } catch (Exception e) { throw ConnectorException.wrap(e); } finally { ThreadClassLoaderManager.getInstance().popClassLoader(); } }
@Override public ConnectorFacade newInstance(APIConfiguration config) { ConnectorFacade ret = null; APIConfigurationImpl impl = (APIConfigurationImpl) config; AbstractConnectorInfo connectorInfo = impl.getConnectorInfo(); if (connectorInfo instanceof LocalConnectorInfoImpl) { LocalConnectorInfoImpl localInfo = (LocalConnectorInfoImpl) connectorInfo; try { // create a new Provisioner.. ret = new LocalConnectorFacadeImpl(localInfo, impl); } catch (Exception ex) { String connector = impl.getConnectorInfo().getConnectorKey().toString(); logger.error( "Failed to create new connector facade: {}, {}", new Object[] {connector, config}, ex); throw ConnectorException.wrap(ex); } } else { throw new ConnectorException("RemoteConnector not supported!"); } return ret; }