/** * {@inheritDoc} * * @param propertyName * the property name * @return the object */ @Override public Object get(String propertyName) { try { return accessorFactory.createPropertyAccessor(propertyName, getClass()).getValue(this); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) { throw new ComponentException(ex, "Can not read component property " + propertyName + " on " + getClass().getName()); } }
/** * Constructs a new {@code ComparableProperties} instance. * * @param sourceObject * the source object to compare properties. * @param orderingAccessors * the accessors to extract properties to compare. */ public ComparableProperties(Object sourceObject, List<IAccessor> orderingAccessors) { this.sourceObject = sourceObject; if (sourceObject != null) { valuesToCompare = new Object[orderingAccessors.size()]; for (int i = 0; i < valuesToCompare.length; i++) { try { valuesToCompare[i] = orderingAccessors.get(i).getValue(sourceObject); } catch (IllegalAccessException | NoSuchMethodException ex) { throw new MissingPropertyException(ex.getMessage()); } catch (InvocationTargetException ex) { if (ex.getCause() instanceof RuntimeException) { throw (RuntimeException) ex.getCause(); } throw new RuntimeException(ex.getCause()); } } } }
/** * Accesses the underlying model property and gets its value. * <p> * {@inheritDoc} */ @Override protected Object getConnecteeValue() { try { return accessor.getValue(getModelProvider().getModel()); } catch (IllegalAccessException ex) { throw new ConnectorBindingException(ex); } catch (InvocationTargetException ex) { if (ex.getCause() instanceof RuntimeException) { throw (RuntimeException) ex.getCause(); } throw new ConnectorBindingException(ex.getCause()); } catch (NoSuchMethodException ex) { // this may be a normal behaviour in case of polymorphism. // don't throw any exception. // throw new ConnectorBindingException(ex); return null; } }
/** * {@inheritDoc} */ @Override protected Object retrievePropertyValue(String propertyName) { try { return getAccessorFactory().createPropertyAccessor(propertyName, getComponentContract()).getValue(delegate); } catch (IllegalAccessException | NoSuchMethodException ex) { throw new ComponentException(ex); } catch (InvocationTargetException ex) { if (ex.getCause() instanceof RuntimeException) { throw (RuntimeException) ex.getCause(); } throw new ComponentException(ex.getCause()); } }
E modelValue = accessor.getValue(elt); eltOpen = shouldOpen(modelValue); if (!openOnTrue) {
IAccessor sessionAccessor = getAccessorFactory() .createPropertyAccessor(sessionProperty, sessionContract); initValue = sessionAccessor.getValue(applicationSession); if (LOG.isDebugEnabled()) { LOG.debug("Session contract : " + sessionContract.getName());
if (lastDotIndexOfReferencePath > 0) { refinedMasterComponent = accessorFactory.createPropertyAccessor( referencePath.substring(0, lastDotIndexOfReferencePath), masterComponentContract).getValue( masterComponent); masterComponentContract = getComponentContract(refinedMasterComponent); IAccessor masterAccessor = accessorFactory.createPropertyAccessor((String) initializedAttributeValue, masterComponentContract); initValue = masterAccessor.getValue(refinedMasterComponent); if (LOG.isDebugEnabled()) { LOG.debug("Master component contract : " + masterComponentContract.getName());
private List<Serializable> extractQueryPropertyValues(IEntity entity, List<String> extraProps) { List<Serializable> values = new ArrayList<>(); values.add(entity.getId()); values.add(entity.toString()); if (extraProps != null) { for (String extraProp : extraProps) { try { Serializable extraPropValue = getComponentFactory().getAccessorFactory().createPropertyAccessor(extraProp, entity.getComponentContract()).getValue(entity); values.add(extraPropValue); } catch (IllegalAccessException | NoSuchMethodException ex) { throw new NestedRuntimeException(ex, "Invalid property: " + extraProp); } catch (InvocationTargetException ex) { throw new NestedRuntimeException(ex.getTargetException(), "Invalid property: " + extraProp); } } } return values; }
/** * To string. * * @param proxy * the proxy * @return the to string */ protected String toString(Object proxy) { try { String toStringPropertyName = componentDescriptor.getToStringProperty(); Object toStringValue = accessorFactory.createPropertyAccessor(toStringPropertyName, componentDescriptor.getComponentContract()).getValue(proxy); if (toStringValue == null) { return ""; } return toStringValue.toString(); } catch (IllegalAccessException | NoSuchMethodException ex) { throw new ComponentException(ex); } catch (InvocationTargetException ex) { if (ex.getCause() instanceof RuntimeException) { throw (RuntimeException) ex.getCause(); } throw new ComponentException(ex.getCause()); } }
try { propertyHolder = getAccessorFactory().createPropertyAccessor(propertyName.substring(0, lastIndexOfDelim), getComponentContract()).getValue(proxy); if (propertyHolder != null && propertyHolder instanceof IComponent) { ((IComponent) propertyHolder).firePropertyChange(propertyName.substring(lastIndexOfDelim + 1), oldValue,
try { initialValue = new BeanAccessorFactory().createPropertyAccessor(sourceProperty, sourceBean.getClass()) .getValue(sourceBean); } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException ex) { throw new NestedRuntimeException(ex);
propertyAccessor.getValue(evt.getSource());
Object reference = accessor.getValue(component); if (reference instanceof Collection<?>) { references.addAll((Collection<?>) reference);
Object propertyValue = getAccessorFactory(context) .createPropertyAccessor(property, targetContract) .getValue(model); setActionParameter(propertyValue, context); } catch (IllegalAccessException | NoSuchMethodException ex) {
if (property != null) { try { property = getAccessorFactory().createPropertyAccessor(nestedProperty, property.getClass()).getValue( property); } catch (IllegalAccessException | NoSuchMethodException e) {
Object newValue = accessorFactory.createPropertyAccessor(prop, targetBeanComponentContract).getValue( targetBean); targetBean.firePropertyChange(prop, IPropertyChangeCapable.UNKNOWN, newValue);
/** * Saves the account information as well as the account devices. * <p> * {@inheritDoc} */ @Override public boolean execute( @SuppressWarnings("unused") IActionHandler actionHandler, Map<String, Object> context) { IEntity model = (IEntity) getModelConnector(context).getConnectorValue(); if (model != null) { try { Object propertyValue = getAccessorFactory(context) .createPropertyAccessor(property, model.getContract()).getValue( model); context.put(ActionContextConstants.ACTION_PARAM, propertyValue); } catch (IllegalAccessException ex) { throw new ActionException(ex); } catch (InvocationTargetException ex) { throw new ActionException(ex); } catch (NoSuchMethodException ex) { throw new ActionException(ex); } } return true; }
E modelValue = accessor.getValue(model); this.open = shouldOpen(modelValue); if (!openOnTrue) {
/** * {@inheritDoc} * * @param actionHandler * the action handler * @param context * the context * @return the boolean */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { Object selectedModel = getSelectedModel(context); Object username; try { username = getBackendController(context).getAccessorFactory().createPropertyAccessor(getUsernameProperty(), selectedModel.getClass()).getValue(selectedModel); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) { throw new ActionException(ex, "Could not extract username from model"); } context.put(AbstractResetPasswordAction.USERNAME_KEY, username); if (super.execute(actionHandler, context)) { getFrontendController(context).popupInfo(getSourceComponent(context), actionHandler.getTranslation("password.reset.title", getLocale(context)), getIconFactory(context).getInfoIconImageURL(), HtmlHelper.toHtml( actionHandler.getTranslation("password.reset.message", getLocale(context)) + HtmlHelper .emphasis((String) context.get(AbstractResetPasswordAction.GENERATED_PASSWORD_KEY)))); return true; } return false; }