JackrabbitRepositoryFactory rf = new RepositoryFactoryImpl();
Properties prop = new Properties();
prop.setProperty("org.apache.jackrabbit.repository.home", TEST_DIR);
prop.setProperty("org.apache.jackrabbit.repository.conf", TEST_DIR + "/repository.xml");
JackrabbitRepository rep = (JackrabbitRepository) rf.getRepository(prop);
RepositoryManager rm = rf.getRepositoryManager(rep);
// need to login to start the repository
Session session = rep.login(new SimpleCredentials("", "".toCharArray()));
DataStoreGarbageCollector gc = rm.createDataStoreGarbageCollector();
try {
gc.mark();
gc.sweep();
} finally {
gc.close();
}
session.logout();
rm.stop();
}