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

org.springframework.contributions.annotation.MappedContributionResolver Maven / Gradle / Ivy

Go to download

This project adds a so called contribution mechanism (like known from Tapestry IOC or Eclipse Plugins) for configuration and extension of services to the Spring project.

There is a newer version: 2.0.0
Show newest version
package org.springframework.contributions.annotation;

import static org.springframework.contributions.ContributionsNamespaceHandler.MAPPED_CONTRIBUTION_PREFIX;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;

/**
 * A service which can be used to retrieve a mapped contribution bean.
 * This service should be used in a beans java configuration method for getting a needed contribution.
 * 
 * @author Ortwin Probst
 *
 * @param 
 */
public class MappedContributionResolver>
{
	private final Log LOG = LogFactory.getLog(MappedContributionResolver.class);

	private ApplicationContext context;

	public MappedContributionResolver(ApplicationContext context)
	{
		this.context = context;
	}

	/**
	 * 
	 * @param contribution the name of the desired mapped contribution bean
	 * @return the contribution bean identified by its name, or an empty list if no contribution was found
	 */
    @SuppressWarnings({"unchecked", "rawtypes"})
    public T resolve(String contribution)
    {
        try
        {
            return (T) context.getBean(MAPPED_CONTRIBUTION_PREFIX + contribution);
        }
        catch (Exception e)
        {
            LOG.warn("Coluld not recieve the mapped contribution bean named '" + contribution + "'");
        }
        return (T) new HashMap();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy