1 /* 
2  * Copyright 2005 Paul Hinds
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 */
16package org.tp23.antinstaller.runtime;
17
18import org.tp23.antinstaller.InstallerContext;
19import org.tp23.antinstaller.antmod.RuntimeLauncher;
20import org.tp23.antinstaller.page.Page;
21
22/**
23 * Abstract Runner superclass that handles the runPost(page) to execute
24 * ant tasks mid display.
25 * @author teknopaul
26 */
27public abstract class AntRunner implements Runner{
28
29    private RuntimeLauncher launcher = null;
30    private InstallerContext ctx;
31    
32    public AntRunner(InstallerContext ctx) {
33        this.ctx = ctx;
34    }
35
36    protected void runPost(Page page){
37        String postTarget = page.getPostDisplayTarget();
38        if(postTarget != null){
39            if(launcher == null){
40                prepareLauncher();
41            }
42            launcher.updateProps();
43            launcher.run(postTarget);
44        }
45    }
46    /**
47     * This should never get run if there are no postTargets
48     *
49     */
50    private void prepareLauncher(){
51        launcher = new RuntimeLauncher(ctx);
52        launcher.parseProject();
53    }
54}
55