javax.ejb.Local Java Examples

The following examples show how to use javax.ejb.Local. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SessionBeanRulesTest.java    From ArchUnit with Apache License 2.0 6 votes vote down vote up
private static DescribedPredicate<JavaClass> haveLocalBeanSubclass() {
    return new DescribedPredicate<JavaClass>("have subclass that is a local bean") {
        @Override
        public boolean apply(JavaClass input) {
            for (JavaClass subClass : input.getAllSubClasses()) {
                if (isLocalBeanImplementation(subClass, input)) {
                    return true;
                }
            }
            return false;
        }

        // NOTE: We assume that in this project by convention @Local is always used as @Local(type) with exactly
        //       one type, otherwise this would need to be more sophisticated
        private boolean isLocalBeanImplementation(JavaClass bean, JavaClass businessInterfaceType) {
            return bean.isAnnotatedWith(Local.class) &&
                    bean.getAnnotationOfType(Local.class).value()[0].getName()
                            .equals(businessInterfaceType.getName());
        }
    };
}
 
Example #2
Source File: SessionBeanRulesTest.java    From ArchUnit with Apache License 2.0 6 votes vote down vote up
private static DescribedPredicate<JavaClass> haveLocalBeanSubclass() {
    return new DescribedPredicate<JavaClass>("have subclass that is a local bean") {
        @Override
        public boolean apply(JavaClass input) {
            for (JavaClass subClass : input.getAllSubClasses()) {
                if (isLocalBeanImplementation(subClass, input)) {
                    return true;
                }
            }
            return false;
        }

        // NOTE: We assume that in this project by convention @Local is always used as @Local(type) with exactly
        //       one type, otherwise this would need to be more sophisticated
        private boolean isLocalBeanImplementation(JavaClass bean, JavaClass businessInterfaceType) {
            return bean.isAnnotatedWith(Local.class) &&
                    bean.getAnnotationOfType(Local.class).value()[0].getName()
                            .equals(businessInterfaceType.getName());
        }
    };
}
 
Example #3
Source File: SessionBeanRulesTest.java    From ArchUnit-Examples with Apache License 2.0 6 votes vote down vote up
private static DescribedPredicate<JavaClass> haveLocalBeanSubclass() {
    return new DescribedPredicate<JavaClass>("have subclass that is a local bean") {
        @Override
        public boolean apply(JavaClass input) {
            for (JavaClass subClass : input.getAllSubClasses()) {
                if (isLocalBeanImplementation(subClass, input)) {
                    return true;
                }
            }
            return false;
        }

        // NOTE: We assume that in this project by convention @Local is always used as @Local(type) with exactly
        //       one type, otherwise this would need to be more sophisticated
        private boolean isLocalBeanImplementation(JavaClass bean, JavaClass businessInterfaceType) {
            return bean.isAnnotatedWith(Local.class) &&
                    bean.getAnnotationOfType(Local.class).value()[0].getName()
                            .equals(businessInterfaceType.getName());
        }
    };
}
 
Example #4
Source File: SessionBeanRulesTest.java    From ArchUnit-Examples with Apache License 2.0 6 votes vote down vote up
private static DescribedPredicate<JavaClass> haveLocalBeanSubclass() {
    return new DescribedPredicate<JavaClass>("have subclass that is a local bean") {
        @Override
        public boolean apply(JavaClass input) {
            for (JavaClass subClass : input.getAllSubClasses()) {
                if (isLocalBeanImplementation(subClass, input)) {
                    return true;
                }
            }
            return false;
        }

        // NOTE: We assume that in this project by convention @Local is always used as @Local(type) with exactly
        //       one type, otherwise this would need to be more sophisticated
        private boolean isLocalBeanImplementation(JavaClass bean, JavaClass businessInterfaceType) {
            return bean.isAnnotatedWith(Local.class) &&
                    bean.getAnnotationOfType(Local.class).value()[0].getName()
                            .equals(businessInterfaceType.getName());
        }
    };
}
 
