private void readObject()

in webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java [241:313]


    private void readObject(java.io.ObjectInputStream inp) throws IOException, ClassNotFoundException
    {

        ObjectInputStream in = new OwbCustomObjectInputStream(inp, WebBeansUtil.getCurrentClassLoader());

        Class<?> ownerBeanClass = (Class<?>)in.readObject();
        Set<Annotation> ownerQualifiers = readQualifiers(in);

        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
        AnnotatedElementFactory annotatedElementFactory = webBeansContext.getAnnotatedElementFactory();

        //process annotations
        BeanManagerImpl beanManager = webBeansContext.getBeanManagerImpl();
        Set<Bean<?>> beans = beanManager.getBeans(ownerBeanClass,
                                                  ownerQualifiers.toArray(new Annotation[ownerQualifiers.size()]));
        ownerBean = beanManager.resolve(beans);

        // 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(ownerBeanClass, fieldName);

            injectionMember = field;
            
            AnnotatedType<?> annotatedType = annotatedElementFactory.newAnnotatedType(ownerBeanClass);
            annotated = annotatedElementFactory.newAnnotatedField(field, annotatedType);
            injectionType = field.getGenericType();

            qualifierAnnotations = readQualifiers(in);
        }
        else if(c == 1)
        {
            String methodName = in.readUTF();
            Class<?>[] parameters = (Class<?>[])in.readObject();
            
            Method method = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod(ownerBeanClass, methodName, parameters);
            injectionMember = method;
            
            AnnotatedType<?> annotatedType = annotatedElementFactory.newAnnotatedType(ownerBeanClass);
            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 = ownerBeanClass.getConstructor(parameters);

            }
            catch(NoSuchMethodException e)
            {
                injectionMember = null;
            }

            AnnotatedType<Object> annotatedType = (AnnotatedType<Object>)annotatedElementFactory.newAnnotatedType(ownerBeanClass);
            AnnotatedConstructor<Object> am =  annotatedElementFactory
                                            .newAnnotatedConstructor((Constructor<Object>) injectionMember,annotatedType);
            List<AnnotatedParameter<Object>> annParameters = am.getParameters();

            annotated = annParameters.get(in.readByte());
            injectionType = annotated.getBaseType();
        }

        delegate = in.readBoolean();
        transientt = in.readBoolean();
    }