Search in sources :

Example 1 with Config

use of org.jaffa.modules.messaging.services.configdomain.Config in project jaffa-framework by jaffa-projects.

the class MessagingManager method registerResource.

/**
 * Unmarshall the contents of the configuration to create and register
 * MessageInfo, QueueInfo, TopicInfo, and/or MessageFilter objects.
 * @param resource the object that contains the xml config file.
 * @param context key with which config file to be registered.
 * @param variation key with which config file to be registered.
 * @throws JAXBException
 * @throws SAXException
 * @throws IOException
 */
@Override
public void registerResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
    Config config = JAXBHelper.unmarshalConfigFile(Config.class, resource, CONFIGURATION_SCHEMA_FILE);
    List<Object> messageObjects = config.getMessageOrQueueOrTopic();
    if (messageObjects != null) {
        for (final Object o : messageObjects) {
            if (o instanceof MessageInfo) {
                final MessageInfo info = (MessageInfo) o;
                validateMessageInfo(info);
                ContextKey contextKey = new ContextKey(info.getDataBean(), resource.getURI().toString(), variation, context);
                registerMessageInfo(contextKey, info);
            } else if (o instanceof QueueInfo) {
                final QueueInfo info = (QueueInfo) o;
                ContextKey contextKey = new ContextKey(info.getName(), resource.getURI().toString(), variation, context);
                registerQueueInfo(contextKey, info);
            } else if (o instanceof TopicInfo) {
                final TopicInfo info = (TopicInfo) o;
                ContextKey contextKey = new ContextKey(info.getName(), resource.getURI().toString(), variation, context);
                registerTopicInfo(contextKey, info);
            } else if (o instanceof MessageFilter) {
                final MessageFilter filter = (MessageFilter) o;
                ContextKey contextKey = new ContextKey(filter.getFilterName(), resource.getURI().toString(), variation, context);
                registerMessageFilter(contextKey, filter);
            } else {
                log.warn("MessagingObject.registerResource, unexpected object: " + o);
            }
        }
        // for
        checkForQueueAndTopicNamingConflicts();
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Config(org.jaffa.modules.messaging.services.configdomain.Config)

Example 2 with Config

use of org.jaffa.modules.messaging.services.configdomain.Config in project jaffa-framework by jaffa-projects.

the class MessagingManager method unregisterResource.

/**
 * Unregister the message objects defined by a particular resource.
 * @param resource the object that contains the xml config file.
 * @param context key with which config file to be registered.
 * @param variation key with which config file to be registered.
 * @throws JAXBException
 * @throws SAXException
 * @throws IOException
 */
@Override
public void unregisterResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
    Config config = JAXBHelper.unmarshalConfigFile(Config.class, resource, CONFIGURATION_SCHEMA_FILE);
    List<Object> messageObjects = config.getMessageOrQueueOrTopic();
    if (messageObjects != null) {
        for (final Object o : messageObjects) {
            if (o instanceof MessageInfo) {
                final MessageInfo info = (MessageInfo) o;
                validateMessageInfo(info);
                ContextKey contextKey = new ContextKey(info.getDataBean(), resource.getURI().toString(), variation, context);
                unregisterMessageInfo(contextKey);
            } else if (o instanceof QueueInfo) {
                final QueueInfo info = (QueueInfo) o;
                ContextKey contextKey = new ContextKey(info.getName(), resource.getURI().toString(), variation, context);
                unregisterQueueInfo(contextKey);
            } else if (o instanceof TopicInfo) {
                final TopicInfo info = (TopicInfo) o;
                ContextKey contextKey = new ContextKey(info.getName(), resource.getURI().toString(), variation, context);
                unregisterTopicInfo(contextKey);
            } else if (o instanceof MessageFilter) {
                final MessageFilter filter = (MessageFilter) o;
                ContextKey contextKey = new ContextKey(filter.getFilterName(), resource.getURI().toString(), variation, context);
                unregisterMessageFilter(contextKey);
            } else {
                log.warn("MessagingObject.registerResource, unexpected object: " + o);
            }
        }
        // for
        checkForQueueAndTopicNamingConflicts();
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Config(org.jaffa.modules.messaging.services.configdomain.Config)

Aggregations

ContextKey (org.jaffa.loader.ContextKey)2 Config (org.jaffa.modules.messaging.services.configdomain.Config)2