Switching to new ehcache version
This commit is contained in:
parent
abd4c736ce
commit
942e173d4b
7
pom.xml
7
pom.xml
|
@ -357,7 +357,7 @@
|
|||
<version>${archiva.comp.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<groupId>org.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
<version>${ehcache.version}</version>
|
||||
</dependency>
|
||||
|
@ -387,11 +387,6 @@
|
|||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons.lang3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-digester</groupId>
|
||||
<artifactId>commons-digester</artifactId>
|
||||
<version>${commons.digester.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
|
|
|
@ -28,6 +28,6 @@
|
|||
default-lazy-init="true">
|
||||
|
||||
<context:annotation-config />
|
||||
<context:component-scan base-package="org.apache.archiva.redback.common.ldap,org.apache.archiva.redback.common.ldap.connection"/>
|
||||
<context:component-scan base-package="org.apache.archiva.redback.common.ldap,org.apache.archiva.redback.common.ldap.connection,org.apache.archiva.redback.common.ldap.role"/>
|
||||
|
||||
</beans>
|
|
@ -125,7 +125,7 @@
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<groupId>org.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.archiva.redback.integration.mail;
|
|||
*/
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import org.apache.archiva.redback.keys.AuthenticationKey;
|
||||
import org.apache.archiva.redback.keys.KeyManager;
|
||||
import org.apache.archiva.redback.keys.KeyManagerException;
|
||||
|
@ -68,7 +67,6 @@ public class MailGeneratorTest
|
|||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
CacheManager.getInstance().clearAll();
|
||||
super.setUp();
|
||||
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
<artifactId>spring-context</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<groupId>org.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.archiva.redback.rest.services;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import org.apache.archiva.components.cache.Cache;
|
||||
import org.apache.archiva.redback.authentication.AuthenticationException;
|
||||
import org.apache.archiva.redback.authentication.TokenBasedAuthenticationDataSource;
|
||||
|
@ -39,7 +38,6 @@ import org.apache.archiva.redback.policy.UserSecurityPolicy;
|
|||
import org.apache.archiva.redback.rbac.RBACManager;
|
||||
import org.apache.archiva.redback.rbac.RbacManagerException;
|
||||
import org.apache.archiva.redback.rbac.UserAssignment;
|
||||
import org.apache.archiva.redback.rest.api.model.ActionStatus;
|
||||
import org.apache.archiva.redback.rest.api.model.ErrorMessage;
|
||||
import org.apache.archiva.redback.rest.api.model.Operation;
|
||||
import org.apache.archiva.redback.rest.api.model.Permission;
|
||||
|
@ -423,16 +421,6 @@ public class DefaultUserService
|
|||
usersCache.remove( userName );
|
||||
}
|
||||
|
||||
CacheManager cacheManager = CacheManager.getInstance();
|
||||
String[] caches = cacheManager.getCacheNames();
|
||||
for ( String cacheName : caches )
|
||||
{
|
||||
if ( StringUtils.startsWith( cacheName, "org.apache.archiva.redback.rbac.jdo" ) )
|
||||
{
|
||||
cacheManager.getCache( cacheName ).removeAll();
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.archiva.redback.rest.services.v2;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import org.apache.archiva.components.cache.Cache;
|
||||
import org.apache.archiva.components.rest.model.PagedResult;
|
||||
import org.apache.archiva.redback.authentication.AuthenticationException;
|
||||
|
@ -518,16 +517,6 @@ public class DefaultUserService extends BaseRedbackService
|
|||
usersCache.remove( userId );
|
||||
}
|
||||
|
||||
CacheManager cacheManager = CacheManager.getInstance( );
|
||||
String[] caches = cacheManager.getCacheNames( );
|
||||
for ( String cacheName : caches )
|
||||
{
|
||||
if ( StringUtils.startsWith( cacheName, "org.apache.archiva.redback.rbac.jdo" ) )
|
||||
{
|
||||
cacheManager.getCache( cacheName ).removeAll( );
|
||||
}
|
||||
}
|
||||
|
||||
return Response.ok( ).build( );
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<groupId>org.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.archiva.redback.keys.KeyManagerException;
|
|||
import org.apache.archiva.redback.keys.KeyNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.util.List;
|
||||
|
@ -149,4 +150,13 @@ public class CachedKeyManager
|
|||
{
|
||||
this.keysCache = keysCache;
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
keysCache.clear();
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
void shutdown() {
|
||||
clearCache( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.archiva.redback.keys.cached;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import org.apache.archiva.redback.keys.KeyManager;
|
||||
import org.apache.archiva.redback.keys.KeyManagerTestCase;
|
||||
import org.junit.Before;
|
||||
|
@ -55,7 +54,6 @@ public class CachedKeyManagerTest
|
|||
protected void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
CacheManager.getInstance().removeAllCaches();
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<groupId>org.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.util.Collection;
|
||||
|
@ -187,8 +188,7 @@ public class CachedRbacManager
|
|||
}
|
||||
finally
|
||||
{
|
||||
// FIXME cleanup
|
||||
//EhcacheUtils.clearAllCaches( log() );
|
||||
clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -548,6 +548,11 @@ public class CachedRbacManager
|
|||
( (RBACManagerListener) this.rbacImpl ).rbacInit( freshdb );
|
||||
}
|
||||
// lookup all Cache and clear all ?
|
||||
clearCache( );
|
||||
}
|
||||
|
||||
public void clearCache( )
|
||||
{
|
||||
this.resourcesCache.clear();
|
||||
this.operationsCache.clear();
|
||||
this.permissionsCache.clear();
|
||||
|
@ -1054,4 +1059,9 @@ public class CachedRbacManager
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
void shutdown() {
|
||||
clearCache( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,16 +19,14 @@ package org.apache.archiva.redback.rbac.cached;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import org.apache.archiva.redback.rbac.RBACManager;
|
||||
import org.apache.archiva.redback.tests.AbstractRbacManagerTestCase;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import org.junit.After;
|
||||
import org.junit.BeforeClass;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
@DirtiesContext( classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD )
|
||||
public class CachedRbacManagerTest
|
||||
|
@ -59,7 +57,6 @@ public class CachedRbacManagerTest
|
|||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
CacheManager.getInstance().clearAll();
|
||||
setRbacManager( rbacManager );
|
||||
|
||||
assertTrue( getRbacManager() instanceof CachedRbacManager );
|
||||
|
@ -76,7 +73,6 @@ public class CachedRbacManagerTest
|
|||
public void testStoreInitialization()
|
||||
throws Exception
|
||||
{
|
||||
CacheManager.getInstance().clearAll();
|
||||
rbacManager.eraseDatabase();
|
||||
super.testStoreInitialization();
|
||||
}
|
||||
|
|
|
@ -107,7 +107,6 @@ public class JpaRbacManagerTest
|
|||
public void testLargeApplicationInit()
|
||||
throws RbacManagerException
|
||||
{
|
||||
this.clearCache();
|
||||
super.testLargeApplicationInit();
|
||||
}
|
||||
|
||||
|
@ -115,7 +114,6 @@ public class JpaRbacManagerTest
|
|||
public void testGetRolesDeep()
|
||||
throws RbacManagerException
|
||||
{
|
||||
this.clearCache();
|
||||
super.testGetRolesDeep();
|
||||
}
|
||||
|
||||
|
@ -124,7 +122,6 @@ public class JpaRbacManagerTest
|
|||
public void testStoreInitialization()
|
||||
throws Exception
|
||||
{
|
||||
this.clearCache();
|
||||
rbacManager.eraseDatabase();
|
||||
eventTracker.rbacInit( true );
|
||||
super.testStoreInitialization();
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<groupId>org.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
|
|
@ -22,7 +22,10 @@ package org.apache.archiva.redback.rbac.ldap;
|
|||
import org.apache.archiva.components.apacheds.ApacheDs;
|
||||
import org.apache.archiva.redback.policy.PasswordEncoder;
|
||||
import org.apache.archiva.redback.policy.encoders.SHA1PasswordEncoder;
|
||||
import org.apache.archiva.redback.rbac.RbacManagerException;
|
||||
import org.apache.archiva.redback.rbac.RbacPermanentException;
|
||||
import org.apache.archiva.redback.rbac.Role;
|
||||
import org.apache.archiva.redback.rbac.memory.MemoryRole;
|
||||
import org.apache.archiva.redback.tests.AbstractRbacManagerTestCase;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -76,7 +79,6 @@ public class LdapRbacManagerTest
|
|||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
this.clearCache();
|
||||
setRbacManager( rbacManager );
|
||||
|
||||
assertTrue( getRbacManager() instanceof LdapRbacManager );
|
||||
|
@ -263,11 +265,20 @@ public class LdapRbacManagerTest
|
|||
public void testStoreInitialization()
|
||||
throws Exception
|
||||
{
|
||||
this.clearCache();
|
||||
for ( Role role : rbacManager.getAllRoles() )
|
||||
{
|
||||
rbacManager.removeRole( role );
|
||||
try
|
||||
{
|
||||
log.info( "permanent: {}, {}", role.isPermanent( ), role.getClass( ).getName( ) );
|
||||
// Workaround to avoid exception because of permanent role.
|
||||
MemoryRole rRole = new MemoryRole( );
|
||||
rRole.setName( role.getName( ) );
|
||||
rbacManager.removeRole( rRole );
|
||||
} catch ( RbacPermanentException ex ) {
|
||||
// Ignore this
|
||||
}
|
||||
}
|
||||
log.info( "Roles {}", rbacManager.getAllRoles( ).size( ) );
|
||||
eventTracker.clear();
|
||||
super.testStoreInitialization();
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<groupId>org.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.archiva.redback.role;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import org.apache.archiva.redback.rbac.RBACManager;
|
||||
import org.junit.Before;
|
||||
|
||||
|
@ -47,7 +46,6 @@ public class RoleManagerTest
|
|||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
CacheManager.getInstance().clearAll();
|
||||
super.setUp();
|
||||
|
||||
rbacManager = rbacManagerMemory;
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<groupId>org.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ package org.apache.archiva.redback.tests;
|
|||
*/
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import org.apache.archiva.redback.rbac.Operation;
|
||||
import org.apache.archiva.redback.rbac.Permission;
|
||||
import org.apache.archiva.redback.rbac.RBACManager;
|
||||
|
@ -146,10 +145,10 @@ public abstract class AbstractRbacManagerTestCase
|
|||
{
|
||||
assertEventCount();
|
||||
}
|
||||
assertEquals( addedRoleNameCount, eventTracker.addedRoleNames.size() );
|
||||
assertEquals( removedRoleNameCount, eventTracker.removedRoleNames.size() );
|
||||
assertEquals( addedPermissionNames, eventTracker.addedPermissionNames.size() );
|
||||
assertEquals( removedPermissionNames, eventTracker.removedPermissionNames.size() );
|
||||
assertEquals( "Wrong number of added roles", addedRoleNameCount, eventTracker.addedRoleNames.size() );
|
||||
assertEquals( "Wrong number of removed roles", removedRoleNameCount, eventTracker.removedRoleNames.size() );
|
||||
assertEquals( "Wrong number of added permissions", addedPermissionNames, eventTracker.addedPermissionNames.size() );
|
||||
assertEquals( "Wrong number of removed permissions", removedPermissionNames, eventTracker.removedPermissionNames.size() );
|
||||
if ( freshness )
|
||||
{
|
||||
assertTrue( eventTracker.lastDbFreshness.booleanValue() );
|
||||
|
@ -169,7 +168,7 @@ public abstract class AbstractRbacManagerTestCase
|
|||
|
||||
Role added = rbacManager.saveRole( role );
|
||||
|
||||
assertEquals( 1, rbacManager.getAllRoles().size() );
|
||||
assertEquals("Wrong number of roles in the rbac manager", 1, rbacManager.getAllRoles().size() );
|
||||
|
||||
assertNotNull( added );
|
||||
|
||||
|
@ -842,7 +841,7 @@ public abstract class AbstractRbacManagerTestCase
|
|||
public void testGetAssignedPermissionsDeep()
|
||||
throws RbacManagerException
|
||||
{
|
||||
this.clearCache();
|
||||
|
||||
assertNotNull( rbacManager );
|
||||
rbacManager.eraseDatabase();
|
||||
rbacDefaults.createDefaults();
|
||||
|
@ -1008,11 +1007,4 @@ public abstract class AbstractRbacManagerTestCase
|
|||
// do nothing
|
||||
}
|
||||
|
||||
protected void clearCache()
|
||||
{
|
||||
for ( String cacheName : CacheManager.getInstance().getCacheNames() )
|
||||
{
|
||||
CacheManager.getInstance().getCache( cacheName ).removeAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<groupId>org.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.util.List;
|
||||
|
@ -358,4 +359,16 @@ public class CachedUserManager
|
|||
{
|
||||
return "archiva.redback.usermanager.cached";
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the users cache
|
||||
*/
|
||||
public void clearCache() {
|
||||
usersCache.clear( );
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void shutdown() {
|
||||
this.clearCache( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,7 @@ package org.apache.archiva.redback.users.cached;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import net.sf.ehcache.CacheManager;
|
||||
|
||||
import org.apache.archiva.redback.users.UserManager;
|
||||
import org.apache.archiva.redback.users.cached.CachedUserManager;
|
||||
import org.apache.archiva.redback.users.provider.test.AbstractUserManagerTestCase;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
|
@ -63,9 +60,5 @@ public class CachedUserManagerTest
|
|||
super.tearDown();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanCache()
|
||||
{
|
||||
CacheManager.getInstance().removeAllCaches();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue