Class ModuleRuntimeAccess
java.lang.Object
com.netflix.module.ModuleRuntimeAccess
Reads, writes, combines, and validates module runtime access requirements.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidadd(ModuleRuntimeAccessOptions.Builder builder, ModuleRuntimeAccessOptions options) Adds all options to a builder.static voidcheckLaunch(List<String> arguments) Resolves a modular launch and verifies recorded requirements against its arguments.static voidcheckRequirements(ModuleRuntimeAccessOptions required, ModuleRuntimeAccessOptions supplied) Verifies that supplied options include every required authorization.static ModuleRuntimeAccessOptionsforModule(ModuleRuntimeAccessOptions options, String moduleName) Selects options whose access is granted to one target module.static ModuleRuntimeAccessOptionsparseArguments(List<String> arguments) Parses recognized runtime access options from launcher arguments.static Optional<ModuleRuntimeAccessOptions> read(ModuleReference reference) Reads the runtime access attribute from a module descriptor.static byte[]write(byte[] moduleInfo, ModuleRuntimeAccessOptions options) Replaces the runtime access attribute in a module descriptor.
-
Method Details
-
forModule
public static ModuleRuntimeAccessOptions forModule(ModuleRuntimeAccessOptions options, String moduleName) Selects options whose access is granted to one target module.- Parameters:
options- the options to filtermoduleName- the target module- Returns:
- the options applying to the target module
-
write
Replaces the runtime access attribute in a module descriptor.- Parameters:
moduleInfo- themodule-info.classbytesoptions- the requirements to record; an empty set removes the attribute- Returns:
- the transformed class-file bytes
- Throws:
IllegalArgumentException- if the bytes do not represent a module descriptor
-
parseArguments
Parses recognized runtime access options from launcher arguments. Unrecognized arguments are ignored.- Parameters:
arguments- launcher arguments- Returns:
- the parsed runtime access options
- Throws:
IllegalArgumentException- if a recognized option has an invalid operand
-
checkLaunch
Resolves a modular launch and verifies recorded requirements against its arguments.- Parameters:
arguments- launcher arguments- Throws:
IllegalArgumentException- if a runtime access requirement is unsatisfiedIOException- if a module descriptor cannot be read
-
checkRequirements
public static void checkRequirements(ModuleRuntimeAccessOptions required, ModuleRuntimeAccessOptions supplied) Verifies that supplied options include every required authorization.- Parameters:
required- the required runtime accesssupplied- the authorized runtime access- Throws:
IllegalArgumentException- if an authorization is missing
-
add
public static void add(ModuleRuntimeAccessOptions.Builder builder, ModuleRuntimeAccessOptions options) Adds all options to a builder.- Parameters:
builder- the destination builderoptions- the options to add
-
read
public static Optional<ModuleRuntimeAccessOptions> read(ModuleReference reference) throws IOException Reads the runtime access attribute from a module descriptor.- Parameters:
reference- the module to inspect- Returns:
- the recorded options, or an empty value when no attribute is present
- Throws:
IOException- if an explicit module descriptor cannot be read
-