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() + "]");
}
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);
}
};
}
Aggregations