Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Description

Accessing attributes

...

  1. SessionContext is an entrypoint for accessing the attributes.
  2. SessionContext can be further extended to retrieve other non-tabular information, such as SecuritySubject, Transaction, ServiceCallContext, etc.
  3. Access requires static methods, because objects injection isn't possible for user functions (QuerySqlFunction are static, CacheInterceptor is a singleton for cache).


Code Block
languagejava
/** SessionContext interface. It's an entrypoint for all non-tabular information. */
public class SessionContext {
    /** @return Client attributes set for current thread. */
    public static @Nullable Map<String, String> getClientAttributes();
 }
 
/** Example, use it in QuerySqlFunction. */
public static class UserDefinedFunctions {
    /** @return Session ID, client attribute. */
    @QuerySqlFunction
    public static String sessionId() {
        Map<String, String> clnAttrs = SessionContext.getClientAttributes();
 
        return clnAttrs == null ? null : clnInfo.getProperty(SESSION_ID);
    }
}

...

Setting attributes

Ignite 

...