injectors.put(accObj, new TimerServicePropertyInjector(property, (Container) container)); // only EJBs
}
else if(type.equals(URL.class) && ref.mappedName() != null && ref.mappedName().length() > 0)
{
createURLInjector(encName, ref.mappedName(), container);
injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
}
else if (type.equals(String.class)
|| type.equals(Character.class)
|| type.equals(Byte.class)
|| type.equals(Short.class)
|| type.equals(Integer.class)
|| type.equals(Long.class)
|| type.equals(Boolean.class)
|| type.equals(Double.class)
|| type.equals(Float.class)
|| type.isPrimitive()
)
{
// don't add an injector if no XML <env-entry is present as there will be no value to inject
if (container.getEncInjectors().containsKey(encName))
{
injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
}
else if (ref.mappedName() != null && ref.mappedName().length() > 0)
{
// Use the mappedName as the string value
String s = ref.mappedName().trim();
try
{
Object value = ValueConvertor.convertValue(type, s);
container.getEncInjectors().put(encName, new ValueEncInjector(encName, value, "@Resource"));
injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
}
catch(Throwable t)
{
throw new RuntimeException("Failed to convert: "+ref.mappedName()+" to type:"+type, t);
}
}
else
{
log.warn("Not injecting " + property.getName() + ", no matching enc injector " + encName + " found");
}
}
else
{
if (checkEncInjectors && !container.getEncInjectors().containsKey(encName))
{
String mappedName = ref.mappedName();
if (mappedName == null || mappedName.equals(""))
{
// TODO: is this a nice trick?
// if(ConnectionFactory.class.isAssignableFrom(type))
// {
// // neat little trick
// mappedName = "java:/ConnectionFactory";
// }
// else
if(ORB.class.isAssignableFrom(type))
mappedName = "java:comp/ORB";
else if(EJBContext.class.isAssignableFrom(type))
mappedName = "java:comp/EJBContext";
else
throw new RuntimeException("You did not specify a @Resource.mappedName() on " + accObj + " and there is no binding for enc name " + encName + " in XML");
}
container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, mappedName, "@Resource"));
}
injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
}
}