[jboss-cvs] JBossAS SVN: r106411 - in projects/ejb3/tags: jboss-ejb3-timerservice-deployer-1.0.0-alpha-3 and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 5 02:58:46 EDT 2010


Author: jaikiran
Date: 2010-07-05 02:58:46 -0400 (Mon, 05 Jul 2010)
New Revision: 106411

Added:
   projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/
   projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/pom.xml
   projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/src/main/java/org/jboss/ejb3/timerservice/deployer/AutoTimerInitializer.java
Removed:
   projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/pom.xml
   projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/src/main/java/org/jboss/ejb3/timerservice/deployer/AutoTimerInitializer.java
Log:
[maven-release-plugin]  copy for tag jboss-ejb3-timerservice-deployer-1.0.0-alpha-3

Copied: projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3 (from rev 106408, projects/ejb3/trunk/timerservice-deployer)

Deleted: projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/pom.xml
===================================================================
--- projects/ejb3/trunk/timerservice-deployer/pom.xml	2010-07-05 01:17:14 UTC (rev 106408)
+++ projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/pom.xml	2010-07-05 06:58:46 UTC (rev 106411)
@@ -1,172 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-    <!--
-    vi:ts=2:sw=2:expandtab:
-    -->
-<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">
-
-    <!-- Model Information -->
-    <modelVersion>4.0.0</modelVersion>
-
-    <!-- Artifact Information  -->
-    <groupId>org.jboss.ejb3</groupId>
-    <artifactId>jboss-ejb3-timerservice-deployer</artifactId>
-    <packaging>jar</packaging>
-    <version>1.0.0-SNAPSHOT</version>
-    <name>JBoss EJB3.1+ Timerservice deployer</name>
-    <url>http://www.jboss.org</url>
-    <description>MC based deployer(s) for timerservice functionality for EJB containers</description>
-    
-	<!-- SCM -->
-	<scm>
-		<connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/trunk/timerservice-deployer</connection>
-		<developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/ejb3/trunk/timerservice-deployer</developerConnection>
-		<url>http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/trunk/timerservice-deployer</url>
-	</scm>
-
-	<distributionManagement>
-			<repository>
-			  <id>jboss-releases-repository</id>
-			  <name>JBoss Releases Repository</name>
-			  <url>https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/</url>
-			</repository>
-
-			<snapshotRepository>
-				<id>jboss-snapshots-repository</id>
-				<name>JBoss Snapshots Repository</name>
-				<url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url>
-			</snapshotRepository>			
-	</distributionManagement>  
-
-    
-    
-    <properties>
-        <version.org.jboss.deployers>2.2.0.Alpha5</version.org.jboss.deployers>
-        <version.org.jboss.kernel>2.2.0.Alpha10</version.org.jboss.kernel>
-        <version.org.jboss.ejb3.core>1.4.2</version.org.jboss.ejb3.core>
-        <version.org.jboss.ejb.metadata>2.0.0-alpha-16</version.org.jboss.ejb.metadata>
-        <version.org.jboss.ejb3.timerservice_timerservice-extension>1.0.0-alpha-2</version.org.jboss.ejb3.timerservice_timerservice-extension>
-        <version.junit>4.7</version.junit>
-    </properties>
-    
-    <build>
-        <plugins>
-            <!-- Assembly Plugin -->
-            <plugin>
-                <artifactId>maven-assembly-plugin</artifactId>
-                <version>2.2-beta-4</version>
-                <executions>
-                    <!--  Build timerservice deployer "package" -->
-                  <execution>
-                    <id>build-timerservice-deployer-package</id> 
-                    <phase>package</phase>
-                    <goals>
-                      <goal>single</goal>
-                    </goals>
-                  </execution>
-                </executions>
-                <configuration>
-                  <descriptors>
-                    <descriptor>src/assembly/package-assembler.xml</descriptor>
-                  </descriptors>
-                </configuration>
-            </plugin>
-			<plugin>
-				<artifactId>maven-compiler-plugin</artifactId>
-				<configuration>
-					<source>1.6</source>
-					<target>1.6</target>
-				</configuration>
-			</plugin>
-
-			<plugin>
-				<artifactId>maven-enforcer-plugin</artifactId>
-				<executions>
-					<execution>
-						<id>enforce-jdk6</id>
-						<goals>
-							<goal>enforce</goal>
-						</goals>
-						<configuration>
-							<rules>
-								<requireJavaVersion>
-									<version>[1.6,)</version>
-								</requireJavaVersion>
-							</rules>
-						</configuration>
-					</execution>
-				</executions>
-			</plugin>
-			<!-- Maven Release Plugin Configuration -->
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-release-plugin</artifactId>
-				<configuration>
-					<tagBase>
-						https://svn.jboss.org/repos/jbossas/projects/ejb3/tags
-			          </tagBase>
-				</configuration>
-			</plugin>
-
-			
-            
-        </plugins>
-    
-    </build>
-    
-    <dependencies>
-
-        <dependency>
-            <groupId>org.jboss.metadata</groupId>
-            <artifactId>jboss-metadata-ejb</artifactId>
-            <version>${version.org.jboss.ejb.metadata}</version>
-        </dependency>
-        <dependency>
-        	<groupId>org.jboss.ejb3</groupId>
-        	<artifactId>jboss-ejb3-common</artifactId>
-        	<version>1.0.0</version>
-        </dependency>
-        <dependency>
-        	<groupId>org.jboss.ejb3</groupId>
-        	<artifactId>jboss-ejb3-core</artifactId>
-        	<version>${version.org.jboss.ejb3.core}</version>
-        </dependency>
-        <dependency>
-        	<groupId>org.jboss.ejb3.timerservice</groupId>
-        	<artifactId>jboss-ejb3-timerservice-extension</artifactId>
-        	<version>${version.org.jboss.ejb3.timerservice_timerservice-extension}</version>
-        </dependency>
-        <!-- JBoss deployers -->
-        <dependency>
-        	<groupId>org.jboss.kernel</groupId>
-        	<artifactId>jboss-kernel</artifactId>
-        	<version>${version.org.jboss.kernel}</version>
-        </dependency>
-        <dependency>
-          <groupId>org.jboss.deployers</groupId>
-          <artifactId>jboss-deployers-spi</artifactId>
-          <version>${version.org.jboss.deployers}</version>
-        </dependency>
-        <dependency>
-          <groupId>org.jboss.deployers</groupId>
-          <artifactId>jboss-deployers-core-spi</artifactId>
-          <version>${version.org.jboss.deployers}</version>
-        </dependency>
-        <dependency>
-          <groupId>org.jboss.deployers</groupId>
-          <artifactId>jboss-deployers-structure-spi</artifactId>
-          <version>${version.org.jboss.deployers}</version>
-        </dependency>
-        
-        <!-- ***************************** -->
-        <!--  Test dependencies -->
-        <!-- ***************************** -->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>${version.junit}</version>
-            <scope>test</scope>
-        </dependency>
-    
-    </dependencies>
-
-</project>	

