com.sun.jersey.server.impl.inject.InjectableValuesProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ehcache Show documentation
Show all versions of ehcache Show documentation
Ehcache is an open source, standards-based cache used to boost performance,
offload the database and simplify scalability. Ehcache is robust, proven and full-featured and
this has made it the most widely-used Java-based cache.
package com.sun.jersey.server.impl.inject;
import com.sun.jersey.api.container.ContainerException;
import com.sun.jersey.api.core.HttpContext;
import com.sun.jersey.spi.inject.Injectable;
import java.util.List;
import javax.ws.rs.WebApplicationException;
/**
* A hold of a list of injectable that obtains the injectable values
* from that list.
*
* @author [email protected]
*/
public class InjectableValuesProvider {
private final List is;
/**
* Create a new instance given a list of injectable.
*
* @param is the list of injectable.
*/
public InjectableValuesProvider(List is) {
this.is = AbstractHttpContextInjectable.transform(is);
}
public List getInjectables() {
return is;
}
/**
* Get the injectable values.
*
* @param context the http contest.
* @return the injectable values. Each element in the object array
* is a value obtained from the injectable at the list index
* that is the element index.
*/
public Object[] getInjectableValues(HttpContext context) {
final Object[] params = new Object[is.size()];
try {
int index = 0;
for (AbstractHttpContextInjectable i : is) {
params[index++] = i.getValue(context);
}
return params;
} catch (WebApplicationException e) {
throw e;
} catch (ContainerException e) {
throw e;
} catch (RuntimeException e) {
throw new ContainerException("Exception obtaining parameters", e);
}
}
}