Return-Path: Delivered-To: apmail-avalon-cvs-archive@www.apache.org Received: (qmail 9615 invoked from network); 27 Jun 2004 15:24:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 27 Jun 2004 15:24:07 -0000 Received: (qmail 21456 invoked by uid 500); 27 Jun 2004 15:24:07 -0000 Delivered-To: apmail-avalon-cvs-archive@avalon.apache.org Received: (qmail 21297 invoked by uid 500); 27 Jun 2004 15:24:04 -0000 Mailing-List: contact cvs-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list cvs@avalon.apache.org Received: (qmail 21223 invoked by uid 99); 27 Jun 2004 15:24:02 -0000 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Sun, 27 Jun 2004 08:24:01 -0700 Received: (qmail 9589 invoked by uid 65534); 27 Jun 2004 15:23:58 -0000 Date: 27 Jun 2004 15:23:58 -0000 Message-ID: <20040627152358.9585.qmail@minotaur.apache.org> From: mcconnell@apache.org To: cvs@avalon.apache.org Subject: svn commit: rev 22201 - in avalon/trunk/central/laboratory/cache: . etc etc/main etc/main/BLOCK-INF src src/main src/main/org src/main/org/apache src/main/org/apache/avalon src/main/org/apache/avalon/cache X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: mcconnell Date: Sun Jun 27 08:23:57 2004 New Revision: 22201 Added: avalon/trunk/central/laboratory/cache/ avalon/trunk/central/laboratory/cache/build.xml avalon/trunk/central/laboratory/cache/etc/ avalon/trunk/central/laboratory/cache/etc/main/ avalon/trunk/central/laboratory/cache/etc/main/BLOCK-INF/ avalon/trunk/central/laboratory/cache/etc/main/BLOCK-INF/block.xml avalon/trunk/central/laboratory/cache/src/ avalon/trunk/central/laboratory/cache/src/main/ avalon/trunk/central/laboratory/cache/src/main/org/ avalon/trunk/central/laboratory/cache/src/main/org/apache/ avalon/trunk/central/laboratory/cache/src/main/org/apache/avalon/ avalon/trunk/central/laboratory/cache/src/main/org/apache/avalon/cache/ avalon/trunk/central/laboratory/cache/src/main/org/apache/avalon/cache/DefaultCache.java avalon/trunk/central/laboratory/cache/src/main/org/apache/avalon/cache/DefaultCache.xconfig avalon/trunk/central/laboratory/cache/src/main/org/apache/avalon/cache/package.html Log: Add private repository cache component. Added: avalon/trunk/central/laboratory/cache/build.xml ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/cache/build.xml Sun Jun 27 08:23:57 2004 @@ -0,0 +1,13 @@ + + + + + + + + + + + + Added: avalon/trunk/central/laboratory/cache/etc/main/BLOCK-INF/block.xml ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/cache/etc/main/BLOCK-INF/block.xml Sun Jun 27 08:23:57 2004 @@ -0,0 +1,33 @@ + + + + + + + + + + jar:avalon/framework/avalon-framework-api#4.3.0-DEV + jar:avalon/repository/avalon-repository-main#2.1.0-DEV + jar:avalon/repository/avalon-repository-spi#2.0.0 + jar:avalon/repository/avalon-repository-api#2.1.0-DEV + jar:avalon/repository/avalon-repository-util#2.0.0 + jar:avalon/util/avalon-util-exception#1.0.0 + jar:avalon/util/avalon-util-env#1.1.1 + jar:avalon/util/avalon-util-i18n#1.0.0 + jar:avalon/util/avalon-util-criteria#1.1.0 + jar:avalon/util/avalon-util-defaults#1.2.1 + jar:avalon/planet/avalon-planet-cache#1.0.0-DEV + + + + + + + + + + Added: avalon/trunk/central/laboratory/cache/src/main/org/apache/avalon/cache/DefaultCache.java ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/cache/src/main/org/apache/avalon/cache/DefaultCache.java Sun Jun 27 08:23:57 2004 @@ -0,0 +1,258 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed 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. + */ + +package org.apache.avalon.cache; + +import java.net.URL; +import java.io.File; +import java.io.IOException; +import javax.naming.directory.Attributes; + +import org.apache.avalon.framework.logger.Logger; +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.context.ContextException; +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.configuration.ConfigurationException; + +import org.apache.avalon.repository.Artifact; +import org.apache.avalon.repository.Repository; +import org.apache.avalon.repository.RepositoryException; +import org.apache.avalon.repository.provider.InitialContext; +import org.apache.avalon.repository.provider.InitialContextFactory; +import org.apache.avalon.repository.main.DefaultInitialContextFactory; + +/** + * A component implementing a file cache using the Avalon Repository API + * as the service contract. + * + * @avalon.component name="cache" lifestyle="singleton" + * @avalon.service type="org.apache.avalon.repository.Repository" + * @avalon.attribute key="urn:composition:deployment.timeout" value="0" + * @author Avalon Development Team + * @version $Revision: 1.6 $ + */ +public class DefaultCache implements Repository +{ + public static final String DEFAULT_CACHE_KEY = "cache"; + public static final String DEFAULT_CACHE_NAME = "cache"; + public static final String CACHE_DIR_KEY = "urn:avalon:cache.dir"; + public static final String CACHE_KEY_KEY = "urn:avalon:cache.key"; + + private final Logger m_logger; + private final Repository m_repository; + + /** + * Creation of a new cashe instance. The cache implementation + * will establish a cache relative to the supplied context + * entry urn:avalon:cache.dir" if supplied (optional context entry). + * If not declared the cache will be established under ${avalon.home}/cache + * (where ${avalon.home} is the value of the file returned from + * "urn:avalon:home". + * + * @avalon.entry key="urn:avalon:home" type="java.io.File" + * @avalon.entry key="urn:avalon:cache.dir" type="java.io.File" optional="true" + * @avalon.entry key="urn:avalon:cache.key" optional="true" + * + * @param logger the assigned logging channel + * @param context the component context + * @param config the component configuration + */ + public DefaultCache( Logger logger, Context context, Configuration config ) + throws ContextException, ConfigurationException, + RepositoryException, IOException + { + m_logger = logger; + + File basedir = (File) context.get( "urn:avalon:home" ); + File cache = getCacheDirectory( basedir, context ); + String key = getCacheKey( context ); + + + String host = config.getAttribute( "default" ); + Configuration conf = config.getChild( "hosts" ); + Configuration[] children = conf.getChildren( "host" ); + String[] hosts = new String[ children.length ]; + for( int i=0; i 0 ) + { + factory.setHosts( hosts ); + } + else + { + factory.setHosts( new String[]{ host } ); + } + + getLogger().debug( "Repository context creation." ); + + InitialContext context = factory.createInitialContext(); + + // + // prints out the working and cache directory, and the + // set of initial hosts assigned to the initial context + // + + if( getLogger().isDebugEnabled() ) + { + getLogger().debug( + "InitialContext work: " + + context.getInitialWorkingDirectory() ); + getLogger().debug( + "InitialContext cache: " + + context.getInitialCacheDirectory() ); + final String[] theHosts = context.getInitialHosts(); + for( int i=0; i + + + Added: avalon/trunk/central/laboratory/cache/src/main/org/apache/avalon/cache/package.html ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/cache/src/main/org/apache/avalon/cache/package.html Sun Jun 27 08:23:57 2004 @@ -0,0 +1,5 @@ + + +

+A component that implements a repository service.

+ --------------------------------------------------------------------- To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org For additional commands, e-mail: cvs-help@avalon.apache.org