Copied: projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/pom.xml (from rev 106410, projects/ejb3/trunk/timerservice-deployer/pom.xml)
===================================================================
--- projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/pom.xml	                        (rev 0)
+++ projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/pom.xml	2010-07-05 06:58:46 UTC (rev 106411)
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="UTF-8"?>
+    <!--
+    vi:ts=2:sw=2:expandtab:
+    -->
+<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">
+
+    <!-- Model Information -->
+    <modelVersion>4.0.0</modelVersion>
+
+    <!-- Artifact Information  -->
+    <groupId>org.jboss.ejb3</groupId>
+    <artifactId>jboss-ejb3-timerservice-deployer</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0.0-alpha-3</version>
+    <name>JBoss EJB3.1+ Timerservice deployer</name>
+    <url>http://www.jboss.org</url>
+    <description>MC based deployer(s) for timerservice functionality for EJB containers</description>
+    
+	<!-- SCM -->
+	<scm>
+		<connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3</connection>
+		<developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3</developerConnection>
+		<url>http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3</url>
+	</scm>
+
+	<distributionManagement>
+			<repository>
+			  <id>jboss-releases-repository</id>
+			  <name>JBoss Releases Repository</name>
+			  <url>https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/</url>
+			</repository>
+
+			<snapshotRepository>
+				<id>jboss-snapshots-repository</id>
+				<name>JBoss Snapshots Repository</name>
+				<url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url>
+			</snapshotRepository>			
+	</distributionManagement>  
+
+    
+    
+    <properties>
+        <version.org.jboss.deployers>2.2.0.Alpha5</version.org.jboss.deployers>
+        <version.org.jboss.kernel>2.2.0.Alpha10</version.org.jboss.kernel>
+        <version.org.jboss.ejb3.core>1.4.2</version.org.jboss.ejb3.core>
+        <version.org.jboss.ejb.metadata>2.0.0-alpha-16</version.org.jboss.ejb.metadata>
+        <version.org.jboss.ejb3.timerservice_timerservice-extension>1.0.0-alpha-2</version.org.jboss.ejb3.timerservice_timerservice-extension>
+        <version.junit>4.7</version.junit>
+    </properties>
+    
+    <build>
+        <plugins>
+            <!-- Assembly Plugin -->
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>2.2-beta-4</version>
+                <executions>
+                    <!--  Build timerservice deployer "package" -->
+                  <execution>
+                    <id>build-timerservice-deployer-package</id> 
+                    <phase>package</phase>
+                    <goals>
+                      <goal>single</goal>
+                    </goals>
+                  </execution>
+                </executions>
+                <configuration>
+                  <descriptors>
+                    <descriptor>src/assembly/package-assembler.xml</descriptor>
+                  </descriptors>
+                </configuration>
+            </plugin>
+			<plugin>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.6</source>
+					<target>1.6</target>
+				</configuration>
+			</plugin>
+
+			<plugin>
+				<artifactId>maven-enforcer-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>enforce-jdk6</id>
+						<goals>
+							<goal>enforce</goal>
+						</goals>
+						<configuration>
+							<rules>
+								<requireJavaVersion>
+									<version>[1.6,)</version>
+								</requireJavaVersion>
+							</rules>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<!-- Maven Release Plugin Configuration -->
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-release-plugin</artifactId>
+				<configuration>
+					<tagBase>
+						https://svn.jboss.org/repos/jbossas/projects/ejb3/tags
+			          </tagBase>
+				</configuration>
+			</plugin>
+
+			
+            
+        </plugins>
+    
+    </build>
+    
+    <dependencies>
+
+        <dependency>
+            <groupId>org.jboss.metadata</groupId>
+            <artifactId>jboss-metadata-ejb</artifactId>
+            <version>${version.org.jboss.ejb.metadata}</version>
+        </dependency>
+        <dependency>
+        	<groupId>org.jboss.ejb3</groupId>
+        	<artifactId>jboss-ejb3-common</artifactId>
+        	<version>1.0.0</version>
+        </dependency>
+        <dependency>
+        	<groupId>org.jboss.ejb3</groupId>
+        	<artifactId>jboss-ejb3-core</artifactId>
+        	<version>${version.org.jboss.ejb3.core}</version>
+        </dependency>
+        <dependency>
+        	<groupId>org.jboss.ejb3.timerservice</groupId>
+        	<artifactId>jboss-ejb3-timerservice-extension</artifactId>
+        	<version>${version.org.jboss.ejb3.timerservice_timerservice-extension}</version>
+        </dependency>
+        <!-- JBoss deployers -->
+        <dependency>
+        	<groupId>org.jboss.kernel</groupId>
+        	<artifactId>jboss-kernel</artifactId>
+        	<version>${version.org.jboss.kernel}</version>
+        </dependency>
+        <dependency>
+          <groupId>org.jboss.deployers</groupId>
+          <artifactId>jboss-deployers-spi</artifactId>
+          <version>${version.org.jboss.deployers}</version>
+        </dependency>
+        <dependency>
+          <groupId>org.jboss.deployers</groupId>
+          <artifactId>jboss-deployers-core-spi</artifactId>
+          <version>${version.org.jboss.deployers}</version>
+        </dependency>
+        <dependency>
+          <groupId>org.jboss.deployers</groupId>
+          <artifactId>jboss-deployers-structure-spi</artifactId>
+          <version>${version.org.jboss.deployers}</version>
+        </dependency>
+        
+        <!-- ***************************** -->
+        <!--  Test dependencies -->
+        <!-- ***************************** -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${version.junit}</version>
+            <scope>test</scope>
+        </dependency>
+    
+    </dependencies>
+
+</project>	

