Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
55 changed files
with
4,724 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -49,6 +49,7 @@ | ||
<module>spring-apacheds</module> | ||
<module>graph</module> | ||
<module>spring-registry</module> | ||
<module>spring-cache</module> | ||
</modules> | ||
|
||
<scm> | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,70 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ 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. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.apache.archiva.components</groupId> | ||
<artifactId>archiva-components</artifactId> | ||
<version>3.0-SNAPSHOT</version> | ||
</parent> | ||
<groupId>org.apache.archiva.components.cache</groupId> | ||
<artifactId>archiva-components-spring-cache</artifactId> | ||
<name>Archiva Components :: Spring Cache</name> | ||
<version>3.0-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<description>Cache API with various implementations : simple HashMap, ehcache, oscache. Based on Spring container. | ||
</description> | ||
<url>${webUrl}/spring-cache/</url> | ||
<properties> | ||
<site.staging.base>${project.parent.basedir}</site.staging.base> | ||
</properties> | ||
|
||
<modules> | ||
<module>spring-cache-api</module> | ||
<module>spring-cache-test</module> | ||
<module>spring-cache-providers</module> | ||
</modules> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<reporting> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jxr-plugin</artifactId> | ||
<reportSets> | ||
<reportSet> | ||
<id>aggregate</id> | ||
<inherited>false</inherited> | ||
<reports> | ||
<report>aggregate</report> | ||
</reports> | ||
</reportSet> | ||
</reportSets> | ||
</plugin> | ||
</plugins> | ||
</reporting> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ 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. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.archiva.components.cache</groupId> | ||
<artifactId>archiva-components-spring-cache</artifactId> | ||
<version>3.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>archiva-components-spring-cache-api</artifactId> | ||
|
||
<name>Archiva Components :: Spring Cache API</name> | ||
<properties> | ||
<site.staging.base>${project.parent.basedir}</site.staging.base> | ||
</properties> | ||
<description>Common Cache API.</description> | ||
|
||
<url>${webUrl}/spring-cache/${project.artifactId}</url> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.inject</groupId> | ||
<artifactId>javax.inject</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.annotation</groupId> | ||
<artifactId>javax.annotation-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,75 @@ | ||
package org.apache.archiva.components.cache; | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @author Olivier Lamy | ||
* @since 2.1 | ||
*/ | ||
public abstract class AbstractCache<V, T> | ||
implements Cache<V, T> | ||
{ | ||
private int timeToIdleSeconds = 0; | ||
|
||
private int timeToLiveSeconds = 0; | ||
|
||
private int maxElementsInMemory = 0; | ||
|
||
private int maxElementsOnDisk = 0; | ||
|
||
public int getTimeToIdleSeconds( ) | ||
{ | ||
return timeToIdleSeconds; | ||
} | ||
|
||
public void setTimeToIdleSeconds( int timeToIdleSeconds ) | ||
{ | ||
this.timeToIdleSeconds = timeToIdleSeconds; | ||
} | ||
|
||
public int getTimeToLiveSeconds( ) | ||
{ | ||
return timeToLiveSeconds; | ||
} | ||
|
||
public void setTimeToLiveSeconds( int timeToLiveSeconds ) | ||
{ | ||
this.timeToLiveSeconds = timeToLiveSeconds; | ||
} | ||
|
||
public int getMaxElementsInMemory( ) | ||
{ | ||
return maxElementsInMemory; | ||
} | ||
|
||
public void setMaxElementsInMemory( int maxElementsInMemory ) | ||
{ | ||
this.maxElementsInMemory = maxElementsInMemory; | ||
} | ||
|
||
public int getMaxElementsOnDisk( ) | ||
{ | ||
return maxElementsOnDisk; | ||
} | ||
|
||
public void setMaxElementsOnDisk( int maxElementsOnDisk ) | ||
{ | ||
this.maxElementsOnDisk = maxElementsOnDisk; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,79 @@ | ||
package org.apache.archiva.components.cache; | ||
|
||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @author Olivier Lamy | ||
*/ | ||
public abstract class AbstractCacheStatistics | ||
implements CacheStatistics | ||
{ | ||
|
||
private long cacheHits; | ||
|
||
private long cacheMiss; | ||
|
||
public AbstractCacheStatistics( ) | ||
{ | ||
this.cacheHits = 0; | ||
this.cacheMiss = 0; | ||
} | ||
|
||
public long getCacheHits( ) | ||
{ | ||
return this.cacheHits; | ||
} | ||
|
||
public long getCacheMiss( ) | ||
{ | ||
return this.cacheMiss; | ||
} | ||
|
||
public double getCacheHitRate( ) | ||
{ | ||
return cacheHits == 0 && cacheMiss == 0 ? 0 : (double) cacheHits / (double) ( cacheHits + cacheMiss ); | ||
} | ||
|
||
public abstract long getSize( ); | ||
|
||
public void hit( ) | ||
{ | ||
this.cacheHits++; | ||
} | ||
|
||
public void miss( ) | ||
{ | ||
this.cacheMiss++; | ||
} | ||
|
||
public void clear( ) | ||
{ | ||
this.cacheHits = 0; | ||
this.cacheMiss = 0; | ||
} | ||
|
||
/** | ||
* @return default implementation return 0 | ||
*/ | ||
public long getInMemorySize( ) | ||
{ | ||
return 0; | ||
} | ||
} |
Oops, something went wrong.