Search in sources :

Example 1 with BeanMap

use of org.apache.commons.collections.BeanMap in project iaf by ibissource.

the class JmsRealm method copyRealm.

/**
 * copies matching properties to any other class
 */
public void copyRealm(Object destination) {
    String logPrefixDest = destination.getClass().getName() + " ";
    if (destination instanceof INamedObject) {
        INamedObject namedDestination = (INamedObject) destination;
        logPrefixDest += "[" + namedDestination.getName() + "] ";
    }
    try {
        BeanMap thisBeanMap = new BeanMap(this);
        BeanMap destinationBeanMap = new BeanMap(destination);
        Iterator<String> iterator = thisBeanMap.keyIterator();
        while (iterator.hasNext()) {
            String key = iterator.next();
            Object value = thisBeanMap.get(key);
            if (value != null && !key.equals("class") && destinationBeanMap.containsKey(key)) {
                PropertyUtils.setProperty(destination, key, value);
            }
        }
    } catch (Exception e) {
        log.error(logPrefixDest + "unable to copy properties of JmsRealm", e);
    }
    log.info(logPrefixDest + "loaded properties from jmsRealm [" + toString() + "]");
}
Also used : BeanMap(org.apache.commons.collections.BeanMap) INamedObject(nl.nn.adapterframework.core.INamedObject) INamedObject(nl.nn.adapterframework.core.INamedObject) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 2 with BeanMap

use of org.apache.commons.collections.BeanMap in project jackrabbit by apache.

the class TestRepository method getIntegratedInstance.

/**
 * Attempts to retrieve the test repository instance used by the
 * Jackrabbit main test suite without having a direct dependency to any
 * of the classes in src/test/java. This method assumes that we are
 * running within the Jackrabbit main test suite if the AbstractJCRTest
 * class is available. The initialized RepositoryHelper instance is
 * retrieved from the static "helper" field of the AbstractJCRTest class,
 * and the underlying repository and configured superuser credentials are
 * extracted from the helper instance. This information is in turn used
 * to create a custom Repository adapter that delegates calls to the
 * underlying repository and uses the superuser credentials for the login
 * methods where no credentials are passed by the client.
 *
 * @return test repository instance
 * @throws Exception if the test repository could not be retrieved
 */
private static Repository getIntegratedInstance() throws Exception {
    Class test = Class.forName("org.apache.jackrabbit.test.AbstractJCRTest");
    Map helper = new BeanMap(test.getField("helper").get(null));
    final Repository repository = (Repository) helper.get("repository");
    final Credentials superuser = (Credentials) helper.get("superuserCredentials");
    return new ProxyRepository(new RepositoryFactory() {

        public Repository getRepository() throws RepositoryException {
            return repository;
        }
    }) {

        public Session login(String workspace) throws RepositoryException {
            return repository.login(superuser, workspace);
        }

        public Session login() throws RepositoryException {
            return repository.login(superuser);
        }
    };
}
Also used : BeanMap(org.apache.commons.collections.BeanMap) Repository(javax.jcr.Repository) ProxyRepository(org.apache.jackrabbit.commons.repository.ProxyRepository) ProxyRepository(org.apache.jackrabbit.commons.repository.ProxyRepository) RepositoryException(javax.jcr.RepositoryException) RepositoryFactory(org.apache.jackrabbit.commons.repository.RepositoryFactory) Map(java.util.Map) BeanMap(org.apache.commons.collections.BeanMap) Credentials(javax.jcr.Credentials)

Aggregations

BeanMap (org.apache.commons.collections.BeanMap)2 Map (java.util.Map)1 Credentials (javax.jcr.Credentials)1 Repository (javax.jcr.Repository)1 RepositoryException (javax.jcr.RepositoryException)1 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)1 INamedObject (nl.nn.adapterframework.core.INamedObject)1 ProxyRepository (org.apache.jackrabbit.commons.repository.ProxyRepository)1 RepositoryFactory (org.apache.jackrabbit.commons.repository.RepositoryFactory)1