Deleted: projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/src/main/java/org/jboss/ejb3/timerservice/deployer/AutoTimerInitializer.java
===================================================================
--- projects/ejb3/trunk/timerservice-deployer/src/main/java/org/jboss/ejb3/timerservice/deployer/AutoTimerInitializer.java	2010-07-05 01:17:14 UTC (rev 106408)
+++ projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/src/main/java/org/jboss/ejb3/timerservice/deployer/AutoTimerInitializer.java	2010-07-05 06:58:46 UTC (rev 106411)
@@ -1,252 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.timerservice.deployer;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.ejb.TimerConfig;
-import javax.ejb.TimerService;
-
-import org.jboss.beans.metadata.api.annotations.Start;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBean31MetaData;
-import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
-import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
-import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
-import org.jboss.metadata.ejb.spec.TimerMetaData;
-
-/**
- * Responsible for creating any necessary auto timers for an EJB
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class AutoTimerInitializer
-{
-
-   /**
-    * Logger
-    */
-   private static Logger logger = Logger.getLogger(AutoTimerInitializer.class);
-
-   /**
-    * The EJB container
-    */
-   private EJBContainer container;
-
-   /**
-    * 
-    */
-   public AutoTimerInitializer()
-   {
-
-   }
-
-   /**
-    * Creates a {@link AutoTimerInitializer} for a {@link EJBContainer}
-    * @param container {@link EJBContainer}
-    */
-   public AutoTimerInitializer(EJBContainer container)
-   {
-      this.container = container;
-   }
-
-   /**
-    * Sets the {@link EJBContainer}
-    * @param container {@link EJBContainer}
-    */
-   public void setContainer(EJBContainer container)
-   {
-      this.container = container;
-   }
-
-   /**
-    * Returns the {@link EJBContainer} for which this {@link AutoTimerInitializer} is responsible
-    * for creating auto timers
-    * @return
-    */
-   public EJBContainer getContainer()
-   {
-      return this.container;
-   }
-
-   /**
-    * Creates any auto timers that are required for the {@link EJBContainer}, which this
-    * {@link AutoTimerInitializer} represents.
-    */
-   @Start
-   public void initializeAutoTimers()
-   {
-      if (this.container == null)
-      {
-         throw new IllegalStateException("Cannot initialize auto-timers since container is not present");
-      }
-
-      JBossEnterpriseBeanMetaData enterpriseBeanMetaData = this.container.getXml();
-      // Auto timers are only since EJB3.1
-      // TODO: This check will fail when EJB3.2 or any newer versions are introduced.
-      // A better check would be to look for any version greater than EJB3.1
-      if (enterpriseBeanMetaData.getJBossMetaData().isEJB31() == false)
-      {
-         return;
-      }
-
-      List<TimerMetaData> autoTimersMetaData = null;
-
-      if (enterpriseBeanMetaData.isSession() && enterpriseBeanMetaData instanceof JBossSessionBean31MetaData)
-      {
-         JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBeanMetaData;
-         // Stateful beans don't have timerservice/timers
-         if (sessionBean.isStateful())
-         {
-            return;
-         }
-         // Get hold of the auto timer metadata
-         autoTimersMetaData = sessionBean.getTimers();
-      }
-      else if (enterpriseBeanMetaData.isMessageDriven()
-            && enterpriseBeanMetaData instanceof JBossMessageDrivenBean31MetaData)
-      {
-         JBossMessageDrivenBean31MetaData mdb = (JBossMessageDrivenBean31MetaData) enterpriseBeanMetaData;
-         // get hold of auto timer metadata
-         autoTimersMetaData = mdb.getTimers();
-      }
-      // If there's no auto timers, then there's nothing to do
-      if (autoTimersMetaData == null)
-      {
-         return;
-      }
-
-      // get hold of the timerservice since we need it to create the autotimers
-      TimerService timerService = this.container.getTimerService();
-
-      if (timerService instanceof org.jboss.ejb3.timerservice.extension.TimerService == false)
-      {
-         // can't do anything about this
-         logger.warn("Cannot create auto timers for EJB: " + enterpriseBeanMetaData.getEjbName()
-               + " since the timerservice isn't of type "
-               + org.jboss.ejb3.timerservice.extension.TimerService.class.getName());
-         return;
-      }
-      org.jboss.ejb3.timerservice.extension.TimerService ejb31TimerService = (org.jboss.ejb3.timerservice.extension.TimerService) timerService;
-      // process each auto timer
-      for (TimerMetaData autoTimerMetaData : autoTimersMetaData)
-      {
-         // create a timer config
-         TimerConfig timerConfig = new TimerConfig();
-         timerConfig.setPersistent(autoTimerMetaData.isPersistent());
-         timerConfig.setInfo(autoTimerMetaData.getInfo());
-         NamedMethodMetaData timeoutMethodMetaData = autoTimerMetaData.getTimeoutMethod();
-         // get hold of the timeout method for this auto-timer
-         Method timeoutMethod = this.getTimeoutMethod(timeoutMethodMetaData, this.container.getBeanClass());
-         if (timeoutMethod == null)
-         {
-            StringBuilder methodStringBuilder = new StringBuilder();
-            methodStringBuilder.append(timeoutMethodMetaData.getMethodName());
-            if (timeoutMethodMetaData.getMethodParams() != null)
-            {
-               methodStringBuilder.append(Arrays.toString(timeoutMethodMetaData.getMethodParams().toArray()));
-            }
-            throw new IllegalStateException("Timeout method: " + methodStringBuilder.toString() + " not found for bean class: "
-                  + enterpriseBeanMetaData.getEjbClass());
-         }
-         // finally create/get the auto timer
-         ejb31TimerService.getAutoTimer(autoTimerMetaData.getScheduleExpression(), timerConfig, timeoutMethod);
-      }
-
-   }
-
-   /**
-    * Returns the {@link Method}, represented by the {@link NamedMethodMetaData}, from the <code>beanClass</code>
-    * <p>
-    *   This method looks for private, protected, package and public methods on the <code>beanClass</code>
-    *   and its superclass(es). If no matching method is found, then this method returns null.
-    * </p>
-    * @param timeoutMethodMetaData The method metadata
-    * @param beanClass The class on which the method has to be looked for
-    * @return
-    * @throws NullPointerException If either of the passed parameters is null
-    */
-   private Method getTimeoutMethod(NamedMethodMetaData timeoutMethodMetaData, Class<?> beanClass)
-   {
-
-      String timeoutMethodName = timeoutMethodMetaData.getMethodName();
-      MethodParametersMetaData timeoutMethodParams = timeoutMethodMetaData.getMethodParams();
-      // load the method param classes
-      Class<?>[] timeoutMethodParamTypes = new Class<?>[]
-      {};
-      if (timeoutMethodParams != null)
-      {
-         timeoutMethodParamTypes = new Class<?>[timeoutMethodParams.size()];
-         int i = 0;
-         for (String paramClassName : timeoutMethodParams)
-         {
-            Class<?> methodParamClass = null;
-            try
-            {
-               methodParamClass = Class.forName(paramClassName, false, beanClass.getClassLoader());
-            }
-            catch (ClassNotFoundException cnfe)
-            {
-               throw new RuntimeException("Could not load method param class: " + paramClassName + " of timeout method");
-            }
-            timeoutMethodParamTypes[i++] = methodParamClass;
-         }
-      }
-      // now start looking for the method
-      Class<?> klass = beanClass;
-      while (klass != null)
-      {
-         Method[] methods = beanClass.getDeclaredMethods();
-         for (Method method : methods)
-         {
-            if (method.getName().equals(timeoutMethodName))
-            {
-               Class<?>[] methodParamTypes = method.getParameterTypes();
-               // param length doesn't match
-               if (timeoutMethodParamTypes.length != methodParamTypes.length)
-               {
-                  continue;
-               }
-               for (int i = 0; i < methodParamTypes.length; i++)
-               {
-                  // param type doesn't match
-                  if (timeoutMethodParamTypes[i].equals(methodParamTypes[i]) == false)
-                  {
-                     continue;
-                  }
-               }
-               // match found
-               return method;
-            }
-         }
-         klass = klass.getSuperclass();
-      }
-      // no match found
-      return null;
-   }
-
-}

