org.jboss.errai.bus.client.api.QueueSession.getAttribute()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(67)

本文整理了Java中org.jboss.errai.bus.client.api.QueueSession.getAttribute方法的一些代码示例,展示了QueueSession.getAttribute的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueueSession.getAttribute方法的具体详情如下:
包路径:org.jboss.errai.bus.client.api.QueueSession
类名称:QueueSession
方法名:getAttribute

QueueSession.getAttribute介绍

[英]Returns the value associated with the given key.

See the class-level documentation for a note on the scope of these attributes.
[中]返回与给定键关联的值。
有关这些属性范围的说明,请参见类级文档。

代码示例

代码示例来源:origin: org.jboss.errai/errai-bus

/**
 * @return the HTTP session object associated with this {@link Thread}
 */
public static HttpSession getHttpSession() {
 final QueueSession qs = getQueueSession();
 if (qs == null) {
  return null;
 }
 
 return qs.getAttribute(HttpSession.class, HttpSession.class.getName());
}

代码示例来源:origin: org.jboss.errai/errai-bus

@SuppressWarnings({"unchecked", "SynchronizationOnLocalVariableOrMethodParameter"})
public static String getNewOneTimeToken(final QueueSession session) {
 synchronized (session) {
  List tokenStore = session.getAttribute(List.class, TOKEN_STORE);
  if (tokenStore == null) {
   session.setAttribute(TOKEN_STORE, tokenStore = new ArrayList());
  }
  if (tokenStore.size() == 6) {
   log.warn("Client with session " + session  +
       " has too many active tokens. Removing oldest one and deactivating channel.");
   tokenStore.remove(0);
  }
  final String oneTimeToken = SecureHashUtil.nextSecureHash("SHA-256");
  tokenStore.add(oneTimeToken);
  return oneTimeToken;
 }
}

代码示例来源:origin: org.jboss.errai/errai-bus

@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
 public static boolean verifyOneTimeToken(final QueueSession session, final String token) {
  synchronized (session) {
   final boolean tokenRemoved;
   if (session.hasAttribute(TOKEN_STORE)) {
    final List tokenStore = session.getAttribute(List.class, TOKEN_STORE);
    tokenRemoved = tokenStore.remove(token);
    if (tokenStore.isEmpty()) {
     session.removeAttribute(TOKEN_STORE);
    }
   }
   else {
    tokenRemoved = false;
   }
   return tokenRemoved;
  }
 }
}

代码示例来源:origin: org.jboss.errai/errai-bus

private SubContext getLocalContext() {
 synchronized (this) {
  SubContext ctx = session.getAttribute(SubContext.class, context);
  if (ctx == null) {
   session.setAttribute(context, ctx = new SubContext());
  }
  return ctx;
 }
}

代码示例来源:origin: errai/errai

/**
 * @return the HTTP session object associated with this {@link Thread}
 */
public static HttpSession getHttpSession() {
 final QueueSession qs = getQueueSession();
 if (qs == null) {
  return null;
 }
 
 return qs.getAttribute(HttpSession.class, HttpSession.class.getName());
}

代码示例来源:origin: errai/errai

@SuppressWarnings({"unchecked", "SynchronizationOnLocalVariableOrMethodParameter"})
public static String getNewOneTimeToken(final QueueSession session) {
 synchronized (session) {
  List tokenStore = session.getAttribute(List.class, TOKEN_STORE);
  if (tokenStore == null) {
   session.setAttribute(TOKEN_STORE, tokenStore = new ArrayList());
  }
  if (tokenStore.size() == 6) {
   log.warn("Client with session " + session  +
       " has too many active tokens. Removing oldest one and deactivating channel.");
   tokenStore.remove(0);
  }
  final String oneTimeToken = SecureHashUtil.nextSecureHash("SHA-256");
  tokenStore.add(oneTimeToken);
  return oneTimeToken;
 }
}

代码示例来源:origin: errai/errai

private SubContext getLocalContext() {
 synchronized (this) {
  SubContext ctx = session.getAttribute(SubContext.class, context);
  if (ctx == null) {
   session.setAttribute(context, ctx = new SubContext());
  }
  return ctx;
 }
}

代码示例来源:origin: errai/errai

@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
 public static boolean verifyOneTimeToken(final QueueSession session, final String token) {
  synchronized (session) {
   final boolean tokenRemoved;
   if (session.hasAttribute(TOKEN_STORE)) {
    final List tokenStore = session.getAttribute(List.class, TOKEN_STORE);
    tokenRemoved = tokenStore.remove(token);
    if (tokenStore.isEmpty()) {
     session.removeAttribute(TOKEN_STORE);
    }
   }
   else {
    tokenRemoved = false;
   }
   return tokenRemoved;
  }
 }
}

代码示例来源:origin: org.jboss.errai/errai-weld-integration

private void updateLaundry(final QueueSession queueSession) {
  Boolean routesActive = queueSession.getAttribute(Boolean.class, CDI_EVENT_ROUTES_ACTIVE);
  if (routesActive == null) {
   synchronized (queueSession) {
    routesActive = queueSession.getAttribute(Boolean.class, CDI_EVENT_ROUTES_ACTIVE);
    if (routesActive == null) {
     final LaundryList laundryList = LaundryListProviderFactory.get().getLaundryList(queueSession);
     laundryList.add(new Laundry() {
      @Override
      public void clean() throws Exception {
       removeAllForId(queueSession.getSessionId());
      }
     });
    }
   }
  }
 }
}

代码示例来源:origin: kiegroup/appformer

@Before
public void setup() {
  setupRpcContext();
  User testUser = new UserImpl("testUser");
  when(sessionInfo.getIdentity()).thenReturn(testUser);
  when(queueSession.getAttribute(HttpSession.class,
                  HttpSession.class.getName())).thenReturn(httpSession);
}

代码示例来源:origin: org.uberfire/uberfire-backend-server

@Before
public void setup() {
  setupRpcContext();
  User testUser = new UserImpl("testUser");
  when(sessionInfo.getIdentity()).thenReturn(testUser);
  when(queueSession.getAttribute(HttpSession.class,
                  HttpSession.class.getName())).thenReturn(httpSession);
}

相关文章

微信公众号

最新文章

更多