public class UserPromptCondition
extends java.lang.Object
implements org.osgi.service.condpermadmin.Condition
Modifier and Type | Field and Description |
---|---|
private org.osgi.framework.Bundle |
bundle |
private java.lang.String |
catalogName |
private java.lang.String |
defaultLevel |
(package private) static java.lang.reflect.Method |
factory |
private java.lang.String |
levels |
private java.lang.String |
message |
(package private) org.osgi.service.condpermadmin.Condition |
realUserPromptCondition |
Modifier | Constructor and Description |
---|---|
private |
UserPromptCondition(org.osgi.framework.Bundle bundle,
java.lang.String levels,
java.lang.String defaultLevel,
java.lang.String catalogName,
java.lang.String message)
Instances of the UserPromptCondition are simply store the construction parameters
until a "real" UserPromptCondition is registered in setFactory().
|
Modifier and Type | Method and Description |
---|---|
static org.osgi.service.condpermadmin.Condition |
getCondition(org.osgi.framework.Bundle bundle,
org.osgi.service.condpermadmin.ConditionInfo conditionInfo)
Returns a UserPromptCondition object with the given prompt string and permission
level.
|
boolean |
isMutable()
Checks whether the condition may change during the lifetime of the UserPromptCondition object.
|
boolean |
isPostponed()
Checks if the
isSatisfied() method needs to prompt the user, thus cannot
give results instantly. |
boolean |
isSatisfied()
Displays the prompt string to
the user and returns true if the user accepts.
|
boolean |
isSatisfied(org.osgi.service.condpermadmin.Condition[] conds,
java.util.Dictionary context)
Checks an array of UserPrompt conditions.
|
private void |
lookForImplementation()
Check if a factory is registered, and if yes, create userprompt to delegate calls to.
|
static java.lang.reflect.Method factory
org.osgi.service.condpermadmin.Condition realUserPromptCondition
private final org.osgi.framework.Bundle bundle
private final java.lang.String levels
private final java.lang.String defaultLevel
private final java.lang.String catalogName
private final java.lang.String message
private UserPromptCondition(org.osgi.framework.Bundle bundle, java.lang.String levels, java.lang.String defaultLevel, java.lang.String catalogName, java.lang.String message)
unused
- this parameter is here so that ConditionalPermissionAdmin would not
use this as the constructor instead of the getInstancebundle
- levels
- defaultLevel
- catalogName
- message
- public static org.osgi.service.condpermadmin.Condition getCondition(org.osgi.framework.Bundle bundle, org.osgi.service.condpermadmin.ConditionInfo conditionInfo)
bundle
- the bundle to ask about.conditionInfo
- the conditionInfo containing the construction information. Its
ConditionInfo.getArgs()
method should return a String array with 4
strings in it:
ResourceBundle
,
or equivalent
from an exporting OSGi Bundle. Thus, if the catalogName is "com.provider.messages.userprompt",
then there should be an OSGi Bundle exporting the "com.provider.messages" package, and inside
it files like "userprompt_en_US.properties".java.lang.IllegalArgumentException
- if the parameters are malformed.java.lang.NullPointerException
- if one of the parameters is null
.private void lookForImplementation()
public boolean isPostponed()
isSatisfied()
method needs to prompt the user, thus cannot
give results instantly.
This depends on the permission level given in
getCondition(Bundle, ConditionInfo)
.
isSatisfied()
returns false.isPostponed
in interface org.osgi.service.condpermadmin.Condition
public boolean isMutable()
getCondition(Bundle, ConditionInfo)
.
isMutable
in interface org.osgi.service.condpermadmin.Condition
public boolean isSatisfied()
getCondition(Bundle, ConditionInfo)
).
It must always be possible for the user
to stop further prompting of this question, even with ONESHOT and SESSION levels.
In case of BLANKET
and SESSION levels, it is possible that the user has already answered the question,
in this case there will be no prompting, but immediate return with the previous answer.isSatisfied
in interface org.osgi.service.condpermadmin.Condition
public boolean isSatisfied(org.osgi.service.condpermadmin.Condition[] conds, java.util.Dictionary context)
isSatisfied
in interface org.osgi.service.condpermadmin.Condition
conds
- The array containing the UserPrompt conditions to evaluate.context
- Storage area for evaluation. The ConditionalPermissionAdmin
may evaluate a condition several times for one permission check, so this context
will be used to store results of ONESHOT questions. This way asking the same question
twice in a row can be avoided. If context is null, temporary results will not be stored.java.lang.NullPointerException
- if conds is null.