List of usage examples for java.lang InstantiationException getMessage
public String getMessage()
From source file:org.jruby.rack.mock.WebUtils.java
/** * Get the specified session attribute, creating and setting a new attribute if * no existing found. The given class needs to have a public no-arg constructor. * Useful for on-demand state objects in a web tier, like shopping carts. * @param session current HTTP session/*from ww w. j a va 2 s . c om*/ * @param name the name of the session attribute * @param clazz the class to instantiate for a new attribute * @return the value of the session attribute, newly created if not found * @throws IllegalArgumentException if the session attribute could not be instantiated */ public static Object getOrCreateSessionAttribute(HttpSession session, String name, Class<?> clazz) throws IllegalArgumentException { Assert.notNull(session, "Session must not be null"); Object sessionObject = session.getAttribute(name); if (sessionObject == null) { try { sessionObject = clazz.newInstance(); } catch (InstantiationException ex) { throw new IllegalArgumentException("Could not instantiate class [" + clazz.getName() + "] for session attribute '" + name + "': " + ex.getMessage()); } catch (IllegalAccessException ex) { throw new IllegalArgumentException("Could not access default constructor of class [" + clazz.getName() + "] for session attribute '" + name + "': " + ex.getMessage()); } session.setAttribute(name, sessionObject); } return sessionObject; }
From source file:com.concursive.connect.web.portal.PortalUtils.java
public static Object getFormBean(RenderRequest request, String beanName, Class beanClass) { // The RenderRequest will not auto-populate, but looks for an existing form bean from the action Object beanRef = request.getAttribute(AbstractPortletModule.FORM_BEAN); if (beanRef == null) { // Construct the bean if not found try {/*from w w w. ja v a2 s . co m*/ beanRef = beanClass.newInstance(); } catch (InstantiationException ie) { LOG.error("Instantiation Exception. MESSAGE = " + ie.getMessage(), ie); } catch (IllegalAccessException iae) { LOG.error("Illegal Access Exception. MESSAGE = " + iae.getMessage(), iae); } } if (beanRef != null) { // Add it to the request request.setAttribute(beanName, beanRef); } return beanRef; }
From source file:org.vulpe.commons.util.VulpeReflectUtil.java
public static void instanciate(Object object, String expression, Object value) { final String[] expressionParts = expression.split("\\."); if (expressionParts.length > 1) { for (final String part : expressionParts) { Object fieldValue = getFieldValue(object, part); final Field field = getField(object.getClass(), part); if (fieldValue == null) { try { final Class<?> type = field.getType(); if (VulpeEntity.class.isAssignableFrom(type)) { final Object instance = type.newInstance(); setFieldValue(object, part, instance); object = instance; } else { setFieldValue(object, part, value); }// w w w. j a v a2 s . co m } catch (InstantiationException e) { LOG.error(e.getMessage()); } catch (IllegalAccessException e) { LOG.error(e.getMessage()); } } else { object = fieldValue; final Class<?> type = field.getType(); if (!VulpeEntity.class.isAssignableFrom(type)) { setFieldValue(object, part, value); } } } } else { setFieldValue(object, expression, value); } }
From source file:org.jaffa.soa.dataaccess.DataTransformer.java
private static Object newGraphDataObject(Class clazz) throws InstantiationException { try {//from www.j a v a 2 s. c om Constructor c = clazz.getConstructor(new Class[] {}); if (c == null) throw new InstantiationException("No zero argument construtor found"); Object dao = c.newInstance((Object[]) null); if (log.isDebugEnabled()) log.debug("Created Object : " + dao); return dao; } catch (InstantiationException e) { throw e; } catch (Exception e) { log.error("Can't create Graph Data Object - " + e.getMessage(), e); throw new InstantiationException(e.getMessage()); } }
From source file:shell.framework.dao.support.ListExtractor4Bean.java
@SuppressWarnings("all") public Object extractData(ResultSet rs) throws SQLException, DataAccessException { List resultList = new ArrayList(); try {// w w w . java 2s. co m Object bean = null; ResultSetDynaClass rsdc = new ResultSetDynaClass(rs); Iterator rows = rsdc.iterator(); while (rows.hasNext()) { bean = beanClazz.newInstance(); DynaBean rowBean = (DynaBean) rows.next(); BeanUtils.copyProperties(rowBean, bean); resultList.add(bean); } } catch (InstantiationException e) { logger.error(e.getMessage() + "| bean instance failure!"); throw new DaoException(e); } catch (IllegalAccessException e) { logger.error(e.getMessage() + "| bean instance failure!"); throw new DaoException(e); } catch (InvocationTargetException e) { logger.error(e.getMessage() + "| bean instance failure!"); throw new DaoException(e); } return resultList; }
From source file:org.codehaus.groovy.grails.commons.metaclass.CreateDynamicMethod.java
@SuppressWarnings("rawtypes") @Override//from www . ja v a 2 s .c o m public Object invoke(Class clazz, String methodName, Object[] arguments) { try { return clazz.newInstance(); } catch (InstantiationException e) { LOG.warn("Unable to instantiate class [" + clazz.getName() + "]: " + e.getMessage()); } catch (IllegalAccessException e) { LOG.warn("Illegal access instantiating class [" + clazz.getName() + "]: " + e.getMessage()); } return null; }
From source file:org.dhatim.rules.RulesProviderFactory.java
RuleProvider createProvider(final Class<? extends RuleProvider> providerClass) throws SmooksException { try {/* w w w .ja v a2s. c om*/ return providerClass.newInstance(); } catch (final InstantiationException e) { throw new SmooksException(e.getMessage(), e); } catch (final IllegalAccessException e) { throw new SmooksException(e.getMessage(), e); } }
From source file:com.alfresco.orm.Session.java
public <T extends AlfrescoContent> List<T> fillObject(final List<NodeRef> nodeRefs, Class<T> classType, boolean isLazy) throws ORMException { LOGGER.debug("fillObject start number of data fetch count is " + nodeRefs.size()); List<T> retVAl = new ArrayList<T>(); T orm;/*w ww .j a v a 2 s . c o m*/ try { for (NodeRef nodeRef : nodeRefs) { LOGGER.debug("fillObject start for noderef:" + nodeRef); orm = classType.newInstance(); objectFillHelper.getFilledObject(nodeRef, orm, isLazy); retVAl.add(orm); LOGGER.debug("fillObject end for noderef:" + nodeRef); } } catch (InstantiationException e) { throw new ORMException(e.getMessage(), e); } catch (IllegalAccessException e) { throw new ORMException(e.getMessage(), e); } LOGGER.debug("fillObject end "); return retVAl; }
From source file:de.highbyte_le.weberknecht.request.view.ActionViewProcessorFactory.java
/** * @param viewProcessorName//from w w w . ja v a 2 s. c o m * unique name identifying the view processor (formerly called suffix) */ public ActionViewProcessor createActionProcessor(String viewProcessorName, ServletContext servletContext) { ActionViewProcessor processor = null; Class<? extends ActionViewProcessor> clazz = suffixProcessorMap.get(viewProcessorName); if (clazz != null) { try { processor = clazz.newInstance(); processor.setServletContext(servletContext); processor.setActionViewProcessorFactory(this); } catch (InstantiationException e) { log.error("createActionProcessor() - InstantiationException: " + e.getMessage(), e); //$NON-NLS-1$ } catch (IllegalAccessException e) { log.error("createActionProcessor() - IllegalAccessException: " + e.getMessage(), e); //$NON-NLS-1$ } } return processor; }
From source file:org.wso2.carbon.appmgt.impl.idp.WebAppIdPFactory.java
public WebAppIdPManager getIdpManager() throws AppManagementException { if (idpManager == null) { String className = config.getFirstProperty(AppMConstants.SSO_CONFIGURATION_IDENTITY_PROVIDER_MANAGER); try {/* w w w . ja v a2s . co m*/ idpManager = (WebAppIdPManager) Class.forName(className) .getConstructor(AppManagerConfiguration.class).newInstance(config); } catch (InstantiationException e) { log.error(e); throw new AppManagementException(e.getMessage()); } catch (IllegalAccessException e) { log.error(e); throw new AppManagementException(e.getMessage()); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { log.error(e); throw new AppManagementException(e.getMessage()); } catch (NoSuchMethodException e) { log.error(e); throw new AppManagementException(e.getMessage()); } catch (SecurityException e) { log.error(e); throw new AppManagementException(e.getMessage()); } catch (ClassNotFoundException e) { log.error(e); throw new AppManagementException(e.getMessage()); } } return idpManager; }