Class CombinedJavaConfigSystemPropertyListener

  • All Implemented Interfaces:
    org.glassfish.hk2.api.PostConstruct, ConfigListener

    @Service
    @RunLevel(mode=1,
              value=1)
    public final class CombinedJavaConfigSystemPropertyListener
    extends Object
    implements org.glassfish.hk2.api.PostConstruct, ConfigListener
    Listens for the changes to the configuration of JVM and Java system properties (including the Java VM options). Most of the effort involves the jvm-options list, but restart is also required for any changes to the java-config.

    This class is implemented so that the server restart is NOT required if a deployer wants to deploy an application and the application depends on a particular Java system property (-D) to be specified. As of now, the deployer specifies the system property and deploys the application and the application should find it when it does System.getProperty("property-name"). Here is the complete algorithm:

    1. If any of the attributes of the java-config element (JavaConfig) change, this listener flags it as server-restart-required kind of change.
    2. If a system property is being defined and it is NOT one that starts with "-Djava." or "-Djavax.", it will be immediately set in the System using System.setProperty() call. A server restart won't be needed.
    3. If any other JVM option is defined that does not start with "-D" (excluding the cases covered above), it is deemed to be a JVM option resulting in server-restart-required flag set.
    4. If a System Property (with above distinctions) is removed, System.clearProperty() is called and server-restart-required flag is set accordingly.
    Change in the value of a particular system property level is not handled explicitly. User interfaces should take a note of it. e.g. CLI does not make -Dfoo=bar and -Dfoo=bar1 as same properties being set to two different values since it is hard to distinguish it in general case. Users should delete -Dfoo=bar and add -Dfoo=bar1explicitly in this case.
    Since:
    GlassFish V3
    Author:
    केदार ([email protected])
    See Also:
    JavaConfig
    • Constructor Detail

      • CombinedJavaConfigSystemPropertyListener

        public CombinedJavaConfigSystemPropertyListener()
    • Method Detail

      • postConstruct

        public void postConstruct()
        Specified by:
        postConstruct in interface org.glassfish.hk2.api.PostConstruct
      • changed

        public UnprocessedChangeEvents changed​(PropertyChangeEvent[] events)
        Description copied from interface: ConfigListener
        Notification that @Configured objects that were injected have changed
        Specified by:
        changed in interface ConfigListener
        Parameters:
        events - list of changes
        Returns:
        the list of unprocessed events (requiring a restart) or null if all reconfiguration was processed successfully