sun.module.config
Class DefaultVisibilityPolicy

java.lang.Object
  extended by sun.module.config.DefaultVisibilityPolicy
All Implemented Interfaces:
VisibilityPolicy

public class DefaultVisibilityPolicy
extends Object
implements VisibilityPolicy

This class represents a default implementation for java.module.VisibilityPolicy.

This object stores the policy for entire Java runtime, and is the amalgamation of multiple visiblity policies that resides in files. The algorithm for locating the policy file(s) and reading their information is:

  1. Loop through the sun.module.config.ModuleSystemConfig properties, visibility.policy.url.1, visibility.policy.url.2, ..., visibility.policy.X". These properties are set in the module system properties file, which is located in the file named <JAVA_HOME>/lib/module/module.properties. <JAVA_HOME> refers to the value of the java.home system property, and specifies the directory where the JRE is installed. Each property value specifies a URL pointing to a policy file to be loaded. Read in and load each policy.
  2. The java.lang.System property java.module.visibility.policy may also be set to a URL pointing to another policy file (which is the case when a user uses the -D switch at runtime). If this property is defined, and its use is allowed by the module system property file (the Module System property, visibility.policy.allowSystemProperty is set to true), also load that policy. If the java.module.visibility.policy property is defined using "==" (rather than "="), then ignore all other specified policies and only load this policy.

Since:
1.7
Version:
%V%
Author:
Stanley M. Ho
See Also:
VisibilityPolicy

Constructor Summary
DefaultVisibilityPolicy()
          Initializes the DefaultVisibilityPolicy object and reads the default visibility policies.
 
Method Summary
 boolean isVisible(ModuleDefinition moduleDef)
          Returns true if the module definition should be visible in the repository of the module system.
 boolean refresh()
          Refreshes the DefaultVisibilityPolicy object and loads the visibility policy configuration file(s).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultVisibilityPolicy

public DefaultVisibilityPolicy()
Initializes the DefaultVisibilityPolicy object and reads the default visibility policies.

Method Detail

refresh

public boolean refresh()
Refreshes the DefaultVisibilityPolicy object and loads the visibility policy configuration file(s). The algorithm for locating the standard visibility policy file(s) is as follows:
   loop through the Module System Properties named 
   "visibility.policy.url.1", "visibility.policy.url.2", etc, until
   no more is found. Each of these specify a visibility policy file.
   
   if the system property "java.module.visibility.policy" is defined
     (which is the case when the user uses the -D switch at runtime), and
     its use is allowed by the module system property file, also load it.
 

Returns:
true if the visibility policy configuration file(s) are loaded properly; returns false otherwise.

isVisible

public boolean isVisible(ModuleDefinition moduleDef)
Returns true if the module definition should be visible in the repository of the module system. Otherwise, returns false.

Specified by:
isVisible in interface VisibilityPolicy
Parameters:
moduleDef - the module definition.
Returns:
true if the module definition should be visible in the module system; false otherwise.