List of usage examples for org.springframework.beans BeanUtils instantiateClass
public static <T> T instantiateClass(Class<T> clazz) throws BeanInstantiationException
From source file:biz.c24.io.spring.util.C24Utils.java
/** * Returns all the classes supported by the given model {@link Element}. * /*www . j ava2 s . com*/ * @param element * @return */ @SuppressWarnings("unchecked") public static Set<Class<? extends ComplexDataObject>> getSupportedTypes(Element element) { Class<? extends ComplexDataObject> type = element.getType().getValidObjectClass(); HashSet<Class<? extends ComplexDataObject>> result = new HashSet<Class<? extends ComplexDataObject>>(); if (!DocumentRoot.class.isAssignableFrom(type)) { result.add(type); return result; } DocumentRoot root = (DocumentRoot) BeanUtils.instantiateClass(type); for (int i = 0; i < root.getElementDeclCount(); i++) { Element declaredElement = root.getElementDecl(i); result.add(declaredElement.getType().getValidObjectClass()); } return result; }
From source file:org.shept.util.PageHolderFactory.java
public Refreshable getObject() { Refreshable pageHolder = BeanUtils.instantiateClass(listHolderClass); pageHolder.setDao(dao); return pageHolder; }
From source file:org.codehaus.griffon.runtime.quartz.CustomTriggerFactoryBean.java
public void afterPropertiesSet() throws ParseException { customTrigger = BeanUtils.instantiateClass(triggerClass); if (triggerAttributes.containsKey(QuartzConstants.START_DELAY)) { Number startDelay = (Number) triggerAttributes.remove(QuartzConstants.START_DELAY); customTrigger.setStartTime(new Date(System.currentTimeMillis() + startDelay.longValue())); }//from ww w. ja va 2 s . c o m if (jobDetail != null) { customTrigger.setJobName(jobDetail.getName()); customTrigger.setJobGroup(jobDetail.getGroup()); } BeanWrapper customTriggerWrapper = PropertyAccessorFactory.forBeanPropertyAccess(customTrigger); customTriggerWrapper.registerCustomEditor(String.class, new StringEditor()); customTriggerWrapper.setPropertyValues(triggerAttributes); }
From source file:com.ebay.pulsar.metric.server.MetricDispatcherServlet.java
protected WebApplicationContext createWebApplicationContext(ApplicationContext parent) { Class<?> contextClass = getContextClass(); if (this.logger.isDebugEnabled()) { this.logger.debug("Servlet with name '" + getServletName() + "' will try to create custom WebApplicationContext context of class '" + contextClass.getName() + "'" + ", using parent context [" + parent + "]"); }//from w ww. j ava2 s. c o m if (!ConfigurableWebApplicationContext.class.isAssignableFrom(contextClass)) { throw new ApplicationContextException("Fatal initialization error in servlet with name '" + getServletName() + "': custom WebApplicationContext class [" + contextClass.getName() + "] is not of type ConfigurableWebApplicationContext"); } ConfigurableWebApplicationContext wac = (ConfigurableWebApplicationContext) BeanUtils .instantiateClass(contextClass); wac.setParent(parent); if (wac.getParent() == null) { ApplicationContext rootContext = (ApplicationContext) getServletContext().getAttribute("JetStreamRoot"); wac.setParent(rootContext); } wac.setConfigLocation(getContextConfigLocation()); configureAndRefreshWebApplicationContext(wac); return wac; }
From source file:corner.orm.services.impl.PersistedEntity.java
Object restore(EntityService entityService) { try {//from w w w. j a va 2 s. c om Class<?> clazz = Class.forName(entityName); if (id != null) {//persist from store return entityService.get(clazz, id); } else {//new class return BeanUtils.instantiateClass(clazz); } } catch (Exception ex) { throw new RuntimeException(ex); } }
From source file:org.shept.util.PageHolderFactoryBean.java
public FilteredListHolder getObject() throws Exception { FilteredListHolder pageHolder = (FilteredListHolder) BeanUtils.instantiateClass(listHolderClass); pageHolder.setDao(dao);/*from www . j ava 2 s .c o m*/ pageHolder.setPageSize(getPageSize()); return pageHolder; }
From source file:grails.plugins.quartz.CustomTriggerFactoryBean.java
public void afterPropertiesSet() throws ParseException { // Create a trigger by the class name customTrigger = BeanUtils.instantiateClass(triggerClass); // If trigger is a standard trigger, set standard properties if (customTrigger instanceof AbstractTrigger) { AbstractTrigger<?> at = (AbstractTrigger<?>) customTrigger; if (jobDetail != null) { at.setJobKey(jobDetail.getKey()); }/*from w ww . ja v a2 s.c o m*/ if (triggerAttributes.containsKey(GrailsJobClassConstants.START_DELAY)) { Number startDelay = (Number) triggerAttributes.remove(GrailsJobClassConstants.START_DELAY); at.setStartTime(new Date(System.currentTimeMillis() + startDelay.longValue())); } } // Set non standard properties. BeanWrapper customTriggerWrapper = PropertyAccessorFactory.forBeanPropertyAccess(customTrigger); customTriggerWrapper.registerCustomEditor(String.class, new StringEditor()); customTriggerWrapper.setPropertyValues(triggerAttributes); }
From source file:corner.tapestry.base.EntityPage.java
@PageAttached void initEntity() { if (this.getEntity() == null) { this.setEntity((T) BeanUtils.instantiateClass(entityClass)); } }
From source file:org.lightadmin.core.config.bootstrap.RepositoriesFactoryBean.java
@Override protected Repositories createInstance() throws Exception { Repositories repositories = BeanUtils.instantiateClass(Repositories.class); configureRepositories(repositories); return repositories; }
From source file:org.lightadmin.core.config.domain.unit.ConfigurationUnitsConverter.java
private static AdministrationConfiguration configurationInstance(final Class configurationClass) { return (AdministrationConfiguration) BeanUtils.instantiateClass(configurationClass); }