tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r707512 - in /openejb/trunk/openejb3/container: openejb-core/src/main/java/org/apache/openejb/ openejb-core/src/main/java/org/apache/openejb/assembler/classic/ openejb-core/src/main/java/org/apache/openejb/config/ openejb-core/src/main/java...
Date Fri, 24 Oct 2008 00:01:11 GMT
Author: dblevins
Date: Thu Oct 23 17:01:10 2008
New Revision: 707512

URL: http://svn.apache.org/viewvc?rev=707512&view=rev
Log:
OPENEJB-930: @Schedule annotation and xml processing

Added:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodScheduleBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodScheduleInfo.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ScheduleInfo.java
Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/NamedMethodInfo.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AssemblyDescriptor.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodAttribute.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodSchedule.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/NamedMethod.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java?rev=707512&r1=707511&r2=707512&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java
Thu Oct 23 17:01:10 2008
@@ -27,6 +27,7 @@
 import java.util.List;
 import java.util.Set;
 import javax.naming.Context;
+import javax.ejb.ScheduleExpression;
 
 public interface DeploymentInfo {
 
@@ -39,7 +40,7 @@
     public BeanType getComponentType();
 
     public InterfaceType getInterfaceType(Class clazz);
-    
+
     public TransactionType getTransactionType(Method method);
 
     public Collection<String> getAuthorizedRoles(Method method);
@@ -109,11 +110,13 @@
     public List<Method> getPrePassivate();
 
     public List<Method> getRemoveMethods();
-    
+
     public List<Injection> getInjections();
-    
+
     public List<InterceptorData> getMethodInterceptors(Method method);
 
+    public List<ScheduleExpression> getMethodSchedules(Method method);
+
     public void setContainer(Container container);
 
     public Method getEjbTimeout();

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=707512&r1=707511&r2=707512&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
Thu Oct 23 17:01:10 2008
@@ -529,9 +529,13 @@
                     jaccPermissionsBuilder.install(policyContext);
                 }
 
+                MethodScheduleBuilder methodScheduleBuilder = new MethodScheduleBuilder(classLoader,
ejbJar);
                 TransactionPolicyFactory transactionPolicyFactory = createTransactionPolicyFactory(ejbJar,
classLoader);
                 for (DeploymentInfo deploymentInfo : deployments.values()) {
                     CoreDeploymentInfo coreDeploymentInfo = (CoreDeploymentInfo) deploymentInfo;
+
+                    methodScheduleBuilder.build(coreDeploymentInfo);
+
                     coreDeploymentInfo.setTransactionPolicyFactory(transactionPolicyFactory);
                 }
 

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java?rev=707512&r1=707511&r2=707512&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java
Thu Oct 23 17:01:10 2008
@@ -33,6 +33,7 @@
     public final List<MethodPermissionInfo> methodPermissions= new ArrayList<MethodPermissionInfo>();
     public final List<MethodTransactionInfo> methodTransactions = new ArrayList<MethodTransactionInfo>();
     public final List<MethodConcurrencyInfo> methodConcurrency = new ArrayList<MethodConcurrencyInfo>();
