View Javadoc

1   package org.apache.maven.classrealm;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.List;
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.sonatype.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      /**
40       * Gets the class realm hosting the Maven core.
41       * 
42       * @return The class realm hosting the Maven core, never {@code null}.
43       */
44      ClassRealm getCoreRealm();
45  
46      /**
47       * Creates a new class realm for the specified project and its build extensions.
48       * 
49       * @param model The model of the project for which to create a realm, must not be {@code null}.
50       * @param artifacts The artifacts to add to the class realm, may be {@code null}. Unresolved artifacts (i.e. with a
51       *            missing file) will automatically be excluded from the realm.
52       * @return The new project realm, never {@code null}.
53       */
54      ClassRealm createProjectRealm( Model model, List<Artifact> artifacts );
55  
56      /**
57       * Creates a new class realm for the specified build extension.
58       * 
59       * @param plugin The extension plugin for which to create a realm, must not be {@code null}.
60       * @param artifacts The artifacts to add to the class realm, may be {@code null}. Unresolved artifacts (i.e. with a
61       *            missing file) will automatically be excluded from the realm.
62       * @return The new extension realm, never {@code null}.
63       */
64      ClassRealm createExtensionRealm( Plugin extension, List<Artifact> artifacts );
65  
66      /**
67       * Creates a new class realm for the specified plugin.
68       * 
69       * @param plugin The plugin for which to create a realm, must not be {@code null}.
70       * @param parent The parent realm for the new realm, may be {@code null} to use the Maven core realm.
71       * @param imports The packages/types to import from the parent realm, may be {@code null}.
72       * @param artifacts The artifacts to add to the class realm, may be {@code null}. Unresolved artifacts (i.e. with a
73       *            missing file) will automatically be excluded from the realm.
74       * @return The new plugin realm, never {@code null}.
75       */
76      ClassRealm createPluginRealm( Plugin plugin, ClassLoader parent, List<String> imports, List<Artifact> artifacts );
77  
78  }