KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > core > system > StandaloneApplicationContext


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11  * the license for the specific language governing your rights and limitations.
12  *
13  * @created Jun 22, 2005
14  * @author James Dixon
15  *
16  */

17
18 package org.pentaho.core.system;
19
20 import java.io.File JavaDoc;
21 import java.util.*;
22
23 public class StandaloneApplicationContext implements IApplicationContext {
24
25     private String JavaDoc solutionRootPath;
26
27     private String JavaDoc baseUrl;
28
29     private String JavaDoc applicationPath;
30
31     private Properties properties = new Properties();
32
33     private List entryPointsList = new ArrayList();
34     private List exitPointsList = new ArrayList();
35     
36     
37     public StandaloneApplicationContext(String JavaDoc solutionRootPath, String JavaDoc applicationPath) {
38         this.solutionRootPath = solutionRootPath;
39         this.applicationPath = applicationPath;
40         baseUrl = null;
41     }
42
43     public void setBaseUrl(String JavaDoc baseUrl) {
44         this.baseUrl = baseUrl;
45     }
46
47     public String JavaDoc getFileOutputPath(String JavaDoc path) {
48         return solutionRootPath + File.separator + path;
49     }
50
51     public String JavaDoc getSolutionPath(String JavaDoc path) {
52         return solutionRootPath + File.separator + path;
53     }
54
55     /*
56      * (non-Javadoc)
57      *
58      * @see org.pentaho.newcode.IApplicationContext#getServerName()
59      */

60     public String JavaDoc getPentahoServerName() {
61         return ""; //$NON-NLS-1$
62
}
63
64     /*
65      * (non-Javadoc)
66      *
67      * @see org.pentaho.newcode.IApplicationContext#getServerPort()
68      */

69     public int getServerPort() {
70         // TODO Auto-generated method stub
71
return 0;
72     }
73
74     public String JavaDoc getBaseUrl() {
75         return baseUrl;
76     }
77
78     public String JavaDoc getApplicationPath(String JavaDoc path) {
79         return applicationPath + File.separator + path;
80     }
81
82     public String JavaDoc getProperty(String JavaDoc key) {
83         return properties.getProperty(key);
84     }
85
86     public String JavaDoc getProperty(String JavaDoc key, String JavaDoc defaultValue) {
87         return properties.getProperty(key, defaultValue);
88     }
89
90     protected void setProperties(Properties props) {
91         properties = props;
92     }
93
94     public void addEntryPointHandler(IPentahoSystemEntryPoint entryPoint) {
95       entryPointsList.add(entryPoint);
96     }
97     
98     public void removeEntryPointHandler(IPentahoSystemEntryPoint entryPoint) {
99       entryPointsList.remove(entryPoint);
100     }
101     
102     public void addExitPointHandler(IPentahoSystemExitPoint exitPoint) {
103       exitPointsList.add(exitPoint);
104     }
105     
106     public void removeExitPointHandler(IPentahoSystemExitPoint exitPoint) {
107       exitPointsList.remove(exitPoint);
108     }
109     
110     public void invokeEntryPoints() {
111       for (int i=0; i<entryPointsList.size(); i++) {
112         ((IPentahoSystemEntryPoint)entryPointsList.get(i)).systemEntryPoint();
113       }
114     }
115     
116     public void invokeExitPoints() {
117       for (int i=0; i<exitPointsList.size(); i++) {
118         ((IPentahoSystemExitPoint)entryPointsList.get(i)).systemExitPoint();
119       }
120     }
121     
122     
123 }
124
Popular Tags