Copied: projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/src/main/java/org/jboss/ejb3/timerservice/deployer/AutoTimerInitializer.java (from rev 106409, projects/ejb3/trunk/timerservice-deployer/src/main/java/org/jboss/ejb3/timerservice/deployer/AutoTimerInitializer.java)
===================================================================
--- projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/src/main/java/org/jboss/ejb3/timerservice/deployer/AutoTimerInitializer.java	                        (rev 0)
+++ projects/ejb3/tags/jboss-ejb3-timerservice-deployer-1.0.0-alpha-3/src/main/java/org/jboss/ejb3/timerservice/deployer/AutoTimerInitializer.java	2010-07-05 06:58:46 UTC (rev 106411)
@@ -0,0 +1,252 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.timerservice.deployer;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.ejb.TimerConfig;
+import javax.ejb.TimerService;
+
+import org.jboss.beans.metadata.api.annotations.Start;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBean31MetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
+import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
+import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
+import org.jboss.metadata.ejb.spec.TimerMetaData;
+
+/**
+ * Responsible for creating any necessary auto timers for an EJB
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class AutoTimerInitializer
+{
+
+   /**
+    * Logger
+    */
+   private static Logger logger = Logger.getLogger(AutoTimerInitializer.class);
+
+   /**
+    * The EJB container
+    */
+   private EJBContainer container;
+
+   /**
+    * 
+    */
+   public AutoTimerInitializer()
+   {
+
+   }
+
+   /**
+    * Creates a {@link AutoTimerInitializer} for a {@link EJBContainer}
+    * @param container {@link EJBContainer}
+    */
+   public AutoTimerInitializer(EJBContainer container)
+   {
+      this.container = container;
+   }
+
+   /**
+    * Sets the {@link EJBContainer}
+    * @param container {@link EJBContainer}
+    */
+   public void setContainer(EJBContainer container)
+   {
+      this.container = container;
+   }
+
+   /**
+    * Returns the {@link EJBContainer} for which this {@link AutoTimerInitializer} is responsible
+    * for creating auto timers
+    * @return
+    */
+   public EJBContainer getContainer()
+   {
+      return this.container;
+   }
+
+   /**
+    * Creates any auto timers that are required for the {@link EJBContainer}, which this
+    * {@link AutoTimerInitializer} represents.
+    */
+   @Start
+   public void initializeAutoTimers()
+   {
+      if (this.container == null)
+      {
+         throw new IllegalStateException("Cannot initialize auto-timers since container is not present");
+      }
+
+      JBossEnterpriseBeanMetaData enterpriseBeanMetaData = this.container.getXml();
+      // Auto timers are only since EJB3.1
+      // TODO: This check will fail when EJB3.2 or any newer versions are introduced.
+      // A better check would be to look for any version greater than EJB3.1
+      if (enterpriseBeanMetaData.getJBossMetaData().isEJB31() == false)
+      {
+         return;
+      }
+
+      List<TimerMetaData> autoTimersMetaData = null;
+
+      if (enterpriseBeanMetaData.isSession() && enterpriseBeanMetaData instanceof JBossSessionBean31MetaData)
+      {
+         JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBeanMetaData;
+         // Stateful beans don't have timerservice/timers
+         if (sessionBean.isStateful())
+         {
+            return;
+         }
+         // Get hold of the auto timer metadata
+         autoTimersMetaData = sessionBean.getTimers();
+      }
+      else if (enterpriseBeanMetaData.isMessageDriven()
+            && enterpriseBeanMetaData instanceof JBossMessageDrivenBean31MetaData)
+      {
+         JBossMessageDrivenBean31MetaData mdb = (JBossMessageDrivenBean31MetaData) enterpriseBeanMetaData;
+         // get hold of auto timer metadata
+         autoTimersMetaData = mdb.getTimers();
+      }
+      // If there's no auto timers, then there's nothing to do
+      if (autoTimersMetaData == null)
+      {
+         return;
+      }
+
+      // get hold of the timerservice since we need it to create the autotimers
+      TimerService timerService = this.container.getTimerService();
+
+      if (timerService instanceof org.jboss.ejb3.timerservice.extension.TimerService == false)
+      {
+         // can't do anything about this
+         logger.warn("Cannot create auto timers for EJB: " + enterpriseBeanMetaData.getEjbName()
+               + " since the timerservice isn't of type "
+               + org.jboss.ejb3.timerservice.extension.TimerService.class.getName());
+         return;
+      }
+      org.jboss.ejb3.timerservice.extension.TimerService ejb31TimerService = (org.jboss.ejb3.timerservice.extension.TimerService) timerService;
+      // process each auto timer
+      for (TimerMetaData autoTimerMetaData : autoTimersMetaData)
+      {
+         // create a timer config
+         TimerConfig timerConfig = new TimerConfig();
+         timerConfig.setPersistent(autoTimerMetaData.isPersistent());
+         timerConfig.setInfo(autoTimerMetaData.getInfo());
+         NamedMethodMetaData timeoutMethodMetaData = autoTimerMetaData.getTimeoutMethod();
+         // get hold of the timeout method for this auto-timer
+         Method timeoutMethod = this.getTimeoutMethod(timeoutMethodMetaData, this.container.getBeanClass());
+         if (timeoutMethod == null)
+         {
+            StringBuilder methodStringBuilder = new StringBuilder();
+            methodStringBuilder.append(timeoutMethodMetaData.getMethodName());
+            if (timeoutMethodMetaData.getMethodParams() != null)
+            {
+               methodStringBuilder.append(Arrays.toString(timeoutMethodMetaData.getMethodParams().toArray()));
+            }
+            throw new IllegalStateException("Timeout method: " + methodStringBuilder.toString() + " not found for bean class: "
+                  + enterpriseBeanMetaData.getEjbClass());
+         }
+         // finally create/get the auto timer
+         ejb31TimerService.getAutoTimer(autoTimerMetaData.getScheduleExpression(), timerConfig, timeoutMethod);
+      }
+
+   }
+
+   /**
+    * Returns the {@link Method}, represented by the {@link NamedMethodMetaData}, from the <code>beanClass</code>
+    * <p>
+    *   This method looks for private, protected, package and public methods on the <code>beanClass</code>
+    *   and its superclass(es). If no matching method is found, then this method returns null.
+    * </p>
+    * @param timeoutMethodMetaData The method metadata
+    * @param beanClass The class on which the method has to be looked for
+    * @return
+    * @throws NullPointerException If either of the passed parameters is null
+    */
+   private Method getTimeoutMethod(NamedMethodMetaData timeoutMethodMetaData, Class<?> beanClass)
+   {
+
+      String timeoutMethodName = timeoutMethodMetaData.getMethodName();
+      MethodParametersMetaData timeoutMethodParams = timeoutMethodMetaData.getMethodParams();
+      // load the method param classes
+      Class<?>[] timeoutMethodParamTypes = new Class<?>[]
+      {};
+      if (timeoutMethodParams != null)
+      {
+         timeoutMethodParamTypes = new Class<?>[timeoutMethodParams.size()];
+         int i = 0;
+         for (String paramClassName : timeoutMethodParams)
+         {
+            Class<?> methodParamClass = null;
+            try
+            {
+               methodParamClass = Class.forName(paramClassName, false, beanClass.getClassLoader());
+            }
+            catch (ClassNotFoundException cnfe)
+            {
+               throw new RuntimeException("Could not load method param class: " + paramClassName + " of timeout method");
+            }
+            timeoutMethodParamTypes[i++] = methodParamClass;
+         }
+      }
+      // now start looking for the method
+      Class<?> klass = beanClass;
+      while (klass != null)
+      {
+         Method[] methods = klass.getDeclaredMethods();
+         for (Method method : methods)
+         {
+            if (method.getName().equals(timeoutMethodName))
+            {
+               Class<?>[] methodParamTypes = method.getParameterTypes();
+               // param length doesn't match
+               if (timeoutMethodParamTypes.length != methodParamTypes.length)
+               {
+                  continue;
+               }
+               for (int i = 0; i < methodParamTypes.length; i++)
+               {
+                  // param type doesn't match
+                  if (timeoutMethodParamTypes[i].equals(methodParamTypes[i]) == false)
+                  {
+                     continue;
+                  }
+               }
+               // match found
+               return method;
+            }
+         }
+         klass = klass.getSuperclass();
+      }
+      // no match found
+      return null;
+   }
+
+}



More information about the jboss-cvs-commits mailing list