public ManagedReference getReference() {
final ClassLoader oldCL = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
final ServiceRefFactory serviceRefFactory = getServiceRefFactory();
return new ImmediateManagedReference(serviceRefFactory.newServiceRef(serviceRef));
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldCL);
}
}