@SuppressWarnings("unchecked") public Set<Object> getAdminACLs(ActiveMQDestination destination) { return adminACLs.get(destination); }
DestinationMap map = new DestinationMap(); map.put(destination, destination); writer.println(" label = \"Queues\""); writer.println(); printNodeLinks(writer, map.getQueueRootNode(), "queue"); writer.println("}"); writer.println(); writer.println(" label = \"TempQueues\""); writer.println(); printNodeLinks(writer, map.getTempQueueRootNode(), "tempqueue"); writer.println("}"); writer.println(); writer.println(" label = \"Topics\""); writer.println(); printNodeLinks(writer, map.getTopicRootNode(), "topic"); writer.println("}"); writer.println(); writer.println(" label = \"TempTopics\""); writer.println(); printNodeLinks(writer, map.getTempTopicRootNode(), "temptopic"); writer.println("}"); writer.println(); printNodes(writer, map.getQueueRootNode(), "queue");
void removeMessageInterceptor(ActiveMQDestination activeMQDestination, MessageInterceptor interceptor) { interceptorMap.remove(activeMQDestination, interceptor); }
public void setVirtualDestinations(VirtualDestination[] virtualDestinations) { destinationMap = new DestinationMap(); mappedDestinationMap = new DestinationMap(); this.virtualDestinations = virtualDestinations; for (int i = 0; i < virtualDestinations.length; i++) { VirtualDestination virtualDestination = virtualDestinations[i]; destinationMap.put(virtualDestination.getVirtualDestination(), virtualDestination); mappedDestinationMap.put(virtualDestination.getMappedDestinations(), virtualDestination); } }
/** * Returns the value which matches the given destination or null if there is * no matching value. If there are multiple values, the results are sorted * and the last item (the biggest) is returned. * * @param destination the destination to find the value for * @return the largest matching value or null if no value matches */ @SuppressWarnings({"rawtypes", "unchecked"}) public DestinationMapEntry chooseValue(final ActiveMQDestination destination) { Set<DestinationMapEntry> set = get(destination); if (set == null || set.isEmpty()) { return null; } //Comparator to sort in order - we want to pick the exact match by destination or the //closest parent that applies final Comparator<DestinationMapEntry> comparator = new Comparator<DestinationMapEntry>() { @Override public int compare(DestinationMapEntry entry1, DestinationMapEntry entry2) { return destination.equals(entry1.destination) ? -1 : (destination.equals(entry2.destination) ? 1 : entry1.compareTo(entry2)); } }; //Sort and filter out any children and non matching entries final SortedSet<DestinationMapEntry> sortedSet = set.stream() .filter(entry -> isMatchOrParent(destination, (DestinationMapEntry)entry)) .collect(Collectors.toCollection(() -> new TreeSet<DestinationMapEntry>(comparator))); return sortedSet.size() > 0 ? sortedSet.first() : null; }
/** * A helper method to allow the destination map to be populated from a * dependency injection framework such as Spring */ @SuppressWarnings({"rawtypes"}) protected void setEntries(List<DestinationMapEntry> entries) { for (Object element : entries) { Class<? extends DestinationMapEntry> type = getEntryClass(); if (type.isInstance(element)) { DestinationMapEntry entry = (DestinationMapEntry) element; put(entry.getDestination(), entry.getValue()); } else { throw new IllegalArgumentException("Each entry must be an instance of type: " + type.getName() + " but was: " + element); } } }
@Override public void setEntries(List<DestinationMapEntry> entries) { super.setEntries(entries); } };
public void unsynchronizedPut(ActiveMQDestination key, Object value) { if (key.isComposite()) { ActiveMQDestination[] destinations = key.getCompositeDestinations(); for (int i = 0; i < destinations.length; i++) { ActiveMQDestination childDestination = destinations[i]; put(childDestination, value); } return; } String[] paths = key.getDestinationPaths(); getRootNode(key).add(paths, 0, value); }
public void unsynchronizedRemove(ActiveMQDestination key, Object value) { if (key.isComposite()) { ActiveMQDestination[] destinations = key.getCompositeDestinations(); for (int i = 0; i < destinations.length; i++) { ActiveMQDestination childDestination = destinations[i]; remove(childDestination, value); } return; } String[] paths = key.getDestinationPaths(); getRootNode(key).remove(paths, 0, value); }
MessageInterceptor addMessageInterceptor(ActiveMQDestination activeMQDestination, MessageInterceptor messageInterceptor) { interceptorMap.put(activeMQDestination, messageInterceptor); return messageInterceptor; }
@SuppressWarnings({"rawtypes", "unchecked"}) public Set unsynchronizedGet(ActiveMQDestination key) { if (key.isComposite()) { ActiveMQDestination[] destinations = key.getCompositeDestinations(); Set answer = new HashSet(destinations.length); for (int i = 0; i < destinations.length; i++) { ActiveMQDestination childDestination = destinations[i]; Object value = unsynchronizedGet(childDestination); if (value instanceof Set) { answer.addAll((Set) value); } else if (value != null) { answer.add(value); } } return answer; } return findWildcardMatches(key); }
@Override public void send(ProducerBrokerExchange producerExchange, final Message messageSend) throws Exception { ActiveMQDestination activeMQDestination = messageSend.getDestination(); if (!interceptorMap.isEmpty() && activeMQDestination != null) { Set<MessageInterceptor> set = interceptorMap.get(activeMQDestination); if (set != null && !set.isEmpty()) { for (MessageInterceptor mi : set) { mi.intercept(producerExchange, messageSend); } } else { super.send(producerExchange, messageSend); } } else { super.send(producerExchange, messageSend); } } }
/** * @param key * @return */ @SuppressWarnings({"rawtypes", "unchecked"}) public Set removeAll(ActiveMQDestination key) { Set rc = new HashSet(); if (key.isComposite()) { ActiveMQDestination[] destinations = key.getCompositeDestinations(); for (int i = 0; i < destinations.length; i++) { rc.add(removeAll(destinations[i])); } return rc; } String[] paths = key.getDestinationPaths(); getRootNode(key).removeAll(rc, paths, 0); return rc; }
/** * Looks up the value(s) matching the given Destination key. For simple * destinations this is typically a List of one single value, for wildcards * or composite destinations this will typically be a List of matching * values. * * @param key the destination to lookup * @return a List of matching values or an empty list if there are no * matching values. */ public synchronized Set get(ActiveMQDestination key) { if (key.isComposite()) { ActiveMQDestination[] destinations = key.getCompositeDestinations(); Set answer = new HashSet(destinations.length); for (int i = 0; i < destinations.length; i++) { ActiveMQDestination childDestination = destinations[i]; Object value = get(childDestination); if (value instanceof Set) { answer.addAll((Set)value); } else if (value != null) { answer.add(value); } } return answer; } return findWildcardMatches(key); }
@SuppressWarnings({"rawtypes", "unchecked"}) protected Set findWildcardMatches(ActiveMQDestination key, boolean deep) { String[] paths = key.getDestinationPaths(); Set answer = new HashSet(); getRootNode(key).appendMatchingValues(answer, paths, 0, deep); return answer; }
@SuppressWarnings({"rawtypes", "unchecked"}) protected Set findWildcardMatches(ActiveMQDestination key) { return findWildcardMatches(key, true); }
/** * Sets the individual entries on the policy map * * @org.apache.xbean.ElementType class="org.apache.activemq.broker.region.policy.PolicyEntry" */ public void setPolicyEntries(List entries) { super.setEntries(entries); }
public void setVirtualDestinations(VirtualDestination[] virtualDestinations) { destinationMap = new DestinationMap(); mappedDestinationMap = new DestinationMap(); this.virtualDestinations = virtualDestinations; for (int i = 0; i < virtualDestinations.length; i++) { VirtualDestination virtualDestination = virtualDestinations[i]; destinationMap.put(virtualDestination.getVirtualDestination(), virtualDestination); mappedDestinationMap.put(virtualDestination.getMappedDestinations(), virtualDestination); } }
public void unsynchronizedPut(ActiveMQDestination key, Object value) { if (key.isComposite()) { ActiveMQDestination[] destinations = key.getCompositeDestinations(); for (int i = 0; i < destinations.length; i++) { ActiveMQDestination childDestination = destinations[i]; put(childDestination, value); } return; } String[] paths = key.getDestinationPaths(); getRootNode(key).add(paths, 0, value); }
public void unsynchronizedRemove(ActiveMQDestination key, Object value) { if (key.isComposite()) { ActiveMQDestination[] destinations = key.getCompositeDestinations(); for (int i = 0; i < destinations.length; i++) { ActiveMQDestination childDestination = destinations[i]; remove(childDestination, value); } return; } String[] paths = key.getDestinationPaths(); getRootNode(key).remove(paths, 0, value); }