List of usage examples for java.lang IllegalAccessException getMessage
public String getMessage()
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 {// w ww .j a v a 2 s .c o 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:net.mojodna.sprout.support.SproutUtils.java
/** * Bean initialization method. Uses reflection to determine properties * for which auto-wiring may be appropriate. Subsequently attempts to * retrieve appropriate beans from the WebApplicationContext and set them * locally.//from www. j av a 2 s . c om * * @param bean Bean to initialize. * @param context WebApplicationContext containing Spring beans. * @param clazz Type of Sprout. This is used to determine which declared * methods are candidates for auto-wiring. */ public static void initialize(final Object bean, final WebApplicationContext context, final Class clazz) { final Collection<Method> methods = SproutUtils.getDeclaredMethods(bean.getClass(), clazz); final PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(bean.getClass()); for (final PropertyDescriptor descriptor : descriptors) { final Class type = descriptor.getPropertyType(); // beans should never be of type String // there must be a write method present // the write method must exist within the relevant subset of declared methods if (!type.equals(String.class) && null != descriptor.getWriteMethod() && methods.contains(descriptor.getWriteMethod())) { final Object serviceBean = context.getBean(descriptor.getName()); if (null != serviceBean) { try { log.debug("Wiring property '" + descriptor.getName() + "' with bean of type " + serviceBean.getClass().getName()); PropertyUtils.setProperty(bean, descriptor.getName(), serviceBean); } catch (final IllegalAccessException e) { throw new RuntimeException(e); } catch (final InvocationTargetException e) { throw new RuntimeException(e); } catch (final NoSuchMethodException e) { throw new RuntimeException(e); } } } } /** * TODO additional lifecycle interface callbacks as defined in BeanFactory * should be implemented here * @see org.springframework.beans.factory.BeanFactory */ // InitializingBean callback if (bean instanceof InitializingBean) { try { ((InitializingBean) bean).afterPropertiesSet(); } catch (final Exception e) { log.warn("Exception while running afterPropertiesSet() on an InitializingBean: " + e.getMessage(), e); } } }
From source file:org.nekorp.workflow.desktop.view.binding.listener.BindingActionListener.java
@Override public void actionPerformed(ActionEvent e) { try {// w w w . j a v a 2 s . c om Object value = source.getModelValue(); source.ignoreUpdate(value); BeanUtils.setProperty(target, property, value); } catch (IllegalAccessException ex) { BindingActionListener.LOGGER.debug(ex.getMessage()); } catch (InvocationTargetException ex) { BindingActionListener.LOGGER.debug( "quiere actualizar doble target:" + target + " property:" + property + " origen:" + source); } }
From source file:org.jaffa.soa.dataaccess.DataTransformer.java
/** * Take a source object and delete it or delete is children if it has any * * @param path The path of this object being processed. This identifies possible parent * and/or indexed entries where this object is contained. * @param source Source object to mould from, typically a GraphDataObject * @param uow Transaction handle all creates/update will be performed within. * Throws an exception if null. * @param handler Possible bean handler to be used when processing this source object graph * @throws ApplicationExceptions Thrown if one or more application logic errors are generated during moulding * @throws FrameworkException Thrown if any runtime moulding error has occured. *///w ww .j av a 2 s . co m public static void deleteGraph(String path, GraphDataObject source, UOW uow, ITransformationHandler handler) throws ApplicationExceptions, FrameworkException { if (log.isDebugEnabled()) log.debug("Delete Bean " + path); try { IPersistent domainObject = null; GraphMapping mapping = MappingFactory.getInstance(source); Map keys = new LinkedHashMap(); Class doClass = mapping.getDomainClass(); // Get the key fields used in the domain object boolean gotKeys = TransformerUtils.fillInKeys(path, source, mapping, keys); //---------------------------------------------------------------- // read DO based on key if (gotKeys) { // get the method on the DO to read via PK Method[] ma = doClass.getMethods(); Method findByPK = null; for (int i = 0; i < ma.length; i++) { if (ma[i].getName().equals("findByPK")) { if (ma[i].getParameterTypes().length == (keys.size() + 1) && (ma[i].getParameterTypes())[0] == UOW.class) { // Found with name and correct no. of input params findByPK = ma[i]; break; } } } if (findByPK == null) throw new ApplicationExceptions(new DomainObjectNotFoundException(doClass.getName())); // Build input array Object[] inputs = new Object[keys.size() + 1]; { inputs[0] = uow; int i = 1; for (Iterator it = keys.values().iterator(); it.hasNext(); i++) { inputs[i] = it.next(); } } // Find Object based on key domainObject = (IPersistent) findByPK.invoke(null, inputs); } else { if (log.isDebugEnabled()) log.debug( "Object " + path + " has either missing or null key values - Assume Create is needed"); } // Error if DO not found if (domainObject == null) throw new ApplicationExceptions( new DomainObjectNotFoundException(TransformerUtils.findDomainLabel(doClass))); // Process the delete, either on this DO, or a related DO if there is one TransformerUtils.deleteBeanData(path, source, uow, handler, mapping, domainObject); // Invoke the changeDone trigger if (handler != null && handler.isChangeDone()) { for (ITransformationHandler transformationHandler : handler.getTransformationHandlers()) { transformationHandler.changeDone(path, source, domainObject, uow); } } } catch (IllegalAccessException e) { TransformException me = new TransformException(TransformException.ACCESS_ERROR, path, e.getMessage()); log.error(me.getLocalizedMessage(), e); throw me; } catch (InvocationTargetException e) { ApplicationExceptions appExps = ExceptionHelper.extractApplicationExceptions(e); if (appExps != null) throw appExps; FrameworkException fe = ExceptionHelper.extractFrameworkException(e); if (fe != null) throw fe; TransformException me = new TransformException(TransformException.INVOCATION_ERROR, path, e); log.error(me.getLocalizedMessage(), me.getCause()); throw me; } catch (InstantiationException e) { TransformException me = new TransformException(TransformException.INSTANTICATION_ERROR, path, e.getMessage()); log.error(me.getLocalizedMessage(), e); throw me; } // } catch (Exception e) { // throw handleException(e,aes); // } }
From source file:org.nekorp.workflow.desktop.view.binding.listener.BindingDocumentListener.java
@Override public void insertUpdate(DocumentEvent e) { try {//from ww w . j a va 2 s . c o m Object value = source.getModelValue(); source.ignoreUpdate(value); BeanUtils.setProperty(target, property, value); } catch (IllegalAccessException ex) { BindingDocumentListener.LOGGER.debug(ex.getMessage()); } catch (InvocationTargetException ex) { BindingDocumentListener.LOGGER.debug( "quiere actualizar doble target:" + target + " property:" + property + " origen:" + source); } }
From source file:org.nekorp.workflow.desktop.view.binding.listener.BindingDocumentListener.java
@Override public void removeUpdate(DocumentEvent e) { try {// w w w .j a va2 s . c o m Object value = source.getModelValue(); source.ignoreUpdate(value); BeanUtils.setProperty(target, property, value); } catch (IllegalAccessException ex) { BindingDocumentListener.LOGGER.debug(ex.getMessage()); } catch (InvocationTargetException ex) { BindingDocumentListener.LOGGER.debug( "quiere actualizar doble target:" + target + " property:" + property + " origen:" + source); } }
From source file:org.nekorp.workflow.desktop.view.binding.listener.BindingDocumentListener.java
@Override public void changedUpdate(DocumentEvent e) { try {//ww w .j a va2 s . c o m Object value = source.getModelValue(); source.ignoreUpdate(value); BeanUtils.setProperty(target, property, value); } catch (IllegalAccessException ex) { BindingDocumentListener.LOGGER.debug(ex.getMessage()); } catch (InvocationTargetException ex) { BindingDocumentListener.LOGGER.debug( "quiere actualizar doble target:" + target + " property:" + property + " origen:" + source); } }
From source file:com.liferay.util.PropertyComparator.java
public int compare(Object obj1, Object obj2) { try {/*from ww w . java 2s . c o m*/ for (int i = 0; i < _propertyNames.length; i++) { String propertyName = _propertyNames[i]; Object property1 = PropertyUtils.getProperty(obj1, propertyName); Object property2 = PropertyUtils.getProperty(obj2, propertyName); if (property1 instanceof String) { int result = property1.toString().compareToIgnoreCase(property2.toString()); if (result != 0) { return result; } } if (property1 instanceof Comparable) { int result = ((Comparable) property1).compareTo(property2); if (result != 0) { return result; } } } } catch (NoSuchMethodException nsme) { Logger.error(this, nsme.getMessage(), nsme); } catch (InvocationTargetException ite) { Logger.error(this, ite.getMessage(), ite); } catch (IllegalAccessException iae) { Logger.error(this, iae.getMessage(), iae); } return -1; }
From source file:com.panet.imeta.job.entry.validator.NotNullValidator.java
public boolean validate(CheckResultSourceInterface source, String propertyName, List<CheckResultInterface> remarks, ValidatorContext context) { LogWriter log = LogWriter.getInstance(); Object value = null;/*from w w w. j av a 2s. c o m*/ try { value = PropertyUtils.getProperty(source, propertyName); if (null == value) { JobEntryValidatorUtils.addFailureRemark(source, propertyName, VALIDATOR_NAME, remarks, JobEntryValidatorUtils.getLevelOnFail(context, VALIDATOR_NAME)); return false; } else { return true; } } catch (IllegalAccessException e) { log.logBasic(JobEntryValidatorUtils.class.getSimpleName(), e.getMessage()); JobEntryValidatorUtils.addExceptionRemark(source, propertyName, VALIDATOR_NAME, remarks, e); } catch (InvocationTargetException e) { log.logBasic(JobEntryValidatorUtils.class.getSimpleName(), e.getMessage()); JobEntryValidatorUtils.addExceptionRemark(source, propertyName, VALIDATOR_NAME, remarks, e); } catch (NoSuchMethodException e) { log.logBasic(JobEntryValidatorUtils.class.getSimpleName(), e.getMessage()); JobEntryValidatorUtils.addExceptionRemark(source, propertyName, VALIDATOR_NAME, remarks, e); } return false; }
From source file:org.jasig.cas.util.annotation.AbstractAnnotationBeanPostProcessor.java
public final Object postProcessBeforeInitialization(final Object bean, final String beanName) throws BeansException { final List<Field> fields = new ArrayList<Field>(); final Class<?> clazz = bean.getClass(); final Class<?>[] classes = clazz.getClasses(); addDeclaredFields(clazz, fields);//w ww . jav a 2s . c om for (int i = 0; i < classes.length; i++) { addDeclaredFields(classes[i], fields); } try { for (final Field field : fields) { final boolean originalValue = field.isAccessible(); field.setAccessible(true); final Annotation annotation = field.getAnnotation(getSupportedAnnotation()); if (annotation != null) { processField(field, annotation, bean, beanName); } field.setAccessible(originalValue); } } catch (final IllegalAccessException e) { log.warn("Could not access field: " + e.getMessage(), e); } return bean; }