001: /*
002: * Copyright 2006 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
007: * BI Platform. The Initial Developer is Pentaho Corporation.
008: *
009: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
011: * the license for the specific language governing your rights and limitations.
012: *
013: * @created Jun 22, 2005
014: * @author James Dixon
015: *
016: */
017:
018: package org.pentaho.core.system;
019:
020: import java.io.File;
021: import java.util.*;
022:
023: public class StandaloneApplicationContext implements
024: IApplicationContext {
025:
026: private String solutionRootPath;
027:
028: private String baseUrl;
029:
030: private String applicationPath;
031:
032: private Object context;
033:
034: private Properties properties = new Properties();
035:
036: private List entryPointsList = new ArrayList();
037: private List exitPointsList = new ArrayList();
038:
039: public StandaloneApplicationContext(String solutionRootPath,
040: String applicationPath, Object context) {
041: this (solutionRootPath, applicationPath);
042: this .context = context;
043: }
044:
045: public StandaloneApplicationContext(String solutionRootPath,
046: String applicationPath) {
047: //TODO sbarkdull, do we need to consider path separators for windows?
048: //assert !solutionRootPath.endsWith("\\") : "solutionRootPathin StandaloneApplicationContext appears to be using Windows path separators.";
049: //assert !applicationPath.endsWith("\\") : "applicationPath in StandaloneApplicationContext appears to be using Windows path separators.";
050:
051: this .solutionRootPath = solutionRootPath;
052: this .applicationPath = applicationPath;
053: baseUrl = null;
054: }
055:
056: public void setBaseUrl(String baseUrl) {
057: this .baseUrl = baseUrl;
058: }
059:
060: public String getFileOutputPath(String path) {
061: return solutionRootPath + File.separator + path;
062: }
063:
064: public String getSolutionPath(String path) {
065: return solutionRootPath + File.separator + path;
066: }
067:
068: public void setSolutionRootPath(String solutionRootPath) {
069: this .solutionRootPath = solutionRootPath;
070: }
071:
072: /*
073: * (non-Javadoc)
074: *
075: * @see org.pentaho.newcode.IApplicationContext#getServerName()
076: */
077: public String getPentahoServerName() {
078: return ""; //$NON-NLS-1$
079: }
080:
081: /*
082: * (non-Javadoc)
083: *
084: * @see org.pentaho.newcode.IApplicationContext#getServerPort()
085: */
086: public int getServerPort() {
087: // TODO Auto-generated method stub
088: return 0;
089: }
090:
091: public String getBaseUrl() {
092: return baseUrl;
093: }
094:
095: public String getApplicationPath(String path) {
096: return applicationPath + File.separator + path;
097: }
098:
099: public String getProperty(String key) {
100: return properties.getProperty(key);
101: }
102:
103: public String getProperty(String key, String defaultValue) {
104: return properties.getProperty(key, defaultValue);
105: }
106:
107: protected void setProperties(Properties props) {
108: properties = props;
109: }
110:
111: public void addEntryPointHandler(IPentahoSystemEntryPoint entryPoint) {
112: entryPointsList.add(entryPoint);
113: }
114:
115: public void removeEntryPointHandler(
116: IPentahoSystemEntryPoint entryPoint) {
117: entryPointsList.remove(entryPoint);
118: }
119:
120: public void addExitPointHandler(IPentahoSystemExitPoint exitPoint) {
121: exitPointsList.add(exitPoint);
122: }
123:
124: public void removeExitPointHandler(IPentahoSystemExitPoint exitPoint) {
125: exitPointsList.remove(exitPoint);
126: }
127:
128: public void invokeEntryPoints() {
129: for (int i = 0; i < entryPointsList.size(); i++) {
130: ((IPentahoSystemEntryPoint) entryPointsList.get(i))
131: .systemEntryPoint();
132: }
133: }
134:
135: public void invokeExitPoints() {
136: for (int i = 0; i < exitPointsList.size(); i++) {
137: ((IPentahoSystemExitPoint) entryPointsList.get(i))
138: .systemExitPoint();
139: }
140: }
141:
142: public Object getContext() {
143: return context;
144: }
145:
146: public void setContext(Object context) {
147: this .context = context;
148: }
149:
150: public String getSolutionRootPath() {
151: return solutionRootPath;
152: }
153:
154: }
|