+    public final List<MethodScheduleInfo> methodSchedules = new ArrayList<MethodScheduleInfo>();
     public final List<InterceptorInfo> interceptors = new ArrayList<InterceptorInfo>();
     public final List<InterceptorBindingInfo> interceptorBindings = new ArrayList<InterceptorBindingInfo>();
     public final List<MethodInfo> excludeList = new ArrayList<MethodInfo>();

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodScheduleBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodScheduleBuilder.java?rev=707512&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodScheduleBuilder.java
(added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodScheduleBuilder.java
Thu Oct 23 17:01:10 2008
@@ -0,0 +1,131 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.assembler.classic;
+
+import org.apache.openejb.util.Logger;
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Classes;
+import org.apache.openejb.util.SetAccessible;
+import org.apache.openejb.core.interceptor.InterceptorData;
+import org.apache.openejb.core.CoreDeploymentInfo;
+import org.apache.openejb.OpenEJBException;
+
+import javax.interceptor.InvocationContext;
+import javax.ejb.ScheduleExpression;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Comparator;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+public class MethodScheduleBuilder {
+
+    public static final Logger logger = Logger.getInstance(LogCategory.OPENEJB_STARTUP, MethodScheduleBuilder.class.getPackage().getName());
+
+    private final List<MethodScheduleInfo> methodSchedules;
+
+    public MethodScheduleBuilder(ClassLoader cl, EjbJarInfo ejbJarInfo) throws OpenEJBException
{
+        methodSchedules = ejbJarInfo.methodSchedules;
+    }
+
+    public void build(CoreDeploymentInfo deploymentInfo) {
+        Class clazz = deploymentInfo.getBeanClass();
+        String ejbName = deploymentInfo.getEjbName();
+
+        for (MethodScheduleInfo info : methodSchedules) {
+            if (!ejbName.equals(info.ejbName)) continue;
+
+            Method method;
+            try {
+                method = getMethod(clazz, info.method.methodName, toClasses(info.method.methodParams,
clazz.getClassLoader()));
+            } catch (NoSuchMethodException e) {
+                // method doesn't exist
+                logger.warning("Schedule method does not exist: "+info.method.methodName,
e);
+                continue;
+            } catch (ClassNotFoundException e) {
+                logger.warning("Schedule method param cannot be loaded.", e);
+                continue;
+            }
+
+            if (info.method.className == null || method.getDeclaringClass().getName().equals(info.method.className)){
+                ArrayList<ScheduleExpression> schedules = new ArrayList<ScheduleExpression>();
+                for (ScheduleInfo scheduleInfo : info.schedules) {
+                    ScheduleExpression expr = new ScheduleExpression();
+                    expr.second(scheduleInfo.second);
+                    expr.minute(scheduleInfo.minute);
+                    expr.hour(scheduleInfo.hour);
+                    expr.dayOfWeek(scheduleInfo.dayOfWeek);
+                    expr.dayOfMonth(scheduleInfo.dayOfMonth);
+                    expr.month(scheduleInfo.month);
+                    expr.year(scheduleInfo.year);
+                    // TODO: we loose 'persistent' and 'info'
+
+                    schedules.add(expr);
+                }
+
+                deploymentInfo.setMethodSchedules(method, schedules);
+            }
+        }
+
+
+    }
+
+    private Class[] toClasses(List<String> params, ClassLoader classLoader) throws
ClassNotFoundException {
+        Class[] paramsArray = new Class[params.size()];
+        for (int j = 0; j < paramsArray.length; j++) {
+            String methodParam = params.get(j);
+            paramsArray[j] = Classes.forName(methodParam, classLoader);
+
+        }
+        return paramsArray;
+    }
+
+
+
+    /**
+     * Finds the nearest java.lang.reflect.Method with the given
+     * name and parameters.  Callbacks can be private so class.getMethod() cannot be used.
 Searching
+     * starts by looking in the specified class, if the method is not found searching continues
with
+     * the immediate parent and continues recurssively until the method is found or java.lang.Object
+     * is reached.  If the method is not found a NoSuchMethodException is thrown.
+     *
+     * @param clazz
+     * @param methodName
+     * @param parameterTypes
+     * @return
+     * @throws NoSuchMethodException if the method is not found in this class or any of its
parent classes
+     */
+    private Method getMethod(Class clazz, String methodName, Class... parameterTypes) throws
NoSuchMethodException {
+        NoSuchMethodException original = null;
+        while (clazz != null){
+            try {
+                Method method = clazz.getDeclaredMethod(methodName, parameterTypes);
+                return SetAccessible.on(method);
+            } catch (NoSuchMethodException e) {
+                if (original == null) original = e;
+            }
+            clazz = clazz.getSuperclass();
+        }
+        throw original;
+    }
+
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodScheduleInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodScheduleInfo.java?rev=707512&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodScheduleInfo.java
(added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodScheduleInfo.java
Thu Oct 23 17:01:10 2008
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.assembler.classic;
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class MethodScheduleInfo extends InfoObject {
+
+    public String description;
+
+    public String ejbName;
+
+    public final List<ScheduleInfo> schedules = new ArrayList<ScheduleInfo>();
+
+    public NamedMethodInfo method;
+}

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/NamedMethodInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/NamedMethodInfo.java?rev=707512&r1=707511&r2=707512&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/NamedMethodInfo.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/NamedMethodInfo.java
Thu Oct 23 17:01:10 2008
@@ -21,6 +21,7 @@
 
 public class NamedMethodInfo extends InfoObject {
 
+    public String className;
     public String methodName;
     public List<String> methodParams;
     public String id;

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ScheduleInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ScheduleInfo.java?rev=707512&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ScheduleInfo.java
(added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ScheduleInfo.java
Thu Oct 23 17:01:10 2008
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.assembler.classic;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ScheduleInfo extends InfoObject {
+
+    public String second;
+    public String minute;
+    public String hour;
+    public String dayOfWeek;
+    public String dayOfMonth;
+    public String month;
+    public String year;
+    public String info;
+    public boolean persistent;
+
+}

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=707512&r1=707511&r2=707512&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
Thu Oct 23 17:01:10 2008
@@ -80,6 +80,8 @@
 import org.apache.openejb.jee.TransactionType;
 import org.apache.openejb.jee.WebApp;
 import org.apache.openejb.jee.WebserviceDescription;
+import org.apache.openejb.jee.MethodSchedule;
+import org.apache.openejb.jee.Schedule;
 import static org.apache.openejb.util.Join.join;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
@@ -821,10 +823,56 @@
                 processSecurityAnnotations(clazz, ejbName, ejbModule, inheritedClassFinder,
bean);
 
                 /*
+                 * @Schedule
+                 * @Schedules
+                 */
+                Set<Method> scheduleMethods = new HashSet<Method>();
+                scheduleMethods.addAll(inheritedClassFinder.findAnnotatedMethods(javax.ejb.Schedules.class));
+                scheduleMethods.addAll(inheritedClassFinder.findAnnotatedMethods(javax.ejb.Schedule.class));
+
+                Map<String, List<MethodAttribute>> existingDeclarations = assemblyDescriptor.getMethodScheduleMap(ejbName);
+
+                for (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 (hasMethodAttribute(existingDeclarations, method)) break;
+
+                    List<javax.ejb.Schedule> list = new ArrayList<javax.ejb.Schedule>();
+
+                    javax.ejb.Schedules schedulesAnnotation = method.getAnnotation(javax.ejb.Schedules.class);
+                    if (schedulesAnnotation != null){
+                        list.addAll(asList(schedulesAnnotation.value()));
+                    }
+
+                    javax.ejb.Schedule scheduleAnnotation = method.getAnnotation(javax.ejb.Schedule.class);
+                    if (scheduleAnnotation != null){
+                        list.add(scheduleAnnotation);
+                    }
+
+                    if (list.size() == 0) continue;
+
+                    MethodSchedule methodSchedule = new MethodSchedule(ejbName, method);
+                    for (javax.ejb.Schedule schedule : list) {
+                        Schedule s = new Schedule();
+                        s.setSecond(schedule.second());
+                        s.setMinute(schedule.minute());
+                        s.setHour(schedule.hour());
+                        s.setDayOfWeek(schedule.dayOfWeek());
+                        s.setDayOfMonth(schedule.dayOfMonth());
+                        s.setMonth(schedule.month());
+                        s.setYear(schedule.year());
+                        s.setPersistent(schedule.persistent());
+                        s.setInfo(schedule.info());
+                        methodSchedule.getSchedule().add(s);
+                    }
+                    assemblyDescriptor.getMethodSchedule().add(methodSchedule);
+                }
+
+                /*
                  * @Interceptors
                  */
-                for (Class<?> interceptorsAnnotatedClass : inheritedClassFinder.findAnnotatedClasses(Interceptors.class))
-                {
+                for (Class<?> interceptorsAnnotatedClass : inheritedClassFinder.findAnnotatedClasses(Interceptors.class))
{
                     Interceptors interceptors = interceptorsAnnotatedClass.getAnnotation(Interceptors.class);
                     EjbJar ejbJar = ejbModule.getEjbJar();
                     for (Class interceptor : interceptors.value()) {
@@ -1179,6 +1227,30 @@
             return ejbModule;
         }
 
+        private boolean hasMethodAttribute(Map<String, List<MethodAttribute>>
existingDeclarations, Method method) {
+            List<MethodAttribute> list = existingDeclarations.get(method.getName());
+            if (list == null) return false;
+
+            for (MethodAttribute attribute : list) {
+                MethodParams methodParams = attribute.getMethodParams();
+                if (methodParams == null) break;
+
+                List<String> params1 = methodParams.getMethodParam();
+                String[] params2 = asStrings(method.getParameterTypes());
+                if (params1.size() != params2.length) break;
+
+                for (int i = 0; i < params1.size(); i++) {
+                    String a = params1.get(i);
+                    String b = params2[i];
+                    if (!a.equals(b)) break;
+                }
+
+                return true;
+            }
+
+            return false;
+        }
+
         private void processApplicationExceptions(Class<?> clazz, AssemblyDescriptor
assemblyDescriptor) {
             /*
              * @ApplicationException

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java?rev=707512&r1=707511&r2=707512&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
Thu Oct 23 17:01:10 2008
@@ -41,6 +41,8 @@
 import org.apache.openejb.assembler.classic.JndiNameInfo;
 import org.apache.openejb.assembler.classic.SingletonBeanInfo;
 import org.apache.openejb.assembler.classic.MethodConcurrencyInfo;
+import org.apache.openejb.assembler.classic.MethodScheduleInfo;
+import org.apache.openejb.assembler.classic.ScheduleInfo;
 import org.apache.openejb.jee.ActivationConfig;
 import org.apache.openejb.jee.ActivationConfigProperty;
 import org.apache.openejb.jee.CallbackMethod;
@@ -77,6 +79,8 @@
 import org.apache.openejb.jee.ApplicationException;
 import org.apache.openejb.jee.ConcurrencyType;
 import org.apache.openejb.jee.ContainerConcurrency;
+import org.apache.openejb.jee.MethodSchedule;
+import org.apache.openejb.jee.Schedule;
 import org.apache.openejb.jee.oejb3.EjbDeployment;
 import org.apache.openejb.jee.oejb3.ResourceLink;
 import org.apache.openejb.jee.oejb3.Jndi;
@@ -176,6 +180,7 @@
             initExcludesList(jar, ejbds, ejbJar);
             initMethodTransactions(jar, ejbds, ejbJar);
             initMethodConcurrency(jar, ejbds, ejbJar);
+            initMethodSchedules(jar, ejbds, ejbJar);
             initApplicationExceptions(jar, ejbJar);
 
             for (EnterpriseBeanInfo bean : ejbJar.enterpriseBeans) {
@@ -332,6 +337,33 @@
         }
     }
 
+    private void initMethodSchedules(EjbModule jar, Map ejbds, EjbJarInfo ejbJarInfo) {
+
+        List<MethodSchedule> methodSchedule = jar.getEjbJar().getAssemblyDescriptor().getMethodSchedule();
+        for (MethodSchedule att : methodSchedule) {
+            MethodScheduleInfo info = new MethodScheduleInfo();
+
+            info.description = att.getDescription();
+            info.method = toInfo(att.getMethod());
+
+            for (Schedule schedule : att.getSchedule()) {
+                ScheduleInfo scheduleInfo = new ScheduleInfo();
+                scheduleInfo.second = schedule.getSecond();
+                scheduleInfo.minute = schedule.getMinute();
+                scheduleInfo.hour = schedule.getHour();
+                scheduleInfo.dayOfWeek = schedule.getDayOfWeek();
+                scheduleInfo.dayOfMonth = schedule.getDayOfMonth();
+                scheduleInfo.month = schedule.getMonth();
+                scheduleInfo.year = schedule.getYear();
+                scheduleInfo.info = schedule.getInfo();
+                scheduleInfo.persistent = schedule.isPersistent();
+                info.schedules.add(scheduleInfo);
+            }
+
+            ejbJarInfo.methodSchedules.add(info);
+        }
+    }
+
     private void initApplicationExceptions(EjbModule jar, EjbJarInfo ejbJarInfo) {
         for (ApplicationException applicationException : jar.getEjbJar().getAssemblyDescriptor().getApplicationException())
{
             ApplicationExceptionInfo info = new ApplicationExceptionInfo();

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java?rev=707512&r1=707511&r2=707512&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java
Thu Oct 23 17:01:10 2008
@@ -34,6 +34,7 @@
 import javax.ejb.MessageDrivenBean;
 import javax.ejb.TimedObject;
 import javax.ejb.Timer;
+import javax.ejb.ScheduleExpression;
 import javax.naming.Context;
 import javax.persistence.EntityManagerFactory;
 
@@ -115,6 +116,7 @@
     private TransactionPolicyFactory transactionPolicyFactory;
 
     private final Map<Method, List<InterceptorData>> methodInterceptors = new
HashMap<Method, List<InterceptorData>>();
+    private final Map<Method, List<ScheduleExpression>> methodSchedules = new
HashMap<Method, List<ScheduleExpression>>();
     private final List<InterceptorData> callbackInterceptors = new ArrayList<InterceptorData>();
     private final Map<Method, Method> methodMap = new HashMap<Method, Method>();
     private final Map<String, String> securityRoleReferenceMap = new HashMap<String,
String>();
@@ -703,12 +705,23 @@
         return interceptors;
     }
 
-
     public void setMethodInterceptors(Method method, List<InterceptorData> interceptors)
{
         methodInterceptors.put(method, interceptors);
         this.interceptors.addAll(interceptors);
     }
 
+    public List<ScheduleExpression> getMethodSchedules(Method method) {
+        List<ScheduleExpression> schedules = methodSchedules.get(method);
+        if (schedules == null) {
+            schedules = new ArrayList<ScheduleExpression>();
+        }
+        return schedules;
+    }
+
+    public void setMethodSchedules(Method method, List<ScheduleExpression> schedules)
{
+        methodSchedules.put(method, schedules);
+    }
+
     private final Set<InterceptorData> interceptors = new HashSet<InterceptorData>();
 
     public Set<InterceptorData> getAllInterceptors() {

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AssemblyDescriptor.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AssemblyDescriptor.java?rev=707512&r1=707511&r2=707512&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AssemblyDescriptor.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AssemblyDescriptor.java
Thu Oct 23 17:01:10 2008
@@ -133,7 +133,21 @@
     }
 
     public Map<String,List<MethodAttribute>> getMethodScheduleMap(String ejbName)
{
-        return getMethodAttributes(ejbName, getMethodSchedule());
+        Map<String,List<MethodAttribute>> methods = new LinkedHashMap<String,List<MethodAttribute>>();
+
+        for (MethodSchedule methodSchedule : getMethodSchedule()) {
+            if (!methodSchedule.getEjbName().equals(ejbName)) continue;
+
+            NamedMethod method = methodSchedule.getMethod();
+            String methodName = method.getMethodName();
+            List<MethodAttribute> list = methods.get(methodName);
+            if (list == null){
+                list = new ArrayList<MethodAttribute>();
+                methods.put(methodName, list);
+            }
+            list.add(new MethodAttribute(methodSchedule.getAttribute(), ejbName, method));
+        }
+        return methods;
     }
 
     private Map<String, List<MethodAttribute>> getMethodAttributes(String ejbName,
List<? extends AttributeBinding> bindings) {

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodAttribute.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodAttribute.java?rev=707512&r1=707511&r2=707512&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodAttribute.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodAttribute.java
Thu Oct 23 17:01:10 2008
@@ -20,39 +20,46 @@
  * @version $Rev$ $Date$
  */
 public class MethodAttribute<A> {
-    private final Method method;
+
     private final A attribute;
+    private final String ejbName;
+    private final String methodName;
+    private final MethodParams methodParams;
+    private final String className;
 
     public MethodAttribute(A attribute, Method method) {
         this.attribute = attribute;
-        this.method = method;
+        this.ejbName = method.getEjbName();
+        this.methodName = method.getMethodName();
+        this.methodParams = method.getMethodParams();
+        this.className = method.getClassName();
+    }
+
+    public MethodAttribute(A attribute, String ejbName, NamedMethod method) {
+        this.attribute = attribute;
+        this.ejbName = ejbName;
+        this.methodName = method.getMethodName();
+        this.methodParams = method.getMethodParams();
+        this.className = method.getClassName();
     }
 
     public A getAttribute() {
         return attribute;
     }
 
-    public String getEjbName() {
-        return method.getEjbName();
+    public String getClassName() {
+        return className;
     }
 
-    public MethodIntf getMethodIntf() {
-        return method.getMethodIntf();
+    public String getEjbName() {
+        return ejbName;
     }
 
     public String getMethodName() {
-        return method.getMethodName();
+        return methodName;
     }
 
     public MethodParams getMethodParams() {
-        return method.getMethodParams();
-    }
-
-    public Method getMethod() {
-        return method;
-    }
-
-    public String getClassName() {
-        return method.getClassName();
+        return methodParams;
     }
 }

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodSchedule.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodSchedule.java?rev=707512&r1=707511&r2=707512&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodSchedule.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodSchedule.java
Thu Oct 23 17:01:10 2008
@@ -31,16 +31,20 @@
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "method-scheduleType", propOrder = {
         "descriptions",
+        "ejbName",
         "schedule",
         "method"
         })
-public class MethodSchedule implements AttributeBinding<List<Schedule>> {
+public class MethodSchedule {
 
     @XmlElement(name = "schedule", required = true)
     protected List<Schedule> schedule;
 
     @XmlElement(required = true)
-    protected List<Method> method;
+    protected NamedMethod method;
+
+    @XmlElement(name = "ejb-name", required = true)
+    protected String ejbName;
 
     @XmlAttribute
     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@@ -54,15 +58,16 @@
     }
 
     public MethodSchedule(String className, String ejbName, String methodName, Schedule...
schedules) {
-        this(new Method(ejbName, className, methodName), schedules);
+        this(ejbName, new NamedMethod(className, methodName), schedules);
     }
 
     public MethodSchedule(String ejbName, java.lang.reflect.Method method, Schedule... schedules)
{
-        this(new Method(ejbName, method), schedules);
+        this(ejbName, new NamedMethod(method), schedules);
     }
 
-    public MethodSchedule(Method method, Schedule... schedules) {
-        getMethod().add(method);
+    public MethodSchedule(String ejbName, NamedMethod method, Schedule... schedules) {
+        this.method = method;
+        this.ejbName = ejbName;
         for (Schedule schedule : schedules) {
             getSchedule().add(schedule);
         }
@@ -88,11 +93,20 @@
         return this.schedule;
     }
 
-    public List<Method> getMethod() {
-        if (method == null) {
-            method = new ArrayList<Method>();
-        }
-        return this.method;
+    public String getEjbName() {
+        return ejbName;
+    }
+
+    public void setEjbName(String ejbName) {
+        this.ejbName = ejbName;
+    }
+
+    public NamedMethod getMethod() {
+        return method;
+    }
+
+    public void setMethod(NamedMethod method) {
+        this.method = method;
     }
 
     public String getId() {

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/NamedMethod.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/NamedMethod.java?rev=707512&r1=707511&r2=707512&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/NamedMethod.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/NamedMethod.java
Thu Oct 23 17:01:10 2008
@@ -24,6 +24,7 @@
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlID;
 import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 
@@ -39,8 +40,13 @@
 
     @XmlElement(name = "method-name", required = true)
     protected String methodName;
+
     @XmlElement(name = "method-params")
     protected MethodParams methodParams;
+
+    @XmlTransient
+    protected String className;
+
     @XmlAttribute
     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
     @XmlID
@@ -50,6 +56,7 @@
     }
 
     public NamedMethod(java.lang.reflect.Method method) {
+        this.className = method.getDeclaringClass().getName();
         this.methodName = method.getName();
         MethodParams methodParams = new MethodParams();
         for (Class<?> type : method.getParameterTypes()) {
@@ -86,6 +93,14 @@
         this.methodParams = value;
     }
 
+    public String getClassName() {
+        return className;
+    }
+
+    public void setClassName(String className) {
+        this.className = className;
+    }
+
     public String getId() {
         return id;
     }



Mime
View raw message