1 package org.apache.continuum.buildagent.build.execution.manager;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.continuum.buildagent.build.execution.ContinuumAgentBuildExecutor;
23 import org.apache.maven.continuum.ContinuumException;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 import java.util.HashMap;
28 import java.util.Map;
29
30
31
32
33
34 public class DefaultBuildAgentBuildExecutorManager
35 implements BuildAgentBuildExecutorManager
36 {
37 private static final Logger log = LoggerFactory.getLogger( DefaultBuildAgentBuildExecutorManager.class );
38
39
40
41
42 private Map<String, ContinuumAgentBuildExecutor> executors;
43
44
45
46
47
48 public void initialize()
49 {
50 if ( executors == null )
51 {
52 executors = new HashMap<String, ContinuumAgentBuildExecutor>();
53 }
54
55 if ( executors.size() == 0 )
56 {
57 log.warn( "No build executors defined." );
58 }
59 else
60 {
61 log.info( "Build executors:" );
62
63 for ( String key : executors.keySet() )
64 {
65 log.info( " " + key );
66 }
67 }
68 }
69
70
71
72
73
74 public ContinuumAgentBuildExecutor getBuildExecutor( String builderType )
75 throws ContinuumException
76 {
77 ContinuumAgentBuildExecutor executor = executors.get( builderType );
78
79 if ( executor == null )
80 {
81 throw new ContinuumException( "No such executor: '" + builderType + "'." );
82 }
83
84 return executor;
85 }
86
87 public boolean hasBuildExecutor( String executorId )
88 {
89 return executors.containsKey( executorId );
90 }
91 }