@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit du = phaseContext.getDeploymentUnit();
if (GateInWSRPKey.isGateInWSRPArchive(du)) {
// Only process if we have a META-INF/services ServiceLoader directory in the archive
final ServicesAttachment services = du.getAttachment(Attachments.SERVICES);
if (services != null) {
// get the module class loader
final Module module = du.getAttachment(Attachments.MODULE);
final ModuleClassLoader classLoader;
if (module != null) {
classLoader = module.getClassLoader();
} else {
classLoader = null;
}
for (String interfaceName : KNOWN_PLUGIN_INTERFACE_NAMES) {
// retrieve all service implementations for each known plugin interface and add them if they exist
final List<String> serviceImplementations = services.getServiceImplementations(interfaceName);
plugins.addPluginImplementations(interfaceName, serviceImplementations);
if (classLoader != null) {
// remember the module for each service implementation
for (String implementation : serviceImplementations) {