1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.maven.project; 20 21 import java.util.List; 22 import org.codehaus.plexus.classworlds.realm.ClassRealm; 23 import org.eclipse.aether.graph.DependencyFilter; 24 25 /** 26 * Caches project class realms. <strong>Warning:</strong> This is an internal utility interface that is only public for 27 * technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted without 28 * prior notice. 29 * 30 * @author Igor Fedorenko 31 * @author Benjamin Bentmann 32 */ 33 public interface ProjectRealmCache { 34 35 /** 36 * A cache key. 37 */ 38 interface Key { 39 // marker interface for cache keys 40 } 41 42 /** 43 * CacheRecord 44 */ 45 class CacheRecord { 46 47 public ClassRealm getRealm() { 48 return realm; 49 } 50 51 public DependencyFilter getExtensionArtifactFilter() { 52 return extensionArtifactFilter; 53 } 54 55 private final ClassRealm realm; 56 57 private final DependencyFilter extensionArtifactFilter; 58 59 CacheRecord(ClassRealm realm, DependencyFilter extensionArtifactFilter) { 60 this.realm = realm; 61 this.extensionArtifactFilter = extensionArtifactFilter; 62 } 63 } 64 65 Key createKey(List<? extends ClassRealm> extensionRealms); 66 67 CacheRecord get(Key key); 68 69 CacheRecord put(Key key, ClassRealm projectRealm, DependencyFilter extensionArtifactFilter); 70 71 void flush(); 72 73 /** 74 * Registers the specified cache record for usage with the given project. Integrators can use the information 75 * collected from this method in combination with a custom cache implementation to dispose unused records from the 76 * cache. 77 * 78 * @param project The project that employs the plugin realm, must not be {@code null}. 79 * @param record The cache record being used for the project, must not be {@code null}. 80 */ 81 void register(MavenProject project, Key key, CacheRecord record); 82 }