ObjectInputStream in = new OwbCustomObjectInputStream(inp, WebBeansUtil.getCurrentClassLoader());
Class<?> beanClass = (Class<?>)in.readObject();
Set<Annotation> anns = new HashSet<Annotation>();
WebBeansContext webBeansContext = WebBeansContext.currentInstance();
AnnotatedElementFactory annotatedElementFactory = webBeansContext.getAnnotatedElementFactory();
while(!in.readObject().equals('~')) // read throw-away '-' or '~' terminal delimiter.
{
Annotation ann = (Annotation) in.readObject(); // now read the annotation.
anns.add(ann);
}
//process annotations
ownerBean = webBeansContext.getBeanManagerImpl().getBeans(beanClass, anns.toArray(new Annotation[anns.size()])).iterator().next();
qualifierAnnotations = anns;
// determine type of injection point member (0=field, 1=method, 2=constructor) and read...
int c = in.readByte();
if(c == 0)
{
String fieldName = in.readUTF();
Field field = webBeansContext.getSecurityService().doPrivilegedGetDeclaredField(beanClass, fieldName);
injectionMember = field;
AnnotatedType<?> annotatedType = annotatedElementFactory.newAnnotatedType(beanClass);
annotated = annotatedElementFactory.newAnnotatedField(field, annotatedType);
injectionType = field.getGenericType();
}
else if(c == 1)
{
String methodName = in.readUTF();
Class<?>[] parameters = (Class<?>[])in.readObject();
Method method = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod(beanClass, methodName, parameters);
injectionMember = method;
AnnotatedType<?> annotatedType = annotatedElementFactory.newAnnotatedType(beanClass);
AnnotatedMethod<Object> am = (AnnotatedMethod<Object>)annotatedElementFactory.
newAnnotatedMethod((Method) injectionMember,annotatedType);
List<AnnotatedParameter<Object>> annParameters = am.getParameters();
annotated = annParameters.get(in.readByte());
injectionType = annotated.getBaseType();
}
else if(c == 2)
{
Class<?>[] parameters = (Class<?>[])in.readObject();
try
{
injectionMember = beanClass.getConstructor(parameters);
}
catch(NoSuchMethodException e)
{
injectionMember = null;
}
AnnotatedType<Object> annotatedType = (AnnotatedType<Object>)annotatedElementFactory.newAnnotatedType(beanClass);
AnnotatedConstructor<Object> am = annotatedElementFactory
.newAnnotatedConstructor((Constructor<Object>) injectionMember,annotatedType);
List<AnnotatedParameter<Object>> annParameters = am.getParameters();
annotated = annParameters.get(in.readByte());
injectionType = annotated.getBaseType();