com.partnersoft.core
Class Environment

java.lang.Object
  extended by com.partnersoft.core.Environment
All Implemented Interfaces:
Immutable
Direct Known Subclasses:
J2seEnvironment, WebstartEnvironment

public abstract class Environment
extends java.lang.Object
implements Immutable

Describes the high-level runtime environment for the system. This includes such info as what operating system we're on, what kind of JVM is used, how it was launched, whether we must run in "read-only" mode, etc.

To access Environment, use the currentEnvironment() static method. Like Thread.currentThread(), this will fetch the appropriate one for your thread and runtime context.

It is possible that we may add "sandboxes" in the future, which have different Environments. For example, we may start the system from a web-launched app, then go into a more traditional file-based mode for another application. However, at present Environment is a de facto singleton.

Instances of Environment are immutable objects. Once created you cannot change them; feel free to pass around copies all you like. Environment is thread-safe.

Copyright 1997-2006 Partner Software, Inc.

Version:
$Id: Environment.java 2037 2009-08-18 13:35:26Z paul $
Author:
Paul Reavis, Russell Cagle

Field Summary
protected  boolean headless
           
protected  java.lang.String jreDescription
           
protected  boolean modular
           
protected  OS os
           
protected  java.lang.String osDescription
           
protected  java.lang.String partnerBuild
           
protected  java.lang.String partnerCopyright
           
protected  java.lang.String partnerRelease
           
protected  boolean readOnly
           
protected  java.lang.String userName
           
protected  boolean webStarted
           
protected  java.lang.String webStartURL
           
 
Constructor Summary
protected Environment()
           
 
Method Summary
static Environment currentEnvironment()
          Returns the correct Environment for your thread and runtime context.
 java.lang.String getJREDescription()
           
 OS getOS()
          Returns the specific OS object for this environment.
 java.lang.String getOSDescription()
           
 java.lang.String getPartnerBuild()
           
 java.lang.String getPartnerCopyright()
           
 java.lang.String getPartnerRelease()
           
 java.lang.String getUserName()
           
 java.lang.String getWebStartURL()
           
 boolean isHeadless()
          Returns true if the app is running in headless (daemon) mode.
 boolean isLinux()
          Convenience method to test for Linuxness.
 boolean isMac()
          Convenience method to test for Macness.
 boolean isModular()
          Returns true if system is running in a modular context (with a modular class loader).
 boolean isReadOnly()
           
 boolean isWebStarted()
          Returns true if the app is running via Java WebStart.
 boolean isWindows()
          Convenience method to test for Windosity.
static void setDefaultEnvironment(Environment newDefault)
          Sets the default Environment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

os

protected OS os

osDescription

protected java.lang.String osDescription

jreDescription

protected java.lang.String jreDescription

userName

protected java.lang.String userName

headless

protected boolean headless

readOnly

protected boolean readOnly

webStarted

protected boolean webStarted

webStartURL

protected java.lang.String webStartURL

partnerRelease

protected java.lang.String partnerRelease

partnerBuild

protected java.lang.String partnerBuild

partnerCopyright

protected java.lang.String partnerCopyright

modular

protected boolean modular
Constructor Detail

Environment

protected Environment()
Method Detail

currentEnvironment

public static Environment currentEnvironment()
Returns the correct Environment for your thread and runtime context.

Returns:
Environment for your context

setDefaultEnvironment

public static void setDefaultEnvironment(Environment newDefault)
Sets the default Environment. Should generally only be called from early initialization or launcher code.

Parameters:
newDefault - new default Environment implementation

isLinux

public boolean isLinux()
Convenience method to test for Linuxness.

Returns:
true if running under Linux.

isMac

public boolean isMac()
Convenience method to test for Macness.

Returns:
true if running under Mac OSX.

isWindows

public boolean isWindows()
Convenience method to test for Windosity.

Returns:
true if "running" under Windows.

getOS

public OS getOS()
Returns the specific OS object for this environment.

Returns:
the instance of OS the app is running on.

isHeadless

public boolean isHeadless()
Returns true if the app is running in headless (daemon) mode.

Returns:
true if app is running without a head.

isWebStarted

public boolean isWebStarted()
Returns true if the app is running via Java WebStart.

Returns:
true if app is running via Java WebStart.

getWebStartURL

public java.lang.String getWebStartURL()
Returns:
the URL web start was launched from, or null if isWebStarted() == false.

getOSDescription

public java.lang.String getOSDescription()
Returns:
the full text description of the operating system and its version.

getJREDescription

public java.lang.String getJREDescription()
Returns:
the full text description of the Java Runtime Environment and its version.

isReadOnly

public boolean isReadOnly()
Returns:
true if the app is running in a read-only environment.

getUserName

public java.lang.String getUserName()
Returns:
user name

getPartnerRelease

public java.lang.String getPartnerRelease()
Returns:
name or number of Partner platform release (e.g. development, or 4.4.1)

getPartnerBuild

public java.lang.String getPartnerBuild()
Returns:
name or tag number of Partner platform build (e.g. 441)

getPartnerCopyright

public java.lang.String getPartnerCopyright()
Returns:
copyright notice for Partner platform.

isModular

public boolean isModular()
Returns true if system is running in a modular context (with a modular class loader).

Returns: