Search in sources :

Example 1 with Config

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

the class TransactionManager method unregisterXML.

/**
 * unregisters all the transactions and typeInfo in the xml from the repository
 * @param uri for the xml location
 */
public void unregisterXML(String uri, String context, String variation) throws JAXBException, SAXException, IOException {
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    Config config = JAXBHelper.unmarshalConfigFile(Config.class, resolver.getResource(uri), CONFIGURATION_SCHEMA_FILE);
    if (config.getTransactionOrType() != null) {
        for (final Object o : config.getTransactionOrType()) {
            if (o.getClass() == TransactionInfo.class) {
                final TransactionInfo transactionInfo = (TransactionInfo) o;
                ContextKey contextKey = new ContextKey(transactionInfo.getDataBean(), uri, variation, context);
                unregisterTransactionInfo(contextKey);
            } else if (o.getClass() == TypeInfo.class) {
                final TypeInfo typeInfo = (TypeInfo) o;
                ContextKey contextKey = new ContextKey(typeInfo.getName(), uri, variation, context);
                unregisterTypeInfo(contextKey);
            }
        }
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Config(org.jaffa.transaction.services.configdomain.Config) TransactionInfo(org.jaffa.transaction.services.configdomain.TransactionInfo) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) TypeInfo(org.jaffa.transaction.services.configdomain.TypeInfo)

Example 2 with Config

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

the class TransactionManager method registerResource.

/**
 * {@inheritDoc}
 */
@Override
public void registerResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
    Config config = JAXBHelper.unmarshalConfigFile(Config.class, resource, CONFIGURATION_SCHEMA_FILE);
    if (config.getTransactionOrType() != null) {
        for (final Object o : config.getTransactionOrType()) {
            if (o.getClass() == TransactionInfo.class) {
                final TransactionInfo transactionInfo = (TransactionInfo) o;
                ContextKey contextKey = new ContextKey(transactionInfo.getDataBean(), resource.getURI().toString(), variation, context);
                registerTransactionInfo(contextKey, transactionInfo);
            } else if (o.getClass() == TypeInfo.class) {
                final TypeInfo typeInfo = (TypeInfo) o;
                ContextKey contextKey = new ContextKey(typeInfo.getName(), resource.getURI().toString(), variation, context);
                registerTypeInfo(contextKey, typeInfo);
            }
        }
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Config(org.jaffa.transaction.services.configdomain.Config) TransactionInfo(org.jaffa.transaction.services.configdomain.TransactionInfo) TypeInfo(org.jaffa.transaction.services.configdomain.TypeInfo)

Example 3 with Config

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

the class TransactionManager 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.getTransactionOrType() != null) {
        for (final Object o : config.getTransactionOrType()) {
            if (o.getClass() == TransactionInfo.class) {
                final TransactionInfo transactionInfo = (TransactionInfo) o;
                ContextKey contextKey = new ContextKey(transactionInfo.getDataBean(), resource.getURI().toString(), variation, context);
                unregisterTransactionInfo(contextKey);
            } else if (o.getClass() == TypeInfo.class) {
                final TypeInfo typeInfo = (TypeInfo) o;
                ContextKey contextKey = new ContextKey(typeInfo.getName(), resource.getURI().toString(), variation, context);
                unregisterTypeInfo(contextKey);
            }
        }
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Config(org.jaffa.transaction.services.configdomain.Config) TransactionInfo(org.jaffa.transaction.services.configdomain.TransactionInfo) TypeInfo(org.jaffa.transaction.services.configdomain.TypeInfo)

Aggregations

ContextKey (org.jaffa.loader.ContextKey)3 Config (org.jaffa.transaction.services.configdomain.Config)3 TransactionInfo (org.jaffa.transaction.services.configdomain.TransactionInfo)3 TypeInfo (org.jaffa.transaction.services.configdomain.TypeInfo)3 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)1