use of fish.payara.appserver.monitoring.rest.service.adapter.RestMonitoringEndpointDecider in project Payara by payara.
the class RestMonitoringService method changed.
@Override
public UnprocessedChangeEvents changed(PropertyChangeEvent[] propertyChangeEvents) {
List<UnprocessedChangeEvent> unprocessedChanges = new ArrayList<>();
boolean dynamicStart = false;
for (PropertyChangeEvent propertyChangeEvent : propertyChangeEvents) {
// Check that the property change event is for us.
if (propertyChangeEvent.getSource().toString().equals("GlassFishConfigBean." + RestMonitoringConfiguration.class.getName()) && isCurrentInstanceMatchTarget(propertyChangeEvent)) {
// Check if the property has actually changed
if (!propertyChangeEvent.getOldValue().equals(propertyChangeEvent.getNewValue())) {
// If the application hasn't attempted to start yet
if (!startAttempted) {
// property, we don't need to compare it to the current value - it can only be true
if (propertyChangeEvent.getPropertyName().equals("enabled")) {
// Flag that we want to dynamically start Rest Monitoring
dynamicStart = true;
} else if (propertyChangeEvent.getPropertyName().equals("context-root")) {
// If we haven't attempted to start the app yet, grab the new context root
Config serverConfig = domain.getServerNamed(serverEnv.getInstanceName()).getConfig();
RestMonitoringEndpointDecider endpointDecider = new RestMonitoringEndpointDecider(serverConfig, restMonitoringConfiguration);
contextRoot = endpointDecider.getContextRoot();
}
} else if (!propertyChangeEvent.getPropertyName().equals("security-enabled")) {
// If a startup has been attempted and the changed property isn't securityEnabled, throw an
// unprocessed change event as we need to restart
unprocessedChanges.add(new UnprocessedChangeEvent(propertyChangeEvent, "Rest monitoring redeployment required"));
}
}
}
}
// This should only be true if rest monitoring was not enabled at startup, and we've just enabled the service
if (dynamicStart) {
loadApplication(true);
}
// If we need to restart, throw an unprocessed change event
if (unprocessedChanges.isEmpty()) {
return null;
} else {
return new UnprocessedChangeEvents(unprocessedChanges);
}
}
Aggregations