Package org.apache.openejb.jee

Examples of org.apache.openejb.jee.NamedMethod


            List<Timer> timers = timerConsumer.getTimer();

            // TODO : The NamedMethod object implements equals and hashCode, so we could rely on that rather than collecting strings
            Set<String> methodsConfiguredInDeploymentXml = new HashSet<String>();
            for (Timer timer : timers) {
                NamedMethod namedMethod = timer.getTimeoutMethod();
                methodsConfiguredInDeploymentXml.add(namedMethod.getMethodName() + (namedMethod.getMethodParams() == null ? "" : Join.join("", namedMethod.getMethodParams().getMethodParam())));
            }

            for (Annotated<Method> method : scheduleMethods) {

                // Don't add the schedules from annotations if the schedules have been
                // supplied for this method via xml.  The xml is considered an override.
                if (methodsConfiguredInDeploymentXml.contains(method.get().getName() + Join.join("", (Object[]) asStrings(method.get().getParameterTypes())))) {
                    continue;
                }

                List<javax.ejb.Schedule> scheduleAnnotationList = new ArrayList<javax.ejb.Schedule>();

                javax.ejb.Schedules schedulesAnnotation = method.getAnnotation(javax.ejb.Schedules.class);
                if (schedulesAnnotation != null) {
                    scheduleAnnotationList.addAll(asList(schedulesAnnotation.value()));
                }

                javax.ejb.Schedule scheduleAnnotation = method.getAnnotation(javax.ejb.Schedule.class);
                if (scheduleAnnotation != null) {
                    scheduleAnnotationList.add(scheduleAnnotation);
                }

                for (javax.ejb.Schedule schedule : scheduleAnnotationList) {
                    Timer timer = new Timer();
                    timer.setPersistent(schedule.persistent());
                    timer.setInfo((schedule.info() == null || schedule.info().isEmpty()) ? null : schedule.info());
                    timer.setTimezone((schedule.timezone() == null || schedule.timezone().isEmpty()) ? null : schedule.timezone());
                    //Copy TimerSchedule
                    TimerSchedule timerSchedule = new TimerSchedule();
                    timerSchedule.setSecond(schedule.second());
                    timerSchedule.setMinute(schedule.minute());
                    timerSchedule.setHour(schedule.hour());
                    timerSchedule.setDayOfWeek(schedule.dayOfWeek());
                    timerSchedule.setDayOfMonth(schedule.dayOfMonth());
                    timerSchedule.setMonth(schedule.month());
                    timerSchedule.setYear(schedule.year());
                    timer.setSchedule(timerSchedule);
                    //Copy Method Signature
                    timer.setTimeoutMethod(new NamedMethod(method.get()));

                    timers.add(timer);
                }
            }
        }
View Full Code Here


                    List<Annotated<Method>> timeoutMethods = sortMethods(annotationFinder.findMetaAnnotatedMethods(javax.ejb.Timeout.class));
                    //Validation Logic is moved to CheckCallback class.
                    if(timeoutMethods.size()  >=  1){
                        // Use the timeout method most near the child class because
                        // the timeout method in child class will override the timeout method in super classes
                        timerConsumer.setTimeoutMethod(new NamedMethod(timeoutMethods.get(timeoutMethods.size() - 1).get()));
                    }
                }
            }

            if (bean instanceof org.apache.openejb.jee.Session) {
View Full Code Here

    }

    private void copySchedules(List<Timer> timers, List<MethodScheduleInfo> scheduleInfos) {
        Map<NamedMethod, MethodScheduleInfo> methodScheduleInfoMap = new HashMap<NamedMethod, MethodScheduleInfo>();
        for (Timer timer : timers) {
            NamedMethod timeoutMethod = timer.getTimeoutMethod();
            MethodScheduleInfo methodScheduleInfo = methodScheduleInfoMap.get(timer.getTimeoutMethod());
            if (methodScheduleInfo == null) {
                methodScheduleInfo = new MethodScheduleInfo();
                methodScheduleInfoMap.put(timeoutMethod, methodScheduleInfo);
                methodScheduleInfo.method = toInfo(timeoutMethod);
View Full Code Here

        assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorOne.class)));
        assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorTwo.class)));

        InterceptorBinding b = assembly.addInterceptorBinding(new InterceptorBinding(bean));
        b.setExcludeDefaultInterceptors(true);
        b.setMethod(new NamedMethod("methodWithDefaultInterceptorsExcluded"));

        return ejbJar;
    }
View Full Code Here

        interceptor = ejbJar.addInterceptor(new Interceptor(DefaultInterceptor.class));
        ad.addInterceptorBinding(new InterceptorBinding("*", interceptor));

        interceptor = ejbJar.addInterceptor(new Interceptor(EchoMethodInterceptor.class));
        InterceptorBinding binding = ad.addInterceptorBinding(new InterceptorBinding(bean, interceptor));
        binding.setMethod(new NamedMethod("echo"));

        return new EjbModule(this.getClass().getClassLoader(), this.getClass().getSimpleName(), "test", ejbJar, null);
    }
