com.arjuna.webservices11.util.PrivilegedServiceFactory Maven / Gradle / Ivy
The newest version!
/*
Copyright The Narayana Authors
SPDX-License-Identifier: Apache-2.0
*/
package com.arjuna.webservices11.util;
import jakarta.xml.ws.Service;
import java.security.AccessController;
/**
* @author Gytis Trikleris
*/
public class PrivilegedServiceFactory {
private final Class serviceClass;
public PrivilegedServiceFactory(final Class serviceClass) {
this.serviceClass = serviceClass;
}
public static PrivilegedServiceFactory getInstance(final Class serviceClass) {
return new PrivilegedServiceFactory<>(serviceClass);
}
public T getService() {
final ServiceAction serviceAction = ServiceAction.getInstance(serviceClass);
if (System.getSecurityManager() == null) {
return serviceAction.run();
}
return AccessController.doPrivileged(serviceAction);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy