Author: dblevins
Date: Sat Apr  9 03:46:35 2011
New Revision: 1090519

URL: http://svn.apache.org/viewvc?rev=1090519&view=rev
Log:
OPENEJB-1514: Example: @Schedule Methods

Added:
    openejb/trunk/openejb3/examples/schedule-methods/
      - copied from r1090482, openejb/trunk/openejb3/examples/async-methods/
    
openejb/trunk/openejb3/examples/schedule-methods/src/main/java/org/superbiz/corn/
    
openejb/trunk/openejb3/examples/schedule-methods/src/main/java/org/superbiz/corn/FarmerBrown.java
   (with props)
    
openejb/trunk/openejb3/examples/schedule-methods/src/test/java/org/superbiz/corn/
    
openejb/trunk/openejb3/examples/schedule-methods/src/test/java/org/superbiz/corn/FarmerBrownTest.java
   (with props)
Removed:
    openejb/trunk/openejb3/examples/schedule-methods/README.txt
Modified:
    openejb/trunk/openejb3/examples/schedule-methods/pom.xml

Modified: openejb/trunk/openejb3/examples/schedule-methods/pom.xml
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/schedule-methods/pom.xml?rev=1090519&r1=1090482&r2=1090519&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/schedule-methods/pom.xml (original)
+++ openejb/trunk/openejb3/examples/schedule-methods/pom.xml Sat Apr  9 
03:46:35 2011
@@ -22,10 +22,10 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.superbiz</groupId>
-  <artifactId>async-methods</artifactId>
+  <artifactId>schedule-methods</artifactId>
   <packaging>jar</packaging>
   <version>1.0-SNAPSHOT</version>
-  <name>OpenEJB :: Examples :: @Asynchronous Methods</name>
+  <name>OpenEJB :: Examples :: @Schedule Methods</name>
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>

Added: 
openejb/trunk/openejb3/examples/schedule-methods/src/main/java/org/superbiz/corn/FarmerBrown.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/schedule-methods/src/main/java/org/superbiz/corn/FarmerBrown.java?rev=1090519&view=auto
==============================================================================
--- 
openejb/trunk/openejb3/examples/schedule-methods/src/main/java/org/superbiz/corn/FarmerBrown.java
 (added)
+++ 
openejb/trunk/openejb3/examples/schedule-methods/src/main/java/org/superbiz/corn/FarmerBrown.java
 Sat Apr  9 03:46:35 2011
@@ -0,0 +1,58 @@
+/**
+ * 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.superbiz.corn;
+
+import javax.ejb.Schedule;
+import javax.ejb.Schedules;
+import javax.ejb.Singleton;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * This is where we schedule all of Farmer Brown's corn jobs
+ * 
+ * @version $Revision$ $Date$
+ */
+@Singleton
+public class FarmerBrown {
+
+    private final AtomicInteger checks = new AtomicInteger();
+
+    @Schedules({
+            @Schedule(month = "5", dayOfMonth = "20-Last", minute = "0", hour 
= "8"),
+            @Schedule(month = "6", dayOfMonth = "1-10", minute = "0", hour = 
"8")
+    })
+    private void plantTheCorn() {
+        // Dig out the planter!!!
+    }
+
+    @Schedules({
+            @Schedule(month = "9", dayOfMonth = "20-Last", minute = "0", hour 
= "8"),
+            @Schedule(month = "10", dayOfMonth = "1-10", minute = "0", hour = 
"8")
+    })
+    private void harvestTheCorn() {
+        // Dig out the combine!!!
+    }
+
+    @Schedule(second = "*", minute = "*", hour = "*")
+    private void checkOnTheDaughters() {
+        checks.incrementAndGet();
+    }
+
+    public int getChecks() {
+        return checks.get();
+    }
+}

Propchange: 
openejb/trunk/openejb3/examples/schedule-methods/src/main/java/org/superbiz/corn/FarmerBrown.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
openejb/trunk/openejb3/examples/schedule-methods/src/test/java/org/superbiz/corn/FarmerBrownTest.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/schedule-methods/src/test/java/org/superbiz/corn/FarmerBrownTest.java?rev=1090519&view=auto
==============================================================================
--- 
openejb/trunk/openejb3/examples/schedule-methods/src/test/java/org/superbiz/corn/FarmerBrownTest.java
 (added)
+++ 
openejb/trunk/openejb3/examples/schedule-methods/src/test/java/org/superbiz/corn/FarmerBrownTest.java
 Sat Apr  9 03:46:35 2011
@@ -0,0 +1,42 @@
+/**
+ * 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.superbiz.corn;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class FarmerBrownTest extends TestCase {
+
+    public void test() throws Exception {
+
+        final Context context = EJBContainer.createEJBContainer().getContext();
+
+        final FarmerBrown farmerBrown = (FarmerBrown) 
context.lookup("java:global/schedule-methods/FarmerBrown");
+
+        // Give Farmer brown a chance to do some work
+        Thread.sleep(SECONDS.toMillis(5));
+
+        assertTrue(farmerBrown.getChecks() > 4);
+    }
+}

Propchange: 
openejb/trunk/openejb3/examples/schedule-methods/src/test/java/org/superbiz/corn/FarmerBrownTest.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to