@Override
 public void run() {
   final SessionID sessionID;
   try {
     try {
       sessionID = statefulSessionComponent.createSession();
     } catch (Throwable t) {
       SessionOpenRequestHandler.this.writeException(
           channelAssociation,
           SessionOpenRequestHandler.this.marshallerFactory,
           invocationId,
           t,
           null);
       return;
     }
     // get the affinity of the component
     final Affinity hardAffinity = statefulSessionComponent.getCache().getStrictAffinity();
     SessionOpenRequestHandler.this.writeSessionId(
         channelAssociation, invocationId, sessionID, hardAffinity);
   } catch (IOException ioe) {
     EjbLogger.ROOT_LOGGER.exceptionGeneratingSessionId(
         ioe, invocationId, channelAssociation.getChannel());
     // close the channel
     IoUtils.safeClose(this.channelAssociation.getChannel());
     return;
   }
 }
  @Override
  public void processMessage(
      ChannelAssociation channelAssociation, MessageInputStream messageInputStream)
      throws IOException {
    if (messageInputStream == null) {
      throw EjbMessages.MESSAGES.messageInputStreamCannotBeNull();
    }
    final DataInputStream dataInputStream = new DataInputStream(messageInputStream);
    // read invocation id
    final short invocationId = dataInputStream.readShort();
    final String appName = dataInputStream.readUTF();
    final String moduleName = dataInputStream.readUTF();
    final String distinctName = dataInputStream.readUTF();
    final String beanName = dataInputStream.readUTF();

    final EjbDeploymentInformation ejbDeploymentInformation =
        this.findEJB(appName, moduleName, distinctName, beanName);
    if (ejbDeploymentInformation == null) {
      this.writeNoSuchEJBFailureMessage(
          channelAssociation, invocationId, appName, moduleName, distinctName, beanName, null);
      return;
    }
    final Component component = ejbDeploymentInformation.getEjbComponent();
    if (!(component instanceof StatefulSessionComponent)) {
      final String failureMessage =
          EjbLogger.ROOT_LOGGER
              .notStatefulSessionBean(beanName, appName, moduleName, distinctName)
              .getLocalizedMessage();
      this.writeInvocationFailure(
          channelAssociation, HEADER_EJB_NOT_STATEFUL, invocationId, failureMessage);
      return;
    }
    final StatefulSessionComponent statefulSessionComponent = (StatefulSessionComponent) component;
    // generate the session id and write out the response on a separate thread
    executorService.submit(
        new SessionIDGeneratorTask(statefulSessionComponent, channelAssociation, invocationId));
  }