Previously all properties used to configure the Java stack were located in the mpeenv.ini file. Along with the support for separable extension builds, the mechanism by which these properties are accessed has been redesigned.

Properties Manager

The new properties management system is implemented in org.cablelabs.impl.manager.PropertiesManager. Java properties modules are organized in a linear precedence structure as defined by the file $OCAPROOT/java/src/base/org/cablelabs/impl/manager/props.properties. Several of the PropertiesManager APIs retrieve property values based on the precendence of the module in which that property is found.

##
## Module Definitions
## Higher numbered modules have higher precedence
##

# Base OCAP functionality
OCAP.properties.module.0=base

# Front Panel extension
OCAP.properties.module.1=fp

# Device Settings extension
OCAP.properties.module.2=ds

# DVR Extension
OCAP.properties.module.3=dvr

# Home Networking Extension
OCAP.properties.module.4=hn

As you can see, each area of OCAP functionality (base and extensions) is represented by a module name. Extensions that expand on the functionality of others are given a higher precendence. Each module has an associated property file located in the module's source directory -- i.e. <module>.properties is located in $OCAPROOT/java/src/<module>.

Finally, there is a module that is defined strictly for the purpose of handling developer overrides. This module is called final.

# Final module definition used by developers to override
# defaults from each module for testing or device
# deployment purposes.
#
# This should always be the highest precedence module
OCAP.properties.module.5=final

The file final.properties must live somewhere in the VM classpath. Developers can place all of their property overrides in this file to control stack behavior.

NOTE: All properties that configure the Java stack have been removed from mpeenv.ini and placed in their module-specific properties files.

Retrieving Java Properties

Developers wishing to retrieve property values from these files have several options for doing so.

Single Property Value

PropertiesManager.getPropertyValueByPrecendence(String name) will retrieve the value of the given property from the highest precedence property file in which in can be found. This is the simplest and most typical use of the PropertiesManager.

Multiple Properties (no duplicates)

PropertiesManager.getPropertiesByPrecedence(String propNamePrefix) returns a java.util.Properties that matches multiple property names based on the given prefix, but only returns the highest precedence property for each unique name

Multiple Property Values (with duplicates)

PropertiesManager.getAllPropertyValues(String propNamePrefix) returns a sorted list of all property values from property names matching the given prefix. The values are sorted in order from highest-to-lowest precedence based on which properties file they were located.

Single Object Instance

PropertiesManager.getInstanceByPrecedence(name) returns a single Object instance based on the given property name. The property value is expected to be the fully-qualified name of a Java class that can be default-instantiated. Property value is determined in the same fashion as PropertiesManager.getPropertyValueByPrecedence().

Multiple Object Instance

PropertiesManager.getInstancesByPrecedence(propNamePrefix) returns a sorted List of object instances. The property values are determined in the same fashion as PropertiesManager.getAllPropertyValues().

  • No labels