Search in sources :

Example 46 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class MessagingManager method getMessageInfo.

/**
 * Returns the MessageInfo object for the input dataBeanClass,
 * as defined in the configuration file.
 * @param dataBeanClass key used for the repository
 * @return the MessageInfo object for the input dataBeanClass
 */
public MessageInfo getMessageInfo(String dataBeanClass) {
    MessageInfo messageInfo = messageInfoRepository.query(dataBeanClass);
    if (messageInfo == null) {
        // Lookup the class heirarchy. Add a NULL for the dataBeanClassName, even if a MessageInfo is not found
        synchronized (messageInfoRepository) {
            messageInfo = messageInfoRepository.query(dataBeanClass);
            try {
                if (messageInfo == null) {
                    Class clazz = Class.forName(dataBeanClass);
                    ContextKey superClassContextKey = null;
                    while (clazz.getSuperclass() != null && messageInfo == null) {
                        clazz = clazz.getSuperclass();
                        messageInfo = messageInfoRepository.query(clazz.getName());
                        superClassContextKey = messageInfoRepository.findKey(clazz.getName());
                    }
                    if (superClassContextKey != null) {
                        messageInfoRepository.register(new ContextKey(dataBeanClass, superClassContextKey.getFileName(), superClassContextKey.getVariation(), superClassContextKey.getPrecedence()), messageInfo);
                    }
                }
            } catch (ClassNotFoundException e) {
                log.error("Unable to find class definition for " + dataBeanClass, e);
            }
        }
    }
    return messageInfo;
}
Also used : ContextKey(org.jaffa.loader.ContextKey)

Example 47 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class JndiJmsManager method registerResource.

/**
 * Unmarshall the contents of the configuration to create and register
 * JmsConfig 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 {
    JndiConfig config = JAXBHelper.unmarshalConfigFile(JndiConfig.class, resource, JMS_JNDI_CONFIGURATION_SCHEMA_FILE);
    JmsConfig jmsConfig = config.getJmsConfig();
    populateJmsConfig(jmsConfig);
    ContextKey contextKey = new ContextKey(jmsConfig.getUser(), resource.getURI().toString(), variation, context);
    jmsRepository.register(contextKey, jmsConfig);
}
Also used : JndiConfig(org.jaffa.modules.messaging.services.configdomain.JndiConfig) ContextKey(org.jaffa.loader.ContextKey) JmsConfig(org.jaffa.modules.messaging.services.configdomain.JmsConfig)

Example 48 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class JndiJmsManager method unregisterResource.

/**
 * Unregister the JmsConfig 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 {
    JndiConfig config = JAXBHelper.unmarshalConfigFile(JndiConfig.class, resource, JMS_JNDI_CONFIGURATION_SCHEMA_FILE);
    JmsConfig jmsConfig = config.getJmsConfig();
    ContextKey contextKey = new ContextKey(jmsConfig.getUser(), resource.getURI().toString(), variation, context);
    jmsRepository.unregister(contextKey);
}
Also used : JndiConfig(org.jaffa.modules.messaging.services.configdomain.JndiConfig) ContextKey(org.jaffa.loader.ContextKey) JmsConfig(org.jaffa.modules.messaging.services.configdomain.JmsConfig)

Example 49 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class SchedulerManager method unregisterResource.

/**
 * {@inheritDoc}
 */
@Override
public void unregisterResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
    Config config = JAXBHelper.unmarshalConfigFile(Config.class, resource, CONFIGURATION_SCHEMA_FILE);
    if (config.getTask() != null) {
        for (final Task schedulerTask : config.getTask()) {
            ContextKey contextKey = new ContextKey(schedulerTask.getDataBean(), resource.getURI().toString(), variation, context);
            unregisterSchedulerTask(contextKey);
        }
    }
}
Also used : Task(org.jaffa.modules.scheduler.services.configdomain.Task) ContextKey(org.jaffa.loader.ContextKey) Config(org.jaffa.modules.scheduler.services.configdomain.Config)

Example 50 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class SchedulerManager method getSchedulerTask.

/**
 * Returns the scheduler task object for the input dataBeanClass, as defined in the configuration file.
 *
 * @param dataBeanClass the class for a dataBean.
 * @return the TransactionInfo object for the input dataBeanClass, as defined in the configuration file.
 */
public Task getSchedulerTask(String dataBeanClass) {
    Task task = schedulerTaskRepository.query(dataBeanClass);
    if (task == null) {
        // Lookup the class hierarchy. Add a NULL for the dataBeanClassName, even if a Task is not found
        synchronized (schedulerTaskRepository) {
            task = schedulerTaskRepository.query(dataBeanClass);
            try {
                if (task == null) {
                    Class clazz = Class.forName(dataBeanClass);
                    ContextKey superClassContextKey = null;
                    while (clazz.getSuperclass() != null && task == null) {
                        clazz = clazz.getSuperclass();
                        task = schedulerTaskRepository.query(clazz.getName());
                        superClassContextKey = schedulerTaskRepository.findKey(clazz.getName());
                    }
                    if (superClassContextKey != null) {
                        schedulerTaskRepository.register(new ContextKey(dataBeanClass, superClassContextKey.getFileName(), superClassContextKey.getVariation(), superClassContextKey.getVariation()), task);
                    }
                }
            } catch (ClassNotFoundException e) {
                log.error("Unable to find class definition for " + dataBeanClass, e);
            }
        }
    }
    return task;
}
Also used : Task(org.jaffa.modules.scheduler.services.configdomain.Task) ContextKey(org.jaffa.loader.ContextKey)

Aggregations

ContextKey (org.jaffa.loader.ContextKey)55 Test (org.junit.Test)21 Properties (java.util.Properties)6 ComponentDefinition (org.jaffa.presentation.portlet.component.ComponentDefinition)6 Component (org.jaffa.presentation.portlet.component.componentdomain.Component)5 TransactionInfo (org.jaffa.transaction.services.configdomain.TransactionInfo)5 TypeInfo (org.jaffa.transaction.services.configdomain.TypeInfo)5 InputStream (java.io.InputStream)4 Task (org.jaffa.modules.scheduler.services.configdomain.Task)4 GlobalMenu (org.jaffa.components.navigation.domain.GlobalMenu)3 BusinessFunction (org.jaffa.security.businessfunctionsdomain.BusinessFunction)3 Role (org.jaffa.security.securityrolesdomain.Role)3 Config (org.jaffa.transaction.services.configdomain.Config)3 Config (org.jaffa.modules.messaging.services.configdomain.Config)2 JmsConfig (org.jaffa.modules.messaging.services.configdomain.JmsConfig)2 JndiConfig (org.jaffa.modules.messaging.services.configdomain.JndiConfig)2 Config (org.jaffa.modules.scheduler.services.configdomain.Config)2 Components (org.jaffa.presentation.portlet.component.componentdomain.Components)2 BusinessFunctions (org.jaffa.security.businessfunctionsdomain.BusinessFunctions)2 Roles (org.jaffa.security.securityrolesdomain.Roles)2