• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IllegalStateException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.resource.spi.IllegalStateException的典型用法代码示例。如果您正苦于以下问题:Java IllegalStateException类的具体用法?Java IllegalStateException怎么用?Java IllegalStateException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IllegalStateException类属于javax.resource.spi包,在下文中一共展示了IllegalStateException类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: cleanup

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
/**
 * Cleanup
 *
 * @throws ResourceException Thrown if an error occurs
 */
@Override
public void cleanup() throws ResourceException {
   if (logger.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("cleanup()");
   }

   if (isDestroyed.get()) {
      throw new IllegalStateException("ManagedConnection already destroyed");
   }

   destroyHandles();

   inManagedTx = false;

   inManagedTx = false;

   // I'm recreating the lock object when we return to the pool
   // because it looks too nasty to expect the connection handle
   // to unlock properly in certain race conditions
   // where the dissociation of the managed connection is "random".
   lock = new ReentrantLock();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:28,代码来源:ActiveMQRAManagedConnection.java


示例2: checkTransactionActive

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
public void checkTransactionActive() throws JMSException {
   // don't bother looking at the transaction if there's an active XID
   if (!inManagedTx && tm != null) {
      try {
         Transaction tx = tm.getTransaction();
         if (tx != null) {
            int status = tx.getStatus();
            // Only allow states that will actually succeed
            if (status != Status.STATUS_ACTIVE && status != Status.STATUS_PREPARING && status != Status.STATUS_PREPARED && status != Status.STATUS_COMMITTING) {
               throw new javax.jms.IllegalStateException("Transaction " + tx + " not active");
            }
         }
      } catch (SystemException e) {
         JMSException jmsE = new javax.jms.IllegalStateException("Unexpected exception on the Transaction ManagerTransaction");
         jmsE.initCause(e);
         throw jmsE;
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:20,代码来源:ActiveMQRAManagedConnection.java


示例3: configure

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
@Override
public void configure() throws Exception {

    final CountDownLatch startLatch = new CountDownLatch(1);

    // verify that a component can be added manually
    getContext().addComponent("quartz2", new QuartzComponent() {
        @Override
        public void onCamelContextStarted(CamelContext context, boolean alreadyStarted) throws Exception {
            super.onCamelContextStarted(context, alreadyStarted);
            startLatch.countDown();
        }
    });

    from("quartz2://mytimer?trigger.repeatCount=3&trigger.repeatInterval=100")
    .process(new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            if (startLatch.getCount() > 0)
                throw new IllegalStateException("onCamelContextStarted not called");
        }
    })
    .to(MOCK_RESULT_URI);
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:25,代码来源:RouteBuilderF.java


示例4: getConnection

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
/**
 * Get the physical connection handler.
 * This bummer will be called in two situations:
 * <ol>
 * <li>When a new mc has bean created and a connection is needed
 * <li>When an mc has been fetched from the pool (returned in match*)
 * </ol>
 * It may also be called multiple time without a cleanup, to support connection sharing.
 *
 * @param subject
 * @param info
 * @return A new connection object.
 * @throws ResourceException
 */
public Object getConnection(final Subject subject, final ConnectionRequestInfo info) throws ResourceException {
    // Check user first
    JmsCred cred = JmsCred.getJmsCred(mcf, subject, info);

    // Null users are allowed!
    if (user != null && !user.equals(cred.name)) {
        throw new SecurityException
                ("Password credentials not the same, reauthentication not allowed");
    }
    if (cred.name != null && user == null) {
        throw new SecurityException
                ("Password credentials not the same, reauthentication not allowed");
    }

    user = cred.name; // Basically meaningless

    if (isDestroyed) {
        throw new IllegalStateException("ManagedConnection already destroyd");
    }

    // Create a handle
    JmsSession handle = new JmsSession(this, (JmsConnectionRequestInfo) info);
    handles.add(handle);
    return handle;
}
 
开发者ID:vratsel,项目名称:generic-jms-ra,代码行数:40,代码来源:JmsManagedConnection.java


示例5: getConnection

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
/**
 * Get a connection
 *
 * @param subject       The security subject
 * @param cxRequestInfo The request info
 * @return The connection
 * @throws ResourceException Thrown if an error occurs
 */
@Override
public synchronized Object getConnection(final Subject subject,
                                         final ConnectionRequestInfo cxRequestInfo) throws ResourceException {
   if (logger.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("getConnection(" + subject + ", " + cxRequestInfo + ")");
   }

   // Check user first
   ActiveMQRACredential credential = ActiveMQRACredential.getCredential(mcf, subject, cxRequestInfo);

   // Null users are allowed!
   if (userName != null && !userName.equals(credential.getUserName())) {
      throw new SecurityException("Password credentials not the same, reauthentication not allowed");
   }

   if (userName == null && credential.getUserName() != null) {
      throw new SecurityException("Password credentials not the same, reauthentication not allowed");
   }

   if (isDestroyed.get()) {
      throw new IllegalStateException("The managed connection is already destroyed");
   }

   ActiveMQRASession session = new ActiveMQRASession(this, (ActiveMQRAConnectionRequestInfo) cxRequestInfo);
   handles.add(session);
   return session;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:36,代码来源:ActiveMQRAManagedConnection.java


示例6: associateConnection

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
/**
 * Move a handler from one mc to this one.
 *
 * @param obj An object of type ActiveMQSession.
 * @throws ResourceException     Failed to associate connection.
 * @throws IllegalStateException ManagedConnection in an illegal state.
 */
@Override
public void associateConnection(final Object obj) throws ResourceException {
   if (logger.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("associateConnection(" + obj + ")");
   }

   if (!isDestroyed.get() && obj instanceof ActiveMQRASession) {
      ActiveMQRASession h = (ActiveMQRASession) obj;
      h.setManagedConnection(this);
      handles.add(h);
   } else {
      throw new IllegalStateException("ManagedConnection in an illegal state");
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:ActiveMQRAManagedConnection.java


示例7: getMetaData

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
/**
 * Get the meta data for the connection.
 *
 * @return The meta data for the connection.
 * @throws ResourceException     Thrown if the operation fails.
 * @throws IllegalStateException Thrown if the managed connection already is destroyed.
 */
@Override
public ManagedConnectionMetaData getMetaData() throws ResourceException {
   if (logger.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("getMetaData()");
   }

   if (isDestroyed.get()) {
      throw new IllegalStateException("The managed connection is already destroyed");
   }

   return new ActiveMQRAMetaData(this);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:20,代码来源:ActiveMQRAManagedConnection.java


示例8: associateConnection

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
/**
 * Move a handler from one mc to this one.
 *
 * @param obj An object of type JmsSession.
 * @throws ResourceException     Failed to associate connection.
 * @throws IllegalStateException ManagedConnection in an illegal state.
 */
public void associateConnection(final Object obj) throws ResourceException {
    //
    // Should we check auth, ie user and pwd? FIXME
    //

    if (!isDestroyed && obj instanceof JmsSession) {
        JmsSession h = (JmsSession) obj;
        h.setManagedConnection(this);
        handles.add(h);
    } else {
        throw new IllegalStateException
                ("ManagedConnection in an illegal state");
    }
}
 
开发者ID:vratsel,项目名称:generic-jms-ra,代码行数:22,代码来源:JmsManagedConnection.java


示例9: getMetaData

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
/**
 * Get the meta data for the connection.
 *
 * @return The meta data for the connection.
 * @throws ResourceException
 * @throws IllegalStateException ManagedConnection already destroyed.
 */
public ManagedConnectionMetaData getMetaData() throws ResourceException {
    if (isDestroyed) {
        throw new IllegalStateException("ManagedConnection already destroyd");
    }

    return new JmsMetaData(this);
}
 
开发者ID:vratsel,项目名称:generic-jms-ra,代码行数:15,代码来源:JmsManagedConnection.java


示例10: checkSize

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
private void checkSize(int val, String name) throws IllegalStateException {
  if (val <= 0) throw new IllegalStateException(name + " must be > 0");
}
 
开发者ID:mrstampy,项目名称:gameboot,代码行数:4,代码来源:GameBootConcurrentConfiguration.java


示例11: unencrypted

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
private void unencrypted(Session ctx, byte[] msg) throws Exception {
  Response r = getResponse(msg);
  lastResponse = r;

  log.info("Unencrypted: on session {}\n{}", ctx.getId(), mapper.writeValueAsString(r));

  if (!ok(r.getResponseCode())) return;

  if (ResponseCode.INFO == r.getResponseCode()) {
    Object[] payload = r.getPayload();
    if (payload == null || payload.length == 0 || !(payload[0] instanceof Map<?, ?>)) {
      throw new IllegalStateException("Expecting map of systemId:[value]");
    }

    systemId = (Long) ((Map<?, ?>) payload[0]).get("systemId");

    log.info("Setting system id {}", systemId);
    this.session = ctx;
    return;
  }

  JsonNode node = mapper.readTree(msg);
  JsonNode response = node.get("payload");

  boolean hasKey = response != null && response.isArray() && response.size() == 1;

  if (hasKey) {
    log.info("Setting key");
    otpKey = response.get(0).binaryValue();
    return;
  }

  switch (r.getType()) {
  case OtpKeyRequest.TYPE:
    log.info("Deleting key");
    otpKey = null;
    break;
  default:
    break;
  }
}
 
开发者ID:mrstampy,项目名称:gameboot,代码行数:42,代码来源:WebSocketEndpoint.java


示例12: unencrypted

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
private void unencrypted(ChannelHandlerContext ctx, byte[] msg) throws Exception {
  Response r = getResponse(msg);
  lastResponse = r;

  boolean c = ctx.pipeline().get(SslHandler.class) != null;

  log.info("Unencrypted: on {} channel\n{}", (c ? "secured" : "unsecured"), mapper.writeValueAsString(r));

  if (!ok(r.getResponseCode())) return;

  if (ResponseCode.INFO == r.getResponseCode()) {
    Object[] payload = r.getPayload();
    if (payload == null || payload.length == 0 || !(payload[0] instanceof Map<?, ?>)) {
      throw new IllegalStateException("Expecting map of systemId:[value]");
    }

    systemId = (Long) ((Map<?, ?>) payload[0]).get("systemId");

    log.info("Setting system id {}", systemId);
    clearChannel = ctx.channel();
    return;
  }

  JsonNode node = mapper.readTree(msg);
  JsonNode response = node.get("payload");

  boolean hasKey = response != null && response.isArray() && response.size() == 1;

  if (hasKey) {
    log.info("Setting key");
    otpKey = response.get(0).binaryValue();
    return;
  }

  switch (r.getType()) {
  case OtpKeyRequest.TYPE:
    log.info("Deleting key");
    otpKey = null;
    break;
  default:
    break;
  }
}
 
开发者ID:mrstampy,项目名称:gameboot,代码行数:44,代码来源:ClientHandler.java


示例13: aroundInvoke

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
@AroundInvoke
public Object aroundInvoke(final InvocationContext invocationContext) throws Exception {
    Principal desiredUser = null;
    RealmUser connectionUser = null;

    Map<String, Object> contextData = invocationContext.getContextData();
    if (contextData.containsKey(DELEGATED_USER_KEY)) {
        desiredUser = new SimplePrincipal((String) contextData.get(DELEGATED_USER_KEY));

        Connection con = SecurityActions.remotingContextGetConnection();

        if (con != null) {
            UserInfo userInfo = con.getUserInfo();
            if (userInfo instanceof SubjectUserInfo) {
                SubjectUserInfo sinfo = (SubjectUserInfo) userInfo;
                for (Principal current : sinfo.getPrincipals()) {
                    if (current instanceof RealmUser) {
                        connectionUser = (RealmUser) current;
                        break;
                    }
                }
            }

        } else {
            throw new IllegalStateException("Delegation user requested but no user on connection found.");
        }
    }

    SecurityContext cachedSecurityContext = null;
    boolean contextSet = false;
    try {
        if (desiredUser != null && connectionUser != null
                && (desiredUser.getName().equals(connectionUser.getName()) == false)) {
            // The final part of this check is to verify that the change does actually indicate a change in user.
            try {
                // We have been requested to switch user and have successfully identified the user from the connection
                // so now we attempt the switch.
                cachedSecurityContext = SecurityActions.securityContextSetPrincipalInfo(desiredUser,
                        new OuterUserCredential(connectionUser));
                // keep track that we switched the security context
                contextSet = true;
                SecurityActions.remotingContextClear();
            } catch (Exception e) {
                logger.error("Failed to switch security context for user", e);
                // Don't propagate the exception stacktrace back to the client for security reasons
                throw new EJBAccessException("Unable to attempt switching of user.");
            }
        }

        return invocationContext.proceed();
    } finally {
        // switch back to original security context
        if (contextSet) {
            SecurityActions.securityContextSet(cachedSecurityContext);
        }
    }
}
 
开发者ID:red-fox-mulder,项目名称:eap-6.1-quickstarts,代码行数:58,代码来源:ServerSecurityInterceptor.java


示例14: aroundInvoke

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
@AroundInvoke
public Object aroundInvoke(final InvocationContext invocationContext) throws Exception {
    Principal desiredUser = null;
    RealmUser connectionUser = null;

    Map<String, Object> contextData = invocationContext.getContextData();
    if (contextData.containsKey(DELEGATED_USER_KEY)) {
        desiredUser = new SimplePrincipal((String) contextData.get(DELEGATED_USER_KEY));

        Connection con = SecurityActions.remotingContextGetConnection();

        if (con != null) {
            UserInfo userInfo = con.getUserInfo();
            if (userInfo instanceof SubjectUserInfo) {
                SubjectUserInfo sinfo = (SubjectUserInfo) userInfo;
                for (Principal current : sinfo.getPrincipals()) {
                    if (current instanceof RealmUser) {
                        connectionUser = (RealmUser) current;
                        break;
                    }
                }
            }

        } else {
            throw new IllegalStateException("Delegation user requested but no user on connection found.");
        }
    }

    SecurityContext cachedSecurityContext = null;
    boolean contextSet = false;
    try {
        if (desiredUser != null && connectionUser != null
            && (desiredUser.getName().equals(connectionUser.getName()) == false)) {
            // The final part of this check is to verify that the change does actually indicate a change in user.
            try {
                // We have been requested to switch user and have successfully identified the user from the connection
                // so now we attempt the switch.
                cachedSecurityContext = SecurityActions.securityContextSetPrincipalInfo(desiredUser,
                    new OuterUserCredential(connectionUser));
                // keep track that we switched the security context
                contextSet = true;
                SecurityActions.remotingContextClear();
            } catch (Exception e) {
                logger.error("Failed to switch security context for user", e);
                // Don't propagate the exception stacktrace back to the client for security reasons
                throw new EJBAccessException("Unable to attempt switching of user.");
            }
        }

        return invocationContext.proceed();
    } finally {
        // switch back to original security context
        if (contextSet) {
            SecurityActions.securityContextSet(cachedSecurityContext);
        }
    }
}
 
开发者ID:wfink,项目名称:jboss-as-quickstart,代码行数:58,代码来源:ServerSecurityInterceptor.java


示例15: aroundInvoke

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
@AroundInvoke
public Object aroundInvoke(final InvocationContext invocationContext) throws Exception {
    Principal desiredUser = null;
    RealmUser connectionUser = null;

    Map<String, Object> contextData = invocationContext.getContextData();
    logger.info(">>>>>>>>>> contextData " + contextData);
    if (contextData.containsKey(DELEGATED_USER_KEY)) {
        desiredUser = new SimplePrincipal((String) contextData.get(DELEGATED_USER_KEY));
        logger.info("desiredUser " + desiredUser);

        Connection con = SecurityActions.remotingContextGetConnection();

        if (con != null) {
            UserInfo userInfo = con.getUserInfo();
            if (userInfo instanceof SubjectUserInfo) {
                SubjectUserInfo sinfo = (SubjectUserInfo) userInfo;
                for (Principal current : sinfo.getPrincipals()) {
                    if (current instanceof RealmUser) {
                        connectionUser = (RealmUser) current;
                        break;
                    }
                }
            }

        } else {
            throw new IllegalStateException("Delegation user requested but no user on connection found.");
        }
    }

    SecurityContext cachedSecurityContext = null;
    boolean contextSet = false;
    try {
        if (desiredUser != null && connectionUser != null
                && (desiredUser.getName().equals(connectionUser.getName()) == false)) {
            // The final part of this check is to verify that the change does actually indicate a change in user.
            try {
                // We have been requested to switch user and have successfully identified the user from the connection
                // so now we attempt the switch.
                cachedSecurityContext = SecurityActions.securityContextSetPrincipalInfo(desiredUser,
                        new OuterUserCredential(connectionUser));
                logger.info(">>>>>>>>>>>>> Switch users ");
                // keep track that we switched the security context
                contextSet = true;
                SecurityActions.remotingContextClear();
            } catch (Exception e) {
                logger.error("Failed to switch security context for user", e);
                // Don't propagate the exception stacktrace back to the client for security reasons
                throw new EJBAccessException("Unable to attempt switching of user.");
            }
        }

        return invocationContext.proceed();
    } finally {
        // switch back to original security context
        if (contextSet) {
            SecurityActions.securityContextSet(cachedSecurityContext);
        }
    }
}
 
开发者ID:wfink,项目名称:jboss-as-quickstart,代码行数:61,代码来源:ServerSecurityInterceptor.java


示例16: aroundInvoke

import javax.resource.spi.IllegalStateException; //导入依赖的package包/类
@AroundInvoke
public Object aroundInvoke(final InvocationContext invocationContext) throws Exception {
    Principal userPrincipal = null;
    RealmUser connectionUser = null;
    String authToken = null;

    Map<String, Object> contextData = invocationContext.getContextData();
    if (contextData.containsKey(SECURITY_TOKEN_KEY)) {
        authToken = (String) contextData.get(SECURITY_TOKEN_KEY);

        Connection con = SecurityActions.remotingContextGetConnection();

        if (con != null) {
            UserInfo userInfo = con.getUserInfo();
            if (userInfo instanceof SubjectUserInfo) {
                SubjectUserInfo sinfo = (SubjectUserInfo) userInfo;
                for (Principal current : sinfo.getPrincipals()) {
                    if (current instanceof RealmUser) {
                        connectionUser = (RealmUser) current;
                        break;
                    }
                }
            }
            userPrincipal = new SimplePrincipal(connectionUser.getName());

        } else {
            throw new IllegalStateException("Token authentication requested but no user on connection found.");
        }
    }

    SecurityContext cachedSecurityContext = null;
    boolean contextSet = false;
    try {
        if (userPrincipal != null && connectionUser != null && authToken != null) {
            try {
                // We have been requested to use an authentication token
                // so now we attempt the switch.
                cachedSecurityContext = SecurityActions.securityContextSetPrincipalCredential(userPrincipal,
                        new OuterUserPlusCredential(connectionUser, authToken));
                // keep track that we switched the security context
                contextSet = true;
                SecurityActions.remotingContextClear();
            } catch (Exception e) {
                logger.error("Failed to switch security context for user", e);
                // Don't propagate the exception stacktrace back to the client for security reasons
                throw new EJBAccessException("Unable to attempt switching of user.");
            }
        }

        return invocationContext.proceed();
    } finally {
        // switch back to original security context
        if (contextSet) {
            SecurityActions.securityContextSet(cachedSecurityContext);
        }
    }
}
 
开发者ID:wfink,项目名称:jboss-as-quickstart,代码行数:58,代码来源:ServerSecurityInterceptor.java



注:本文中的javax.resource.spi.IllegalStateException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IMEMonitorHandlerReceiver类代码示例发布时间:2022-05-22
下一篇:
Java ClassLoaderUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap