1 package org.apache.maven.plugins.enforcer;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
36
37
38
39
40
41 public class DefaultEnforcementRuleHelper
42 implements EnforcerRuleHelper
43 {
44
45
46 private Log log;
47
48
49 private ExpressionEvaluator evaluator;
50
51
52 private MavenSession session;
53
54
55 private PlexusContainer container;
56
57
58
59
60
61
62
63
64
65 public DefaultEnforcementRuleHelper( MavenSession session, ExpressionEvaluator evaluator, Log log,
66 PlexusContainer container )
67 {
68 this.evaluator = evaluator;
69 this.log = log;
70 this.session = session;
71 if ( container != null )
72 {
73 this.container = container;
74 }
75 else
76 {
77 this.container = session.getContainer();
78 }
79 }
80
81
82
83
84
85
86 public Log getLog()
87 {
88 return log;
89 }
90
91
92
93
94
95
96 public File alignToBaseDirectory( File theFile )
97 {
98 return evaluator.alignToBaseDirectory( theFile );
99 }
100
101
102
103
104
105
106 public Object evaluate( String theExpression )
107 throws ExpressionEvaluationException
108 {
109 return evaluator.evaluate( theExpression );
110 }
111
112
113
114
115
116
117 public Object getComponent( Class clazz )
118 throws ComponentLookupException
119 {
120 return getComponent( clazz.getName() );
121 }
122
123
124
125
126
127
128 public Object getComponent( String theComponentKey )
129 throws ComponentLookupException
130 {
131 return container.lookup( theComponentKey );
132 }
133
134
135
136
137
138
139 public Object getComponent( String theRole, String theRoleHint )
140 throws ComponentLookupException
141 {
142 return container.lookup( theRole, theRoleHint );
143 }
144
145
146
147
148
149
150 public List getComponentList( String theRole )
151 throws ComponentLookupException
152 {
153 return container.lookupList( theRole );
154 }
155
156
157
158
159
160
161 public Map getComponentMap( String theRole )
162 throws ComponentLookupException
163 {
164 return container.lookupMap( theRole );
165 }
166
167
168
169
170
171
172 public PlexusContainer getContainer()
173 {
174 return container;
175 }
176 }