Example #5
Source File: TransactionMandatoryTest.java    From development with Apache License 2.0 5 votes vote down vote up
private List<Class<?>> getLocalInterfaces(Class<?> clazz) {
    List<Class<?>> localInterfaces = new ArrayList<Class<?>>();
    for (Class<?> c : clazz.getInterfaces()) {
        if (c.getAnnotation(Local.class) != null) {
            localInterfaces.add(c);
        }
    }
    return localInterfaces;
}
 
Example #6
Source File: InterfaceMap.java    From development with Apache License 2.0 5 votes vote down vote up
private boolean considerInterface(Class<?> i) {
    if (i.getAnnotation(Local.class) != null) {
        return true;
    } else if (i.getAnnotation(Remote.class) != null) {
        return true;
    } else {
        return isExcplicitlyRequiredClass(i);
    }
}
 
Example #7
Source File: SessionBeanRulesTest.java    From ArchUnit with Apache License 2.0 4 votes vote down vote up
private boolean isLocalBeanImplementation(JavaClass bean, JavaClass businessInterfaceType) {
    return bean.isAnnotatedWith(Local.class) &&
            bean.getAnnotationOfType(Local.class).value()[0].getName()
                    .equals(businessInterfaceType.getName());
}
 
Example #8
Source File: SessionBeanRulesTest.java    From ArchUnit-Examples with Apache License 2.0 4 votes vote down vote up
private boolean isLocalBeanImplementation(JavaClass bean, JavaClass businessInterfaceType) {
    return bean.isAnnotatedWith(Local.class) &&
            bean.getAnnotationOfType(Local.class).value()[0].getName()
                    .equals(businessInterfaceType.getName());
}
 
Example #9
Source File: ClassFilter.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isNeglectableClass(Class<?> clazz) {
    boolean isInterface = clazz.isInterface();
    Local annotation = clazz.getAnnotation(Local.class);
    return !(isInterface && annotation != null);
}
 
Example #10
Source File: CheckClasses.java    From tomee with Apache License 2.0 2 votes vote down vote up
private boolean isValidInterface(final RemoteBean b, final Class clazz, final Class beanClass, final String tag) {

        if (clazz.equals(beanClass)) {

            fail(b, "xml." + tag + ".beanClass", clazz.getName());

        } else if (!clazz.isInterface()) {

            fail(b, "xml." + tag + ".notInterface", clazz.getName());

        } else if (EJBHome.class.isAssignableFrom(clazz)) {

            if (tag.equals("home")) {
                return true;
            }

            fail(b, "xml." + tag + ".ejbHome", clazz.getName());

        } else if (EJBLocalHome.class.isAssignableFrom(clazz)) {

            if (tag.equals("localHome")) {
                return true;
            }

            fail(b, "xml." + tag + ".ejbLocalHome", clazz.getName());

        } else if (EJBObject.class.isAssignableFrom(clazz)) {

            if (tag.equals("remote")) {
                return true;
            }

            fail(b, "xml." + tag + ".ejbObject", clazz.getName());

        } else if (EJBLocalObject.class.isAssignableFrom(clazz)) {

            if (tag.equals("local")) {
                return true;
            }

            fail(b, "xml." + tag + ".ejbLocalObject", clazz.getName());

        } else {
            if (tag.equals("businessLocal") || tag.equals("businessRemote")) {

                return true;

            } else if (clazz.isAnnotationPresent(Local.class)) {

                fail(b, "xml." + tag + ".businessLocal", clazz.getName());

            } else if (clazz.isAnnotationPresent(Remote.class)) {

                fail(b, "xml." + tag + ".businessRemote", clazz.getName());

            } else {

                fail(b, "xml." + tag + ".unknown", clazz.getName());

            }

        }

        // must be tagged as <home>, <local-home>, <remote>, or <local>

        return false;
    }