private SecurityController configureController(final Element rootEl) throws ConfigurationException { SecurityController controller = (SecurityController) configureClass(rootEl, "controller", this); try { if (controller == null) { controller = (SecurityController) ClassLoaderUtil.loadClass(SecurityController.NULL_CONTROLLER, getClass()).newInstance(); } } catch (final Exception e) { throw new ConfigurationException("Could not lookup class: " + SecurityController.NULL_CONTROLLER, e); } return controller; }
private void addProvider() { if (logger.isDebugEnabled()) { logger.debug("UserProvider class = " + currentClass + " " + currentProperties); } if (configurationBuilder != null) { try { UserProvider provider; provider = (UserProvider) ClassLoaderUtil.loadClass(currentClass, this.getClass()).newInstance(); if (provider.init(currentProperties)) { configurationBuilder.addProvider(provider); } else { logger.error("Could not initialize provider " + currentClass); throw new RuntimeException("Could not initialize provider " + currentClass); } } catch (final Exception e) { logger.error("Could not create instance of provider", e); throw new RuntimeException(e); } } }
@Override protected void addResultTypes( PackageConfig packageContext, Element element ) { NodeList resultTypeList = element.getElementsByTagName( "result-type" ); for ( int i = 0; i < resultTypeList.getLength(); i++ ) { Element resultTypeElement = (Element) resultTypeList.item( i ); String name = resultTypeElement.getAttribute( "name" ); String className = resultTypeElement.getAttribute( "class" ); String def = resultTypeElement.getAttribute( "default" ); try { Class<?> clazz = ClassLoaderUtil.loadClass( className, getClass() ); ResultTypeConfig resultType = new ResultTypeConfig( name, clazz ); packageContext.addResultTypeConfig( resultType ); // set the default result type if ( "true".equals( def ) ) { packageContext.setDefaultResultType( name ); } } catch ( ClassNotFoundException e ) { LOG.error( "Result class [" + className + "] doesn't exist, ignoring" ); } } }
final SecurityService service = (SecurityService) ClassLoaderUtil.loadClass(serviceClazz, getClass()).newInstance();
private void configureInterceptors(final Element rootEl) throws ConfigurationException { final NodeList nl = rootEl.getElementsByTagName("interceptors"); if ((nl != null) && (nl.getLength() > 0)) { final Element interceptorsEl = (Element) nl.item(0); final NodeList interceptorList = interceptorsEl.getElementsByTagName("interceptor"); for (int i = 0; i < interceptorList.getLength(); i++) { final Element interceptorEl = (Element) interceptorList.item(i); final String interceptorClazz = interceptorEl.getAttribute("class"); if ((interceptorClazz == null) || "".equals(interceptorClazz)) { throw new ConfigurationException("Interceptor element with bad class attribute"); } try { SecurityConfigImpl.log.debug("Adding interceptor of class: " + interceptorClazz); final Interceptor interceptor = (Interceptor) ClassLoaderUtil.loadClass(interceptorClazz, getClass()).newInstance(); interceptor.init(getInitParameters(interceptorEl), this); interceptors.add(interceptor); } catch (final Exception e) { throw new ConfigurationException("Could not getRequest service: " + interceptorClazz, e); } } } }
configProvider = (HibernateConfigurationProvider) ClassLoaderUtil.loadClass(configProviderClass, this.getClass()).newInstance();
configProvider = (HibernateConfigurationProvider) ClassLoaderUtil.loadClass(configProviderClass, this.getClass()).newInstance();
try initable = (Initable) ClassLoaderUtil.loadClass(clazz, owner.getClass()).newInstance();
configProvider = (HibernateConfigurationProvider) ClassLoaderUtil.loadClass(configProviderClass, this.getClass()).newInstance();
@Nonnull private static <T> T configureClass(Element root, String tagname, Class<T> expectedClass, Class<? extends T> defaultClass) { ElementIterable elements = getElementsByTagName(root, tagname); if (elements.isEmpty()) { try { return defaultClass.newInstance(); } catch (Exception e) { throw new ConfigurationJohnsonException("Default [" + expectedClass.getName() + "], [" + defaultClass.getName() + "] is not valid", e); } } Element element = Iterables.getOnlyElement(elements); String className = element.getAttribute("class"); try { Class<?> clazz = ClassLoaderUtil.loadClass(className, XmlJohnsonConfig.class); if (!expectedClass.isAssignableFrom(clazz)) { throw new ConfigurationJohnsonException("The class specified by " + tagname + " (" + className + ") is required to implement [" + expectedClass.getName() + "]"); } T instance = expectedClass.cast(clazz.newInstance()); if (instance instanceof Initable) { Map<String, String> params = getInitParameters(element); ((Initable) instance).init(params); } return instance; } catch (Exception e) { throw new ConfigurationJohnsonException("Could not create: " + tagname, e); } }
configProvider = (OSUserHibernateConfigurationProvider) ClassLoaderUtil.loadClass(configProviderClass, this.getClass()).newInstance(); } catch (Exception e) { log.error("Unable to load configuration provider class: " + configProviderClass, e);
configProvider = (OSUserHibernateConfigurationProvider) ClassLoaderUtil.loadClass(configProviderClass, this.getClass()).newInstance(); } catch (Exception e) { log.error("Unable to load configuration provider class: " + configProviderClass, e);
configProvider = (OSUserHibernateConfigurationProvider) ClassLoaderUtil.loadClass(configProviderClass, this.getClass()).newInstance(); } catch (Exception e) { log.error("Unable to load configuration provider class: " + configProviderClass, e);
try { LOG.trace("Loading class [{}]", className); Class eventCheckClazz = ClassLoaderUtil.loadClass(className, XmlJohnsonConfig.class); LOG.trace("Instantiating [{}]", className); o = eventCheckClazz.newInstance();
Class<?> erResolverClazz = ClassLoaderUtil.loadClass( externalReferenceResolver, ExternalReferenceResolver.class );
Class clazz = ClassLoaderUtil.loadClass(className, DispatcherUtils.class); objectFactory = (ObjectFactory) clazz.newInstance(); if (objectFactory instanceof ObjectFactoryInitializable) { Class clazz = ClassLoaderUtil.loadClass(className, DispatcherUtils.class); ObjectTypeDeterminer objectTypeDeterminer = (ObjectTypeDeterminer) clazz.newInstance(); ObjectTypeDeterminerFactory.setInstance(objectTypeDeterminer);
public boolean start(Writer writer) { boolean result = super.start(writer); OgnlValueStack stack = getStack(); try { String beanName = findString(name, "name", "Bean name is required. Example: com.acme.FooBean"); bean = ObjectFactory.getObjectFactory().buildBean(ClassLoaderUtil.loadClass(beanName, getClass()), stack.getContext()); } catch (Exception e) { log.error("Could not instantiate bean", e); return false; } // push bean on stack stack.push(bean); // store for reference later if (getId() != null) { getStack().getContext().put(getId(), bean); } return result; }
Class clazz = ClassLoaderUtil.loadClass(className, Jsr168Dispatcher.class); ObjectFactory objectFactory = (ObjectFactory) clazz