com.ibm.commons
Class Platform

java.lang.Object
  extended by com.ibm.commons.Platform

public abstract class Platform
extends java.lang.Object

Access to platform specific services.

There is one platform object (singleton) for the JVM. It encapsulate the services for the undelying platform. This platform object is automatically instanciated when necessary.


Field Summary
static java.lang.String FACTORY_CLASS
           
static java.lang.String PLATFORM_PROPERTY_KEY
           
static java.lang.String PORTAL6_PLATFORM_CLASS
           
 
Constructor Summary
protected Platform()
           
 
Method Summary
protected abstract  com.ibm.commons.log.LogMgrFactory createLogMgrFactory()
           
abstract  java.io.PrintStream getErrorStream()
          Get the error stream for this platform.
 java.io.InputStream getGlobalResource(java.lang.String resourceName)
          Get a global resource file as an input stream.
 java.io.File getGlobalResourceFile(java.lang.String resourceName)
          Get a global resource as a file.
static Platform getInstance()
          Return the platform singleton.
 com.ibm.commons.log.LogMgrFactory getLogMgrFactory()
          Get the Log manager factory used for this platform.
abstract  java.lang.String getName()
          Return the name of the platform.
 java.lang.Object getObject(java.lang.String key)
          Get an object cached by the platform.
abstract  java.io.PrintStream getOutputStream()
          Get the output stream for this platform.
 com.ibm.commons.IPlatformService getPlatformService(java.lang.String serviceId)
          Return a sevice implementation giving its name.
 java.lang.String getProperty(java.lang.String key)
          Get a platform property.
protected  void initialize()
           
static void initPlatform(Platform platform)
           
abstract  boolean isEclipseBased()
          Check if the runtime platform is Eclipse based.
abstract  boolean isFeatureEnabled(java.lang.String featureId)
           
 boolean isPlatform(java.lang.String name)
          Check if it is a particular platform.
 void log(java.lang.String message)
          Log a message.
 void log(java.lang.String message, java.lang.Object... parameters)
          Log a message after formatting it.
 void log(java.lang.Throwable ex)
          Log an exception.
 void putProperty(java.lang.String key, java.lang.String object)
          Set a platform property.
 void registerPlatformService(java.lang.String serviceId, com.ibm.commons.IPlatformService platformService)
          Register a platform service.
 void removeProperty(java.lang.String key)
          Remove a platform property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FACTORY_CLASS

public static final java.lang.String FACTORY_CLASS
See Also:
Constant Field Values

PORTAL6_PLATFORM_CLASS

public static final java.lang.String PORTAL6_PLATFORM_CLASS
See Also:
Constant Field Values

PLATFORM_PROPERTY_KEY

public static final java.lang.String PLATFORM_PROPERTY_KEY
See Also:
Constant Field Values
Constructor Detail

Platform

protected Platform()
Method Detail

initPlatform

public static void initPlatform(Platform platform)

getInstance

public static Platform getInstance()
Return the platform singleton.

Returns:
the Platform singleton

initialize

protected void initialize()

getName

public abstract java.lang.String getName()
Return the name of the platform.

Returns:
the platform name

getLogMgrFactory

public final com.ibm.commons.log.LogMgrFactory getLogMgrFactory()
Get the Log manager factory used for this platform.

Returns:

createLogMgrFactory

protected abstract com.ibm.commons.log.LogMgrFactory createLogMgrFactory()

getOutputStream

public abstract java.io.PrintStream getOutputStream()
Get the output stream for this platform.

Returns:

getErrorStream

public abstract java.io.PrintStream getErrorStream()
Get the error stream for this platform.

Returns:

isEclipseBased

public abstract boolean isEclipseBased()
Check if the runtime platform is Eclipse based.

Returns:
true if the host is Eclipse

isPlatform

public boolean isPlatform(java.lang.String name)
Check if it is a particular platform.

Returns:
true if the platform matches the name

getPlatformService

public com.ibm.commons.IPlatformService getPlatformService(java.lang.String serviceId)
Return a sevice implementation giving its name.

Parameters:
serviceId - : unique id representing the platform service
Returns:
the service implementation

registerPlatformService

public void registerPlatformService(java.lang.String serviceId,
                                    com.ibm.commons.IPlatformService platformService)
Register a platform service.

Parameters:
serviceId - unique id
platformService -

getProperty

public java.lang.String getProperty(java.lang.String key)
Get a platform property.

Parameters:
key - the property name
Returns:
the property value

putProperty

public void putProperty(java.lang.String key,
                        java.lang.String object)
Set a platform property.

Parameters:
key - the property name
object - the new property value

removeProperty

public void removeProperty(java.lang.String key)
Remove a platform property.

Parameters:
key - the property name

getGlobalResource

public java.io.InputStream getGlobalResource(java.lang.String resourceName)
Get a global resource file as an input stream.

Returns:
the input stream, or null if the resource is not available

getGlobalResourceFile

public java.io.File getGlobalResourceFile(java.lang.String resourceName)
Get a global resource as a file. This returns a file object when the resource is an actual file. This allows an application to get the lastModificationDate as well as the file length when needed. If the resource is not backed by a file, it return null.

Parameters:
resourceName -
Returns:
the corresponding file, if exists

getObject

public java.lang.Object getObject(java.lang.String key)
Get an object cached by the platform.

Returns:

log

public void log(java.lang.Throwable ex)
Log an exception.

Note that the log not only goes to default output stream, but it can also go a to log file if implemented by the platform.


log

public void log(java.lang.String message)
Log a message.

Note that the log not only goes to default output stream, but it can also go a to log file if implemented by the platform.


log

public void log(java.lang.String message,
                java.lang.Object... parameters)
Log a message after formatting it.

Note that the log not only goes to default output stream, but it can also go a to log file if implemented by the platform.


isFeatureEnabled

public abstract boolean isFeatureEnabled(java.lang.String featureId)