Example usage for org.apache.commons.lang3.reflect FieldUtils getField

List of usage examples for org.apache.commons.lang3.reflect FieldUtils getField

Introduction

In this page you can find the example usage for org.apache.commons.lang3.reflect FieldUtils getField.

Prototype

public static Field getField(final Class<?> cls, final String fieldName, final boolean forceAccess) 

Source Link

Document

Gets an accessible Field by name, breaking scope if requested.

Usage

From source file:uk.q3c.krail.core.ui.ScopedUI.java

/**
 * A rather horrible way of setting the value of private field from parent class.  See http://krail.readthedocs.io/en/develop/devguide/devguide-push.html
 *
 * @param pushConfig/*from  www  . j a v a  2 s.  c o m*/
 */
private void overridePushConfiguration(KrailPushConfiguration pushConfig) {
    try {
        pushConfig.setUi(this);
        Field pushConfigField = FieldUtils.getField(this.getClass(), "pushConfiguration", true);
        pushConfigField.set(this, pushConfig);

    } catch (Exception e) {
        throw new ConfigurationException("Unable to set up push for the UI", e);
    }
}

From source file:uk.q3c.krail.core.ui.ScopedUI.java

/**
 *
 *///from  w  ww .  j  av a 2s. c o m
private void setConnectionUid() {
    PushConnection pushConnection = getPushConnection();
    if (pushConnection != null) {
        if (pushConnection instanceof SockJSPushConnection) {
            SockJSPushConnection sockConnection = (SockJSPushConnection) pushConnection;
            Field uiIdField = FieldUtils.getField(SockJSPushConnection.class, "uiId", true);
            try {
                uiIdField.set(sockConnection, this.getUIId());
            } catch (IllegalAccessException e) {
                throw new ConfigurationException("Unable to set up push connection with correct UI Id", e);
            }
        }
    }
}