All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.beangle.struts2.convention.config.ContainerActionFinder Maven / Gradle / Ivy

There is a newer version: 3.11.3
Show newest version
/*
 * Beangle, Agile Development Scaffold and Toolkits.
 *
 * Copyright © 2005, The Beangle Software.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see .
 */
package org.beangle.struts2.convention.config;

import java.util.Map;

import org.beangle.commons.collection.CollectUtils;
import org.beangle.commons.inject.Container;
import org.beangle.commons.inject.ContainerAware;

/**
 * Find actions from application context
 *
 * @author chaostone
 * @since 3.1.0
 */
public class ContainerActionFinder implements ActionFinder, ContainerAware {

  Container container;

  public Map, String> getActions(ActionTest actionTest) {
    Map, String> actions = CollectUtils.newHashMap();
    if (null != container) {
      for (Object name : container.keys()) {
        Class type = container.getType(name).orNull();
        if (null != type && actionTest.apply(type.getName())) actions.put(type, name.toString());
      }
    }
    return actions;
  }

  @Override
  public void setContainer(Container container) {
    this.container = container;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy