]> source.dussan.org Git - archiva.git/commitdiff
package move to o.a.a.r module redback-keys-cached
authorOlivier Lamy <olamy@apache.org>
Sat, 7 Apr 2012 22:05:15 +0000 (22:05 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 7 Apr 2012 22:05:15 +0000 (22:05 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1310886 13f79535-47bb-0310-9956-ffa450edef68

redback-integrations/redback-struts2/redback-struts2-integration/src/test/resources/org/codehaus/plexus/redback/struts2/action/admin/AssignmentsActionTest.xml
redback-integrations/redback-struts2/redback-struts2-integration/src/test/resources/org/codehaus/plexus/redback/struts2/action/admin/UserEditActionTest.xml
redback-integrations/redback-struts2/redback-struts2-integration/src/test/resources/spring-context.xml
redback-keys/redback-keys-providers/redback-keys-cached/src/main/java/org/apache/archiva/redback/keys/cached/CachedKeyManager.java [new file with mode: 0644]
redback-keys/redback-keys-providers/redback-keys-cached/src/main/java/org/codehaus/plexus/redback/keys/cached/CachedKeyManager.java [deleted file]
redback-keys/redback-keys-providers/redback-keys-cached/src/main/resources/META-INF/spring-context.xml
redback-keys/redback-keys-providers/redback-keys-cached/src/test/java/org/apache/archiva/redback/keys/cached/CachedKeyManagerTest.java [new file with mode: 0644]
redback-keys/redback-keys-providers/redback-keys-cached/src/test/java/org/codehaus/plexus/redback/keys/cached/CachedKeyManagerTest.java [deleted file]

index 1705a1fc126c8415d1820c6e374f17e3f13d85c8..d1773a5762e50774dded3093f4824547973784c1 100644 (file)
@@ -89,7 +89,7 @@
     <component>
       <role>org.apache.archiva.redback.keys.KeyManager</role>
       <role-hint>cached</role-hint>
-      <implementation>org.codehaus.plexus.redback.keys.cached.CachedKeyManager</implementation>
+      <implementation>org.apache.archiva.redback.keys.cached.CachedKeyManager</implementation>
       <description>CachedKeyManager</description>
       <requirements>
         <requirement>
index 1705a1fc126c8415d1820c6e374f17e3f13d85c8..d1773a5762e50774dded3093f4824547973784c1 100644 (file)
@@ -89,7 +89,7 @@
     <component>
       <role>org.apache.archiva.redback.keys.KeyManager</role>
       <role-hint>cached</role-hint>
-      <implementation>org.codehaus.plexus.redback.keys.cached.CachedKeyManager</implementation>
+      <implementation>org.apache.archiva.redback.keys.cached.CachedKeyManager</implementation>
       <description>CachedKeyManager</description>
       <requirements>
         <requirement>
index aa9e46143155d4a9378d41509ad01d9ab28da1be..fac9a773f5187574dcacbfbdfe88b450e5a21005 100755 (executable)
     </component>
   -->
 
-  <bean name="keyManager#cached" class="org.codehaus.plexus.redback.keys.cached.CachedKeyManager">
+  <bean name="keyManager#cached" class="org.apache.archiva.redback.keys.cached.CachedKeyManager">
     <property name="keyImpl" ref="keyManager#memory"/>
   </bean>
   <!--
     <component>
       <role>org.apache.archiva.redback.keys.KeyManager</role>
       <role-hint>cached</role-hint>
-      <implementation>org.codehaus.plexus.redback.keys.cached.CachedKeyManager</implementation>
+      <implementation>org.apache.archiva.redback.keys.cached.CachedKeyManager</implementation>
       <description>CachedKeyManager</description>
       <requirements>
         <requirement>
diff --git a/redback-keys/redback-keys-providers/redback-keys-cached/src/main/java/org/apache/archiva/redback/keys/cached/CachedKeyManager.java b/redback-keys/redback-keys-providers/redback-keys-cached/src/main/java/org/apache/archiva/redback/keys/cached/CachedKeyManager.java
new file mode 100644 (file)
index 0000000..bf81a5b
--- /dev/null
@@ -0,0 +1,152 @@
+package org.apache.archiva.redback.keys.cached;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.codehaus.plexus.cache.Cache;
+import org.apache.archiva.redback.keys.AbstractKeyManager;
+import org.apache.archiva.redback.keys.AuthenticationKey;
+import org.apache.archiva.redback.keys.KeyManager;
+import org.apache.archiva.redback.keys.KeyManagerException;
+import org.apache.archiva.redback.keys.KeyNotFoundException;
+import org.springframework.stereotype.Service;
+
+/**
+ * CachedKeyManager 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+@Service("keyManager#cached")
+public class CachedKeyManager
+    extends AbstractKeyManager
+    implements KeyManager
+{
+    @Inject @Named(value="keyManager#jdo")
+    private KeyManager keyImpl;
+
+    @Inject @Named(value="cache#keys")
+    private Cache keysCache;
+
+    public AuthenticationKey addKey( AuthenticationKey key )
+    {
+        if ( key != null )
+        {
+            keysCache.remove( key.getKey() );
+        }
+        return this.keyImpl.addKey( key );
+    }
+
+    public AuthenticationKey createKey( String principal, String purpose, int expirationMinutes )
+        throws KeyManagerException
+    {
+        AuthenticationKey authkey = this.keyImpl.createKey( principal, purpose, expirationMinutes );
+        keysCache.remove( authkey.getKey() );
+        return authkey;
+    }
+
+    public void deleteKey( AuthenticationKey key )
+        throws KeyManagerException
+    {
+        keysCache.remove( key.getKey() );
+        this.keyImpl.deleteKey( key );
+    }
+
+    public void deleteKey( String key )
+        throws KeyManagerException
+    {
+        keysCache.remove( key );
+        this.keyImpl.deleteKey( key );
+    }
+
+    public void eraseDatabase()
+    {
+        try
+        {
+            this.keyImpl.eraseDatabase();
+        }
+        finally
+        {
+            this.keysCache.clear();
+        }
+    }
+
+    public AuthenticationKey findKey( String key )
+        throws KeyNotFoundException, KeyManagerException
+    {
+        try
+        {
+            AuthenticationKey authkey = (AuthenticationKey) keysCache.get( key );
+            if ( authkey != null )
+            {
+                assertNotExpired( authkey );
+                return authkey;
+            }
+            else
+            {
+                authkey = this.keyImpl.findKey( key );
+                keysCache.put( key,authkey );
+                return authkey;
+            }
+        }
+        catch ( KeyNotFoundException knfe )
+        {
+            // this is done to remove keys that have been expired.
+            // TODO: need to make a listener for the key manager.
+            keysCache.remove( key );
+            throw knfe;
+        }
+    }
+
+    public List<AuthenticationKey> getAllKeys()
+    {
+        log.debug( "NOT CACHED - .getAllKeys()" );
+        return this.keyImpl.getAllKeys();
+    }
+
+    public String getId()
+    {
+        return "Cached Key Manager [" + this.keyImpl.getId() + "]";
+    }
+
+    public KeyManager getKeyImpl()
+    {
+        return keyImpl;
+    }
+
+    public void setKeyImpl( KeyManager keyImpl )
+    {
+        this.keyImpl = keyImpl;
+    }
+
+    public Cache getKeysCache()
+    {
+        return keysCache;
+    }
+
+    public void setKeysCache( Cache keysCache )
+    {
+        this.keysCache = keysCache;
+    }
+}
diff --git a/redback-keys/redback-keys-providers/redback-keys-cached/src/main/java/org/codehaus/plexus/redback/keys/cached/CachedKeyManager.java b/redback-keys/redback-keys-providers/redback-keys-cached/src/main/java/org/codehaus/plexus/redback/keys/cached/CachedKeyManager.java
deleted file mode 100644 (file)
index 7c1ea5c..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-package org.codehaus.plexus.redback.keys.cached;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.codehaus.plexus.cache.Cache;
-import org.apache.archiva.redback.keys.AbstractKeyManager;
-import org.apache.archiva.redback.keys.AuthenticationKey;
-import org.apache.archiva.redback.keys.KeyManager;
-import org.apache.archiva.redback.keys.KeyManagerException;
-import org.apache.archiva.redback.keys.KeyNotFoundException;
-import org.springframework.stereotype.Service;
-
-/**
- * CachedKeyManager 
- *
- * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
- * @version $Id$
- */
-@Service("keyManager#cached")
-public class CachedKeyManager
-    extends AbstractKeyManager
-    implements KeyManager
-{
-    @Inject @Named(value="keyManager#jdo")
-    private KeyManager keyImpl;
-
-    @Inject @Named(value="cache#keys")
-    private Cache keysCache;
-
-    public AuthenticationKey addKey( AuthenticationKey key )
-    {
-        if ( key != null )
-        {
-            keysCache.remove( key.getKey() );
-        }
-        return this.keyImpl.addKey( key );
-    }
-
-    public AuthenticationKey createKey( String principal, String purpose, int expirationMinutes )
-        throws KeyManagerException
-    {
-        AuthenticationKey authkey = this.keyImpl.createKey( principal, purpose, expirationMinutes );
-        keysCache.remove( authkey.getKey() );
-        return authkey;
-    }
-
-    public void deleteKey( AuthenticationKey key )
-        throws KeyManagerException
-    {
-        keysCache.remove( key.getKey() );
-        this.keyImpl.deleteKey( key );
-    }
-
-    public void deleteKey( String key )
-        throws KeyManagerException
-    {
-        keysCache.remove( key );
-        this.keyImpl.deleteKey( key );
-    }
-
-    public void eraseDatabase()
-    {
-        try
-        {
-            this.keyImpl.eraseDatabase();
-        }
-        finally
-        {
-            this.keysCache.clear();
-        }
-    }
-
-    public AuthenticationKey findKey( String key )
-        throws KeyNotFoundException, KeyManagerException
-    {
-        try
-        {
-            AuthenticationKey authkey = (AuthenticationKey) keysCache.get( key );
-            if ( authkey != null )
-            {
-                assertNotExpired( authkey );
-                return authkey;
-            }
-            else
-            {
-                authkey = this.keyImpl.findKey( key );
-                keysCache.put( key,authkey );
-                return authkey;
-            }
-        }
-        catch ( KeyNotFoundException knfe )
-        {
-            // this is done to remove keys that have been expired.
-            // TODO: need to make a listener for the key manager.
-            keysCache.remove( key );
-            throw knfe;
-        }
-    }
-
-    public List<AuthenticationKey> getAllKeys()
-    {
-        log.debug( "NOT CACHED - .getAllKeys()" );
-        return this.keyImpl.getAllKeys();
-    }
-
-    public String getId()
-    {
-        return "Cached Key Manager [" + this.keyImpl.getId() + "]";
-    }
-
-    public KeyManager getKeyImpl()
-    {
-        return keyImpl;
-    }
-
-    public void setKeyImpl( KeyManager keyImpl )
-    {
-        this.keyImpl = keyImpl;
-    }
-
-    public Cache getKeysCache()
-    {
-        return keysCache;
-    }
-
-    public void setKeysCache( Cache keysCache )
-    {
-        this.keysCache = keysCache;
-    }
-}
index aa017cf5f0a3a216a701105952d52fca53b9905d..cb8c29f6187dcbf8f02c6798bc61f0139d2ff95a 100644 (file)
@@ -29,7 +29,7 @@
 
   <context:annotation-config />
   <context:component-scan 
-    base-package="org.codehaus.plexus.redback.keys.cached"/>
+    base-package="org.apache.archiva.redback.keys.cached"/>
 
   <bean name="cache#keys" class="org.codehaus.plexus.cache.ehcache.EhcacheCache"
       init-method="initialize">
diff --git a/redback-keys/redback-keys-providers/redback-keys-cached/src/test/java/org/apache/archiva/redback/keys/cached/CachedKeyManagerTest.java b/redback-keys/redback-keys-providers/redback-keys-cached/src/test/java/org/apache/archiva/redback/keys/cached/CachedKeyManagerTest.java
new file mode 100644 (file)
index 0000000..90dca43
--- /dev/null
@@ -0,0 +1,62 @@
+package org.apache.archiva.redback.keys.cached;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import net.sf.ehcache.CacheManager;
+import org.apache.archiva.redback.keys.KeyManager;
+import org.apache.archiva.redback.keys.cached.CachedKeyManager;
+import org.codehaus.plexus.redback.keys.KeyManagerTestCase;
+import org.junit.Before;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ * CachedKeyManagerTest
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class CachedKeyManagerTest
+    extends KeyManagerTestCase
+{
+
+    @Inject
+    @Named( value = "keyManager#cached" )
+    KeyManager manager;
+
+    @Before
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        setKeyManager( manager );
+
+        assertTrue( manager instanceof CachedKeyManager );
+    }
+
+    protected void tearDown()
+        throws Exception
+    {
+        CacheManager.getInstance().removalAll();
+        super.tearDown();
+    }
+}
diff --git a/redback-keys/redback-keys-providers/redback-keys-cached/src/test/java/org/codehaus/plexus/redback/keys/cached/CachedKeyManagerTest.java b/redback-keys/redback-keys-providers/redback-keys-cached/src/test/java/org/codehaus/plexus/redback/keys/cached/CachedKeyManagerTest.java
deleted file mode 100644 (file)
index aaea862..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.codehaus.plexus.redback.keys.cached;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import net.sf.ehcache.CacheManager;
-import org.apache.archiva.redback.keys.KeyManager;
-import org.codehaus.plexus.redback.keys.KeyManagerTestCase;
-import org.junit.Before;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-/**
- * CachedKeyManagerTest
- *
- * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class CachedKeyManagerTest
-    extends KeyManagerTestCase
-{
-
-    @Inject
-    @Named( value = "keyManager#cached" )
-    KeyManager manager;
-
-    @Before
-    public void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        setKeyManager( manager );
-
-        assertTrue( manager instanceof CachedKeyManager );
-    }
-
-    protected void tearDown()
-        throws Exception
-    {
-        CacheManager.getInstance().removalAll();
-        super.tearDown();
-    }
-}