jadex.bridge.service.ServiceScope Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-platform-bridge Show documentation
Show all versions of jadex-platform-bridge Show documentation
Jadex bridge is a base package for kernels and platforms, i.e., it is used by both and provides commonly used interfaces and classes for active components and their management.
package jadex.bridge.service;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* Scopes for service publication (provided) and search (e.g. required).
*/
public enum ServiceScope
{
/**
* Marker for default scope to be replaced automatically according to context;
* for required services (search scope): the default scope is 'platform' for system services and 'application' for non-system services,
* for provided services (publication scope): the default scope is always platform.
*/
DEFAULT,
/**
* Marker for using a separate expression in required/provided service annotations.
* This scope can not be used at runtime, e.g. for service queries.
* Concrete scope expression is given in further scopeexpression attribute.
*/
EXPRESSION,
/** None component scope (nothing will be searched, forces required service creation). */
NONE,
/** Available in immediate parent and all direct and indirect subcomponents. */
PARENT,
// todo: rename (COMPONENT_LOCAL)
/** Available in component itself. */
COMPONENT_ONLY,
/** Available in component and all direct and indirect subcomponents. */
COMPONENT,
// todo: rename (APPLICATION_PLATFORM) or remove
/** Available in local application, i.e. second level component plus direct and indirect subcomponents. */
APPLICATION,
/** Available in all components on the local platform. */
PLATFORM,
/** Application network scope (any platform with which a secret is shared and application tag must be shared). */
APPLICATION_NETWORK,
// public static final String SCOPE_APPLICATION_CLOUD = "application_cloud";
/** Network scope (any platform with which a secret is shared). */
NETWORK,
// public static final String SCOPE_CLOUD = "cloud";
// needed?!
/** Global application scope. */
APPLICATION_GLOBAL,
/** Global scope (any reachable platform including those with unrestricted services). */
GLOBAL;
//-------- constants --------
/** The scopes local to a platform. */
public static final Set LOCAL_SCOPES;
static
{
Set localscopes = new HashSet<>();
localscopes.add(null);
localscopes.add(NONE);
localscopes.add(COMPONENT_ONLY);
localscopes.add(COMPONENT);
localscopes.add(APPLICATION);
localscopes.add(PLATFORM);
localscopes.add(PARENT);
localscopes.add(DEFAULT);
LOCAL_SCOPES = Collections.unmodifiableSet(localscopes);
}
/** The global scopes. */
public static final Set GLOBAL_SCOPES;
static
{
Set localscopes = new HashSet<>();
localscopes.add(GLOBAL);
localscopes.add(APPLICATION_GLOBAL);
GLOBAL_SCOPES = Collections.unmodifiableSet(localscopes);
}
/** The network scopes. */
public static final Set NETWORK_SCOPES;
static
{
Set localscopes = new HashSet<>();
localscopes.add(NETWORK);
localscopes.add(APPLICATION_NETWORK);
NETWORK_SCOPES = Collections.unmodifiableSet(localscopes);
}
//-------- methods --------
/**
* Check if the scope not remote.
* @return True, scope on the local platform.
*/
public boolean isLocal()
{
return LOCAL_SCOPES.contains(this);
}
/**
* Check if the scope is global.
*/
public boolean isGlobal()
{
return GLOBAL_SCOPES.contains(this);
}
/**
* Check if the scope is a network scope.
*/
public boolean isNetwork()
{
return NETWORK_SCOPES.contains(this);
}
/**
* Get the enum per string.
* @param val The value.
* @return The enum or null.
*/
public static ServiceScope getEnum(String val)
{
if(val==null)
return null;
return ServiceScope.valueOf(val.toUpperCase());
}
}