Exemplo n.º 1
0
  protected String getFilterLogString() {
    StringBuilder filterLogString = new StringBuilder();
    String delimiter = ", ";
    boolean hasEntries = false;
    if (_filters != null && _filters.hasFilters()) {
      filterLogString.append(_filters.toString());
      hasEntries = true;
    }

    if (!acquires()) {
      if (hasEntries) {
        filterLogString.append(delimiter);
      }
      filterLogString.append("Browser");
    }

    return filterLogString.toString();
  }
Exemplo n.º 2
0
  public final boolean hasInterest(QueueEntry entry) {
    // check that the message hasn't been rejected
    if (entry.isRejectedBy(this)) {

      return false;
    }

    if (entry.getMessage().getClass() == _messageClass) {
      if (_noLocal) {
        Object connectionRef = entry.getMessage().getConnectionReference();
        if (connectionRef != null && connectionRef == _sessionReference) {
          return false;
        }
      }
    } else {
      // no interest in messages we can't convert
      if (_messageClass != null
          && MessageConverterRegistry.getConverter(entry.getMessage().getClass(), _messageClass)
              == null) {
        return false;
      }
    }

    if (_filters == null) {
      return true;
    } else {
      MessageReference ref = entry.newMessageReference();
      if (ref != null) {
        try {

          Filterable msg = entry.asFilterable();
          try {
            return _filters.allAllow(msg);
          } catch (SelectorParsingException e) {
            LOGGER.info(
                this
                    + " could not evaluate filter ["
                    + _filters
                    + "]  against message "
                    + msg
                    + ". Error was : "
                    + e.getMessage());
            return false;
          }
        } finally {
          ref.release();
        }
      } else {
        return false;
      }
    }
  }
Exemplo n.º 3
0
  private static Map<String, Object> createAttributeMap(
      String name, FilterManager filters, EnumSet<Option> optionSet) {
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put(ID, UUID.randomUUID());
    attributes.put(NAME, name);
    attributes.put(EXCLUSIVE, optionSet.contains(Option.EXCLUSIVE));
    attributes.put(NO_LOCAL, optionSet.contains(Option.NO_LOCAL));
    attributes.put(DISTRIBUTION_MODE, optionSet.contains(Option.ACQUIRES) ? "MOVE" : "COPY");
    attributes.put(DURABLE, optionSet.contains(Option.DURABLE));
    attributes.put(LIFETIME_POLICY, LifetimePolicy.DELETE_ON_SESSION_END);
    if (filters != null) {
      Iterator<MessageFilter> iter = filters.filters();
      while (iter.hasNext()) {
        MessageFilter filter = iter.next();
        if (filter instanceof JMSSelectorFilter) {
          attributes.put(SELECTOR, ((JMSSelectorFilter) filter).getSelector());
          break;
        }
      }
    }

    return attributes;
  }