Search in sources :

Example 1 with GridSpringResourceContextImpl

use of org.apache.ignite.internal.processors.resource.GridSpringResourceContextImpl in project ignite by apache.

the class IgniteSpringHelperImpl method loadConfigurations.

/**
 * {@inheritDoc}
 */
@Override
public <T> IgniteBiTuple<Collection<T>, ? extends GridSpringResourceContext> loadConfigurations(InputStream cfgStream, Class<T> cls, String... excludedProps) throws IgniteCheckedException {
    ApplicationContext springCtx = applicationContext(cfgStream, excludedProps);
    Map<String, T> cfgMap;
    try {
        cfgMap = springCtx.getBeansOfType(cls);
    } catch (BeansException e) {
        throw new IgniteCheckedException("Failed to instantiate bean [type=" + cls + ", err=" + e.getMessage() + ']', e);
    }
    if (cfgMap == null || cfgMap.isEmpty())
        throw new IgniteCheckedException("Failed to find configuration in: " + cfgStream);
    return F.t(cfgMap.values(), new GridSpringResourceContextImpl(springCtx));
}
Also used : GridSpringResourceContextImpl(org.apache.ignite.internal.processors.resource.GridSpringResourceContextImpl) ApplicationContext(org.springframework.context.ApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) BeansException(org.springframework.beans.BeansException)

Example 2 with GridSpringResourceContextImpl

use of org.apache.ignite.internal.processors.resource.GridSpringResourceContextImpl in project ignite by apache.

the class IgniteSpringHelperImpl method loadConfigurations.

/**
 * {@inheritDoc}
 */
@Override
public <T> IgniteBiTuple<Collection<T>, ? extends GridSpringResourceContext> loadConfigurations(URL cfgUrl, Class<T> cls, String... excludedProps) throws IgniteCheckedException {
    ApplicationContext springCtx = applicationContext(cfgUrl, excludedProps);
    Map<String, T> cfgMap;
    try {
        cfgMap = springCtx.getBeansOfType(cls);
    } catch (BeansException e) {
        throw new IgniteCheckedException("Failed to instantiate bean [type=" + cls + ", err=" + e.getMessage() + ']', e);
    }
    if (cfgMap == null || cfgMap.isEmpty())
        throw new IgniteCheckedException("Failed to find configuration in: " + cfgUrl);
    return F.t(cfgMap.values(), new GridSpringResourceContextImpl(springCtx));
}
Also used : GridSpringResourceContextImpl(org.apache.ignite.internal.processors.resource.GridSpringResourceContextImpl) ApplicationContext(org.springframework.context.ApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) BeansException(org.springframework.beans.BeansException)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 GridSpringResourceContextImpl (org.apache.ignite.internal.processors.resource.GridSpringResourceContextImpl)2 BeansException (org.springframework.beans.BeansException)2 ApplicationContext (org.springframework.context.ApplicationContext)2 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)2