public void onMessage(Message message) {
    final boolean rollbackOnError =
        JmsProperties.PROCESSING_FAILURE_MODE_ROLLBACK.equalsIgnoreCase(
            Parameters.instance()
                .getString(
                    JmsProperties.MESSAGE_LISTENER_FAILURE_MODE_PROPERTY,
                    JmsProperties.PROCESSING_FAILURE_MODE_FORGET));
    final int nRetries =
        Parameters.instance().getInteger(JmsProperties.MESSAGE_LISTENER_RETRY_COUNT_PROPERTY, 20);
    final int tPause =
        Parameters.instance().getInteger(JmsProperties.MESSAGE_LISTENER_RETRY_PAUSE_PROPERTY, 500);

    Action action =
        (Action)
            Proxy.newProxyInstance(
                Action.class.getClassLoader(),
                new Class[] {Action.class},
                new MessageHandlingInvocationManager(
                    this,
                    JmsProperties.MDB_NAME_MESSAGE_LISTENER,
                    new SystemQueueMessageDeliveryAction(message),
                    nRetries,
                    tPause,
                    rollbackOnError));

    action.execute();
  }
  /** default constructor */
  public CorrespondenceViewBean() {
    super("correspondenceView");
    attachments = new ArrayList<Attachment>();
    Document document =
        (Document) PortalApplication.getInstance().getFocusView().getViewParams().get("attachment");
    if (null != document) {
      addAttachments(new Attachment(document, DocumentMgmtUtility.getDocumentManagementService()));
    }
    String procInstOID =
        (String)
            PortalApplication.getInstance()
                .getFocusView()
                .getViewParams()
                .get("processInstanceOID");
    processInstance = ProcessInstanceUtils.getProcessInstance(Long.valueOf(procInstOID));
    requestParamMap.put("To", "toaddressess");
    requestParamMap.put("Cc", "ccaddressess");
    requestParamMap.put("Bcc", "bccaddressess");
    requestParamMap.put("Fax", "faxaddressess");
    dropBoxEffect = new Pulsate(EFFECT_DURATION);
    dropBoxEffect.setFired(true);

    // set sender's mail address
    String emailId = getMailSender();
    emailId =
        (emailId == null || emailId.equals(""))
            ? DocumentMgmtUtility.getUser().getEMail()
            : emailId;
    emailId =
        (emailId == null || emailId.equals(""))
            ? Parameters.instance().getString(EngineProperties.MAIL_SENDER)
            : emailId;
    setMailSender(emailId);

    pdfConverterHelper = new PDFConverterHelper();
    printAvailable = pdfConverterHelper.isPDFConverterAvailable();

    correspondenceAttachments =
        new CorrespondenceAttachments(
            new CorrespondenceAttachmentsHandler() {
              public boolean addAttachment(Document document) {
                return CorrespondenceViewBean.this.addAttachments(
                    new Attachment(document, DocumentMgmtUtility.getDocumentManagementService()));
              }

              public boolean addTemplate(Document document, AddPolicy addPolicy) {
                return CorrespondenceViewBean.this.addTemplate(
                    document, AddPolicy.AT_TOP == addPolicy);
              }

              public boolean isDocumentTemplate(Document document) {
                return CorrespondenceViewBean.this.isDocumentTemplate(document);
              }
            });
  }
  /**
   * @param loginProperties
   * @return
   * @throws PortalException
   */
  public static SessionContext login(Map<String, String> loginProperties) throws PortalException {
    SessionContext sessionCtx;

    // Login With Technical User
    trace.debug("Technical User about to log in...");

    Parameters parameters = Parameters.instance();

    String user = parameters.getString(Constants.TECH_USER_PARAM_ACCOUNT);
    String pwd = parameters.getString(Constants.TECH_USER_PARAM_PASSWORD);
    String realm = parameters.getString(Constants.TECH_USER_PARAM_REALM);

    Map<String, String> properties = CollectionUtils.newHashMap();
    properties.put(SecurityProperties.REALM, realm);

    if (StringUtils.isEmpty(user) || StringUtils.isEmpty(pwd) || StringUtils.isEmpty(realm)) {
      user = TECH_USER_ACCOUNT;
      pwd = TECH_USER_PASSWORD;
      realm = TECH_USER_REALM;

      trace.info(
          "The default user credentials were used to initiate the 'Technical User login' request. Please configure a new technical user.");
    } else {
      trace.debug("Technical User is found to be configured. Using the same to login");
    }

    // Set the partition of Tech User same as the current user
    if (loginProperties.containsKey(SecurityProperties.PARTITION)) {
      properties.put(
          SecurityProperties.PARTITION, loginProperties.get(SecurityProperties.PARTITION));
    }

    sessionCtx = SessionContext.findSessionContext();
    sessionCtx.initInternalSession(user, pwd, properties);

    if (trace.isDebugEnabled()) {
      trace.debug("Technical User" + user + " Logged in...");
    }
    return sessionCtx;
  }
  @SuppressWarnings("rawtypes")
  public Cache createCache(Map env) throws CacheException {
    Parameters params = Parameters.instance();

    try {
      String txMode = params.getString(PRP_HAZELCAST_TX_MODE, "rw");
      if (!Arrays.asList("none", "w", "rw").contains(txMode)) {
        trace.warn("Unsupported Hazelcast TX mode \"" + txMode + "\". Using \"rw\" instead.");
        txMode = "rw";
      }

      ConnectionFactory hzCf = null;
      if (!"none".equals(txMode)) {
        hzCf = CONNECTION_FACTORY_PROVIDER.connectionFactory();
      }
      return new HazelcastCacheAdapter(txMode, hzCf, env);
    } catch (Exception e) {
      trace.warn("Failed initializing Hazelcast cache.", e);
    }

    return null;
  }
  private static ServiceFactory __get__(Map credentials, Map properties) throws PublicException {
    try {
      ServiceFactory result =
          (ServiceFactory)
              Reflect.createInstance(
                  Parameters.instance()
                      .getString(
                          WebProperties.WEB_SERVICE_FACTORY,
                          PredefinedConstants.PLAIN_WEB_SERVICEFACTORY_CLASS),
                  ServiceFactoryLocator.class.getClassLoader());
      result.setCredentials(credentials);

      Map mergedProps = new HashMap(properties);
      LoginUtils.mergeCredentialProperties(mergedProps, credentials);
      LoginUtils.mergeDefaultCredentials(mergedProps);

      result.setProperties(mergedProps);

      return result;
    } catch (InternalException e) {
      throw new PublicException(
          BpmRuntimeError.EJB_INVALID_SERVICE_FACTORY_CONFIGURATION.raise(e.getMessage()));
    }
  }
  public CachingSequenceGenerator() {
    this.typeDescriptorToIdCache = new ConcurrentHashMap();

    this.sequenceBatchSize =
        Parameters.instance().getInteger(KernelTweakingProperties.SEQUENCE_BATCH_SIZE, 100);
  }