Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jet.server.api.dynamiccon
Interface DynamicConnectionProvider

    public interface DynamicConnectionProvider

The DynamicConnection provider.

The JReport server provide the default implementation of this API to get dynamic connection from the server system database (see `DynamicConnectionManager` ).

When run a report

1. The server get used data sources in the report at first.
2. For Advanced Run & Schedule Run, Then get available dynamic connections for the log-in user, catalog and data sources by call `#getAvailableDynamicConnections(String, String, String, DynamicConnection)` of DynamicConnectionProvider
3. Then get the dynamic connection selected by the end-user or one default by call `#getDynamicConnection(String, String, String, DynamicConnection, String)`
4. Then pass the dynamic connection into the report engine. The report engine will merge the dynamic connection information with the original catalog connection to setup the database connection

In the default implementation, One user can have multiple dynamic connections for one catalog data source (distinguish by the dynamicConnectionId).

Users also can implement this API to get dynamic connections from their own system. Server will call this API when run a report. Users can register a customized DynamicConnectionProvider into JReport Server by the option "server.custom.DynamicConnectionProvider" in the file report_home/bin/server.properties.

Method Summary
`DynamicConnection[]` | `getAvailableDynamicConnections(java.lang.String clientId, java.lang.String userName, java.lang.String catalog, java.lang.String datasource, DynamicConnection originalConnectionInfo)` Gets the available connections information against the original catalog connection information.
`DynamicConnection[]` | `getAvailableDynamicConnections(java.lang.String clientId, java.lang.String userName, java.lang.String catalog, java.lang.String datasource, java.lang.String connectionName, DynamicConnection originalConnectionInfo)`
`DynamicConnection` | `getDynamicConnection(java.lang.String clientId, java.lang.String userName, java.lang.String catalog, java.lang.String datasource, DynamicConnection originalConnectionInfo, java.lang.String dynamicConnectionId)` Gets the dynamic connection against the original catalog connection information.
`DynamicConnection` | `getDynamicConnection(java.lang.String clientId, java.lang.String userName, java.lang.String catalog, java.lang.String datasource, java.lang.String connectionName, DynamicConnection originalConnectionInfo, java.lang.String dynamicConnectionId)`

Method Detail

### getAvailableDynamicConnections

    DynamicConnection[] getAvailableDynamicConnections(java.lang.String clientId,
                                                       java.lang.String userName,
                                                       java.lang.String catalog,
                                                       java.lang.String datasource,
                                                       DynamicConnection originalConnectionInfo)

  Gets the available connections information against the original catalog connection information.

  This method support multiple dynamic connections. One user can have multiple dynamic connections for one catalog data source (distinguish by dynamicConnectionId).

  The server will call this method when show Advanced Run and Schedule Run page, to let the end-user select one from available dynamic connections.

  In the default implementation, the server get dynamic connections by below logic:

  1. Filter dynamic connections by used data sources of the catalog of the report.
  2. Filter dynamic connections by the username. If have, return them as available dynamic connections. If no, filter by groups.
  3. Filter dynamic connections by groups that the username belong to. If have, return them as available dynamic connections. If no, filter by roles.
  4. Filter dynamic connections by roles that the username belong to. If have, return them as available dynamic connections. If no, return null.
  5. If there is available dynamic connection, then select one from available dynamic connections. If no, use the original catalog connection information to setup the database connection.

  Parameters:
    `clientId` - the multiple tenancy client ID
    `userName` - the server logon username.
    `catalog` - the catalog resource path. For example, "/WebDemo/SampleReports.cat".
    `datasource` - the data source name in the catalog.
    `originalConnectionInfo` - the original catalog connection information
  Returns:
    the array of available dynamic connections.

### getAvailableDynamicConnections

    DynamicConnection[] getAvailableDynamicConnections(java.lang.String clientId,
                                                       java.lang.String userName,
                                                       java.lang.String catalog,
                                                       java.lang.String datasource,
                                                       java.lang.String connectionName,
                                                       DynamicConnection originalConnectionInfo)

### getDynamicConnection

    DynamicConnection getDynamicConnection(java.lang.String clientId,
                                           java.lang.String userName,
                                           java.lang.String catalog,
                                           java.lang.String datasource,
                                           DynamicConnection originalConnectionInfo,
                                           java.lang.String dynamicConnectionId)

  Gets the dynamic connection against the original catalog connection information.

  When run a report, the server will pass the dynamic connection information into the report engine. The report engine will merge the connection information with the original catalog connection information to setup the database connection.

  The server will call this method when run report (Direct Run, or Advanced Run & Schedule Run submit back). This method return the dynamic connection for the specified identifier or choose a dynamic connection from available connections (if without specified `dynamicConnectionId`).``

  In the default implementation, the server get dynamic connection by below logic:

  1. Filter dynamic connections by used data sources of the catalog of the report.
  2. If has dynamicConnectionId specified, use the dynamic connection specified by the identifier if exists in the previous step result.
  3. Otherwise, use the first dynamic connection from available connections (`#getAvailableDynamicConnections(String, String, String, DynamicConnection)`) .

  Parameters:
    `clientId` - the multiple tenancy client ID
    `userName` - the server logon username.
    `catalog` - the catalog resource path. For example, "/WebDemo/SampleReports.cat".
    `datasource` - the data source name in the catalog.
    `originalConnectionInfo` - the original catalog connection information.
    `dynamicConnectionId` - the user specified identifier of dynamic connection, `null` to get default dynamic connection, recommend the fist one of available connections.
  Returns:
    the dynamic connection, `null` use original connection.

### getDynamicConnection

    DynamicConnection getDynamicConnection(java.lang.String clientId,
                                           java.lang.String userName,
                                           java.lang.String catalog,
                                           java.lang.String datasource,
                                           java.lang.String connectionName,
                                           DynamicConnection originalConnectionInfo,
                                           java.lang.String dynamicConnectionId)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD