Search in sources :

Example 26 with ContextKey

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

the class TransactionManagerTest method testRegisterTransactionInfo.

/**
 * tests the registerTransactionInfo
 */
@Test
public void testRegisterTransactionInfo() {
    // test
    transactionManager.registerTransactionInfo(new ContextKey("testBean", null, "DEF", "cust-code"), new TransactionInfo());
    // verify
    verify(transactionRepoMock).register(eq(new ContextKey("testBean", null, "DEF", "cust-code")), Matchers.anyObject());
}
Also used : ContextKey(org.jaffa.loader.ContextKey) TransactionInfo(org.jaffa.transaction.services.configdomain.TransactionInfo) Test(org.junit.Test)

Example 27 with ContextKey

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

the class TransactionManagerTest method testUnRegisterTypeInfo.

/**
 * tests the unregisterTypeInfo
 */
@Test
public void testUnRegisterTypeInfo() {
    // initialize
    TypeInfo typeInfo = new TypeInfo();
    typeInfo.setName("typeInfoName");
    ContextKey key = new ContextKey("typeInfoName", null, "DEF", "cust-code");
    // test
    transactionManager.unregisterTypeInfo(key);
    // verify
    verify(typeInfoRepoMock).unregister(eq(key));
}
Also used : ContextKey(org.jaffa.loader.ContextKey) TypeInfo(org.jaffa.transaction.services.configdomain.TypeInfo) Test(org.junit.Test)

Example 28 with ContextKey

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

the class ComponentManager method unregisterResource.

/**
 * Unregister a given component resource.
 * @param resource the object that contains the xml config file.
 * @param context key with which config file to be registered.
 * @param variation with which config file to be registered.
 * @throws JAXBException
 * @throws SAXException
 * @throws IOException for file opening or reading errors, or when an
 * attempt to create a ComponentDefinition throws a
 * ComponentDefinitionException
 */
@Override
public void unregisterResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
    Components components = JAXBHelper.unmarshalConfigFile(Components.class, resource, COMPONENT_XSD);
    List<Component> componentList = components.getComponent();
    if (componentList != null) {
        for (final Component component : componentList) {
            ComponentDefinition definition = createComponentDefinition(component);
            ContextKey contextKey = new ContextKey(definition.getComponentName(), resource.getURI().toString(), variation, context);
            unregisterComponentDefinition(contextKey);
        }
    }
}
Also used : Components(org.jaffa.presentation.portlet.component.componentdomain.Components) ContextKey(org.jaffa.loader.ContextKey) Component(org.jaffa.presentation.portlet.component.componentdomain.Component) ComponentDefinition(org.jaffa.presentation.portlet.component.ComponentDefinition)

Example 29 with ContextKey

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

the class ComponentManager method registerResource.

/**
 * Unmarshall the contents of the configuration to create and register
 * ComponentDefinition, 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 with which config file to be registered.
 * @throws JAXBException
 * @throws SAXException
 * @throws IOException for file opening or reading errors, or when an
 * attempt to create a ComponentDefinition throws a
 * ComponentDefinitionException
 */
@Override
public void registerResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
    Components components = JAXBHelper.unmarshalConfigFile(Components.class, resource, COMPONENT_XSD);
    List<Component> componentList = components.getComponent();
    if (componentList != null) {
        for (final Component component : componentList) {
            ComponentDefinition definition = createComponentDefinition(component);
            ContextKey contextKey = new ContextKey(definition.getComponentName(), resource.getURI().toString(), variation, context);
            registerComponentDefinition(contextKey, definition);
        }
    }
}
Also used : Components(org.jaffa.presentation.portlet.component.componentdomain.Components) ContextKey(org.jaffa.loader.ContextKey) Component(org.jaffa.presentation.portlet.component.componentdomain.Component) ComponentDefinition(org.jaffa.presentation.portlet.component.ComponentDefinition)

Example 30 with ContextKey

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

the class ApplicationRulesManager method registerResource.

/**
 * registerResource - Provides a method which submits the contents of the resource file to the application rules
 * repository.
 *
 * @param resource   the object that contains the xml config file.
 * @param precedence associated with the module based on its definition in manifest
 * @param variation  associated with the module based on its definition in manifest
 * @throws JAXBException
 * @throws SAXException
 * @throws IOException
 */
@Override
public void registerResource(Resource resource, String precedence, String variation) throws JAXBException, SAXException, IOException {
    Properties properties = new Properties();
    InputStream resourceInputStream = resource.getInputStream();
    if (resource != null && resourceInputStream != null) {
        loadPropertiesResource(resourceInputStream, properties);
        if (!properties.isEmpty()) {
            for (Object property : properties.keySet()) {
                ContextKey key = new ContextKey((String) property, resource.getURI().toString(), variation, precedence);
                registerProperties(key, properties.getProperty((String) property));
            }
        }
        resourceInputStream.close();
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) InputStream(java.io.InputStream) Properties(java.util.Properties)

Aggregations

ContextKey (org.jaffa.loader.ContextKey)49 Test (org.junit.Test)21 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 Properties (java.util.Properties)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 InputStream (java.io.InputStream)2 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