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 */ 34 public interface ExtensionRealmCache { 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 private final ClassRealm realm; 48 49 private final ExtensionDescriptor descriptor; 50 51 private final List<Artifact> artifacts; 52 53 CacheRecord(ClassRealm realm, ExtensionDescriptor descriptor, List<Artifact> artifacts) { 54 this.realm = realm; 55 this.descriptor = descriptor; 56 this.artifacts = artifacts; 57 } 58 59 public ClassRealm getRealm() { 60 return realm; 61 } 62 63 public ExtensionDescriptor getDescriptor() { 64 return descriptor; 65 } 66 67 public List<Artifact> getArtifacts() { 68 return artifacts; 69 } 70 } 71 72 Key createKey(List<Artifact> extensionArtifacts); 73 74 CacheRecord get(Key key); 75 76 CacheRecord put( 77 Key key, ClassRealm extensionRealm, ExtensionDescriptor extensionDescriptor, List<Artifact> artifacts); 78 79 void flush(); 80 81 /** 82 * Registers the specified cache record for usage with the given project. Integrators can use the information 83 * collected from this method in combination with a custom cache implementation to dispose unused records from the 84 * cache. 85 * 86 * @param project The project that employs the plugin realm, must not be {@code null}. 87 * @param record The cache record being used for the project, must not be {@code null}. 88 */ 89 void register(MavenProject project, Key key, CacheRecord record); 90 }