Class BuiltinRPC

java.lang.Object
com.isomorphic.base.Base
com.isomorphic.rpc.BuiltinRPC
com.isomorphic.tools.BuiltinRPC
All Implemented Interfaces:
com.isomorphic.base.IAutoConfigurable

public class BuiltinRPC extends BuiltinRPC
This class implements an extra set of "built-in" RPC methods over and above the ones implemented in com.isomorphic.rpc.BuiltinRPC. Those are available to all applications as part of all SmartClient distributions. The methods in this class are only available to owners of the Pro or Enterprise versions of SmartClient. Most of these methods should not be callable from the client in a production setting. By default, all of these are enabled in the smartclientSDK and only the methods flagged as enabled in smartclientRuntime are enabled there by default.

You can control which methods are enabled by listing the enabled methods under the server.properties attribute RPCManager.enabledBuiltinMethods.

  • Method Details

    • getDataSourceFromTable

      public static DataSource getDataSourceFromTable(String tableName, String serverType, String dbName, String ID, Map properties) throws Exception
      Returns a DataSource derived from the table provided. If the serverType is "sql", dbName specifies which database configuration to use, with null meaning the default database configuration. If serverType is "hibernate", database information comes from Hibernate instead.
      Parameters:
      tableName - The name of the table.
      serverType - "sql" or "hibernate"
      dbName - Optionally, the name of the database - if null, uses the default
      ID - Optionally, the ID of the DataSource - if null, uses the tableName
      properties - An optional Map of properties to apply to the derived DataSource
      Returns:
      DataSource derived from the table
      Throws:
      Exception
    • getDataSourceJSONFromTable

      public static String getDataSourceJSONFromTable(String tableName, String serverType, String dbName, String ID, Map properties) throws Exception
      Returns the JSON representation of a DataSource derived from the table provided.
      Parameters:
      tableName - The name of the table.
      serverType - "sql" or "hibernate"
      dbName - Optionally, the name of the database - if null, uses the default
      ID - Optionally, the ID of the DataSource - if null, uses the tableName
      properties - An optional Map of properties to apply to the derived DataSource
      Returns:
      The JSON representation of the DataSource derived from the table
      Throws:
      Exception
    • getDataSourceFromHibernateMapping

      public static DataSource getDataSourceFromHibernateMapping(String entityName, String ID) throws Exception
      Returns a DataSource derived from the Hibernate entity provided.
      Parameters:
      entityName - The name of the Hibernate mapped entity.
      Returns:
      DataSource derived from the mapped entity
      Throws:
      Exception
    • getDataSourceJSONFromHibernateMapping

      public static String getDataSourceJSONFromHibernateMapping(String entityName, String ID) throws Exception
      Returns the JSON representation of a DataSource derived from the entity provided.
      Parameters:
      entityName - The name of the Hibernate mapped entity.
      Returns:
      The JSON representation of the DataSource derived from the mapped entity
      Throws:
      Exception
    • getTables

      public static List getTables(String serverType, String dbName, boolean includeTables, boolean includeViews, String catalog, String schema, List include, List exclude) throws Exception
      Returns a list of table and/or view names
      Parameters:
      serverType - "sql" or "hibernate", determines the database connection strategy
      dbName - Optionally, the name of the database - if null, uses the default
      includeTables - If true, includes tables in the returned list
      includeViews - If true, includes views in the returned list
      catalog - Optionally, the catalog name to use to restrict the list. If null, searches all catalogs.
      schema - Optionally, the schema name to use to restrict the list. If null, searches all schemata.
      include - Optionally, a list of partial table names to perform substring checking against. Tables will be included where the table name matches any of the supplied substrings. The matching is not case sensitive.
      exclude - Optionally, a list of partial table names to perform substring checking against. Tables will be excluded where the table name matches any of the supplied substrings. The matching is not case sensitive. Note that if you specify both include and exclude criteria and they conflict (ie, according to the criteria you set, a table should be both included and excluded), exclude wins.
      Returns:
      List of table names and remarks
      Throws:
      Exception
    • getFieldsFromTable

      public static List getFieldsFromTable(String tableName, String schema, String serverType, String dbName) throws Exception
      Returns a list of fields in the passed in table, with properties such as type and length inferred from the database metadata.
      Parameters:
      tableName - The name of the table.
      schema - Optionally, the name of the database schema to use (not all databases require - or even recognize the concept of - a schema)
      serverType - "sql" or "hibernate", determines the database connection strategy
      dbName - Optionally, the name of the database if serverType is "sql". If null, uses the default
      Returns:
      List of fields in the supplied table
      Throws:
      Exception
    • getBeanFields

      public static List getBeanFields(String className) throws Exception
      Returns a list of fields derived from the properties of the passed-in JavaBean.
      Parameters:
      className - The fully-qualified classname of the JavaBean
      Returns:
      List of fields derived from the properties of the supplied JavaBean class
      Throws:
      Exception
    • getHibernateBeans

      public static List getHibernateBeans(List include, List exclude, boolean excludeNullMappings) throws Exception
      Returns a list of classes currently mapped in Hibernate. Each list item contains an entity name and a fully-qualified classname. It is possible for the classname to be null, for example, if you are using SmartClient "hibernate" DataSources to create Hibernate mappings from arbitrary Map objects on the fly. If the excludeNullMappings parameter is true, these mappings to null classnames will be excluded from the returned list.
      Parameters:
      include - Optionally, a list of partial entity names to perform substring checking against. Entities will be included where the entity name matches any of the supplied substrings. The matching is not case sensitive.
      exclude - Optionally, a list of partial entity names to perform substring checking against. Entities will be excluded where the table name matches any of the supplied substrings. The matching is not case sensitive. Note that if you specify both include and exclude criteria and they conflict (ie, according to the criteria you set, an entity should be both included and excluded), exclude wins.
      excludeNullMappings - Excludes mappings with a null classname from the list
      Returns:
      List of Maps, each containing an entityName and a className
      Throws:
      Exception
    • getDatabaseProductNameAndVersion

      public static Map getDatabaseProductNameAndVersion(String serverType, String dbName) throws Exception
      Returns the product name and version of the database connected via Hibernate or the supplied dbName configuration (the default configuration if not supplied), depending on value of serverType
      Parameters:
      serverType - "sql" or "hibernate", determines the database connection strategy
      dbName - Optional name of the configuration to use, if serverType is "sql"
      Returns:
      String containing the database product name and version
      Throws:
      Exception
    • setAttributes

      public static void setAttributes(String scope, Object attributes, String prefix, jakarta.servlet.http.HttpServletRequest req) throws Exception
      Stores the supplied attributes on the server, in either request or session scope. This method allows you to explicitly add state to your server-side.

      This method is used by the batchUploader to store uploadFormFields.

      Parameters:
      scope - Either "request" or "session", indicates where SmartClient should store the passed attributes
      attributes - A Map or List of Maps specifying the attributes. Each map should contain at least a name entry and a value entry. If you also supply a type, SmartClient will make a better attempt at storing your attributes as appropriate types (Integer, Boolean etc, rather than String)
      prefix - String to prepend to field names before they are stored in the request or session. This provides a basic namespace facility, allowing you to avoid name collisions with existing session attributes.

      Example usage: if you pass an attribute called "someDate" and a prefix of "myFields_", your attribute will be available as "myFields_someDate"

      Throws:
      Exception
    • clearAttributes

      public void clearAttributes(jakarta.servlet.http.HttpSession session) throws Exception
      Clears any attributes previously stored by the setAttributes method. Only applicable to parameters in session scope.
      Throws:
      Exception
    • getDataSourceConfigFromJavaClass

      public static RPCResponse getDataSourceConfigFromJavaClass(String className) throws Exception
      Returns a DataSource config Map for the Java class provided.
      Parameters:
      className - The name of the Java class.
      Returns:
      The DataSource config Map for the passed className, or null
      Throws:
      Exception