1 | package org.apache.maven.continuum.execution.manager; |
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.HashMap; |
23 | import java.util.Map; |
24 | |
25 | import org.apache.maven.continuum.ContinuumException; |
26 | import org.apache.maven.continuum.execution.ContinuumBuildExecutor; |
27 | import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; |
28 | import org.slf4j.Logger; |
29 | import org.slf4j.LoggerFactory; |
30 | |
31 | /** |
32 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> |
33 | * @version $Id: DefaultBuildExecutorManager.java 764863 2009-04-14 16:28:12Z evenisse $ |
34 | * @plexus.component role="org.apache.maven.continuum.execution.manager.BuildExecutorManager" |
35 | * role-hint"default" |
36 | */ |
37 | public class DefaultBuildExecutorManager |
38 | implements BuildExecutorManager, Initializable |
39 | { |
40 | private static final Logger log = LoggerFactory.getLogger( DefaultBuildExecutorManager.class ); |
41 | |
42 | /** |
43 | * @plexus.requirement role="org.apache.maven.continuum.execution.ContinuumBuildExecutor" |
44 | */ |
45 | private Map<String, ContinuumBuildExecutor> executors; |
46 | |
47 | // ---------------------------------------------------------------------- |
48 | // Component Lifecycle |
49 | // ---------------------------------------------------------------------- |
50 | |
51 | public void initialize() |
52 | { |
53 | if ( executors == null ) |
54 | { |
55 | executors = new HashMap<String, ContinuumBuildExecutor>(); |
56 | } |
57 | |
58 | if ( executors.size() == 0 ) |
59 | { |
60 | log.warn( "No build executors defined." ); |
61 | } |
62 | else |
63 | { |
64 | log.info( "Build executors:" ); |
65 | |
66 | for ( String key : executors.keySet() ) |
67 | { |
68 | log.info( " " + key ); |
69 | } |
70 | } |
71 | } |
72 | |
73 | // ---------------------------------------------------------------------- |
74 | // BuildExecutorManager Implementation |
75 | // ---------------------------------------------------------------------- |
76 | |
77 | public ContinuumBuildExecutor getBuildExecutor( String builderType ) |
78 | throws ContinuumException |
79 | { |
80 | ContinuumBuildExecutor executor = executors.get( builderType ); |
81 | |
82 | if ( executor == null ) |
83 | { |
84 | throw new ContinuumException( "No such executor: '" + builderType + "'." ); |
85 | } |
86 | |
87 | return executor; |
88 | } |
89 | |
90 | public boolean hasBuildExecutor( String executorId ) |
91 | { |
92 | return executors.containsKey( executorId ); |
93 | } |
94 | } |