コード例 #1
0
 public static <T> T getInstance(
     Class<T> expectedType,
     String className,
     Collection<?> ctorObjs,
     Class<? extends T> defaultClass)
     throws TranslatorException {
   try {
     if (className == null) {
       if (defaultClass == null) {
         throw new TranslatorException(
             DataPlugin.Event.TEIID60004, DataPlugin.Util.gs(DataPlugin.Event.TEIID60004));
       }
       return expectedType.cast(defaultClass.newInstance());
     }
     return expectedType.cast(
         ReflectionHelper.create(
             className, ctorObjs, Thread.currentThread().getContextClassLoader()));
   } catch (TeiidException e) {
     throw new TranslatorException(DataPlugin.Event.TEIID60005, e);
   } catch (IllegalAccessException e) {
     throw new TranslatorException(DataPlugin.Event.TEIID60005, e);
   } catch (InstantiationException e) {
     throw new TranslatorException(DataPlugin.Event.TEIID60005, e);
   }
 }
コード例 #2
0
  /** @param connectionProperties will be updated with additional information before logon */
  public SocketServerConnection getConnection(Properties connectionProperties)
      throws CommunicationException, ConnectionException {

    TeiidURL url;
    try {
      url = new TeiidURL(connectionProperties.getProperty(TeiidURL.CONNECTION.SERVER_URL));
    } catch (MalformedURLException e1) {
      throw new ConnectionException(e1, e1.getMessage());
    }

    String discoveryStrategyName =
        connectionProperties.getProperty(TeiidURL.CONNECTION.DISCOVERY_STRATEGY, URL);

    ServerDiscovery discovery;

    if (URL.equalsIgnoreCase(discoveryStrategyName)) {
      discovery = new UrlServerDiscovery();
    } else {
      try {
        discovery =
            (ServerDiscovery)
                ReflectionHelper.create(
                    discoveryStrategyName, null, this.getClass().getClassLoader());
      } catch (TeiidClientException e) {
        throw new ConnectionException(e);
      }
    }

    discovery.init(url, connectionProperties);

    return new SocketServerConnection(this, url.isUsingSSL(), discovery, connectionProperties);
  }