View Full Code Here

        testBean.addPostConstruct("wrongMethod");
        ejbJar.addEnterpriseBean(new SingletonBean("TestSingleton", TestBean.class));
        ejbJar.addEnterpriseBean(new StatefulBean("FooStateful", FooBean.class));
        ejbJar.addEnterpriseBean(new StatefulBean("BarStateful", BarBean.class));
        StatefulBean starBean = ejbJar.addEnterpriseBean(new StatefulBean("StarStateful", StarBean.class));
        starBean.setAfterBeginMethod(new NamedMethod("myAfterBegin"));
        starBean.setBeforeCompletionMethod(new NamedMethod("myBeforeCompletion"));
        starBean.setAfterCompletionMethod(new NamedMethod("myAfterCompletion"));
        return ejbJar;
    }
View Full Code Here

        ad.addInterceptorBinding(new InterceptorBinding("*", interceptor));

        {
            interceptor = ejbJar.addInterceptor(new Interceptor(EchoMethodInterceptorViaDD.class));
            InterceptorBinding binding = ad.addInterceptorBinding(new InterceptorBinding(bean, interceptor));
            binding.setMethod(new NamedMethod(TargetBean.class.getMethod("echo", List.class)));
        }

        {
            interceptor = ejbJar.addInterceptor(new Interceptor(EchoMethodInterceptorViaDD.class));
            InterceptorBinding binding = ad.addInterceptorBinding(new InterceptorBinding(bean, interceptor));
            binding.setMethod(new NamedMethod(TargetBean.class.getMethod("echo", int.class)));
        }

        {
            interceptor = ejbJar.addInterceptor(new Interceptor(EchoMethodInterceptorViaDD.class));
            InterceptorBinding binding = ad.addInterceptorBinding(new InterceptorBinding(bean, interceptor));
            binding.setMethod(new NamedMethod(TargetBean.class.getMethod("echo", boolean.class)));
        }

        EnterpriseBean bean3 = ejbJar.addEnterpriseBean(new StatelessBean(Target3Bean.class));
        InterceptorBinding binding = ad.addInterceptorBinding(new InterceptorBinding(bean3));
        binding.setExcludeDefaultInterceptors(true);
View Full Code Here

        return result;
    }

    public void addEjbTimeout(RemoteBean remoteBean, EjbModule ejbModule, PermissionCollection permissions) throws DeploymentException {
        NamedMethod timeout = null;
        if (remoteBean instanceof SessionBean) {
            timeout = ((SessionBean) remoteBean).getTimeoutMethod();
        } else if (remoteBean instanceof MessageDrivenBean) {
            timeout = ((MessageDrivenBean) remoteBean).getTimeoutMethod();
        }
        if (timeout != null) {
            permissions.add(new EJBMethodPermission(remoteBean.getEjbName(), timeout.getMethodName(), null, new String[]{Timer.class.getName()}));
        } else {
            try {
                Class ejbClass = ejbModule.getClassLoader().loadClass(remoteBean.getEjbClass());
                if (TimedObject.class.isAssignableFrom(ejbClass)) {
                    permissions.add(new EJBMethodPermission(remoteBean.getEjbName(), "ejbTimeout", null, new String[]{Timer.class.getName()}));
View Full Code Here

        final StatefulBean bean1 = new StatefulBean(MyLocalBeanImpl.class);
        final Timeout timeout1 = new Timeout();
        timeout1.setTimeout(1000);
        timeout1.setUnit(TimeUnit.MILLISECONDS);
        final ConcurrentMethod method1 = new ConcurrentMethod();
        method1.setMethod(new NamedMethod("*"));
        method1.setAccessTimeout(timeout1);
        bean1.getConcurrentMethod().add(method1);

        final StatefulBean bean2 = new StatefulBean("BeanNegative", MyLocalBeanImpl.class);
        final Timeout timeout2 = new Timeout();
        timeout2.setTimeout(-1);
        timeout2.setUnit(TimeUnit.MILLISECONDS);
        final ConcurrentMethod method2 = new ConcurrentMethod();
        method2.setMethod(new NamedMethod("*"));
        method2.setAccessTimeout(timeout2);
        bean2.getConcurrentMethod().add(method2);

        ejbJar.addEnterpriseBean(bean1);
        ejbJar.addEnterpriseBean(bean2);
View Full Code Here

        final StatefulBean bean1 = new StatefulBean(MyLocalBeanImpl.class);
        final Timeout timeout1 = new Timeout();
        timeout1.setTimeout(10);
        timeout1.setUnit(TimeUnit.SECONDS);
        final ConcurrentMethod method1 = new ConcurrentMethod();
        method1.setMethod(new NamedMethod("*"));
        method1.setAccessTimeout(timeout1);
        bean1.getConcurrentMethod().add(method1);

        ejbJar.addEnterpriseBean(bean1);

View Full Code Here

TOP

Related Classes of org.apache.openejb.jee.NamedMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.