View Javadoc

1   /**
2    * Copyright (C) 2010-2012 Joerg Bellmann <joerg.bellmann@googlemail.com>
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.googlecode.t7mp.steps;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  import com.googlecode.t7mp.DefaultPluginLog;
22  import com.googlecode.t7mp.PluginLog;
23  import com.googlecode.t7mp.T7Configuration;
24  import com.googlecode.t7mp.configuration.PluginArtifactResolver;
25  
26  /**
27   * 
28   * Implementation of an {@link Context}.
29   * 
30   * @author Joerg Bellmann
31   *
32   */
33  public class DefaultContext implements Context {
34  
35      protected Map<String, Object> context = new HashMap<String, Object>();
36  
37      protected PluginArtifactResolver artifactResolver;
38      protected T7Configuration configuration;
39      protected PluginLog pluginLog;
40  
41      public DefaultContext(PluginArtifactResolver artifactResolver, T7Configuration configuration) {
42          this(artifactResolver, configuration, new DefaultPluginLog());
43      }
44  
45      public DefaultContext(PluginArtifactResolver artifactResolver, T7Configuration configuration, PluginLog pluginLog) {
46          this.artifactResolver = artifactResolver;
47          this.configuration = configuration;
48          this.pluginLog = pluginLog;
49      }
50  
51      @Override
52      public PluginLog getLog() {
53          return this.pluginLog;
54      }
55  
56      @Override
57      public PluginArtifactResolver getArtifactResolver() {
58          return artifactResolver;
59      }
60  
61      @Override
62      public T7Configuration getConfiguration() {
63          return configuration;
64      }
65  
66      @Override
67      public void put(String key, Object value) {
68          this.context.put(key, value);
69      }
70  
71      @Override
72      public Object get(String key) {
73          return this.context.get(key);
74      }
75  
76      @Override
77      public void clear() {
78          this.context.clear();
79      }
80  
81  }