001 package org.apache.maven.plugin; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022 import java.util.List; 023 import java.util.Map; 024 025 import org.apache.maven.artifact.Artifact; 026 import org.apache.maven.model.Plugin; 027 import org.apache.maven.project.MavenProject; 028 import org.codehaus.plexus.classworlds.realm.ClassRealm; 029 import org.eclipse.aether.RepositorySystemSession; 030 import org.eclipse.aether.graph.DependencyFilter; 031 import org.eclipse.aether.repository.RemoteRepository; 032 033 /** 034 * Caches plugin class realms. <strong>Warning:</strong> This is an internal utility interface that is only public for 035 * technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted without 036 * prior notice. 037 * 038 * @author Igor Fedorenko 039 * @author Benjamin Bentmann 040 */ 041 public interface PluginRealmCache 042 { 043 044 public static class CacheRecord 045 { 046 public final ClassRealm realm; 047 048 public final List<Artifact> artifacts; 049 050 public CacheRecord( ClassRealm realm, List<Artifact> artifacts ) 051 { 052 this.realm = realm; 053 this.artifacts = artifacts; 054 } 055 } 056 057 /** 058 * A cache key. 059 */ 060 interface Key 061 { 062 // marker interface for cache keys 063 } 064 065 Key createKey( Plugin plugin, ClassLoader parentRealm, Map<String, ClassLoader> foreignImports, 066 DependencyFilter dependencyFilter, List<RemoteRepository> repositories, 067 RepositorySystemSession session ); 068 069 CacheRecord get( Key key ); 070 071 CacheRecord put( Key key, ClassRealm pluginRealm, List<Artifact> pluginArtifacts ); 072 073 void flush(); 074 075 /** 076 * Registers the specified cache record for usage with the given project. Integrators can use the information 077 * collected from this method in combination with a custom cache implementation to dispose unused records from the 078 * cache. 079 * 080 * @param project The project that employs the plugin realm, must not be {@code null}. 081 * @param record The cache record being used for the project, must not be {@code null}. 082 */ 083 void register( MavenProject project, CacheRecord record ); 084 085 }