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.classrealm; 20 21 import java.util.List; 22 import java.util.Map; 23 24 import org.apache.maven.model.Model; 25 import org.apache.maven.model.Plugin; 26 import org.codehaus.plexus.classworlds.realm.ClassRealm; 27 import org.eclipse.aether.artifact.Artifact; 28 29 /** 30 * Manages the class realms used by Maven. <strong>Warning:</strong> This is an internal utility interface that is only 31 * public for technical reasons, it is not part of the public API. In particular, this interface can be changed or 32 * deleted without prior notice. 33 * 34 * @author Benjamin Bentmann 35 */ 36 public interface ClassRealmManager { 37 38 /** 39 * Gets the class realm hosting the Maven core. 40 * 41 * @return The class realm hosting the Maven core, never {@code null}. 42 */ 43 ClassRealm getCoreRealm(); 44 45 /** 46 * Gets the class realm exposing the Maven API. This is basically a restricted view on the Maven core realm. 47 * 48 * @return The class realm exposing the Maven API, never {@code null}. 49 */ 50 ClassRealm getMavenApiRealm(); 51 52 /** 53 * Creates a new class realm for the specified project and its build extensions. 54 * 55 * @param model The model of the project for which to create a realm, must not be {@code null}. 56 * @param artifacts The artifacts to add to the class realm, may be {@code null}. Unresolved artifacts (i.e. with a 57 * missing file) will automatically be excluded from the realm. 58 * @return The new project realm, never {@code null}. 59 */ 60 ClassRealm createProjectRealm(Model model, List<Artifact> artifacts); 61 62 /** 63 * Creates a new class realm for the specified build extension. 64 * 65 * @param extension The extension plugin for which to create a realm, must not be {@code null}. 66 * @param artifacts The artifacts to add to the class realm, may be {@code null}. Unresolved artifacts (i.e. with a 67 * missing file) will automatically be excluded from the realm. 68 * @return The new extension realm, never {@code null}. 69 */ 70 ClassRealm createExtensionRealm(Plugin extension, List<Artifact> artifacts); 71 72 /** 73 * Creates a new class realm for the specified plugin. 74 * 75 * @param plugin The plugin for which to create a realm, must not be {@code null}. 76 * @param parent The parent realm for the new realm, may be {@code null}. 77 * @param parentImports The packages/types to import from the parent realm, may be {@code null}. 78 * @param foreignImports The packages/types to import from foreign realms, may be {@code null}. 79 * @param artifacts The artifacts to add to the class realm, may be {@code null}. Unresolved artifacts (i.e. with a 80 * missing file) will automatically be excluded from the realm. 81 * @return The new plugin realm, never {@code null}. 82 */ 83 ClassRealm createPluginRealm( 84 Plugin plugin, 85 ClassLoader parent, 86 List<String> parentImports, 87 Map<String, ClassLoader> foreignImports, 88 List<Artifact> artifacts); 89 }