Example usage for org.springframework.oxm.xstream XStreamMarshaller setAliasesByType

List of usage examples for org.springframework.oxm.xstream XStreamMarshaller setAliasesByType

Introduction

In this page you can find the example usage for org.springframework.oxm.xstream XStreamMarshaller setAliasesByType.

Prototype

public void setAliasesByType(Map<String, ?> aliasesByType) 

Source Link

Document

Set the aliases by type map, consisting of string aliases mapped to classes.

Usage

From source file:org.georchestra.security.Proxy.java

public void init() throws Exception {
    if (targets != null) {
        for (String url : targets.values()) {
            new URL(url); // test that it is a valid URL
        }/*from  ww  w  .  j  a va  2 s . co m*/
    }
    if (proxyPermissionsFile != null) {
        Closer closer = Closer.create();
        try {
            final ClassLoader classLoader = Proxy.class.getClassLoader();
            InputStream inStream = closer.register(classLoader.getResourceAsStream(proxyPermissionsFile));
            Map<String, Class<?>> aliases = Maps.newHashMap();
            aliases.put(Permissions.class.getSimpleName().toLowerCase(), Permissions.class);
            aliases.put(UriMatcher.class.getSimpleName().toLowerCase(), UriMatcher.class);
            XStreamMarshaller unmarshaller = new XStreamMarshaller();
            unmarshaller.setAliasesByType(aliases);
            setProxyPermissions((Permissions) unmarshaller.unmarshal(new StreamSource(inStream)));
        } finally {
            closer.close();
        }
    }
    // georchestra datadir autoconfiguration
    // dependency injection / properties setter() are made by Spring before
    // init() call
    if ((georchestraConfiguration != null) && (georchestraConfiguration.activated())) {
        logger.info("geOrchestra configuration detected, reconfiguration in progress ...");

        Properties pTargets = georchestraConfiguration.loadCustomPropertiesFile("targets-mapping");

        targets.clear();
        for (String target : pTargets.stringPropertyNames()) {
            targets.put(target, pTargets.getProperty(target));
        }
        logger.info("Done.");
    }
}