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.plugin; 20 21 import java.util.List; 22 23 import org.apache.maven.artifact.Artifact; 24 import org.apache.maven.project.ExtensionDescriptor; 25 import org.apache.maven.project.MavenProject; 26 import org.codehaus.plexus.classworlds.realm.ClassRealm; 27 28 /** 29 * Caches extension class realms. <strong>Warning:</strong> This is an internal utility interface that is only public 30 * for technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted 31 * without prior notice. 32 * 33 * @author Igor Fedorenko 34 * @author Benjamin Bentmann 35 */ 36 public interface ExtensionRealmCache { 37 /** 38 * A cache key. 39 */ 40 interface Key { 41 // marker interface for cache keys 42 } 43 44 /** 45 * CacheRecord 46 */ 47 class CacheRecord { 48 49 private final ClassRealm realm; 50 51 private final ExtensionDescriptor descriptor; 52 53 private final List<Artifact> artifacts; 54 55 CacheRecord(ClassRealm realm, ExtensionDescriptor descriptor, List<Artifact> artifacts) { 56 this.realm = realm; 57 this.descriptor = descriptor; 58 this.artifacts = artifacts; 59 } 60 61 public ClassRealm getRealm() { 62 return realm; 63 } 64 65 public ExtensionDescriptor getDescriptor() { 66 return descriptor; 67 } 68 69 public List<Artifact> getArtifacts() { 70 return artifacts; 71 } 72 } 73 74 Key createKey(List<Artifact> extensionArtifacts); 75 76 CacheRecord get(Key key); 77 78 CacheRecord put( 79 Key key, ClassRealm extensionRealm, ExtensionDescriptor extensionDescriptor, List<Artifact> artifacts); 80 81 void flush(); 82 83 /** 84 * Registers the specified cache record for usage with the given project. Integrators can use the information 85 * collected from this method in combination with a custom cache implementation to dispose unused records from the 86 * cache. 87 * 88 * @param project The project that employs the plugin realm, must not be {@code null}. 89 * @param record The cache record being used for the project, must not be {@code null}. 90 */ 91 void register(MavenProject project, Key key, CacheRecord record); 92 }