Spring bean with custom annotations
<p>I have annotated a Spring bean with custom annotations, but seems that Spring removes my custom annotations after the bean is created.</p>

<pre><code>AnnotatedBean bean = ctx.getBean(AnnotatedBean.class);

Foo.findAndDoStuffWithAnnotatedThings(bean);
</code></pre>

<p>The second step doesn't work, my custom annotations are lost. (Propably due proxy stuff)</p>

<p>My bean    </p>

<pre><code>@Rule(name = "RoutePickupRule")
@Transactional
@Component
public class AnnotatedBean{


    @Autowired
    private ICarpoolDoa carpoolDAO;

    @Condition
    public boolean condition(CustomLocation customLocation, String userId) {
        //snip
    }

    @Action
    public void action() {
        //snip
    }  
</code></pre>

<p>Example of one of my custom annotations</p>

<pre><code>@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Condition {

}
</code></pre>

<p>Where things to wrong in <em>findAndDoStuffWithAnnotatedThings</em><br>
Bean gets passed to a class where my custom annotations are verified, but my verifier can't find any annotations. (Util uses <em>isAnnotationPresent</em> method). Again, when I would create my bean myself using 'new' there is no problem. </p>

<pre><code>public class RuleAnnotationVerifier {


    public void RuleAnnotationVerifier(final Object rule) {
        checkRuleClass(rule);
        checkConditionMethod(rule);
        checkActionMethod(rule);
    }

    private void checkRuleClass(final Object rule) {
        if (!Utils.isClassAnnotatedWith(rule.getClass(), Rule.class)) {
            throw new IllegalArgumentException(String.format("Rule '%s' is not annotated with '%s'", rule.getClass().getName(), Rule.class.getName()));
        }

        if (rule.getClass().getAnnotation(Rule.class).name().isEmpty()) {
            throw new IllegalArgumentException(String.format("Rule '%s' annotation is empty", rule.getClass().getName()));
        }
    }
    ...
</code></pre>

<p>Is there a way to keep the custom annotations on a bean? My program was working correctly before changing my Class to a Bean. </p>

<p><strong>Why do I want to do this?</strong><br>
Methods inside my class are invoked via reflection, but in the methods I'd like to use an Autowired DOA which requires the class to be a bean. :)</p>

<p><strong>What I tried</strong>  but didn't work<br>
AopProxyUtils.ultimateTargetClass(bean)</p>

<p><strong>Found an answer here</strong><br>
<a href="https://stackoverflow.com/a/14248490/3187643">https://stackoverflow.com/a/14248490/3187643</a><br>
Seems that it is not possible without a workaround. Answer is 3 years old so maybe there is another way now?</p>