Package jodd.madvoc.injector

Source Code of jodd.madvoc.injector.ActionPathMacroInjector

// Copyright (c) 2003-2014, Jodd Team (jodd.org). All Rights Reserved.

package jodd.madvoc.injector;

import jodd.bean.BeanUtil;
import jodd.madvoc.ActionConfig;
import jodd.madvoc.ActionConfigSet;
import jodd.madvoc.ActionRequest;
import jodd.util.StringUtil;

/**
* Injects macro values from action path into the action bean.
*/
public class ActionPathMacroInjector implements Injector {

  public void inject(ActionRequest actionRequest) {
    ActionConfig config = actionRequest.getActionConfig();
    ActionConfigSet set = config.getActionConfigSet();

    if (set.actionPathMacros == null) {
      return;
    }

    Object target = actionRequest.getAction();

    String[] names = set.actionPathMacros.getNames();
    String[] values = set.actionPathMacros.extract(actionRequest.getActionPath());

    for (int i = 0; i < values.length; i++) {
      String value = values[i];

      if (StringUtil.isEmpty(value)) {
        continue;
      }

      String name = names[i];

      BeanUtil.setDeclaredPropertyForcedSilent(target, name, value);
    }
  }
}
TOP

Related Classes of jodd.madvoc.injector.ActionPathMacroInjector

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.