use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.
the class ApplicationRulesManager method unregisterResource.
/**
* unregisterResource - Provides a method which unregisters a given properties resource.
*
* @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 unregisterResource(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);
unregisterProperties(key);
}
}
resourceInputStream.close();
}
}
use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.
the class RoleManager method unregisterResource.
/**
* unregisterResource - Unregisters the roles from the role repository using the roles.xml files found in META-INF/roles.xml
* that exist in the classpath. This is used to return the repository to its original state before a custom
* configuration was added.
* @param resource the object that contains the xml config file.
* @param context 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 {
Roles roles = JAXBHelper.unmarshalConfigFile(Roles.class, resource, CONFIGURATION_SCHEMA_FILE);
if (roles.getRole() != null) {
for (final Role role : roles.getRole()) {
ContextKey key = new ContextKey(role.getName(), resource.getURI().toString(), variation, context);
unregisterRole(key);
}
}
}
use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.
the class ComponentManagerTest method testGetName.
/**
* Test the repository name retrieval function
*/
@Test
public void testGetName() throws Exception {
// A componentDefinition must be registered first
Component component = new Component();
String name = "q1";
component.setId(name);
ComponentDefinition definition = new ComponentDefinition(component);
ContextKey key = new ContextKey(name, "components.xml", "DEF", "0-PLATFORM");
manager.registerComponentDefinition(key, definition);
assertEquals("ComponentDefinition", manager.getComponentRepository().getName());
}
use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.
the class ComponentManagerTest method testRegisterComponentDefinition.
/**
* Tests registration of ComponentDefinition objects
* @throws Exception
*/
@Test
public void testRegisterComponentDefinition() throws Exception {
Component component = new Component();
String name = "q1";
component.setId(name);
ComponentDefinition definition = new ComponentDefinition(component);
ContextKey key = new ContextKey(name, "components.xml", VariationContext.NULL_VARIATION, "0-PLATFORM");
manager.registerComponentDefinition(key, definition);
ComponentDefinition retrievedDefinition = manager.getComponentDefinition(name);
assertEquals(definition, retrievedDefinition);
}
use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.
the class ApplicationRulesXmlLoadTest method testApplicationRulesRegistration.
/**
* testApplicationRulesRegistration - Verifies that the ApplicationRules_*.properties has been loaded correctly
* into the NavigationManager.
*/
@Test
public void testApplicationRulesRegistration() {
ApplicationRulesManager applicationRulesManager = xmlLoaderConfig.getBean(ApplicationRulesManager.class);
ContextKey key = new ContextKey("test", "Application_Rules", "DEF", "100-Highest");
assertNull(applicationRulesManager.getApplicationRulesRepository().query(key));
applicationRulesManager.registerProperties(key, "test1");
assertNotNull(applicationRulesManager.getApplicationRulesRepository().query(key));
applicationRulesManager.unregisterProperties(key);
assertNull(applicationRulesManager.getApplicationRulesRepository().query(key));
}
Aggregations