@Override public boolean reloadAddressInfo(AddressInfo addressInfo) throws Exception { return addressInfoMap.putIfAbsent(addressInfo.getName(), addressInfo) == null; }
@Override public String sendMessage(final Map<String, String> headers, final int type, final String body, boolean durable, final String user, final String password) throws Exception { try { return sendMessage(addressInfo.getName(), server, headers, type, body, durable, user, password); } catch (Exception e) { throw new IllegalStateException(e.getMessage()); } }
@Override public String getAddress() { return addressInfo.getName().toString(); }
private PagingStore getPagingStore() throws Exception { return pagingManager.getPageStore(addressInfo.getName()); }
public AddressInfo getAddressAndRoutingType(Map<SimpleString, RoutingType> prefixes) { for (Map.Entry<SimpleString, RoutingType> entry : prefixes.entrySet()) { if (this.getName().startsWith(entry.getKey())) { AddressInfo newAddressInfo = this.create(PrefixUtil.removePrefix(this.getName(), entry.getKey()), entry.getValue()); return newAddressInfo; } } return this; }
@Override public StringBuilder format(AddressInfo addressInfo, StringBuilder output) { output.append("Address [name=").append(addressInfo.getName()); output.append(", routingTypes={"); final EnumSet<RoutingType> routingTypes = addressInfo.getRoutingTypes(); if (!routingTypes.isEmpty()) { for (RoutingType routingType : routingTypes) { output.append(routingType).append(','); } // delete hanging comma output.deleteCharAt(output.length() - 1); } output.append('}'); output.append(", autoCreated=").append(addressInfo.isAutoCreated()); output.append(']'); return output; } };
@Override public AddressInfo removeAddressInfo(SimpleString address) throws Exception { final AddressInfo removed = super.removeAddressInfo(address); if (removed != null) { //Remove from mappings so removeAndUpdateAddressMap processes and cleanup mappings.remove(address); removeAndUpdateAddressMap(new AddressImpl(removed.getName(), wildcardConfiguration)); } return removed; }
@Override public void registerAddress(AddressInfo addressInfo) throws Exception { ObjectName objectName = objectNameBuilder.getAddressObjectName(addressInfo.getName()); AddressControlImpl addressControl = new AddressControlImpl(addressInfo, messagingServer, pagingManager, storageManager, securityRepository, securityStore, this); registerInJMX(objectName, addressControl); registerInRegistry(ResourceNames.ADDRESS + addressInfo.getName(), addressControl); if (logger.isDebugEnabled()) { logger.debug("registered address " + objectName); } }
@Override public AddressInfo createAddress(AddressInfo addressInfo, boolean autoCreated) throws Exception { AddressInfo art = getAddressAndRoutingType(addressInfo); securityCheck(art.getName(), CheckType.CREATE_ADDRESS, this); server.addOrUpdateAddressInfo(art.setAutoCreated(autoCreated)); return server.getAddressInfo(art.getName()); }
@Override public JsonObjectBuilder toJson(AddressInfo address) { if (address == null) { return null; } JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("id", toString(address.getId())).add("name", toString(address.getName())).add("routingTypes", toString(address.getRoutingTypes())); try { obj.add("queueCount", toString(server.bindingQuery(address.getName()).getQueueNames().size())); return obj; } catch (Exception e) { obj.add("queueCount", 0); } return obj; }
private void sendAddressNotification(AddressInfo addressInfo, final CoreNotificationType type) { final ManagementService managementService = getManagementService(); if (managementService != null && sendAddressNotifications) { try { final TypedProperties props = new TypedProperties(); props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, addressInfo.getName()); props.putByteProperty(ManagementHelper.HDR_ROUTING_TYPE, addressInfo.getRoutingType().getType()); managementService.sendNotification(new Notification(null, type, props)); } catch (Exception e) { logger.warn("Error sending notification: " + type, e.getMessage(), e); } } }
@Override public String getRolesAsJSON() throws Exception { clearIO(); try { JsonArrayBuilder json = JsonLoader.createArrayBuilder(); Set<Role> roles = securityRepository.getMatch(addressInfo.getName().toString()); for (Role role : roles) { json.add(role.toJson()); } return json.build().toString(); } finally { blockOnIO(); } }
@Override public Queue createQueue(AddressInfo addressInfo, SimpleString queueName, SimpleString filter, SimpleString user, boolean durable, boolean temporary, boolean autoCreated, Integer maxConsumers, Boolean purgeOnNoConsumers, Boolean exclusive, Boolean lastValue, boolean autoCreateAddress) throws Exception { AddressSettings as = getAddressSettingsRepository().getMatch(addressInfo == null ? queueName.toString() : addressInfo.getName().toString()); return createQueue(addressInfo, queueName, filter, user, durable, temporary, false, false, autoCreated, maxConsumers, purgeOnNoConsumers, exclusive, lastValue, as.getDefaultLastValueKey(), as.isDefaultNonDestructive(), as.getDefaultConsumersBeforeDispatch(), as.getDefaultDelayBeforeDispatch(), autoCreateAddress, false); }
@Override public Object[] getRoles() throws Exception { clearIO(); try { Set<Role> roles = securityRepository.getMatch(addressInfo.getName().toString()); Object[] objRoles = new Object[roles.size()]; int i = 0; for (Role role : roles) { objRoles[i++] = new Object[]{role.getName(), CheckType.SEND.hasRole(role), CheckType.CONSUME.hasRole(role), CheckType.CREATE_DURABLE_QUEUE.hasRole(role), CheckType.DELETE_DURABLE_QUEUE.hasRole(role), CheckType.CREATE_NON_DURABLE_QUEUE.hasRole(role), CheckType.DELETE_NON_DURABLE_QUEUE.hasRole(role), CheckType.MANAGE.hasRole(role)}; } return objRoles; } finally { blockOnIO(); } }
@Override public void addAddressBinding(final long tx, final AddressInfo addressInfo) throws Exception { PersistentAddressBindingEncoding bindingEncoding = new PersistentAddressBindingEncoding(addressInfo.getName(), addressInfo.getRoutingTypes(), addressInfo.isAutoCreated()); readLock(); try { long recordID = idGenerator.generateID(); bindingEncoding.setId(recordID); addressInfo.setId(recordID); bindingsJournal.appendAddRecordTransactional(tx, recordID, JournalRecordIds.ADDRESS_BINDING_RECORD, bindingEncoding); } finally { readUnLock(); } }
@Override public Queue createQueue(AddressInfo addressInfo, SimpleString queueName, SimpleString filter, SimpleString user, boolean durable, boolean temporary, boolean autoCreated, Integer maxConsumers, Boolean purgeOnNoConsumers, boolean autoCreateAddress) throws Exception { AddressSettings as = getAddressSettingsRepository().getMatch(addressInfo == null ? queueName.toString() : addressInfo.getName().toString()); return createQueue(addressInfo, queueName, filter, user, durable, temporary, false, false, autoCreated, maxConsumers, purgeOnNoConsumers, as.isDefaultExclusiveQueue(), as.isDefaultLastValueQueue(), as.getDefaultLastValueKey(), as.isDefaultNonDestructive(), as.getDefaultConsumersBeforeDispatch(), as.getDefaultDelayBeforeDispatch(), autoCreateAddress, false); }
@Override public Queue createQueue(AddressInfo addressInfo, SimpleString name, SimpleString filterString, boolean temporary, boolean durable, boolean autoCreated) throws Exception { AddressSettings as = server.getAddressSettingsRepository().getMatch(addressInfo.getName().toString()); return createQueue(addressInfo, name, filterString, temporary, durable, as.getDefaultMaxConsumers(), as.isDefaultPurgeOnNoConsumers(), as.isDefaultExclusiveQueue(), as.isDefaultLastValueQueue(), as.getDefaultLastValueKey(), as.isDefaultNonDestructive(), as.getDefaultConsumersBeforeDispatch(), as.getDefaultDelayBeforeDispatch(), autoCreated); }
@Override public Queue createQueue(AddressInfo addressInfo, SimpleString name, SimpleString filterString, boolean temporary, boolean durable, Boolean exclusive, Boolean lastValue, boolean autoCreated) throws Exception { AddressSettings as = server.getAddressSettingsRepository().getMatch(addressInfo.getName().toString()); return createQueue(addressInfo, name, filterString, temporary, durable, as.getDefaultMaxConsumers(), as.isDefaultPurgeOnNoConsumers(), exclusive == null ? as.isDefaultExclusiveQueue() : exclusive, lastValue == null ? as.isDefaultLastValueQueue() : lastValue, as.getDefaultLastValueKey(), as.isDefaultNonDestructive(), as.getDefaultConsumersBeforeDispatch(), as.getDefaultDelayBeforeDispatch(), autoCreated); }
@Override public AddressQueryResult addressQuery(SimpleString name) throws Exception { if (name == null) { throw ActiveMQMessageBundle.BUNDLE.queueNameIsNull(); } SimpleString realName = CompositeAddress.extractAddressName(name); AddressSettings addressSettings = getAddressSettingsRepository().getMatch(realName.toString()); boolean autoCreateAddresses = addressSettings.isAutoCreateAddresses(); boolean defaultPurgeOnNoConsumers = addressSettings.isDefaultPurgeOnNoConsumers(); int defaultMaxConsumers = addressSettings.getDefaultMaxConsumers(); AddressInfo addressInfo = postOffice.getAddressInfo(realName); AddressQueryResult response; if (addressInfo != null) { response = new AddressQueryResult(addressInfo.getName(), addressInfo.getRoutingTypes(), addressInfo.getId(), addressInfo.isAutoCreated(), true, autoCreateAddresses, defaultPurgeOnNoConsumers, defaultMaxConsumers); } else { response = new AddressQueryResult(realName, null, -1, false, false, autoCreateAddresses, defaultPurgeOnNoConsumers, defaultMaxConsumers); } return response; }