Javolution 6.0.0 java
javolution.context.LocalContext.Parameter< T > Class Template Referenceabstract
Inheritance diagram for javolution.context.LocalContext.Parameter< T >:
[legend]
Collaboration diagram for javolution.context.LocalContext.Parameter< T >:
[legend]

Public Member Functions

 Parameter ()
 
Permission< Parameter< T > > getSupersedePermission ()
 
get ()
 
String getName ()
 
Permission< Configurable< T > > getReconfigurePermission ()
 
reconfigure (T newValue)
 

Static Public Attributes

static final Permission< Parameter<?> > SUPERSEDE_PERMISSION
 
static Permission< Configurable<?> > RECONFIGURE_PERMISSION
 

Protected Member Functions

abstract T getDefault ()
 
initialized (T value)
 
parse (String str)
 
reconfigured (T oldValue, T newValue)
 

Private Attributes

final Permission< Parameter< T > > supersedePermission
 
String name
 
final Permission< Configurable< T > > reconfigurePermission
 
volatile T value
 

Detailed Description

A configurable parameter whose value can be locally superseded within the scope of LocalContext.

Definition at line 49 of file LocalContext.java.

Constructor & Destructor Documentation

◆ Parameter()

Creates a new parameter (configurable).

Definition at line 66 of file LocalContext.java.

66  {
67  this.supersedePermission = new Permission<Parameter<T>>(
68  Parameter.class, "supersede", this);
69  }

Member Function Documentation

◆ get()

Returns the current parameter value (the default value if not reconfigured nor superseded).

Reimplemented from javolution.lang.Configurable< T >.

Definition at line 83 of file LocalContext.java.

83  {
84  LocalContext ctx = current(LocalContext.class);
85  return (ctx != null) ? ctx.getValue(this, super.get()) : super.get();
86  }

References javolution.context.AbstractContext.current(), and javolution.context.LocalContext.getValue().

Here is the call graph for this function:

◆ getDefault()

abstract T javolution.lang.Configurable< T >.getDefault ( )
abstractprotectedinherited

Returns this configurable default value (always different from

null

).

Referenced by javolution.lang.Configurable< javolution.context.LogContext.Level >.Configurable(), and javolution.lang.Configurable< javolution.context.LogContext.Level >.parse().

Here is the caller graph for this function:

◆ getName()

String javolution.lang.Configurable< T >.getName ( )
inherited

Returns this configurable name. By convention, the name of the configurable is the name of the static field holding the configurable (e.g. "javolution.context.ConcurrentContext#CONCURRENCY"). This method should be overridden if the enclosing class needs to be impervious to obfuscation or if the enclosing class defines multiple configurable fields.

Exceptions
UnsupportedOperationExceptionif the enclosing class has multiple configurable static fields.

Definition at line 185 of file Configurable.java.

185  {
186  if (name != null)
187  return name; // Already set.
188  Class<?> thisClass = this.getClass();
189  Class<?> enclosingClass = thisClass.getEnclosingClass();
190  String fieldName = null;
191  for (Field field : enclosingClass.getFields()) {
192  if (field.getType().isAssignableFrom(thisClass)) {
193  if (fieldName != null) // Indistinguishable field types.
194  throw new UnsupportedOperationException(
195  "Multiple configurables static fields in the same class" +
196  "requires the Configurable.getName() method to be overriden.");
197  fieldName = field.getName();
198  }
199  }
200  return (fieldName != null) ? enclosingClass.getName() + "#" + fieldName
201  : null;
202  }

Referenced by javolution.lang.Configurable< javolution.context.LogContext.Level >.Configurable(), javolution.osgi.internal.ConfigurableListenerImpl.configurableInitialized(), and javolution.osgi.internal.ConfigurableListenerImpl.configurableReconfigured().

Here is the caller graph for this function:

◆ getReconfigurePermission()

Permission<Configurable<T> > javolution.lang.Configurable< T >.getReconfigurePermission ( )
inherited

Returns the permission to configure this instance.

Definition at line 207 of file Configurable.java.

207  {
208  return reconfigurePermission;
209  }

◆ getSupersedePermission()

Permission<Parameter<T> > javolution.context.LocalContext.Parameter< T >.getSupersedePermission ( )

Returns the permission to locally supersede the current value of this instance.

Definition at line 75 of file LocalContext.java.

75  {
76  return supersedePermission;
77  }

References javolution.context.LocalContext.Parameter< T >.supersedePermission.

◆ initialized()

T javolution.lang.Configurable< T >.initialized ( value)
protectedinherited

This methods is called when the configurable is initialized. Developers may override this method to perform any initialization logic (e.g. input validation).

Parameters
valuethe requested value for this configurable.
Returns
the actual value of this configurable.

Definition at line 252 of file Configurable.java.

252  {
253  return value;
254  }

