Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DefaultEnforcementRuleHelper |
|
| 1.1;1.1 |
1 | package org.apache.maven.plugins.enforcer; | |
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.io.File; | |
23 | import java.util.List; | |
24 | import java.util.Map; | |
25 | ||
26 | import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; | |
27 | import org.apache.maven.execution.MavenSession; | |
28 | import org.apache.maven.plugin.logging.Log; | |
29 | import org.codehaus.plexus.PlexusContainer; | |
30 | import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; | |
31 | import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; | |
32 | import org.codehaus.plexus.component.repository.exception.ComponentLookupException; | |
33 | ||
34 | /** | |
35 | * Default implementation of the EnforcementRuleHelper interface. This is used to help retrieve information from the | |
36 | * session and provide useful elements like the log. | |
37 | * | |
38 | * @author <a href="mailto:brianf@apache.org">Brian Fox</a> | |
39 | * @version $Id: DefaultEnforcementRuleHelper.java 805190 2009-08-17 22:30:49Z hboutemy $ | |
40 | */ | |
41 | public class DefaultEnforcementRuleHelper | |
42 | implements EnforcerRuleHelper | |
43 | { | |
44 | ||
45 | /** The log. */ | |
46 | Log log; | |
47 | ||
48 | /** The evaluator. */ | |
49 | ExpressionEvaluator evaluator; | |
50 | ||
51 | /** The session. */ | |
52 | MavenSession session; | |
53 | ||
54 | /** The container. */ | |
55 | PlexusContainer container; | |
56 | ||
57 | /** | |
58 | * Instantiates a new default enforcement rule helper. | |
59 | * | |
60 | * @param session the session | |
61 | * @param evaluator the evaluator | |
62 | * @param log the log | |
63 | * @param container the container | |
64 | */ | |
65 | public DefaultEnforcementRuleHelper( MavenSession session, ExpressionEvaluator evaluator, Log log, | |
66 | PlexusContainer container ) | |
67 | 0 | { |
68 | 0 | this.evaluator = evaluator; |
69 | 0 | this.log = log; |
70 | 0 | this.session = session; |
71 | 0 | if ( container != null ) |
72 | { | |
73 | 0 | this.container = container; |
74 | } | |
75 | else | |
76 | { | |
77 | 0 | this.container = session.getContainer(); |
78 | } | |
79 | 0 | } |
80 | ||
81 | /* | |
82 | * (non-Javadoc) | |
83 | * | |
84 | * @see org.apache.maven.enforcer.rule.api.EnforcerRuleHelper#getLog() | |
85 | */ | |
86 | public Log getLog() | |
87 | { | |
88 | 0 | return log; |
89 | } | |
90 | ||
91 | /* | |
92 | * (non-Javadoc) | |
93 | * | |
94 | * @see org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator#alignToBaseDirectory(java.io.File) | |
95 | */ | |
96 | public File alignToBaseDirectory( File theFile ) | |
97 | { | |
98 | 0 | return evaluator.alignToBaseDirectory( theFile ); |
99 | } | |
100 | ||
101 | /* | |
102 | * (non-Javadoc) | |
103 | * | |
104 | * @see org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator#evaluate(java.lang.String) | |
105 | */ | |
106 | public Object evaluate( String theExpression ) | |
107 | throws ExpressionEvaluationException | |
108 | { | |
109 | 0 | return evaluator.evaluate( theExpression ); |
110 | } | |
111 | ||
112 | /* | |
113 | * (non-Javadoc) | |
114 | * | |
115 | * @see org.apache.maven.shared.enforcer.rule.api.EnforcerRuleHelper#getRuntimeInformation() | |
116 | */ | |
117 | public Object getComponent( Class clazz ) | |
118 | throws ComponentLookupException | |
119 | { | |
120 | 0 | return getComponent( clazz.getName() ); |
121 | } | |
122 | ||
123 | /* | |
124 | * (non-Javadoc) | |
125 | * | |
126 | * @see org.apache.maven.enforcer.rule.api.EnforcerRuleHelper#lookup(java.lang.String) | |
127 | */ | |
128 | public Object getComponent( String theComponentKey ) | |
129 | throws ComponentLookupException | |
130 | { | |
131 | 0 | return container.lookup( theComponentKey ); |
132 | } | |
133 | ||
134 | /* | |
135 | * (non-Javadoc) | |
136 | * | |
137 | * @see org.apache.maven.enforcer.rule.api.EnforcerRuleHelper#lookup(java.lang.String, java.lang.String) | |
138 | */ | |
139 | public Object getComponent( String theRole, String theRoleHint ) | |
140 | throws ComponentLookupException | |
141 | { | |
142 | 0 | return container.lookup( theRole, theRoleHint ); |
143 | } | |
144 | ||
145 | /* | |
146 | * (non-Javadoc) | |
147 | * | |
148 | * @see org.apache.maven.enforcer.rule.api.EnforcerRuleHelper#lookupList(java.lang.String) | |
149 | */ | |
150 | public List getComponentList( String theRole ) | |
151 | throws ComponentLookupException | |
152 | { | |
153 | 0 | return container.lookupList( theRole ); |
154 | } | |
155 | ||
156 | /* | |
157 | * (non-Javadoc) | |
158 | * | |
159 | * @see org.apache.maven.enforcer.rule.api.EnforcerRuleHelper#lookupMap(java.lang.String) | |
160 | */ | |
161 | public Map getComponentMap( String theRole ) | |
162 | throws ComponentLookupException | |
163 | { | |
164 | 0 | return container.lookupMap( theRole ); |
165 | } | |
166 | ||
167 | /* | |
168 | * (non-Javadoc) | |
169 | * | |
170 | * @see org.apache.maven.enforcer.rule.api.EnforcerRuleHelper#getContainer() | |
171 | */ | |
172 | public PlexusContainer getContainer() | |
173 | { | |
174 | 0 | return container; |
175 | } | |
176 | } |