GigaSpaces XAP 9.7.2 API

com.sun.jini.action
Class GetLongAction

java.lang.Object
  extended by com.sun.jini.action.GetLongAction
All Implemented Interfaces:
PrivilegedAction

public class GetLongAction
extends Object
implements PrivilegedAction

A convenience class for retrieving the long value of a system property as a privileged action.

An instance of this class can be used as the argument of AccessController.doPrivileged or Security.doPrivileged.

The following code retrieves the long value of the system property named "prop" as a privileged action. Since it does not pass a default value to be used in case the property "prop" is not defined, it has to check the result for null:

 Long tmp = (Long)
     Security.doPrivileged(new GetLongAction("prop"));
 long l;
 if (tmp != null) {
     l = tmp.longValue();
 }
 

The following code retrieves the long value of the system property named "prop" as a privileged action, and also passes a default value to be used in case the property "prop" is not defined:

 long l = ((Long) Security.doPrivileged(
                 new GetLongAction("prop"))).longValue();
 

If the protection domain of the immediate caller of doPrivileged or the protection domain of this class does not imply the permissions necessary for the operation, the behavior is as if the system property is not defined.

Since:
2.0
Author:
Sun Microsystems, Inc.
See Also:
PrivilegedAction, AccessController, Security

Constructor Summary
GetLongAction(String theProp)
          Constructor that takes the name of the system property whose long value needs to be determined.
GetLongAction(String theProp, long defaultVal)
          Constructor that takes the name of the system property and the default value of that property.
 
Method Summary
 Object run()
          Determines the long value of the system property whose name was specified in the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GetLongAction

public GetLongAction(String theProp)
Constructor that takes the name of the system property whose long value needs to be determined.

Parameters:
theProp - the name of the system property

GetLongAction

public GetLongAction(String theProp,
                     long defaultVal)
Constructor that takes the name of the system property and the default value of that property.

Parameters:
theProp - the name of the system property
defaultVal - the default value
Method Detail

run

public Object run()
Determines the long value of the system property whose name was specified in the constructor. The value is returned in a Long object.

If the system property is defined to be a value that can be parsed successfully by Long.decode, then this method returns an Long with the parsed value. Otherwise, if a default value was supplied to this object's constructor, then this method returns an Long with that default value, or else null is returned.

Specified by:
run in interface PrivilegedAction
Returns:
a Long representing the value of the system property or the default value, or null

GigaSpaces XAP 9.7.2 API

Copyright © GigaSpaces.