Referenced by javolution.lang.Configurable< javolution.context.LogContext.Level >.Configurable().

Here is the caller graph for this function:

◆ parse()

T javolution.lang.Configurable< T >.parse ( String  str)
protectedinherited

Parses the specified text to return the corresponding value. This method is used to initialize this configurable from system properties. The default implementation uses the TextContext to retrieve the text format (based on DefaultTextFormat class annotation).

Definition at line 264 of file Configurable.java.

264  {
265  Class<? extends T> type = (Class<? extends T>) getDefault().getClass();
266  return TextContext.getFormat(type).parse(str);
267  }

Referenced by javolution.lang.Configurable< javolution.context.LogContext.Level >.Configurable().

Here is the caller graph for this function:

◆ reconfigure()

T javolution.lang.Configurable< T >.reconfigure ( newValue)
inherited

Reconfigures this instance with the specified value if authorized by the SecurityContext. This method returns the actual new value which may be different from the requested new value (see reconfigured(Object, Object)).

Parameters
newValuethe requested new value.
Returns
the actual new value.
Exceptions
SecurityExceptionif the permission to reconfigure this configurable is not granted.
UnsupportedOperationExceptionif this configurable does not support dynamic reconfiguration.

Definition at line 224 of file Configurable.java.

224  {
225  SecurityContext.check(reconfigurePermission);
226  synchronized (this) {
227  T oldValue = this.value;
228  this.value = reconfigured(oldValue, newValue);
229  Object[] listeners = OSGiServices.getConfigurableListeners();
230  for (Object listener : listeners) {
231  ((Listener) listener).configurableReconfigured(this, oldValue,
232  this.value);
233  }
234  return this.value;
235  }
236  }

◆ reconfigured()

T javolution.lang.Configurable< T >.reconfigured ( oldValue,
newValue 
)
protectedinherited

This methods is called when the configurable is reconfigured. Developers may override this method to perform any reconfiguration logic (e.g. hard limiting values).

Parameters
oldValuethe old value.
newValuethe requested new value.
Returns
the actual new value of this configurable.
Exceptions
UnsupportedOperationExceptionif this configurable does not support dynamic reconfiguration.

Definition at line 280 of file Configurable.java.

280  {
281  return newValue;
282  }

Referenced by javolution.lang.Configurable< javolution.context.LogContext.Level >.reconfigure().

Here is the caller graph for this function:

Member Data Documentation

◆ name

◆ RECONFIGURE_PERMISSION

Permission<Configurable<?> > javolution.lang.Configurable< T >.RECONFIGURE_PERMISSION
staticinherited
Initial value:
= new Permission<Configurable<?>>(
Configurable.class, "reconfigure")

Holds the general permission to reconfigure configurable instances (action "reconfigure"). Whether or not that permission is granted depends on the current SecurityContext. It is possible that the general permission to reconfigure a configurable is granted but revoked for a specific instance. Also, the general permission to reconfigure a configurable may be revoked but granted only for a specific instance.

Definition at line 115 of file Configurable.java.

◆ reconfigurePermission

◆ SUPERSEDE_PERMISSION

final Permission<Parameter<?> > javolution.context.LocalContext.Parameter< T >.SUPERSEDE_PERMISSION
static
Initial value:
= new Permission<Parameter<?>>(
Parameter.class, "supersede")

Holds the general permission to supersede any parameter value (action "supersede").

Definition at line 55 of file LocalContext.java.

◆ supersedePermission

final Permission<Parameter<T> > javolution.context.LocalContext.Parameter< T >.supersedePermission
private

Holds this instance supersede permission.

Definition at line 61 of file LocalContext.java.

Referenced by javolution.context.LocalContext.Parameter< T >.getSupersedePermission().

◆ value


The documentation for this class was generated from the following file:
javolution.context.LocalContext.LocalContext
LocalContext()
Definition: LocalContext.java:92
javolution.lang.Configurable.name
String name
Definition: Configurable.java:121
javolution.lang.Configurable.value
volatile T value
Definition: Configurable.java:131
javolution.context.LocalContext.Parameter.supersedePermission
final Permission< Parameter< T > > supersedePermission
Definition: LocalContext.java:61
javolution.lang.Configurable.getDefault
abstract T getDefault()
javolution.context.AbstractContext.current
static AbstractContext current()
Definition: AbstractContext.java:61
javolution.context.LocalContext.Parameter.Parameter
Parameter()
Definition: LocalContext.java:66
javolution.lang.Configurable.reconfigured
T reconfigured(T oldValue, T newValue)
Definition: Configurable.java:280
javolution.lang.Configurable.Configurable
Configurable()
Definition: Configurable.java:142
javolution.lang.Configurable.reconfigurePermission
final Permission< Configurable< T > > reconfigurePermission
Definition: Configurable.java:126