ServiceListeners.java revision d78764efc954da87cd81023cc846a6a5af360d95
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2015-2016 ForgeRock AS.
*/
/**
* ServiceListeners provides a simplified API for creating appropriate {@link ServiceListener} instances
* to respond to changes in either Configuration or Schema.
*
* This class is intended to reduce the boiler plate code required to enable a service to respond
* to configuration changes.
*
* For an example of usage, the following indicates an example of listening for changes to the
* global configuration changes in iPlanetAMNamingService.
*
* <code>
* ServiceListeners builder = ...
* builder.config("iPlanetAMNamingService").global(action).listen();
* </code>
*
* Note: The listener triggering order should be considered non-deterministic. <b>Do not depend
* on the order</b> of listener triggering.
*/
public class ServiceListeners {
}
try {
return new ListenerBuilder(new ServiceConfigManager(serviceName, AccessController.doPrivileged(action)));
} catch (SMSException | SSOException e) {
throw new IllegalStateException(e);
}
}
try {
return new ListenerBuilder(new ServiceSchemaManager(serviceName, AccessController.doPrivileged(action)));
} catch (SMSException | SSOException e) {
throw new IllegalStateException(e);
}
}
private enum ConfigType {
}
/**
* Builder responsible for providing fluent-like functions for building up
* Action instances which will respond to changes in Service configuration.
*/
public static class ListenerBuilder {
public ListenerBuilder() {
}
}
this();
this.configManager = configManager;
}
this();
this.schemaManager = schemaManager;
}
return this;
}
return this;
}
return this;
}
}
public void listen() {
a.performUpdate();
}
}
public void globalConfigChanged(String serviceName, String version, String groupName, String serviceComponent, int type) {
a.performUpdate();
}
}
public void organizationConfigChanged(String serviceName, String version, String orgName, String groupName, String serviceComponent, int type) {
a.performUpdate();
}
}
};
if (schemaManager != null) {
}
if (configManager != null) {
}
}
}
/**
* A generic listener which will respond to a configuration or schema change event.
*/
public interface Action {
void performUpdate();
}
}