is Remote Session Bean - Java javax.naming

Java examples for javax.naming:Context

Description

is Remote Session Bean

Demo Code


import javax.ejb.Remote;
import javax.ejb.Stateful;
import javax.ejb.Stateless;

public class Main{
    public static boolean isRemoteSessionBean(Object ejb) {
        Class<?> ejbClass = ejb.getClass();

        Stateless stateless = ejbClass.getAnnotation(Stateless.class);
        Stateful stateful = ejbClass.getAnnotation(Stateful.class);
        if (stateless != null || stateful != null) {
            if (ejbClass.getAnnotation(Remote.class) == null) {
                for (Class<?> ejbInterface : ejbClass.getInterfaces()) {
                    if (ejbInterface.getAnnotation(Remote.class) != null) {
                        return true;
                    }//from w  w w . ja va 2  s . c o m
                }
                return false;
            } else {
                return true;
            }
        } else {
            return false;
        }
    }
}

Related Tutorials