001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.pluto.internal.impl;
018:
019: import java.util.ResourceBundle;
020:
021: /**
022: * Utility class used to retrieve environment information from the
023: * <code>environment.properties</code> file packaged with pluto.
024: */
025: final class Environment {
026:
027: /**
028: * Properties Resource Bundle containing pluto environment information.
029: */
030: public static final ResourceBundle PROPS;
031:
032: static {
033: PROPS = ResourceBundle
034: .getBundle("org.apache.pluto.environment");
035: }
036:
037: /**
038: * Retrieve the name of the container.
039: * @return the container name.
040: */
041: public static final String getPortletContainerName() {
042: return PROPS.getString("pluto.container.name");
043: }
044:
045: /**
046: * Retrieve the major version number.
047: * @return the major version number.
048: * @deprecated
049: */
050: public static final String getPortletContainerMajorVersion() {
051: String version = getPortletContainerVersion();
052: return version.substring(0, version.indexOf("."));
053: }
054:
055: /**
056: * Retrieve the minor version number.
057: * @return the minor version number.
058: * @deprecated
059: */
060: public static final String getPortletContainerMinorVersion() {
061: String version = getPortletContainerVersion();
062: return version.substring(version.indexOf("."));
063: }
064:
065: /**
066: * Retrieve the portlet container version.
067: *
068: * @return container version
069: */
070: public static final String getPortletContainerVersion() {
071: return PROPS.getString("pluto.container.version");
072: }
073:
074: /**
075: * Retrieve the major version number of the specification which this version
076: * of pluto supports.
077: * @return te major specification version.
078: */
079: public static final int getMajorSpecificationVersion() {
080: return Integer.parseInt(PROPS
081: .getString("javax.portlet.version.major"));
082: }
083:
084: /**
085: * Retrieve the minor version number of the specification which this version
086: * of pluto supports.
087: * @return the minor specification version.
088: */
089: public static final int getMinorSpecificationVersion() {
090: return Integer.parseInt(PROPS
091: .getString("javax.portlet.version.minor"));
092: }
093:
094: /**
095: * Retrieve the formatted server info String required to be returned by the
096: * PortletContext.
097: * @return the server info.
098: */
099: public static final String getServerInfo() {
100: StringBuffer sb = new StringBuffer(getPortletContainerName())
101: .append("/").append(getPortletContainerVersion());
102: return sb.toString();
103: }
104:
105: }
|