use of org.xwiki.classloader.ClassLoaderManager in project xwiki-platform by xwiki.
the class WebJarsResourceReferenceHandlerTest method configure.
@Before
public void configure() throws Exception {
Container container = this.componentManager.getInstance(Container.class);
this.response = mock(ServletResponse.class);
ByteArrayOutputStream responseOutputStream = new ByteArrayOutputStream();
when(this.response.getOutputStream()).thenReturn(responseOutputStream);
HttpServletResponse httpResponse = mock(HttpServletResponse.class);
when(this.response.getHttpServletResponse()).thenReturn(httpResponse);
when(container.getResponse()).thenReturn(this.response);
this.request = mock(ServletRequest.class);
HttpServletRequest httpRequest = mock(HttpServletRequest.class);
when(this.request.getHttpServletRequest()).thenReturn(httpRequest);
when(container.getRequest()).thenReturn(this.request);
this.handler = this.componentManager.getComponentUnderTest();
this.classLoader = mock(NamespaceURLClassLoader.class);
ClassLoaderManager clm = this.componentManager.getInstance(ClassLoaderManager.class);
when(clm.getURLClassLoader("wiki:wiki", true)).thenReturn(this.classLoader);
}
use of org.xwiki.classloader.ClassLoaderManager in project xwiki-platform by xwiki.
the class XWiki method getAuthService.
// added some log statements to make debugging easier - LBlaze 2005.06.02
public XWikiAuthService getAuthService() {
synchronized (this.AUTH_SERVICE_LOCK) {
if (this.authService == null) {
LOGGER.info("Initializing AuthService...");
String authClass = getConfiguration().getProperty("xwiki.authentication.authclass");
if (StringUtils.isNotEmpty(authClass)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Using custom AuthClass " + authClass + ".");
}
} else {
if (isLDAP()) {
authClass = "com.xpn.xwiki.user.impl.LDAP.XWikiLDAPAuthServiceImpl";
} else {
authClass = "com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl";
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Using default AuthClass " + authClass + ".");
}
}
try {
// Get the current ClassLoader
@SuppressWarnings("deprecation") ClassLoaderManager clManager = Utils.getComponent(ClassLoaderManager.class);
ClassLoader classloader = null;
if (clManager != null) {
classloader = clManager.getURLClassLoader("wiki:xwiki", false);
}
// Get the class
if (classloader != null) {
this.authService = (XWikiAuthService) Class.forName(authClass, true, classloader).newInstance();
} else {
this.authService = (XWikiAuthService) Class.forName(authClass).newInstance();
}
LOGGER.debug("Initialized AuthService using Relfection.");
} catch (Exception e) {
LOGGER.warn("Failed to initialize AuthService " + authClass + " using Reflection, trying default implementations using 'new'.", e);
this.authService = new XWikiAuthServiceImpl();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Initialized AuthService " + this.authService.getClass().getName() + " using 'new'.");
}
}
}
return this.authService;
}
}
Aggregations