Ejemplo n.º 1
0
    public Element reportDtElem() {
      StringBuffer sb = new StringBuffer(255);
      sb.append(shortTypeName);
      sb.append(" [ dataSourceName: ");
      sb.append(pds.getDataSourceName());
      sb.append("; identityToken: ");
      sb.append(pds.getIdentityToken());
      sb.append(" ]");

      Element dtElem = doc.createElement("dt");
      dtElem.appendChild(doc.createTextNode(sb.toString()));
      return dtElem;
    }
  static String getPdsObjectNameStr(PooledDataSource pds) {
    String dataSourceName = pds.getDataSourceName();

    // if we are excluding the identity token attribute, then we always need a valid name attribute.
    // hopefully users who set EXCLUDE_IDENTITY_TOKEN will update dataSourceName to a reasonable
    // value.
    // in the meantime, we use the identity token value for the name.
    //
    // but note that at present, pds.getDataSourceName() returns the identity token when
    // dataSourceName
    // is unset or set to null. So, this predicate is unlikely ever to be true.
    if (dataSourceName == null && EXCLUDE_IDENTITY_TOKEN) dataSourceName = pds.getIdentityToken();

    // when EXCLUDE_IDENTITY_TOKEN is false, in practice we nearly always generate a 3-attribute
    // name (type, identityToken, name), because even when dataSourceName is not set or set to null,
    // getDataSourceName() returns the identity token rather than null.
    //
    // when EXCLUDE_IDENTITY_TOKEN is true, we reliably generate a two-attribute name.
    StringBuilder sb = new StringBuilder(256);
    sb.append("com.mchange.v2.c3p0:type=PooledDataSource");
    if (!EXCLUDE_IDENTITY_TOKEN) {
      sb.append(",identityToken=");
      sb.append(pds.getIdentityToken());
    }
    if (dataSourceName != null) {
      sb.append(",name=");
      sb.append(dataSourceName);
    }
    return sb.toString();

    // String out = "com.mchange.v2.c3p0:type=PooledDataSource,identityToken=" +
    // pds.getIdentityToken();
    // if ( dataSourceName != null )
    //     out += ",name=" + dataSourceName;
    // return out;
  }
Ejemplo n.º 3
0
 private String getPdsObjectNameStr(PooledDataSource pds) {
   return "com.mchange.v2.c3p0:type=PooledDataSource[" + pds.getIdentityToken() + "]";
 }