[jboss-cvs] JBossAS SVN: r108476 - in projects/metadata/ejb/tags: jboss-metadata-ejb-2.0.0-alpha-19 and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 7 03:03:48 EDT 2010
Author: jaikiran
Date: 2010-10-07 03:03:46 -0400 (Thu, 07 Oct 2010)
New Revision: 108476
Added:
projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/
projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/pom.xml
projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/jboss/JBossMessageDrivenBean31MetaData.java
projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java
projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/spec/MessageDrivenBean31MetaData.java
projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java
projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/test/java/org/jboss/metadata/ejb/test/schedule/unit/ScheduleTestCase.java
Removed:
projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/pom.xml
projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/jboss/JBossMessageDrivenBean31MetaData.java
projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java
projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/spec/MessageDrivenBean31MetaData.java
projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java
projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/test/java/org/jboss/metadata/ejb/test/schedule/unit/ScheduleTestCase.java
Modified:
projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/.settings/org.eclipse.jdt.core.prefs
Log:
[maven-release-plugin] copy for tag jboss-metadata-ejb-2.0.0-alpha-19
Copied: projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19 (from rev 108473, projects/metadata/ejb/trunk)
Modified: projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/metadata/ejb/trunk/.settings/org.eclipse.jdt.core.prefs 2010-10-07 06:09:21 UTC (rev 108473)
+++ projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/.settings/org.eclipse.jdt.core.prefs 2010-10-07 07:03:46 UTC (rev 108476)
@@ -1,5 +1,6 @@
-#Wed Jun 17 11:18:26 CEST 2009
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.source=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
+#Thu Jun 17 19:40:23 IST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
Deleted: projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/pom.xml
===================================================================
--- projects/metadata/ejb/trunk/pom.xml 2010-10-07 06:09:21 UTC (rev 108473)
+++ projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/pom.xml 2010-10-07 07:03:46 UTC (rev 108476)
@@ -1,219 +0,0 @@
-<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>
- <parent>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-parent</artifactId>
- <version>4.0.CR1</version>
- </parent>
- <groupId>org.jboss.metadata</groupId>
- <artifactId>jboss-metadata-ejb</artifactId>
- <packaging>jar</packaging>
- <version>2.0.0-SNAPSHOT</version>
- <name>JBoss Metadata EJB</name>
- <url>http://www.jboss.org</url>
- <description>The common JavaEE metadata classes</description>
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/metadata/ejb/tags/2.0.0-alpha-16</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/metadata/ejb/tags/2.0.0-alpha-16</developerConnection>
- </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>
-
- <build>
- <outputDirectory>${profile.outputDirectory}</outputDirectory>
- <testOutputDirectory>${profile.testOutputDirectory}</testOutputDirectory>
- <plugins>
- <plugin>
- <artifactId>maven-enforcer-plugin</artifactId>
- <executions>
- <!-- Enforce JDK6 -->
- <execution>
- <id>enforce-jdk6</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireJavaVersion>
- <version>1.6</version>
- </requireJavaVersion>
- </rules>
- </configuration>
- </execution>
- <!-- Banned dependencies -->
- <execution>
- <id>enforce-banned-dependencies</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <rules>
- <bannedDependencies>
- <excludes>
- <!-- JBMETA-262 Use org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec -->
- <exclude>org.jboss.ejb3:jboss-ejb3-api</exclude>
- <exclude>org.jboss.javaee:jboss-ejb-api_3.1</exclude>
- </excludes>
- </bannedDependencies>
- </rules>
- </configuration>
-
- </plugin>
-
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.4.3</version>
- <configuration>
- <printSummary>true</printSummary>
- <disableXmlReport>false</disableXmlReport>
- <redirectTestOutputToFile>true</redirectTestOutputToFile>
- <testFailureIgnore>false</testFailureIgnore>
- <includes>
- <include>**/*TestCase.java</include>
- </includes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <repositories>
- <repository>
- <id>repository.jboss.org</id>
- <name>JBoss Repository</name>
- <layout>default</layout>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>snapshots.jboss.org</id>
- <name>JBoss Snapshot Repository</name>
- <layout>default</layout>
- <url>http://snapshots.jboss.org/maven2/</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <!--
- Eclipse settings have been removed from parent. This needs to be
- done via an eclipse profile.
- http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4085896#4085896
- -->
- <profiles>
- <profile>
- <id>default</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <properties>
- <profile.outputDirectory>target/classes</profile.outputDirectory>
- <profile.testOutputDirectory>target/tests-classes</profile.testOutputDirectory>
- </properties>
- </profile>
-
- <profile>
- <id>eclipse</id>
- <properties>
- <profile.outputDirectory>eclipse-target/classes</profile.outputDirectory>
- <profile.testOutputDirectory>eclipse-target/tests-classes</profile.testOutputDirectory>
- </properties>
- </profile>
- </profiles>
-
- <!-- Compile Dependencies -->
- <dependencies>
-
- <dependency>
- <groupId>org.jboss.spec.javax.ejb</groupId>
- <artifactId>jboss-ejb-api_3.1_spec</artifactId>
- <version>1.0.0.Beta2</version>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.metadata</groupId>
- <artifactId>jboss-metadata-common</artifactId>
- <version>2.0.0.Alpha15</version>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.metadata</groupId>
- <artifactId>jboss-metadata-common</artifactId>
- <version>2.0.0.Alpha15</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.ejb3</groupId>
- <artifactId>jboss-ejb3-ext-api</artifactId>
- <version>1.1.0</version>
- <exclusions>
- <exclusion>
- <groupId>org.jboss.metadata</groupId>
- <artifactId>jboss-metadata</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jbossxb</artifactId>
- <version>2.0.2.Beta7</version>
- </dependency>
-
- <!-- Test Dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
- </dependency>
-
- <!-- To counter AbstractMethodErrors -->
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <version>2.2.0.CR1</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.test</groupId>
- <artifactId>jboss-test</artifactId>
- <version>1.1.4.GA</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
-</project>
Copied: projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/pom.xml (from rev 108475, projects/metadata/ejb/trunk/pom.xml)
===================================================================
--- projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/pom.xml (rev 0)
+++ projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/pom.xml 2010-10-07 07:03:46 UTC (rev 108476)
@@ -0,0 +1,219 @@
+<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>
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>4.0.CR1</version>
+ </parent>
+ <groupId>org.jboss.metadata</groupId>
+ <artifactId>jboss-metadata-ejb</artifactId>
+ <packaging>jar</packaging>
+ <version>2.0.0-alpha-19</version>
+ <name>JBoss Metadata EJB</name>
+ <url>http://www.jboss.org</url>
+ <description>The common JavaEE metadata classes</description>
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19</developerConnection>
+ </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>
+
+ <build>
+ <outputDirectory>${profile.outputDirectory}</outputDirectory>
+ <testOutputDirectory>${profile.testOutputDirectory}</testOutputDirectory>
+ <plugins>
+ <plugin>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <!-- Enforce JDK6 -->
+ <execution>
+ <id>enforce-jdk6</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireJavaVersion>
+ <version>1.6</version>
+ </requireJavaVersion>
+ </rules>
+ </configuration>
+ </execution>
+ <!-- Banned dependencies -->
+ <execution>
+ <id>enforce-banned-dependencies</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <rules>
+ <bannedDependencies>
+ <excludes>
+ <!-- JBMETA-262 Use org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec -->
+ <exclude>org.jboss.ejb3:jboss-ejb3-api</exclude>
+ <exclude>org.jboss.javaee:jboss-ejb-api_3.1</exclude>
+ </excludes>
+ </bannedDependencies>
+ </rules>
+ </configuration>
+
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.3</version>
+ <configuration>
+ <printSummary>true</printSummary>
+ <disableXmlReport>false</disableXmlReport>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <testFailureIgnore>false</testFailureIgnore>
+ <includes>
+ <include>**/*TestCase.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <layout>default</layout>
+ <url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <layout>default</layout>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <!--
+ Eclipse settings have been removed from parent. This needs to be
+ done via an eclipse profile.
+ http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4085896#4085896
+ -->
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <properties>
+ <profile.outputDirectory>target/classes</profile.outputDirectory>
+ <profile.testOutputDirectory>target/tests-classes</profile.testOutputDirectory>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>eclipse</id>
+ <properties>
+ <profile.outputDirectory>eclipse-target/classes</profile.outputDirectory>
+ <profile.testOutputDirectory>eclipse-target/tests-classes</profile.testOutputDirectory>
+ </properties>
+ </profile>
+ </profiles>
+
+ <!-- Compile Dependencies -->
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.1_spec</artifactId>
+ <version>1.0.0.Beta2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.metadata</groupId>
+ <artifactId>jboss-metadata-common</artifactId>
+ <version>2.0.0.Alpha15</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.metadata</groupId>
+ <artifactId>jboss-metadata-common</artifactId>
+ <version>2.0.0.Alpha15</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-ext-api</artifactId>
+ <version>1.1.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.metadata</groupId>
+ <artifactId>jboss-metadata</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossxb</artifactId>
+ <version>2.0.2.Beta7</version>
+ </dependency>
+
+ <!-- Test Dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- To counter AbstractMethodErrors -->
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <version>2.2.0.CR1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <version>1.1.4.GA</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
Deleted: projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/jboss/JBossMessageDrivenBean31MetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossMessageDrivenBean31MetaData.java 2010-10-07 06:09:21 UTC (rev 108473)
+++ projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/jboss/JBossMessageDrivenBean31MetaData.java 2010-10-07 07:03:46 UTC (rev 108476)
@@ -1,135 +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.metadata.ejb.jboss;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ejb.Schedule;
-
-import org.jboss.metadata.common.ejb.IScheduleTarget;
-import org.jboss.metadata.common.ejb.ITimeoutTarget;
-import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.spec.MessageDrivenBean31MetaData;
-import org.jboss.metadata.ejb.spec.TimerMetaData;
-
-/**
- * Metadata for EJB3.1 MDBs
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class JBossMessageDrivenBean31MetaData extends JBossMessageDrivenBeanMetaData implements ITimeoutTarget, IScheduleTarget
-{
-
- /**
- * Represents metadata for {@link Schedule}
- */
- private List<TimerMetaData> timers = new ArrayList<TimerMetaData>();
-
- /**
- * Returns the {@link TimerMetaData} associated with this bean
- */
- @Override
- public List<TimerMetaData> getTimers()
- {
- return this.timers;
- }
-
- /**
- * Sets the {@link TimerMetaData} for this bean
- */
- @Override
- public void setTimers(List<TimerMetaData> timers)
- {
- this.timers = timers;
- }
-
- @Override
- public void addTimer(TimerMetaData timer)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.add(timer);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void merge(JBossEnterpriseBeanMetaData override, EnterpriseBeanMetaData original, String overridenFile, String overrideFile, boolean mustOverride)
- {
- super.merge(override, original, overridenFile, overrideFile, mustOverride);
-
- JBossMessageDrivenBean31MetaData joverride = (JBossMessageDrivenBean31MetaData) override;
- MessageDrivenBean31MetaData soriginal = (MessageDrivenBean31MetaData) original;
-
- if(joverride != null && joverride.timers != null)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.addAll(joverride.timers);
- }
- else if (soriginal != null && soriginal.getTimers() != null)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.addAll(soriginal.getTimers());
- }
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void merge(JBossEnterpriseBeanMetaData overrideEjb, JBossEnterpriseBeanMetaData originalEjb)
- {
- super.merge(overrideEjb, originalEjb);
-
- JBossMessageDrivenBean31MetaData override = overrideEjb instanceof JBossGenericBeanMetaData ? null: (JBossMessageDrivenBean31MetaData) overrideEjb;
- JBossMessageDrivenBean31MetaData original = originalEjb instanceof JBossGenericBeanMetaData ? null: (JBossMessageDrivenBean31MetaData) originalEjb;
-
- if(override != null && override.timers != null)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.addAll(override.timers);
- }
- else if (original != null && original.timers != null)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.addAll(original.timers);
- }
- }
-
-}
Copied: projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/jboss/JBossMessageDrivenBean31MetaData.java (from rev 108474, projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossMessageDrivenBean31MetaData.java)
===================================================================
--- projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/jboss/JBossMessageDrivenBean31MetaData.java (rev 0)
+++ projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/jboss/JBossMessageDrivenBean31MetaData.java 2010-10-07 07:03:46 UTC (rev 108476)
@@ -0,0 +1,128 @@
+/*
+ * 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.metadata.ejb.jboss;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.ejb.Schedule;
+
+import org.jboss.metadata.common.ejb.IScheduleTarget;
+import org.jboss.metadata.common.ejb.ITimeoutTarget;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.spec.MessageDrivenBean31MetaData;
+import org.jboss.metadata.ejb.spec.TimerMetaData;
+import org.jboss.metadata.merge.MergeUtil;
+
+/**
+ * Metadata for EJB3.1 MDBs
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class JBossMessageDrivenBean31MetaData extends JBossMessageDrivenBeanMetaData implements ITimeoutTarget, IScheduleTarget
+{
+
+ /**
+ * Represents metadata for {@link Schedule}
+ */
+ private List<TimerMetaData> timers = new ArrayList<TimerMetaData>();
+
+ /**
+ * Returns the {@link TimerMetaData} associated with this bean
+ */
+ @Override
+ public List<TimerMetaData> getTimers()
+ {
+ return this.timers;
+ }
+
+ /**
+ * Sets the {@link TimerMetaData} for this bean
+ */
+ @Override
+ public void setTimers(List<TimerMetaData> timers)
+ {
+ this.timers = timers;
+ }
+
+ @Override
+ public void addTimer(TimerMetaData timer)
+ {
+ if (this.timers == null)
+ {
+ this.timers = new ArrayList<TimerMetaData>();
+ }
+ this.timers.add(timer);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void merge(JBossEnterpriseBeanMetaData override, EnterpriseBeanMetaData original, String overridenFile, String overrideFile, boolean mustOverride)
+ {
+ super.merge(override, original, overridenFile, overrideFile, mustOverride);
+
+ JBossMessageDrivenBean31MetaData joverride = (JBossMessageDrivenBean31MetaData) override;
+ MessageDrivenBean31MetaData soriginal = (MessageDrivenBean31MetaData) original;
+
+ // merge the (auto)timer metadata
+ Collection<TimerMetaData> originalTimers = soriginal == null ? null : soriginal.getTimers();
+ Collection<TimerMetaData> overrideTimers = joverride == null ? null : joverride.timers;
+ if(originalTimers != null || overrideTimers != null)
+ {
+ if (this.timers == null)
+ {
+ this.timers = new ArrayList<TimerMetaData>();
+ }
+ MergeUtil.merge(this.timers, overrideTimers, originalTimers);
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void merge(JBossEnterpriseBeanMetaData overrideEjb, JBossEnterpriseBeanMetaData originalEjb)
+ {
+ super.merge(overrideEjb, originalEjb);
+
+ JBossMessageDrivenBean31MetaData override = overrideEjb instanceof JBossGenericBeanMetaData ? null: (JBossMessageDrivenBean31MetaData) overrideEjb;
+ JBossMessageDrivenBean31MetaData original = originalEjb instanceof JBossGenericBeanMetaData ? null: (JBossMessageDrivenBean31MetaData) originalEjb;
+
+ // merge the (auto)timer metadata
+ Collection<TimerMetaData> originalTimers = original == null ? null : original.timers;
+ Collection<TimerMetaData> overrideTimers = override == null ? null : override.timers;
+ if(originalTimers != null || overrideTimers != null)
+ {
+ if (this.timers == null)
+ {
+ this.timers = new ArrayList<TimerMetaData>();
+ }
+ MergeUtil.merge(this.timers, overrideTimers, originalTimers);
+ }
+
+ }
+
+}
Deleted: projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java 2010-10-07 06:09:21 UTC (rev 108473)
+++ projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java 2010-10-07 07:03:46 UTC (rev 108476)
@@ -1,514 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.metadata.ejb.jboss;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.ejb.ConcurrencyManagementType;
-import javax.ejb.LockType;
-import javax.ejb.Schedule;
-import javax.ejb.Startup;
-
-import org.jboss.metadata.common.ejb.IScheduleTarget;
-import org.jboss.metadata.common.ejb.ITimeoutTarget;
-import org.jboss.metadata.ejb.spec.AccessTimeoutMetaData;
-import org.jboss.metadata.ejb.spec.AsyncMethodsMetaData;
-import org.jboss.metadata.ejb.spec.ConcurrentMethodMetaData;
-import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
-import org.jboss.metadata.ejb.spec.SessionBean31MetaData;
-import org.jboss.metadata.ejb.spec.SessionType;
-import org.jboss.metadata.ejb.spec.TimerMetaData;
-
-/**
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class JBossSessionBean31MetaData extends JBossSessionBeanMetaData implements ITimeoutTarget, IScheduleTarget // FIXME: AbstractProcessor.processClass doesn't take super interfaces into account
-{
- private static final long serialVersionUID = 1L;
-
- private AsyncMethodsMetaData asyncMethods;
-
- /**
- * Flag indicating whether this bean has a no-interface view
- */
- private boolean noInterfaceBean;
-
- /**
- * Flag indicating if a singleton bean is set for init-on-startup
- */
- private Boolean initOnStartup;
-
- /**
- * Concurrent methods of this bean
- */
- private Map<NamedMethodMetaData, ConcurrentMethodMetaData> concurrentMethods;
-
- /**
- * Bean level access timeout
- */
- private AccessTimeoutMetaData beanLevelAccessTimeout;
-
- /**
- * Concurrency management type of the bean
- */
- private ConcurrencyManagementType concurrencyManagementType;
-
- /**
- * The lock type that is set at the bean level
- */
- private LockType beanLevelLockType;
-
- /**
- * DependsOn for a singleton bean
- */
- private String[] dependsOn;
-
- /**
- * For beans which have auto-timers (ex: through use of {@link Schedule})
- */
- private List<TimerMetaData> timers = new ArrayList<TimerMetaData>();
-
- public AsyncMethodsMetaData getAsyncMethods()
- {
- return asyncMethods;
- }
-
- public void setAsyncMethods(AsyncMethodsMetaData asyncMethods)
- {
- if (asyncMethods == null)
- throw new IllegalArgumentException("asyncMethods is null");
-
- this.asyncMethods = asyncMethods;
- }
-
- /**
- * Returns true if this bean exposes a no-interface view
- * @return
- */
- public boolean isNoInterfaceBean()
- {
- return this.noInterfaceBean;
- }
-
- /**
- * Set the metadata to represent whether this bean
- * exposes an no-interface view
- * @param isNoInterfaceBean True if the bean exposes a no-interface
- * view. Else set to false.
- */
- public void setNoInterfaceBean(boolean isNoInterfaceBean)
- {
- this.noInterfaceBean = isNoInterfaceBean;
- }
-
- /**
- *
- * @return Returns true if this is a singleton session bean.
- * Else returns false.
- */
- public boolean isSingleton()
- {
- SessionType type = this.getSessionType();
- if (type == null)
- {
- return false;
- }
- return SessionType.Singleton == type;
- }
-
- /**
- * @return Returns true if a singleton bean is marked for init-on-startup ({@link Startup})
- *
- */
- public boolean isInitOnStartup()
- {
- return this.initOnStartup == null ? Boolean.FALSE : this.initOnStartup;
- }
-
- /**
- * Set the init-on-startup property of a singleton bean
- *
- * @param initOnStartup True if the singleton bean has to be inited on startup. False otherwise
- *
- */
- public void setInitOnStartup(boolean initOnStartup)
- {
-
- this.initOnStartup = initOnStartup;
- }
-
- /**
- * Sets the concurrency management type of this bean
- * @param concurrencyManagementType The concurrency management type
- * @throws If the passed <code>concurrencyManagementType</code> is null
- */
- public void setConcurrencyManagementType(ConcurrencyManagementType concurrencyManagementType)
- {
- if (concurrencyManagementType == null)
- {
- throw new IllegalArgumentException("Concurrency management type cannot be null");
- }
- this.concurrencyManagementType = concurrencyManagementType;
- }
-
- /**
- * Returns the concurrency management type of this bean
- * @return
- */
- public ConcurrencyManagementType getConcurrencyManagementType()
- {
- return this.concurrencyManagementType;
- }
-
- /**
- * Sets the concurrent methods of this bean
- * @param concurrentMethods
- * @throws IllegalArgumentException If the passed <code>concurrentMethods</code> is null
- */
- public void setConcurrentMethods(Set<ConcurrentMethodMetaData> concurrentMethods)
- {
- if (concurrentMethods == null)
- {
- throw new IllegalArgumentException("Concurrent methods cannot be set to null");
- }
- this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
- for (ConcurrentMethodMetaData concurrentMethod : concurrentMethods)
- {
- this.concurrentMethods.put(concurrentMethod.getMethod(), concurrentMethod);
- }
- }
-
- /**
- * Returns a {@link Map} whose key represents a {@link NamedMethodMetaData} and whose value
- * represents {@link ConcurrentMethodMetaData} of this bean. Returns an empty {@link Map} if
- * there are no concurrent methods for this bean
- * @return
- */
- public Map<NamedMethodMetaData, ConcurrentMethodMetaData> getConcurrentMethods()
- {
- if (this.concurrentMethods == null)
- {
- this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
- }
- return this.concurrentMethods;
- }
-
- /**
- * Sets the lock type applicable at the bean level
- * @param lockType {@link LockType}
- */
- public void setLockType(LockType lockType)
- {
- this.beanLevelLockType = lockType;
- }
-
- /**
- * Returns the lock type applicable at the bean level
- * @return
- */
- public LockType getLockType()
- {
- return this.beanLevelLockType;
- }
-
- /**
- * Sets the bean level access timeout metadata
- * @param accessTimeout {@link AccessTimeoutMetaData}
- */
- public void setAccessTimeout(AccessTimeoutMetaData accessTimeout)
- {
- this.beanLevelAccessTimeout = accessTimeout;
- }
-
- /**
- * Returns the access timeout metadata applicable at bean level
- *
- * @return
- */
- public AccessTimeoutMetaData getAccessTimeout()
- {
- return this.beanLevelAccessTimeout;
- }
-
- /**
- * Returns the names of one or more Singleton beans in the same application
- * as the referring Singleton.
- * @return
- */
- public String[] getDependsOn()
- {
- return this.dependsOn;
- }
-
- /**
- * Sets the names of one or more singleton beans, each of which must be initialized before
- * the referring bean. Each dependent bean is expressed using ejb-link syntax.
- *
- * @param dependsOn The singleton bean dependencies
- */
- public void setDependsOn(String[] dependsOn)
- {
- this.dependsOn = dependsOn;
- }
-
- /**
- * Sets the names of one or more singleton beans, each of which must be initialized before
- * the referring bean. Each dependent bean is expressed using ejb-link syntax.
- *
- * @param dependsOn The singleton bean dependencies
- */
- public void setDependsOn(Collection<String> dependsOn)
- {
- if (dependsOn == null)
- {
- return;
- }
- this.setDependsOn(dependsOn.toArray(new String[dependsOn.size()]));
- }
-
-
- /**
- * Returns the {@link TimerMetaData} associated (if any) with this bean
- */
- @Override
- public List<TimerMetaData> getTimers()
- {
- return this.timers;
- }
-
- /**
- * Sets the {@link TimerMetaData} associated with this bean
- */
- @Override
- public void setTimers(List<TimerMetaData> timer)
- {
- this.timers = timer;
- }
-
- @Override
- public void addTimer(TimerMetaData timer)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.add(timer);
- }
-
- @Override
- public void merge(JBossEnterpriseBeanMetaData override, JBossEnterpriseBeanMetaData original)
- {
- super.merge(override, original);
-
- JBossSessionBean31MetaData joverride = override instanceof JBossGenericBeanMetaData
- ? null
- : (JBossSessionBean31MetaData) override;
- JBossSessionBean31MetaData soriginal = original instanceof JBossGenericBeanMetaData
- ? null
- : (JBossSessionBean31MetaData) original;
-
- merge(joverride != null ? joverride.asyncMethods : null, soriginal != null ? soriginal.asyncMethods : null);
-
- // merge the rest
- if (joverride != null)
- {
- this.noInterfaceBean = joverride.isNoInterfaceBean();
- this.initOnStartup = joverride.isInitOnStartup();
- if (joverride.concurrencyManagementType != null)
- {
- this.concurrencyManagementType = joverride.concurrencyManagementType;
- }
- if (joverride.concurrentMethods != null)
- {
- if (this.concurrentMethods == null)
- {
- this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
- }
- this.concurrentMethods.putAll(joverride.concurrentMethods);
- }
- if (joverride.beanLevelLockType != null)
- {
- this.beanLevelLockType = joverride.beanLevelLockType;
- }
- if (joverride.beanLevelAccessTimeout != null)
- {
- this.beanLevelAccessTimeout = joverride.beanLevelAccessTimeout;
- }
- if (joverride.dependsOn != null)
- {
- this.dependsOn = joverride.dependsOn;
- }
- if (joverride.timers != null)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.addAll(joverride.timers);
- }
- }
- else if (soriginal != null)
- {
- this.noInterfaceBean = soriginal.isNoInterfaceBean();
- this.initOnStartup = soriginal.isInitOnStartup();
- if (soriginal.getConcurrencyManagementType() != null)
- {
- this.concurrencyManagementType = soriginal.getConcurrencyManagementType();
- }
- if (soriginal.concurrentMethods != null)
- {
- if (this.concurrentMethods == null)
- {
- this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
- }
- this.concurrentMethods.putAll(soriginal.concurrentMethods);
- }
- if (soriginal.beanLevelLockType != null)
- {
- this.beanLevelLockType = soriginal.beanLevelLockType;
- }
- if (soriginal.beanLevelAccessTimeout != null)
- {
- this.beanLevelAccessTimeout = soriginal.beanLevelAccessTimeout;
- }
- if (soriginal.dependsOn != null)
- {
- this.dependsOn = soriginal.dependsOn;
- }
- if (soriginal.timers != null)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.addAll(soriginal.timers);
- }
- }
-
- }
-
- @Override
- public void merge(JBossEnterpriseBeanMetaData override, EnterpriseBeanMetaData original, String overridenFile,
- String overrideFile, boolean mustOverride)
- {
- super.merge(override, original, overridenFile, overrideFile, mustOverride);
-
- JBossSessionBean31MetaData joverride = (JBossSessionBean31MetaData) override;
- SessionBean31MetaData soriginal = (SessionBean31MetaData) original;
-
- merge(joverride != null ? joverride.asyncMethods : null, soriginal != null ? soriginal.getAsyncMethods() : null);
-
- // merge rest of the metadata
- if (joverride != null)
- {
- this.noInterfaceBean = joverride.isNoInterfaceBean();
- this.initOnStartup = joverride.isInitOnStartup();
- if (joverride.concurrencyManagementType != null)
- {
- this.concurrencyManagementType = joverride.concurrencyManagementType;
- }
- if (joverride.concurrentMethods != null)
- {
- if (this.concurrentMethods == null)
- {
- this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
- }
- this.concurrentMethods.putAll(joverride.concurrentMethods);
- }
- if (joverride.beanLevelLockType != null)
- {
- this.beanLevelLockType = joverride.beanLevelLockType;
- }
- if (joverride.beanLevelAccessTimeout != null)
- {
- this.beanLevelAccessTimeout = joverride.beanLevelAccessTimeout;
- }
- if (joverride.dependsOn != null)
- {
- this.dependsOn = joverride.dependsOn;
- }
- if (joverride.timers != null)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.addAll(joverride.timers);
- }
- }
- else if (soriginal != null)
- {
- this.noInterfaceBean = soriginal.isNoInterfaceBean();
- this.initOnStartup = soriginal.isInitOnStartup();
- if (soriginal.getConcurrencyManagementType() != null)
- {
- this.concurrencyManagementType = soriginal.getConcurrencyManagementType();
- }
- if (soriginal.getConcurrentMethods() != null)
- {
- if (this.concurrentMethods == null)
- {
- this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
- }
- this.concurrentMethods.putAll(soriginal.getConcurrentMethods());
- }
- if (soriginal.getLockType() != null)
- {
- this.beanLevelLockType = soriginal.getLockType();
- }
- if (soriginal.getAccessTimeout() != null)
- {
- this.beanLevelAccessTimeout = soriginal.getAccessTimeout();
- }
- if (soriginal.getDependsOn() != null)
- {
- this.dependsOn = soriginal.getDependsOn();
- }
- if (soriginal.getTimers() != null)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.addAll(soriginal.getTimers());
- }
- }
-
- }
-
- private void merge(AsyncMethodsMetaData override, AsyncMethodsMetaData original)
- {
- this.asyncMethods = new AsyncMethodsMetaData();
- if (override != null)
- asyncMethods.addAll(override);
- if (original != null)
- asyncMethods.addAll(original);
- }
-
-}
Copied: projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java (from rev 108474, projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java)
===================================================================
--- projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java (rev 0)
+++ projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java 2010-10-07 07:03:46 UTC (rev 108476)
@@ -0,0 +1,519 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.metadata.ejb.jboss;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.ConcurrencyManagementType;
+import javax.ejb.LockType;
+import javax.ejb.Schedule;
+import javax.ejb.Startup;
+
+import org.jboss.metadata.common.ejb.IScheduleTarget;
+import org.jboss.metadata.common.ejb.ITimeoutTarget;
+import org.jboss.metadata.ejb.spec.AccessTimeoutMetaData;
+import org.jboss.metadata.ejb.spec.AsyncMethodsMetaData;
+import org.jboss.metadata.ejb.spec.ConcurrentMethodMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
+import org.jboss.metadata.ejb.spec.SessionBean31MetaData;
+import org.jboss.metadata.ejb.spec.SessionType;
+import org.jboss.metadata.ejb.spec.TimerMetaData;
+import org.jboss.metadata.merge.MergeUtil;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class JBossSessionBean31MetaData extends JBossSessionBeanMetaData implements ITimeoutTarget, IScheduleTarget // FIXME: AbstractProcessor.processClass doesn't take super interfaces into account
+{
+ private static final long serialVersionUID = 1L;
+
+ private AsyncMethodsMetaData asyncMethods;
+
+ /**
+ * Flag indicating whether this bean has a no-interface view
+ */
+ private boolean noInterfaceBean;
+
+ /**
+ * Flag indicating if a singleton bean is set for init-on-startup
+ */
+ private Boolean initOnStartup;
+
+ /**
+ * Concurrent methods of this bean
+ */
+ private Map<NamedMethodMetaData, ConcurrentMethodMetaData> concurrentMethods;
+
+ /**
+ * Bean level access timeout
+ */
+ private AccessTimeoutMetaData beanLevelAccessTimeout;
+
+ /**
+ * Concurrency management type of the bean
+ */
+ private ConcurrencyManagementType concurrencyManagementType;
+
+ /**
+ * The lock type that is set at the bean level
+ */
+ private LockType beanLevelLockType;
+
+ /**
+ * DependsOn for a singleton bean
+ */
+ private String[] dependsOn;
+
+ /**
+ * For beans which have auto-timers (ex: through use of {@link Schedule})
+ */
+ private List<TimerMetaData> timers = new ArrayList<TimerMetaData>();
+
+ public AsyncMethodsMetaData getAsyncMethods()
+ {
+ return asyncMethods;
+ }
+
+ public void setAsyncMethods(AsyncMethodsMetaData asyncMethods)
+ {
+ if (asyncMethods == null)
+ throw new IllegalArgumentException("asyncMethods is null");
+
+ this.asyncMethods = asyncMethods;
+ }
+
+ /**
+ * Returns true if this bean exposes a no-interface view
+ * @return
+ */
+ public boolean isNoInterfaceBean()
+ {
+ return this.noInterfaceBean;
+ }
+
+ /**
+ * Set the metadata to represent whether this bean
+ * exposes an no-interface view
+ * @param isNoInterfaceBean True if the bean exposes a no-interface
+ * view. Else set to false.
+ */
+ public void setNoInterfaceBean(boolean isNoInterfaceBean)
+ {
+ this.noInterfaceBean = isNoInterfaceBean;
+ }
+
+ /**
+ *
+ * @return Returns true if this is a singleton session bean.
+ * Else returns false.
+ */
+ public boolean isSingleton()
+ {
+ SessionType type = this.getSessionType();
+ if (type == null)
+ {
+ return false;
+ }
+ return SessionType.Singleton == type;
+ }
+
+ /**
+ * @return Returns true if a singleton bean is marked for init-on-startup ({@link Startup})
+ *
+ */
+ public boolean isInitOnStartup()
+ {
+ return this.initOnStartup == null ? Boolean.FALSE : this.initOnStartup;
+ }
+
+ /**
+ * Set the init-on-startup property of a singleton bean
+ *
+ * @param initOnStartup True if the singleton bean has to be inited on startup. False otherwise
+ *
+ */
+ public void setInitOnStartup(boolean initOnStartup)
+ {
+
+ this.initOnStartup = initOnStartup;
+ }
+
+ /**
+ * Sets the concurrency management type of this bean
+ * @param concurrencyManagementType The concurrency management type
+ * @throws If the passed <code>concurrencyManagementType</code> is null
+ */
+ public void setConcurrencyManagementType(ConcurrencyManagementType concurrencyManagementType)
+ {
+ if (concurrencyManagementType == null)
+ {
+ throw new IllegalArgumentException("Concurrency management type cannot be null");
+ }
+ this.concurrencyManagementType = concurrencyManagementType;
+ }
+
+ /**
+ * Returns the concurrency management type of this bean
+ * @return
+ */
+ public ConcurrencyManagementType getConcurrencyManagementType()
+ {
+ return this.concurrencyManagementType;
+ }
+
+ /**
+ * Sets the concurrent methods of this bean
+ * @param concurrentMethods
+ * @throws IllegalArgumentException If the passed <code>concurrentMethods</code> is null
+ */
+ public void setConcurrentMethods(Set<ConcurrentMethodMetaData> concurrentMethods)
+ {
+ if (concurrentMethods == null)
+ {
+ throw new IllegalArgumentException("Concurrent methods cannot be set to null");
+ }
+ this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
+ for (ConcurrentMethodMetaData concurrentMethod : concurrentMethods)
+ {
+ this.concurrentMethods.put(concurrentMethod.getMethod(), concurrentMethod);
+ }
+ }
+
+ /**
+ * Returns a {@link Map} whose key represents a {@link NamedMethodMetaData} and whose value
+ * represents {@link ConcurrentMethodMetaData} of this bean. Returns an empty {@link Map} if
+ * there are no concurrent methods for this bean
+ * @return
+ */
+ public Map<NamedMethodMetaData, ConcurrentMethodMetaData> getConcurrentMethods()
+ {
+ if (this.concurrentMethods == null)
+ {
+ this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
+ }
+ return this.concurrentMethods;
+ }
+
+ /**
+ * Sets the lock type applicable at the bean level
+ * @param lockType {@link LockType}
+ */
+ public void setLockType(LockType lockType)
+ {
+ this.beanLevelLockType = lockType;
+ }
+
+ /**
+ * Returns the lock type applicable at the bean level
+ * @return
+ */
+ public LockType getLockType()
+ {
+ return this.beanLevelLockType;
+ }
+
+ /**
+ * Sets the bean level access timeout metadata
+ * @param accessTimeout {@link AccessTimeoutMetaData}
+ */
+ public void setAccessTimeout(AccessTimeoutMetaData accessTimeout)
+ {
+ this.beanLevelAccessTimeout = accessTimeout;
+ }
+
+ /**
+ * Returns the access timeout metadata applicable at bean level
+ *
+ * @return
+ */
+ public AccessTimeoutMetaData getAccessTimeout()
+ {
+ return this.beanLevelAccessTimeout;
+ }
+
+ /**
+ * Returns the names of one or more Singleton beans in the same application
+ * as the referring Singleton.
+ * @return
+ */
+ public String[] getDependsOn()
+ {
+ return this.dependsOn;
+ }
+
+ /**
+ * Sets the names of one or more singleton beans, each of which must be initialized before
+ * the referring bean. Each dependent bean is expressed using ejb-link syntax.
+ *
+ * @param dependsOn The singleton bean dependencies
+ */
+ public void setDependsOn(String[] dependsOn)
+ {
+ this.dependsOn = dependsOn;
+ }
+
+ /**
+ * Sets the names of one or more singleton beans, each of which must be initialized before
+ * the referring bean. Each dependent bean is expressed using ejb-link syntax.
+ *
+ * @param dependsOn The singleton bean dependencies
+ */
+ public void setDependsOn(Collection<String> dependsOn)
+ {
+ if (dependsOn == null)
+ {
+ return;
+ }
+ this.setDependsOn(dependsOn.toArray(new String[dependsOn.size()]));
+ }
+
+
+ /**
+ * Returns the {@link TimerMetaData} associated (if any) with this bean
+ */
+ @Override
+ public List<TimerMetaData> getTimers()
+ {
+ return this.timers;
+ }
+
+ /**
+ * Sets the {@link TimerMetaData} associated with this bean
+ */
+ @Override
+ public void setTimers(List<TimerMetaData> timer)
+ {
+ this.timers = timer;
+ }
+
+ @Override
+ public void addTimer(TimerMetaData timer)
+ {
+ if (this.timers == null)
+ {
+ this.timers = new ArrayList<TimerMetaData>();
+ }
+ this.timers.add(timer);
+ }
+
+ @Override
+ public void merge(JBossEnterpriseBeanMetaData override, JBossEnterpriseBeanMetaData original)
+ {
+ super.merge(override, original);
+
+ JBossSessionBean31MetaData joverride = override instanceof JBossGenericBeanMetaData
+ ? null
+ : (JBossSessionBean31MetaData) override;
+ JBossSessionBean31MetaData soriginal = original instanceof JBossGenericBeanMetaData
+ ? null
+ : (JBossSessionBean31MetaData) original;
+
+ merge(joverride != null ? joverride.asyncMethods : null, soriginal != null ? soriginal.asyncMethods : null);
+
+ // merge the rest
+ if (joverride != null)
+ {
+ this.noInterfaceBean = joverride.isNoInterfaceBean();
+ this.initOnStartup = joverride.isInitOnStartup();
+ if (joverride.concurrencyManagementType != null)
+ {
+ this.concurrencyManagementType = joverride.concurrencyManagementType;
+ }
+ if (joverride.concurrentMethods != null)
+ {
+ if (this.concurrentMethods == null)
+ {
+ this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
+ }
+ this.concurrentMethods.putAll(joverride.concurrentMethods);
+ }
+ if (joverride.beanLevelLockType != null)
+ {
+ this.beanLevelLockType = joverride.beanLevelLockType;
+ }
+ if (joverride.beanLevelAccessTimeout != null)
+ {
+ this.beanLevelAccessTimeout = joverride.beanLevelAccessTimeout;
+ }
+ if (joverride.dependsOn != null)
+ {
+ this.dependsOn = joverride.dependsOn;
+ }
+ }
+ else if (soriginal != null)
+ {
+ this.noInterfaceBean = soriginal.isNoInterfaceBean();
+ this.initOnStartup = soriginal.isInitOnStartup();
+ if (soriginal.getConcurrencyManagementType() != null)
+ {
+ this.concurrencyManagementType = soriginal.getConcurrencyManagementType();
+ }
+ if (soriginal.concurrentMethods != null)
+ {
+ if (this.concurrentMethods == null)
+ {
+ this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
+ }
+ this.concurrentMethods.putAll(soriginal.concurrentMethods);
+ }
+ if (soriginal.beanLevelLockType != null)
+ {
+ this.beanLevelLockType = soriginal.beanLevelLockType;
+ }
+ if (soriginal.beanLevelAccessTimeout != null)
+ {
+ this.beanLevelAccessTimeout = soriginal.beanLevelAccessTimeout;
+ }
+ if (soriginal.dependsOn != null)
+ {
+ this.dependsOn = soriginal.dependsOn;
+ }
+ }
+ // merge timers
+ this.mergeTimers(joverride, soriginal);
+
+ }
+
+ @Override
+ public void merge(JBossEnterpriseBeanMetaData override, EnterpriseBeanMetaData original, String overridenFile,
+ String overrideFile, boolean mustOverride)
+ {
+ super.merge(override, original, overridenFile, overrideFile, mustOverride);
+
+ JBossSessionBean31MetaData joverride = (JBossSessionBean31MetaData) override;
+ SessionBean31MetaData soriginal = (SessionBean31MetaData) original;
+
+ merge(joverride != null ? joverride.asyncMethods : null, soriginal != null ? soriginal.getAsyncMethods() : null);
+
+ // merge rest of the metadata
+ if (joverride != null)
+ {
+ this.noInterfaceBean = joverride.isNoInterfaceBean();
+ this.initOnStartup = joverride.isInitOnStartup();
+ if (joverride.concurrencyManagementType != null)
+ {
+ this.concurrencyManagementType = joverride.concurrencyManagementType;
+ }
+ if (joverride.concurrentMethods != null)
+ {
+ if (this.concurrentMethods == null)
+ {
+ this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
+ }
+ this.concurrentMethods.putAll(joverride.concurrentMethods);
+ }
+ if (joverride.beanLevelLockType != null)
+ {
+ this.beanLevelLockType = joverride.beanLevelLockType;
+ }
+ if (joverride.beanLevelAccessTimeout != null)
+ {
+ this.beanLevelAccessTimeout = joverride.beanLevelAccessTimeout;
+ }
+ if (joverride.dependsOn != null)
+ {
+ this.dependsOn = joverride.dependsOn;
+ }
+
+ }
+ else if (soriginal != null)
+ {
+ this.noInterfaceBean = soriginal.isNoInterfaceBean();
+ this.initOnStartup = soriginal.isInitOnStartup();
+ if (soriginal.getConcurrencyManagementType() != null)
+ {
+ this.concurrencyManagementType = soriginal.getConcurrencyManagementType();
+ }
+ if (soriginal.getConcurrentMethods() != null)
+ {
+ if (this.concurrentMethods == null)
+ {
+ this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
+ }
+ this.concurrentMethods.putAll(soriginal.getConcurrentMethods());
+ }
+ if (soriginal.getLockType() != null)
+ {
+ this.beanLevelLockType = soriginal.getLockType();
+ }
+ if (soriginal.getAccessTimeout() != null)
+ {
+ this.beanLevelAccessTimeout = soriginal.getAccessTimeout();
+ }
+ if (soriginal.getDependsOn() != null)
+ {
+ this.dependsOn = soriginal.getDependsOn();
+ }
+ }
+
+ // merge timers
+ this.mergeTimers(joverride, soriginal);
+
+ }
+
+ private void merge(AsyncMethodsMetaData override, AsyncMethodsMetaData original)
+ {
+ this.asyncMethods = new AsyncMethodsMetaData();
+ if (override != null)
+ asyncMethods.addAll(override);
+ if (original != null)
+ asyncMethods.addAll(original);
+ }
+
+ private void mergeTimers(JBossSessionBean31MetaData override, SessionBean31MetaData original)
+ {
+ // merge the (auto)timer metadata
+ Collection<TimerMetaData> originalTimers = original == null ? null : original.getTimers();
+ Collection<TimerMetaData> overrideTimers = override == null ? null : override.timers;
+ if(originalTimers != null || overrideTimers != null)
+ {
+ if (this.timers == null)
+ {
+ this.timers = new ArrayList<TimerMetaData>();
+ }
+ MergeUtil.merge(this.timers, overrideTimers, originalTimers);
+ }
+ }
+
+ private void mergeTimers(JBossSessionBean31MetaData override, JBossSessionBean31MetaData original)
+ {
+ // merge the (auto)timer metadata
+ Collection<TimerMetaData> originalTimers = original == null ? null : original.timers;
+ Collection<TimerMetaData> overrideTimers = override == null ? null : override.timers;
+ if(originalTimers != null || overrideTimers != null)
+ {
+ if (this.timers == null)
+ {
+ this.timers = new ArrayList<TimerMetaData>();
+ }
+ MergeUtil.merge(this.timers, overrideTimers, originalTimers);
+ }
+ }
+
+}
Deleted: projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/spec/MessageDrivenBean31MetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/MessageDrivenBean31MetaData.java 2010-10-07 06:09:21 UTC (rev 108473)
+++ projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/spec/MessageDrivenBean31MetaData.java 2010-10-07 07:03:46 UTC (rev 108476)
@@ -1,114 +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.metadata.ejb.spec;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ejb.Schedule;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-import org.jboss.metadata.common.ejb.IScheduleTarget;
-import org.jboss.metadata.common.ejb.ITimeoutTarget;
-import org.jboss.xb.annotations.JBossXmlConstants;
-import org.jboss.xb.annotations.JBossXmlType;
-
-/**
- * Metadata for EJB3.1 MDBs
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
- at XmlType(name="message-driven-beanType", propOrder={"descriptionGroup", "ejbName", "mappedName", "ejbClass",
- "transactionType", "messageSelector", "acknowledgeMode", "messageDrivenDestination", // <!-- these are ejb2.x
- "messagingType",
- "timeoutMethod", "timers", "transactionType", "messageDestinationType", "messageDestinationLink", "activationConfig", "aroundInvokes",
- "environmentRefsGroup", "securityIdentity"})
- at JBossXmlType(modelGroup=JBossXmlConstants.MODEL_GROUP_UNORDERED_SEQUENCE)
-public class MessageDrivenBean31MetaData extends MessageDrivenBeanMetaData implements ITimeoutTarget, IScheduleTarget
-{
-
- /**
- * Represents metadata for {@link Schedule}
- */
- private List<TimerMetaData> timers = new ArrayList<TimerMetaData>();
-
- /**
- * Returns the {@link TimerMetaData} associated with this bean
- */
- @Override
- public List<TimerMetaData> getTimers()
- {
- return this.timers;
- }
-
- /**
- * Sets the {@link TimerMetaData} for this bean
- */
- @Override
- @XmlElement (name = "timer", required = false)
- public void setTimers(List<TimerMetaData> timers)
- {
- this.timers = timers;
- }
-
- @Override
- public void addTimer(TimerMetaData timer)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.add(timer);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void merge(MessageDrivenBeanMetaData override, MessageDrivenBeanMetaData original)
- {
- super.merge(override, original);
-
- MessageDrivenBean31MetaData overrideMetaData = (MessageDrivenBean31MetaData) override;
- MessageDrivenBean31MetaData originalMetaData = (MessageDrivenBean31MetaData) original;
-
- if (overrideMetaData != null && overrideMetaData.timers != null)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.addAll(overrideMetaData.timers);
- }
- else if (originalMetaData != null && originalMetaData.timers != null)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.addAll(originalMetaData.timers);
- }
-
- }
-}
Copied: projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/spec/MessageDrivenBean31MetaData.java (from rev 108474, projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/MessageDrivenBean31MetaData.java)
===================================================================
--- projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/spec/MessageDrivenBean31MetaData.java (rev 0)
+++ projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/spec/MessageDrivenBean31MetaData.java 2010-10-07 07:03:46 UTC (rev 108476)
@@ -0,0 +1,111 @@
+/*
+ * 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.metadata.ejb.spec;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.ejb.Schedule;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.metadata.common.ejb.IScheduleTarget;
+import org.jboss.metadata.common.ejb.ITimeoutTarget;
+import org.jboss.metadata.merge.MergeUtil;
+import org.jboss.xb.annotations.JBossXmlConstants;
+import org.jboss.xb.annotations.JBossXmlType;
+
+/**
+ * Metadata for EJB3.1 MDBs
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at XmlType(name="message-driven-beanType", propOrder={"descriptionGroup", "ejbName", "mappedName", "ejbClass",
+ "transactionType", "messageSelector", "acknowledgeMode", "messageDrivenDestination", // <!-- these are ejb2.x
+ "messagingType",
+ "timeoutMethod", "timers", "transactionType", "messageDestinationType", "messageDestinationLink", "activationConfig", "aroundInvokes",
+ "environmentRefsGroup", "securityIdentity"})
+ at JBossXmlType(modelGroup=JBossXmlConstants.MODEL_GROUP_UNORDERED_SEQUENCE)
+public class MessageDrivenBean31MetaData extends MessageDrivenBeanMetaData implements ITimeoutTarget, IScheduleTarget
+{
+
+ /**
+ * Represents metadata for {@link Schedule}
+ */
+ private List<TimerMetaData> timers = new ArrayList<TimerMetaData>();
+
+ /**
+ * Returns the {@link TimerMetaData} associated with this bean
+ */
+ @Override
+ public List<TimerMetaData> getTimers()
+ {
+ return this.timers;
+ }
+
+ /**
+ * Sets the {@link TimerMetaData} for this bean
+ */
+ @Override
+ @XmlElement (name = "timer", required = false)
+ public void setTimers(List<TimerMetaData> timers)
+ {
+ this.timers = timers;
+ }
+
+ @Override
+ public void addTimer(TimerMetaData timer)
+ {
+ if (this.timers == null)
+ {
+ this.timers = new ArrayList<TimerMetaData>();
+ }
+ this.timers.add(timer);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void merge(MessageDrivenBeanMetaData override, MessageDrivenBeanMetaData original)
+ {
+ super.merge(override, original);
+
+ MessageDrivenBean31MetaData overrideMetaData = (MessageDrivenBean31MetaData) override;
+ MessageDrivenBean31MetaData originalMetaData = (MessageDrivenBean31MetaData) original;
+
+ // merge the (auto)timer metadata
+ Collection<TimerMetaData> originalTimers = original == null ? null : originalMetaData.timers;
+ Collection<TimerMetaData> overrideTimers = override == null ? null : overrideMetaData.timers;
+ if(originalTimers != null || overrideTimers != null)
+ {
+ if (this.timers == null)
+ {
+ this.timers = new ArrayList<TimerMetaData>();
+ }
+ MergeUtil.merge(this.timers, overrideTimers, originalTimers);
+ }
+
+ }
+}
Deleted: projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java 2010-10-07 06:09:21 UTC (rev 108473)
+++ projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java 2010-10-07 07:03:46 UTC (rev 108476)
@@ -1,456 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.metadata.ejb.spec;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.ConcurrencyManagementType;
-import javax.ejb.LockType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.jboss.metadata.common.ejb.IScheduleTarget;
-import org.jboss.metadata.common.ejb.ITimeoutTarget;
-import org.jboss.metadata.javaee.spec.EmptyMetaData;
-
-/**
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
- at XmlType(name = "session-beanType", propOrder =
-{"descriptionGroup", "ejbName", "mappedName", "home", "remote", "localHome", "local", "businessLocals",
- "businessRemotes", "localBean", "serviceEndpoint", "ejbClass", "sessionType", "timeoutMethod", "timers", "initOnStartup",
- "concurrencyManagementType", "concurrentMethods", "dependsOnMetaData", "initMethods", "removeMethods", "asyncMethods", "transactionType",
- "aroundInvokes", "environmentRefsGroup", "postActivates", "prePassivates", "securityRoleRefs", "securityIdentity"})
-//@JBossXmlType(modelGroup = JBossXmlConstants.MODEL_GROUP_UNORDERED_SEQUENCE)
-public class SessionBean31MetaData extends SessionBeanMetaData implements ITimeoutTarget, IScheduleTarget // FIXME: AbstractProcessor.processClass doesn't take super interfaces into account
-{
- private static final long serialVersionUID = 1L;
-
- private AsyncMethodsMetaData asyncMethods;
-
- /**
- * For <local-bean>
- */
- private EmptyMetaData localBean;
-
- /**
- * init-on-startup
- */
- private Boolean initOnStartup;
-
- /**
- * Concurrent methods against each {@link NamedMethodMetaData}
- */
- private Map<NamedMethodMetaData, ConcurrentMethodMetaData> concurrentMethods;
-
- /**
- * The lock type that is set at the bean level
- */
- private LockType beanLevelLockType;
-
- /**
- * Bean level access timeout
- */
- private AccessTimeoutMetaData beanLevelAccessTimeout;
-
- /**
- * Concurrency management type of the bean
- */
- private ConcurrencyManagementType concurrencyManagementType;
-
- /**
- * DependsOn for a singleton bean
- */
- private DependsOnMetaData dependsOn;
-
-
- /**
- * Represents the metadata for auto created timers
- */
- private List<TimerMetaData> timers;
-
- /**
- * Returns the init-on-startup value of the session bean metadata.
- * Returns null if none is defined.
- * @return
- */
- public Boolean isInitOnStartup()
- {
- return initOnStartup;
- }
-
- @XmlElement(name = "init-on-startup", required = false)
- public void setInitOnStartup(Boolean initOnStartup)
- {
- this.initOnStartup = initOnStartup;
- }
-
- public AsyncMethodsMetaData getAsyncMethods()
- {
- return asyncMethods;
- }
-
- @XmlElement(name = "async-method", required = false)
- public void setAsyncMethods(AsyncMethodsMetaData asyncMethods)
- {
- if (asyncMethods == null)
- throw new IllegalArgumentException("asyncMethods is null");
-
- this.asyncMethods = asyncMethods;
- }
-
- /**
- *
- * @return Returns {@link EmptyMetaData} if the bean represents a no-interface
- * bean. Else returns null.
- * Use the {@link #isNoInterfaceBean()} API which is more intuitive.
- *
- * @see SessionBean31MetaData#isNoInterfaceBean()
- */
- public EmptyMetaData getLocalBean()
- {
- return this.localBean;
- }
-
- /**
- * Set the metadata to represent whether this bean
- * exposes an no-interface view
- * @param isNoInterfaceBean True if the bean exposes a no-interface
- * view. Else set to false.
- */
- @XmlElement(name = "local-bean", required = false)
- public void setLocalBean(EmptyMetaData localBean)
- {
- this.localBean = localBean;
- }
-
- /**
- * @return Returns true if this bean exposes a no-interface view.
- * Else returns false. This is similar to {@link #getLocalBean()}, but
- * is more intuitive
- *
- */
- public boolean isNoInterfaceBean()
- {
- return this.localBean == null ? false : true;
- }
-
- /**
- * Sets the no-interface information in the metadata
- * @param isNoInterfaceBean True if this is a no-interface bean, false otherwise
- */
- public void setNoInterfaceBean(boolean isNoInterfaceBean)
- {
- this.localBean = isNoInterfaceBean ? new EmptyMetaData() : null;
- }
-
- /**
- * Returns true if this is a singleton session bean. Else returns false
- */
- public boolean isSingleton()
- {
- if (this.getSessionType() == null)
- return false;
- return this.getSessionType() == SessionType.Singleton;
- }
-
- /**
- * Sets the concurrency management type of this bean
- * @param concurrencyManagementType The concurrency management type
- * @throws If the passed <code>concurrencyManagementType</code> is null
- */
- @XmlElement(name = "concurrency-management-type", required = false)
- @XmlJavaTypeAdapter(ConcurrencyManagementTypeAdapter.class)
- public void setConcurrencyManagementType(ConcurrencyManagementType concurrencyManagementType)
- {
- if (concurrencyManagementType == null)
- {
- throw new IllegalArgumentException("Concurrency management type cannot be null");
- }
- this.concurrencyManagementType = concurrencyManagementType;
- }
-
- /**
- * Returns the concurrency management type of this bean
- * @return
- */
- public ConcurrencyManagementType getConcurrencyManagementType()
- {
- return this.concurrencyManagementType;
- }
-
- /**
- * Sets the concurrent methods of this bean
- * @param concurrentMethods
- * @throws IllegalArgumentException If the passed <code>concurrentMethods</code> is null
- */
- @XmlElement(name = "concurrent-method", required = false)
- @XmlJavaTypeAdapter (ConcurrentMethodsCollectionToMapAdapter.class)
- public void setConcurrentMethods(Map<NamedMethodMetaData, ConcurrentMethodMetaData> concurrentMethods)
- {
- this.concurrentMethods = concurrentMethods;
- }
-
- /**
- * Returns a {@link Map} whose key represents a {@link NamedMethodMetaData} and whose value
- * represents {@link ConcurrentMethodMetaData} of this bean. Returns an empty {@link Map} if
- * there are no concurrent methods for this bean
- * @return
- */
- public Map<NamedMethodMetaData, ConcurrentMethodMetaData> getConcurrentMethods()
- {
- if (this.concurrentMethods == null)
- {
- this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
- }
- return this.concurrentMethods;
- }
-
-
- /**
- * Sets the lock type applicable at the bean level
- * @param lockType {@link LockType}
- */
- public void setLockType(LockType lockType)
- {
- this.beanLevelLockType = lockType;
- }
-
- /**
- * Returns the lock type applicable at the bean level
- * @return
- */
- public LockType getLockType()
- {
- return this.beanLevelLockType;
- }
-
- /**
- * Sets the bean level access timeout metadata
- * @param accessTimeout {@link AccessTimeoutMetaData}
- */
- public void setAccessTimeout(AccessTimeoutMetaData accessTimeout)
- {
- this.beanLevelAccessTimeout = accessTimeout;
- }
-
- /**
- * Returns the access timeout metadata applicable at bean level
- *
- * @return
- */
- public AccessTimeoutMetaData getAccessTimeout()
- {
- return this.beanLevelAccessTimeout;
- }
-
- /**
- * Returns the names of one or more Singleton beans in the same application
- * as the referring Singleton.
- * @return
- */
- public String[] getDependsOn()
- {
- if (this.dependsOn == null || this.dependsOn.getEjbNames() == null)
- {
- return null;
- }
- List<String> ejbNames = this.dependsOn.getEjbNames();
- return ejbNames.toArray(new String[ejbNames.size()]);
- }
-
- /**
- * Sets the names of one or more singleton beans, each of which must be initialized before
- * the referring bean. Each dependent bean is expressed using ejb-link syntax.
- *
- * @param dependsOn The singleton bean dependencies
- *
- */
- public void setDependsOn(String[] dependsOn)
- {
- this.dependsOn = new DependsOnMetaData(dependsOn);
- }
-
- /**
- * Sets the names of one or more singleton beans, each of which must be initialized before
- * the referring bean. Each dependent bean is expressed using ejb-link syntax.
- *
- * @param dependsOn The singleton bean dependencies
- */
- @XmlElement(name = "depends-on", required = false)
- public void setDependsOnMetaData(DependsOnMetaData dependsOnMetaData)
- {
- this.dependsOn = dependsOnMetaData;
- }
-
-
- /**
- * Sets the names of one or more singleton beans, each of which must be initialized before
- * the referring bean. Each dependent bean is expressed using ejb-link syntax.
- *
- * @param dependsOn The singleton bean dependencies
- */
- public void setDependsOn(Collection<String> dependsOn)
- {
- if (dependsOn == null)
- {
- return;
- }
- this.setDependsOn(dependsOn.toArray(new String[dependsOn.size()]));
- }
-
- @Override
- public List<TimerMetaData> getTimers()
- {
- return this.timers;
- }
-
- @XmlElement (name = "timer", required = false)
- @Override
- public void setTimers(List<TimerMetaData> timers)
- {
- this.timers = timers;
- }
-
- @Override
- public void addTimer(TimerMetaData timer)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.add(timer);
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void merge(EnterpriseBeanMetaData eoverride, EnterpriseBeanMetaData eoriginal)
- {
- super.merge(eoverride, eoriginal);
- SessionBean31MetaData override = (SessionBean31MetaData) eoverride;
- SessionBean31MetaData original = (SessionBean31MetaData) eoriginal;
- if (asyncMethods == null)
- asyncMethods = new AsyncMethodsMetaData();
- if (override != null && override.asyncMethods != null)
- asyncMethods.addAll(override.asyncMethods);
- if (original != null && original.asyncMethods != null)
- asyncMethods.addAll(original.asyncMethods);
-
- // merge rest of the metadata
-
- if (override != null)
- {
- if (override.localBean != null)
- {
- this.localBean = override.localBean;
- }
- if (override.initOnStartup != null)
- {
- this.initOnStartup = override.initOnStartup;
- }
- if (override.concurrencyManagementType != null)
- {
- this.concurrencyManagementType = override.concurrencyManagementType;
- }
- if (override.concurrentMethods != null)
- {
- if (this.concurrentMethods == null)
- {
- this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
- }
- this.concurrentMethods.putAll(override.concurrentMethods);
- }
- if (override.beanLevelLockType != null)
- {
- this.beanLevelLockType = override.beanLevelLockType;
- }
- if (override.beanLevelAccessTimeout != null)
- {
- this.beanLevelAccessTimeout = override.beanLevelAccessTimeout;
- }
- if (override.dependsOn != null)
- {
- this.dependsOn = override.dependsOn;
- }
- if (override.timers != null)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.addAll(override.timers);
- }
- }
- else if (original != null)
- {
- if (original.localBean != null)
- {
- this.localBean = original.localBean;
- }
- if (original.initOnStartup != null)
- {
- this.initOnStartup = original.initOnStartup;
- }
- if (original.concurrencyManagementType != null)
- {
- this.concurrencyManagementType = original.concurrencyManagementType;
- }
- if (original.concurrentMethods != null)
- {
- if (this.concurrentMethods == null)
- {
- this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
- }
- this.concurrentMethods.putAll(original.concurrentMethods);
- }
- if (original.beanLevelLockType != null)
- {
- this.beanLevelLockType = original.beanLevelLockType;
- }
- if (original.beanLevelAccessTimeout != null)
- {
- this.beanLevelAccessTimeout = original.beanLevelAccessTimeout;
- }
- if (original.dependsOn != null)
- {
- this.dependsOn = original.dependsOn;
- }
- if (original.timers != null)
- {
- if (this.timers == null)
- {
- this.timers = new ArrayList<TimerMetaData>();
- }
- this.timers.addAll(original.timers);
- }
- }
- }
-}
Copied: projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java (from rev 108474, projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java)
===================================================================
--- projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java (rev 0)
+++ projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java 2010-10-07 07:03:46 UTC (rev 108476)
@@ -0,0 +1,458 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.metadata.ejb.spec;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.ConcurrencyManagementType;
+import javax.ejb.LockType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.jboss.metadata.common.ejb.IScheduleTarget;
+import org.jboss.metadata.common.ejb.ITimeoutTarget;
+import org.jboss.metadata.javaee.spec.EmptyMetaData;
+import org.jboss.metadata.merge.MergeUtil;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at XmlType(name = "session-beanType", propOrder =
+{"descriptionGroup", "ejbName", "mappedName", "home", "remote", "localHome", "local", "businessLocals",
+ "businessRemotes", "localBean", "serviceEndpoint", "ejbClass", "sessionType", "timeoutMethod", "timers", "initOnStartup",
+ "concurrencyManagementType", "concurrentMethods", "dependsOnMetaData", "initMethods", "removeMethods", "asyncMethods", "transactionType",
+ "aroundInvokes", "environmentRefsGroup", "postActivates", "prePassivates", "securityRoleRefs", "securityIdentity"})
+//@JBossXmlType(modelGroup = JBossXmlConstants.MODEL_GROUP_UNORDERED_SEQUENCE)
+public class SessionBean31MetaData extends SessionBeanMetaData implements ITimeoutTarget, IScheduleTarget // FIXME: AbstractProcessor.processClass doesn't take super interfaces into account
+{
+ private static final long serialVersionUID = 1L;
+
+ private AsyncMethodsMetaData asyncMethods;
+
+ /**
+ * For <local-bean>
+ */
+ private EmptyMetaData localBean;
+
+ /**
+ * init-on-startup
+ */
+ private Boolean initOnStartup;
+
+ /**
+ * Concurrent methods against each {@link NamedMethodMetaData}
+ */
+ private Map<NamedMethodMetaData, ConcurrentMethodMetaData> concurrentMethods;
+
+ /**
+ * The lock type that is set at the bean level
+ */
+ private LockType beanLevelLockType;
+
+ /**
+ * Bean level access timeout
+ */
+ private AccessTimeoutMetaData beanLevelAccessTimeout;
+
+ /**
+ * Concurrency management type of the bean
+ */
+ private ConcurrencyManagementType concurrencyManagementType;
+
+ /**
+ * DependsOn for a singleton bean
+ */
+ private DependsOnMetaData dependsOn;
+
+
+ /**
+ * Represents the metadata for auto created timers
+ */
+ private List<TimerMetaData> timers;
+
+ /**
+ * Returns the init-on-startup value of the session bean metadata.
+ * Returns null if none is defined.
+ * @return
+ */
+ public Boolean isInitOnStartup()
+ {
+ return initOnStartup;
+ }
+
+ @XmlElement(name = "init-on-startup", required = false)
+ public void setInitOnStartup(Boolean initOnStartup)
+ {
+ this.initOnStartup = initOnStartup;
+ }
+
+ public AsyncMethodsMetaData getAsyncMethods()
+ {
+ return asyncMethods;
+ }
+
+ @XmlElement(name = "async-method", required = false)
+ public void setAsyncMethods(AsyncMethodsMetaData asyncMethods)
+ {
+ if (asyncMethods == null)
+ throw new IllegalArgumentException("asyncMethods is null");
+
+ this.asyncMethods = asyncMethods;
+ }
+
+ /**
+ *
+ * @return Returns {@link EmptyMetaData} if the bean represents a no-interface
+ * bean. Else returns null.
+ * Use the {@link #isNoInterfaceBean()} API which is more intuitive.
+ *
+ * @see SessionBean31MetaData#isNoInterfaceBean()
+ */
+ public EmptyMetaData getLocalBean()
+ {
+ return this.localBean;
+ }
+
+ /**
+ * Set the metadata to represent whether this bean
+ * exposes an no-interface view
+ * @param isNoInterfaceBean True if the bean exposes a no-interface
+ * view. Else set to false.
+ */
+ @XmlElement(name = "local-bean", required = false)
+ public void setLocalBean(EmptyMetaData localBean)
+ {
+ this.localBean = localBean;
+ }
+
+ /**
+ * @return Returns true if this bean exposes a no-interface view.
+ * Else returns false. This is similar to {@link #getLocalBean()}, but
+ * is more intuitive
+ *
+ */
+ public boolean isNoInterfaceBean()
+ {
+ return this.localBean == null ? false : true;
+ }
+
+ /**
+ * Sets the no-interface information in the metadata
+ * @param isNoInterfaceBean True if this is a no-interface bean, false otherwise
+ */
+ public void setNoInterfaceBean(boolean isNoInterfaceBean)
+ {
+ this.localBean = isNoInterfaceBean ? new EmptyMetaData() : null;
+ }
+
+ /**
+ * Returns true if this is a singleton session bean. Else returns false
+ */
+ public boolean isSingleton()
+ {
+ if (this.getSessionType() == null)
+ return false;
+ return this.getSessionType() == SessionType.Singleton;
+ }
+
+ /**
+ * Sets the concurrency management type of this bean
+ * @param concurrencyManagementType The concurrency management type
+ * @throws If the passed <code>concurrencyManagementType</code> is null
+ */
+ @XmlElement(name = "concurrency-management-type", required = false)
+ @XmlJavaTypeAdapter(ConcurrencyManagementTypeAdapter.class)
+ public void setConcurrencyManagementType(ConcurrencyManagementType concurrencyManagementType)
+ {
+ if (concurrencyManagementType == null)
+ {
+ throw new IllegalArgumentException("Concurrency management type cannot be null");
+ }
+ this.concurrencyManagementType = concurrencyManagementType;
+ }
+
+ /**
+ * Returns the concurrency management type of this bean
+ * @return
+ */
+ public ConcurrencyManagementType getConcurrencyManagementType()
+ {
+ return this.concurrencyManagementType;
+ }
+
+ /**
+ * Sets the concurrent methods of this bean
+ * @param concurrentMethods
+ * @throws IllegalArgumentException If the passed <code>concurrentMethods</code> is null
+ */
+ @XmlElement(name = "concurrent-method", required = false)
+ @XmlJavaTypeAdapter (ConcurrentMethodsCollectionToMapAdapter.class)
+ public void setConcurrentMethods(Map<NamedMethodMetaData, ConcurrentMethodMetaData> concurrentMethods)
+ {
+ this.concurrentMethods = concurrentMethods;
+ }
+
+ /**
+ * Returns a {@link Map} whose key represents a {@link NamedMethodMetaData} and whose value
+ * represents {@link ConcurrentMethodMetaData} of this bean. Returns an empty {@link Map} if
+ * there are no concurrent methods for this bean
+ * @return
+ */
+ public Map<NamedMethodMetaData, ConcurrentMethodMetaData> getConcurrentMethods()
+ {
+ if (this.concurrentMethods == null)
+ {
+ this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
+ }
+ return this.concurrentMethods;
+ }
+
+
+ /**
+ * Sets the lock type applicable at the bean level
+ * @param lockType {@link LockType}
+ */
+ public void setLockType(LockType lockType)
+ {
+ this.beanLevelLockType = lockType;
+ }
+
+ /**
+ * Returns the lock type applicable at the bean level
+ * @return
+ */
+ public LockType getLockType()
+ {
+ return this.beanLevelLockType;
+ }
+
+ /**
+ * Sets the bean level access timeout metadata
+ * @param accessTimeout {@link AccessTimeoutMetaData}
+ */
+ public void setAccessTimeout(AccessTimeoutMetaData accessTimeout)
+ {
+ this.beanLevelAccessTimeout = accessTimeout;
+ }
+
+ /**
+ * Returns the access timeout metadata applicable at bean level
+ *
+ * @return
+ */
+ public AccessTimeoutMetaData getAccessTimeout()
+ {
+ return this.beanLevelAccessTimeout;
+ }
+
+ /**
+ * Returns the names of one or more Singleton beans in the same application
+ * as the referring Singleton.
+ * @return
+ */
+ public String[] getDependsOn()
+ {
+ if (this.dependsOn == null || this.dependsOn.getEjbNames() == null)
+ {
+ return null;
+ }
+ List<String> ejbNames = this.dependsOn.getEjbNames();
+ return ejbNames.toArray(new String[ejbNames.size()]);
+ }
+
+ /**
+ * Sets the names of one or more singleton beans, each of which must be initialized before
+ * the referring bean. Each dependent bean is expressed using ejb-link syntax.
+ *
+ * @param dependsOn The singleton bean dependencies
+ *
+ */
+ public void setDependsOn(String[] dependsOn)
+ {
+ this.dependsOn = new DependsOnMetaData(dependsOn);
+ }
+
+ /**
+ * Sets the names of one or more singleton beans, each of which must be initialized before
+ * the referring bean. Each dependent bean is expressed using ejb-link syntax.
+ *
+ * @param dependsOn The singleton bean dependencies
+ */
+ @XmlElement(name = "depends-on", required = false)
+ public void setDependsOnMetaData(DependsOnMetaData dependsOnMetaData)
+ {
+ this.dependsOn = dependsOnMetaData;
+ }
+
+
+ /**
+ * Sets the names of one or more singleton beans, each of which must be initialized before
+ * the referring bean. Each dependent bean is expressed using ejb-link syntax.
+ *
+ * @param dependsOn The singleton bean dependencies
+ */
+ public void setDependsOn(Collection<String> dependsOn)
+ {
+ if (dependsOn == null)
+ {
+ return;
+ }
+ this.setDependsOn(dependsOn.toArray(new String[dependsOn.size()]));
+ }
+
+ @Override
+ public List<TimerMetaData> getTimers()
+ {
+ return this.timers;
+ }
+
+ @XmlElement (name = "timer", required = false)
+ @Override
+ public void setTimers(List<TimerMetaData> timers)
+ {
+ this.timers = timers;
+ }
+
+ @Override
+ public void addTimer(TimerMetaData timer)
+ {
+ if (this.timers == null)
+ {
+ this.timers = new ArrayList<TimerMetaData>();
+ }
+ this.timers.add(timer);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void merge(EnterpriseBeanMetaData eoverride, EnterpriseBeanMetaData eoriginal)
+ {
+ super.merge(eoverride, eoriginal);
+ SessionBean31MetaData override = (SessionBean31MetaData) eoverride;
+ SessionBean31MetaData original = (SessionBean31MetaData) eoriginal;
+ if (asyncMethods == null)
+ asyncMethods = new AsyncMethodsMetaData();
+ if (override != null && override.asyncMethods != null)
+ asyncMethods.addAll(override.asyncMethods);
+ if (original != null && original.asyncMethods != null)
+ asyncMethods.addAll(original.asyncMethods);
+
+ // merge rest of the metadata
+
+ if (override != null)
+ {
+ if (override.localBean != null)
+ {
+ this.localBean = override.localBean;
+ }
+ if (override.initOnStartup != null)
+ {
+ this.initOnStartup = override.initOnStartup;
+ }
+ if (override.concurrencyManagementType != null)
+ {
+ this.concurrencyManagementType = override.concurrencyManagementType;
+ }
+ if (override.concurrentMethods != null)
+ {
+ if (this.concurrentMethods == null)
+ {
+ this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
+ }
+ this.concurrentMethods.putAll(override.concurrentMethods);
+ }
+ if (override.beanLevelLockType != null)
+ {
+ this.beanLevelLockType = override.beanLevelLockType;
+ }
+ if (override.beanLevelAccessTimeout != null)
+ {
+ this.beanLevelAccessTimeout = override.beanLevelAccessTimeout;
+ }
+ if (override.dependsOn != null)
+ {
+ this.dependsOn = override.dependsOn;
+ }
+ }
+ else if (original != null)
+ {
+ if (original.localBean != null)
+ {
+ this.localBean = original.localBean;
+ }
+ if (original.initOnStartup != null)
+ {
+ this.initOnStartup = original.initOnStartup;
+ }
+ if (original.concurrencyManagementType != null)
+ {
+ this.concurrencyManagementType = original.concurrencyManagementType;
+ }
+ if (original.concurrentMethods != null)
+ {
+ if (this.concurrentMethods == null)
+ {
+ this.concurrentMethods = new HashMap<NamedMethodMetaData, ConcurrentMethodMetaData>();
+ }
+ this.concurrentMethods.putAll(original.concurrentMethods);
+ }
+ if (original.beanLevelLockType != null)
+ {
+ this.beanLevelLockType = original.beanLevelLockType;
+ }
+ if (original.beanLevelAccessTimeout != null)
+ {
+ this.beanLevelAccessTimeout = original.beanLevelAccessTimeout;
+ }
+ if (original.dependsOn != null)
+ {
+ this.dependsOn = original.dependsOn;
+ }
+ }
+ // merge timers
+ this.mergeTimers(override, original);
+ }
+
+ private void mergeTimers(SessionBean31MetaData override, SessionBean31MetaData original)
+ {
+ // merge the (auto)timer metadata
+ Collection<TimerMetaData> originalTimers = original == null ? null : original.timers;
+ Collection<TimerMetaData> overrideTimers = override == null ? null : override.timers;
+ if(originalTimers != null || overrideTimers != null)
+ {
+ if (this.timers == null)
+ {
+ this.timers = new ArrayList<TimerMetaData>();
+ }
+ MergeUtil.merge(this.timers, overrideTimers, originalTimers);
+ }
+ }
+}
Deleted: projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/test/java/org/jboss/metadata/ejb/test/schedule/unit/ScheduleTestCase.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/unit/ScheduleTestCase.java 2010-10-07 06:09:21 UTC (rev 108473)
+++ projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/test/java/org/jboss/metadata/ejb/test/schedule/unit/ScheduleTestCase.java 2010-10-07 07:03:46 UTC (rev 108476)
@@ -1,898 +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.metadata.ejb.test.schedule.unit;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.lang.reflect.AnnotatedElement;
-import java.net.URL;
-import java.util.Collection;
-import java.util.List;
-
-import javax.ejb.Schedule;
-import javax.ejb.Schedules;
-import javax.ejb.Timer;
-
-import junit.framework.Assert;
-
-import org.jboss.logging.Logger;
-import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBean31MetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
-import org.jboss.metadata.ejb.spec.EjbJar31MetaData;
-import org.jboss.metadata.ejb.spec.EjbJarMetaData;
-import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.spec.MessageDrivenBean31MetaData;
-import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
-import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
-import org.jboss.metadata.ejb.spec.ScheduleMetaData;
-import org.jboss.metadata.ejb.spec.SessionBean31MetaData;
-import org.jboss.metadata.ejb.spec.TimerMetaData;
-import org.jboss.metadata.ejb.test.schedule.MDBWithMultipleSchedules;
-import org.jboss.metadata.ejb.test.schedule.MDBWithSchedule;
-import org.jboss.metadata.ejb.test.schedule.SLSBWithMultipleSchedules;
-import org.jboss.metadata.ejb.test.schedule.SimpleSLSBWithSchedule;
-import org.jboss.metadata.ejb.test.schedule.SingletonWithMultipleSchedules;
-import org.jboss.metadata.ejb.test.schedule.SingletonWithSchedule;
-import org.jboss.test.metadata.common.PackageScanner;
-import org.jboss.test.metadata.common.ScanPackage;
-import org.jboss.xb.binding.JBossXBException;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.resolver.MultiClassSchemaResolver;
-import org.jboss.xb.binding.resolver.MutableSchemaResolver;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Tests that the processing of {@link Schedule} and {@link Schedules} annotations and their
- * xml equivalents on beans is processed correctly, for metadata.
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class ScheduleTestCase
-{
-
- private static Logger logger = Logger.getLogger(ScheduleTestCase.class);
-
- private static MutableSchemaResolver schemaBindingResolver;
-
- private static UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
-
- @BeforeClass
- public static void beforeClass()
- {
- schemaBindingResolver = new MultiClassSchemaResolver();
- schemaBindingResolver.mapLocationToClass("ejb-jar_3_1.xsd", EjbJar31MetaData.class);
- }
-
- /**
- * Tests that a SLSB annotated with {@link Schedule} is processed correctly for metadata
- *
- */
- @Test
- @ScanPackage("org.jboss.metadata.ejb.test.schedule")
- public void testSLSBWithSchedule()
- {
-
- AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
- JBoss50Creator creator = new JBoss50Creator(finder);
- Collection<Class<?>> classes = PackageScanner.loadClasses();
- JBossMetaData metaData = creator.create(classes);
- assertNotNull("Metadata not created", metaData);
-
- // get hold of the bean
- JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(SimpleSLSBWithSchedule.class
- .getSimpleName());
- assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossSessionBean31MetaData.class,
- (enterpriseBean instanceof JBossSessionBean31MetaData));
- JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBean;
-
- // get the timers
- List<TimerMetaData> timers = sessionBean.getTimers();
-
- // check the metadata for validity
- Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
- Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 1, timers.size());
-
- TimerMetaData timerMetaData = timers.get(0);
- Assert.assertTrue("Info object was expected to be empty", timerMetaData.getInfo().isEmpty());
- Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
-
- // get hold of the schedule and validate it
- ScheduleMetaData schedule = timerMetaData.getSchedule();
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
-
- // test the timeout method
- NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
- Assert.assertNotNull("Timeout method is null", timeoutMethod);
- Assert.assertEquals("Unexpected timeout method", "schedule", timeoutMethod.getMethodName());
- MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
- Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
- Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
- String timeoutMethodParam = timeoutMethodParams.get(0);
- Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
-
- }
-
- /**
- * Tests that a MDB marked with {@link Schedule} is processed correctly for metadata
- */
- @Test
- @ScanPackage("org.jboss.metadata.ejb.test.schedule")
- public void testScheduleOnMDB()
- {
- AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
- JBoss50Creator creator = new JBoss50Creator(finder);
- Collection<Class<?>> classes = PackageScanner.loadClasses();
- JBossMetaData metaData = creator.create(classes);
- assertNotNull("Metadata not created", metaData);
-
- // get hold of the bean
- JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(MDBWithSchedule.class.getSimpleName());
- assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossMessageDrivenBean31MetaData.class,
- (enterpriseBean instanceof JBossMessageDrivenBean31MetaData));
- JBossMessageDrivenBean31MetaData mdb = (JBossMessageDrivenBean31MetaData) enterpriseBean;
-
- // get the timers
- List<TimerMetaData> timers = mdb.getTimers();
-
- // check the metadata for validity
- Assert.assertNotNull("Timer metadata not found on bean " + mdb.getName(), timers);
- Assert.assertEquals("Unexpected number of timers found on bean " + mdb.getName(), 1, timers.size());
-
- TimerMetaData timerMetaData = timers.get(0);
- Assert.assertTrue("Info object was expected to be empty", timerMetaData.getInfo().isEmpty());
- Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
-
- // get hold of the schedule and validate it
- ScheduleMetaData schedule = timerMetaData.getSchedule();
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "*", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "1", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
-
- // test the timeout method
- NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
- Assert.assertNotNull("Timeout method is null", timeoutMethod);
- Assert.assertEquals("Unexpected timeout method", "someMethod", timeoutMethod.getMethodName());
- MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
- Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
- Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
- String timeoutMethodParam = timeoutMethodParams.get(0);
- Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
-
- }
-
- /**
- * Tests that a Singleton bean which has a method marked with {@link Schedule} is
- * processed correctly for metadata
- */
- @Test
- @ScanPackage("org.jboss.metadata.ejb.test.schedule")
- public void testScheduleOnSingleton()
- {
- AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
- JBoss50Creator creator = new JBoss50Creator(finder);
- Collection<Class<?>> classes = PackageScanner.loadClasses();
- JBossMetaData metaData = creator.create(classes);
- assertNotNull("Metadata not created", metaData);
-
- // get hold of the bean
- JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(SingletonWithSchedule.class
- .getSimpleName());
- assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossSessionBean31MetaData.class,
- (enterpriseBean instanceof JBossSessionBean31MetaData));
- JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBean;
- Assert.assertTrue(sessionBean.getName() + " is not a singleton", sessionBean.isSingleton());
-
- // get the timers
- List<TimerMetaData> timers = sessionBean.getTimers();
-
- // check the metadata for validity
- Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
- Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 1, timers.size());
-
- TimerMetaData timerMetaData = timers.get(0);
- Assert.assertEquals("Unexpected info on timer metadata", SingletonWithSchedule.INFO_FOR_SCHEDULE, timerMetaData
- .getInfo());
- Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
- Assert.assertEquals("Unexpected timezone on timer metadata", "IST", timerMetaData.getTimezone());
-
- // get hold of the schedule and validate it
- ScheduleMetaData schedule = timerMetaData.getSchedule();
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "10", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "12", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
-
- // test the timeout method
- NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
- Assert.assertNotNull("Timeout method is null", timeoutMethod);
- Assert.assertEquals("Unexpected timeout method", "scheduleTimeout", timeoutMethod.getMethodName());
- MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
- Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
- Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
- String timeoutMethodParam = timeoutMethodParams.get(0);
- Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
- }
-
- /**
- * Tests that a SLSB configured for timer through ejb-jar.xml is processed correctly for metadata
- */
- @Test
- public void testScheduleForSLSBInEjbJarXml() throws Exception
- {
- EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class, "/org/jboss/metadata/ejb/test/schedule/ejb-jar.xml");
- assertNotNull(jarMetaData);
-
- EnterpriseBeanMetaData enterpriseBean = jarMetaData.getEnterpriseBean("SLSBInEjbJarXml");
- assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + SessionBean31MetaData.class,
- (enterpriseBean instanceof SessionBean31MetaData));
- SessionBean31MetaData sessionBean = (SessionBean31MetaData) enterpriseBean;
-
- // get the timers
- List<TimerMetaData> timers = sessionBean.getTimers();
-
- // check the metadata for validity
- Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
- Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 1, timers.size());
-
- TimerMetaData timerMetaData = timers.get(0);
- Assert.assertNull("Unexpected info on timer metadata", timerMetaData.getInfo());
- Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
-
- // get hold of the schedule and validate it
- ScheduleMetaData schedule = timerMetaData.getSchedule();
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "Wed", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
-
- // test the timeout method
- NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
- Assert.assertNotNull("Timeout method is null", timeoutMethod);
- Assert.assertEquals("Unexpected timeout method", "dummySLSBMethod", timeoutMethod.getMethodName());
- MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
- Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
- Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
- String timeoutMethodParam = timeoutMethodParams.get(0);
- Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
-
- }
-
- /**
- * Tests that a MDB configured for timer through ejb-jar.xml is processed correctly for metadata
- */
- @Test
- public void testScheduleForMDBInEjbJarXml() throws Exception
- {
- EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class, "/org/jboss/metadata/ejb/test/schedule/ejb-jar.xml");
- assertNotNull(jarMetaData);
-
- EnterpriseBeanMetaData enterpriseBean = jarMetaData.getEnterpriseBean("MDBInEjbJarXml");
- assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + MessageDrivenBean31MetaData.class,
- (enterpriseBean instanceof MessageDrivenBean31MetaData));
- MessageDrivenBean31MetaData mdb = (MessageDrivenBean31MetaData) enterpriseBean;
-
- // get the timers
- List<TimerMetaData> timers = mdb.getTimers();
-
- // check the metadata for validity
- Assert.assertNotNull("Timer metadata not found on bean " + mdb.getName(), timers);
- Assert.assertEquals("Unexpected number of timers found on bean " + mdb.getName(), 1, timers.size());
-
- TimerMetaData timerMetaData = timers.get(0);
- Assert.assertEquals("Unexpected info on timer metadata", "SomeInfoInXml", timerMetaData.getInfo());
- Assert.assertFalse("Timer was expected to be persistent", timerMetaData.isPersistent());
-
- // get hold of the schedule and validate it
- ScheduleMetaData schedule = timerMetaData.getSchedule();
- Assert.assertEquals("Unexpected seconds in schedule", "5", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "4", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "3", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "2", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "1", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "Jan", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
-
- // test the timeout method
- NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
- Assert.assertNotNull("Timeout method is null", timeoutMethod);
- Assert.assertEquals("Unexpected timeout method", "dummyMDBMethod", timeoutMethod.getMethodName());
- MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
- Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
- Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
- String timeoutMethodParam = timeoutMethodParams.get(0);
- Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
-
- }
-
- /**
- * Tests that a Singleton bean configured for timer through ejb-jar.xml is processed correctly for metadata
- */
- @Test
- public void testScheduleForSingletonInEjbJarXml() throws Exception
- {
- EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class, "/org/jboss/metadata/ejb/test/schedule/ejb-jar.xml");
- assertNotNull(jarMetaData);
-
- EnterpriseBeanMetaData enterpriseBean = jarMetaData.getEnterpriseBean("SingletonInEjbJarXml");
- assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + SessionBean31MetaData.class,
- (enterpriseBean instanceof SessionBean31MetaData));
- SessionBean31MetaData sessionBean = (SessionBean31MetaData) enterpriseBean;
- Assert.assertTrue(sessionBean.getName() + " was not considered a singleton bean", sessionBean.isSingleton());
-
- // get the timers
- List<TimerMetaData> timers = sessionBean.getTimers();
-
- // check the metadata for validity
- Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
- Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 1, timers.size());
-
- TimerMetaData timerMetaData = timers.get(0);
- Assert.assertNull("Unexpected info on timer metadata", timerMetaData.getInfo());
- Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
-
- // get hold of the schedule and validate it
- ScheduleMetaData schedule = timerMetaData.getSchedule();
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "2009", schedule.getYear());
-
- // test the timeout method
- NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
- Assert.assertNotNull("Timeout method is null", timeoutMethod);
- Assert.assertEquals("Unexpected timeout method", "dummySingletonMethod", timeoutMethod.getMethodName());
- MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
- Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
- Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
- String timeoutMethodParam = timeoutMethodParams.get(0);
- Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
-
- }
-
- /**
- * Tests that a Singleton bean which has methods marked with {@link Schedules} is
- * processed correctly for metadata
- */
- @Test
- @ScanPackage("org.jboss.metadata.ejb.test.schedule")
- public void testMultipleSchedulesOnSingleton()
- {
- AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
- JBoss50Creator creator = new JBoss50Creator(finder);
- Collection<Class<?>> classes = PackageScanner.loadClasses();
- JBossMetaData metaData = creator.create(classes);
- assertNotNull("Metadata not created", metaData);
-
- // get hold of the bean
- JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(SingletonWithMultipleSchedules.class
- .getSimpleName());
- assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossSessionBean31MetaData.class,
- (enterpriseBean instanceof JBossSessionBean31MetaData));
- JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBean;
- Assert.assertTrue(sessionBean.getName() + " is not a singleton", sessionBean.isSingleton());
-
- // get the timers
- List<TimerMetaData> timers = sessionBean.getTimers();
-
- // check the metadata for validity
- Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
- Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 4, timers.size());
-
- for (int i = 0; i < timers.size(); i++)
- {
- TimerMetaData timerMetaData = timers.get(i);
- String info = timerMetaData.getInfo();
- Assert.assertNotNull("Info not present on timer metadata", timerMetaData.getInfo());
-
- int infoVal = Integer.parseInt(info);
-
- NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
- Assert.assertNotNull("Timeout method not present on timer metadata", timeoutMethod);
- MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
- Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
- Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
- String timeoutMethodParam = timeoutMethodParams.get(0);
- Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
-
- String timeoutMethodName = timeoutMethod.getMethodName();
- ScheduleMetaData schedule = timerMetaData.getSchedule();
- switch (infoVal)
- {
- case 1 :
- Assert.assertEquals("Unexpected timeout method", "schedule", timeoutMethodName);
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
- Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
- Assert.assertEquals("Unexpected timezone on timer metadata", "CET", timerMetaData.getTimezone());
- break;
- case 2 :
- Assert.assertEquals("Unexpected timeout method", "schedule", timeoutMethodName);
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
- Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
-
- break;
- case 3 :
- Assert.assertEquals("Unexpected timeout method", "schedule", timeoutMethodName);
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "24", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
- Assert.assertFalse("Timer was *not* expected to be persistent", timerMetaData.isPersistent());
-
- break;
- case 4 :
- Assert.assertEquals("Unexpected timeout method", "anotherSchedule", timeoutMethodName);
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "*", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
- break;
- default :
- Assert.fail("Unexpected info " + info + " on timer metadata");
- }
- }
-
- }
-
- /**
- * Tests that a SLSB which has methods marked with {@link Schedules} is
- * processed correctly for metadata
- */
- @Test
- @ScanPackage("org.jboss.metadata.ejb.test.schedule")
- public void testMultipleSchedulesOnSLSB()
- {
- AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
- JBoss50Creator creator = new JBoss50Creator(finder);
- Collection<Class<?>> classes = PackageScanner.loadClasses();
- JBossMetaData metaData = creator.create(classes);
- assertNotNull("Metadata not created", metaData);
-
- // get hold of the bean
- JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(SLSBWithMultipleSchedules.class
- .getSimpleName());
- assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossSessionBean31MetaData.class,
- (enterpriseBean instanceof JBossSessionBean31MetaData));
- JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBean;
-
- // get the timers
- List<TimerMetaData> timers = sessionBean.getTimers();
-
- // check the metadata for validity
- Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
- Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 2, timers.size());
-
- for (int i = 0; i < timers.size(); i++)
- {
- TimerMetaData timerMetaData = timers.get(i);
- String info = timerMetaData.getInfo();
- Assert.assertNotNull("Info not present on timer metadata", timerMetaData.getInfo());
-
- int infoVal = Integer.parseInt(info);
-
- NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
- Assert.assertNotNull("Timeout method not present on timer metadata", timeoutMethod);
- MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
- Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
- Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
- String timeoutMethodParam = timeoutMethodParams.get(0);
- Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
-
- String timeoutMethodName = timeoutMethod.getMethodName();
- ScheduleMetaData schedule = timerMetaData.getSchedule();
- switch (infoVal)
- {
- case 1 :
- Assert.assertEquals("Unexpected timeout method", "schedule", timeoutMethodName);
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
- Assert.assertFalse("Timer was *not* expected to be persistent", timerMetaData.isPersistent());
- break;
- case 2 :
- Assert.assertEquals("Unexpected timeout method", "schedule", timeoutMethodName);
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
- Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
- Assert.assertEquals("Unexpected timezone on timer metadata", "IST", timerMetaData.getTimezone());
- break;
- default :
- Assert.fail("Unexpected info " + info + " on timer metadata");
- }
- }
-
- }
-
- /**
- * Tests that a MDB which has methods marked with {@link Schedules} is
- * processed correctly for metadata
- */
- @Test
- @ScanPackage("org.jboss.metadata.ejb.test.schedule")
- public void testMultipleSchedulesOnMDB()
- {
- AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
- JBoss50Creator creator = new JBoss50Creator(finder);
- Collection<Class<?>> classes = PackageScanner.loadClasses();
- JBossMetaData metaData = creator.create(classes);
- assertNotNull("Metadata not created", metaData);
-
- // get hold of the bean
- JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(MDBWithMultipleSchedules.class
- .getSimpleName());
- assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossMessageDrivenBean31MetaData.class,
- (enterpriseBean instanceof JBossMessageDrivenBean31MetaData));
- JBossMessageDrivenBean31MetaData mdb = (JBossMessageDrivenBean31MetaData) enterpriseBean;
-
- // get the timers
- List<TimerMetaData> timers = mdb.getTimers();
-
- // check the metadata for validity
- Assert.assertNotNull("Timer metadata not found on bean " + mdb.getName(), timers);
- Assert.assertEquals("Unexpected number of timers found on bean " + mdb.getName(), 2, timers.size());
-
- for (int i = 0; i < timers.size(); i++)
- {
- TimerMetaData timerMetaData = timers.get(i);
- String info = timerMetaData.getInfo();
- Assert.assertNotNull("Info not present on timer metadata", timerMetaData.getInfo());
-
- int infoVal = Integer.parseInt(info);
-
- NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
- Assert.assertNotNull("Timeout method not present on timer metadata", timeoutMethod);
- MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
- Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
- Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
- String timeoutMethodParam = timeoutMethodParams.get(0);
- Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
-
- String timeoutMethodName = timeoutMethod.getMethodName();
- ScheduleMetaData schedule = timerMetaData.getSchedule();
- switch (infoVal)
- {
- case 1 :
- Assert.assertEquals("Unexpected timeout method", "someMethod", timeoutMethodName);
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "*", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "1", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
- Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
- break;
- case 2 :
- Assert.assertEquals("Unexpected timeout method", "someMethod", timeoutMethodName);
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "*", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
- Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
- break;
- default :
- Assert.fail("Unexpected info " + info + " on timer metadata");
- }
- }
-
- }
-
- /**
- * Tests that a Singleton bean which has methods marked as auto timeout methods in ejb-jar.xml
- * is processed correctly for metadata
- */
- @Test
- public void testMultipleSchedulesOnSingletonInEjbJarXML() throws Exception
- {
- EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class,
- "/org/jboss/metadata/ejb/test/schedule/ejb-jar-with-multiple-schedules.xml");
- assertNotNull(jarMetaData);
-
- EnterpriseBeanMetaData enterpriseBean = jarMetaData
- .getEnterpriseBean("SingletonWithMultipleSchedulesInEjbJarXml");
- assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + SessionBean31MetaData.class,
- (enterpriseBean instanceof SessionBean31MetaData));
- SessionBean31MetaData sessionBean = (SessionBean31MetaData) enterpriseBean;
- Assert.assertTrue(sessionBean.getName() + " was not considered a singleton bean", sessionBean.isSingleton());
-
- // get the timers
- List<TimerMetaData> timers = sessionBean.getTimers();
-
- // check the metadata for validity
- Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
- Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 2, timers.size());
-
- for (int i = 0; i < timers.size(); i++)
- {
- TimerMetaData timerMetaData = timers.get(i);
- String info = timerMetaData.getInfo();
- Assert.assertNotNull("Info not present on timer metadata", timerMetaData.getInfo());
-
- int infoVal = Integer.parseInt(info);
-
- NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
- Assert.assertNotNull("Timeout method not present on timer metadata", timeoutMethod);
- MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
- Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
- Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
- String timeoutMethodParam = timeoutMethodParams.get(0);
- Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
-
- String timeoutMethodName = timeoutMethod.getMethodName();
- ScheduleMetaData schedule = timerMetaData.getSchedule();
- switch (infoVal)
- {
- case 1 :
- Assert.assertEquals("Unexpected timeout method", "dummySingletonMethod", timeoutMethodName);
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
- Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
- break;
- case 2 :
- Assert.assertEquals("Unexpected timeout method", "dummySingletonMethod", timeoutMethodName);
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "2010", schedule.getYear());
- Assert.assertFalse("Timer was *not* expected to be persistent", timerMetaData.isPersistent());
-
- break;
-
- default :
- Assert.fail("Unexpected info " + info + " on timer metadata");
- }
- }
-
- }
-
- /**
- * Tests that a MDB which has methods marked as auto timeout methods in ejb-jar.xml
- * is processed correctly for metadata
- */
- @Test
- public void testMultipleSchedulesOnMDBInEjbJarXML() throws Exception
- {
- EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class,
- "/org/jboss/metadata/ejb/test/schedule/ejb-jar-with-multiple-schedules.xml");
- assertNotNull(jarMetaData);
-
- EnterpriseBeanMetaData enterpriseBean = jarMetaData
- .getEnterpriseBean("MDBWithMultipleSchedulesInEjbJarXml");
- assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + MessageDrivenBean31MetaData.class,
- (enterpriseBean instanceof MessageDrivenBean31MetaData));
- MessageDrivenBean31MetaData mdb = (MessageDrivenBean31MetaData) enterpriseBean;
-
- // get the timers
- List<TimerMetaData> timers = mdb.getTimers();
-
- // check the metadata for validity
- Assert.assertNotNull("Timer metadata not found on bean " + mdb.getName(), timers);
- Assert.assertEquals("Unexpected number of timers found on bean " + mdb.getName(), 2, timers.size());
-
- for (int i = 0; i < timers.size(); i++)
- {
- TimerMetaData timerMetaData = timers.get(i);
- String info = timerMetaData.getInfo();
- Assert.assertNotNull("Info not present on timer metadata", timerMetaData.getInfo());
-
- int infoVal = Integer.parseInt(info);
-
- NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
- Assert.assertNotNull("Timeout method not present on timer metadata", timeoutMethod);
- MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
- Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
- Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
- String timeoutMethodParam = timeoutMethodParams.get(0);
- Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
-
- String timeoutMethodName = timeoutMethod.getMethodName();
- ScheduleMetaData schedule = timerMetaData.getSchedule();
- switch (infoVal)
- {
- case 1 :
- Assert.assertEquals("Unexpected timeout method", "dummyMDBMethod", timeoutMethodName);
- Assert.assertEquals("Unexpected seconds in schedule", "5", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "4", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "3", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "2", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "1", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "Mar", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
- Assert.assertFalse("Timer was *not* expected to be persistent", timerMetaData.isPersistent());
- break;
- case 2 :
- Assert.assertEquals("Unexpected timeout method", "dummyMDBMethod", timeoutMethodName);
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
- Assert.assertFalse("Timer was *not* expected to be persistent", timerMetaData.isPersistent());
- Assert.assertEquals("Unexpected timezone on timer metadata", "CET", timerMetaData.getTimezone());
- break;
-
- default :
- Assert.fail("Unexpected info " + info + " on timer metadata");
- }
- }
-
- }
-
- /**
- * Tests that a SLSB which has methods marked as auto timeout methods in ejb-jar.xml
- * is processed correctly for metadata
- */
- @Test
- public void testMultipleSchedulesOnSLSBInEjbJarXML() throws Exception
- {
- EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class,
- "/org/jboss/metadata/ejb/test/schedule/ejb-jar-with-multiple-schedules.xml");
- assertNotNull(jarMetaData);
-
- EnterpriseBeanMetaData enterpriseBean = jarMetaData.getEnterpriseBean("MultipleScheduleSLSBInEjbJarXML");
- assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + SessionBean31MetaData.class,
- (enterpriseBean instanceof SessionBean31MetaData));
- SessionBean31MetaData sessionBean = (SessionBean31MetaData) enterpriseBean;
-
- // get the timers
- List<TimerMetaData> timers = sessionBean.getTimers();
-
- // check the metadata for validity
- Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
- Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 2, timers.size());
-
- for (int i = 0; i < timers.size(); i++)
- {
- TimerMetaData timerMetaData = timers.get(i);
- String info = timerMetaData.getInfo();
- Assert.assertNotNull("Info not present on timer metadata", timerMetaData.getInfo());
-
- int infoVal = Integer.parseInt(info);
-
- NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
- Assert.assertNotNull("Timeout method not present on timer metadata", timeoutMethod);
- MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
- Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
- Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
- String timeoutMethodParam = timeoutMethodParams.get(0);
- Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
-
- String timeoutMethodName = timeoutMethod.getMethodName();
- ScheduleMetaData schedule = timerMetaData.getSchedule();
- switch (infoVal)
- {
- case 1 :
- Assert.assertEquals("Unexpected timeout method", "dummySLSBMethod", timeoutMethodName);
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "Wed", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "1", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
- Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
- break;
- case 2 :
- Assert.assertEquals("Unexpected timeout method", "anotherDummyMethod", timeoutMethodName);
- Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
- Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
- Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
- Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
- Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
- Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
- Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
- Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
-
- break;
-
- default :
- Assert.fail("Unexpected info " + info + " on timer metadata");
- }
- }
-
- }
-
- /**
- * Utility method
- * @param <T>
- * @param type
- * @param resource
- * @return
- * @throws JBossXBException
- */
- private static <T> T unmarshal(Class<T> type, String resource) throws JBossXBException
- {
- Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
- unmarshaller.setValidation(false);
- URL url = type.getResource(resource);
- if (url == null)
- throw new IllegalArgumentException("Failed to find resource " + resource);
- return type.cast(unmarshaller.unmarshal(url.toString(), schemaBindingResolver));
- }
-}
Copied: projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/test/java/org/jboss/metadata/ejb/test/schedule/unit/ScheduleTestCase.java (from rev 108474, projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/unit/ScheduleTestCase.java)
===================================================================
--- projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/test/java/org/jboss/metadata/ejb/test/schedule/unit/ScheduleTestCase.java (rev 0)
+++ projects/metadata/ejb/tags/jboss-metadata-ejb-2.0.0-alpha-19/src/test/java/org/jboss/metadata/ejb/test/schedule/unit/ScheduleTestCase.java 2010-10-07 07:03:46 UTC (rev 108476)
@@ -0,0 +1,1097 @@
+/*
+ * 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.metadata.ejb.test.schedule.unit;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.AnnotatedElement;
+import java.net.URL;
+import java.util.Collection;
+import java.util.List;
+
+import javax.ejb.Schedule;
+import javax.ejb.Schedules;
+import javax.ejb.Timer;
+
+import junit.framework.Assert;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBean31MetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
+import org.jboss.metadata.ejb.spec.EjbJar31MetaData;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.spec.MessageDrivenBean31MetaData;
+import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
+import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
+import org.jboss.metadata.ejb.spec.ScheduleMetaData;
+import org.jboss.metadata.ejb.spec.SessionBean31MetaData;
+import org.jboss.metadata.ejb.spec.TimerMetaData;
+import org.jboss.metadata.ejb.test.schedule.MDBWithMultipleSchedules;
+import org.jboss.metadata.ejb.test.schedule.MDBWithSchedule;
+import org.jboss.metadata.ejb.test.schedule.SLSBWithMultipleSchedules;
+import org.jboss.metadata.ejb.test.schedule.SimpleSLSBWithSchedule;
+import org.jboss.metadata.ejb.test.schedule.SingletonWithMultipleSchedules;
+import org.jboss.metadata.ejb.test.schedule.SingletonWithSchedule;
+import org.jboss.test.metadata.common.PackageScanner;
+import org.jboss.test.metadata.common.ScanPackage;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.resolver.MultiClassSchemaResolver;
+import org.jboss.xb.binding.resolver.MutableSchemaResolver;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests that the processing of {@link Schedule} and {@link Schedules} annotations and their
+ * xml equivalents on beans is processed correctly, for metadata.
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ScheduleTestCase
+{
+
+ private static Logger logger = Logger.getLogger(ScheduleTestCase.class);
+
+ private static MutableSchemaResolver schemaBindingResolver;
+
+ private static UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+
+ @BeforeClass
+ public static void beforeClass()
+ {
+ schemaBindingResolver = new MultiClassSchemaResolver();
+ schemaBindingResolver.mapLocationToClass("ejb-jar_3_1.xsd", EjbJar31MetaData.class);
+ }
+
+ /**
+ * Tests that a SLSB annotated with {@link Schedule} is processed correctly for metadata
+ *
+ */
+ @Test
+ @ScanPackage("org.jboss.metadata.ejb.test.schedule")
+ public void testSLSBWithSchedule()
+ {
+
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ JBoss50Creator creator = new JBoss50Creator(finder);
+ Collection<Class<?>> classes = PackageScanner.loadClasses();
+ JBossMetaData metaData = creator.create(classes);
+ assertNotNull("Metadata not created", metaData);
+
+ // get hold of the bean
+ JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(SimpleSLSBWithSchedule.class
+ .getSimpleName());
+ assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossSessionBean31MetaData.class,
+ (enterpriseBean instanceof JBossSessionBean31MetaData));
+ JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBean;
+
+ // get the timers
+ List<TimerMetaData> timers = sessionBean.getTimers();
+
+ // check the metadata for validity
+ Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
+ Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 1, timers.size());
+
+ TimerMetaData timerMetaData = timers.get(0);
+ Assert.assertTrue("Info object was expected to be empty", timerMetaData.getInfo().isEmpty());
+ Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+
+ // get hold of the schedule and validate it
+ ScheduleMetaData schedule = timerMetaData.getSchedule();
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+
+ // test the timeout method
+ NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+ Assert.assertNotNull("Timeout method is null", timeoutMethod);
+ Assert.assertEquals("Unexpected timeout method", "schedule", timeoutMethod.getMethodName());
+ MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+ Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+ Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+ String timeoutMethodParam = timeoutMethodParams.get(0);
+ Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+
+ }
+
+ /**
+ * Tests that a MDB marked with {@link Schedule} is processed correctly for metadata
+ */
+ @Test
+ @ScanPackage("org.jboss.metadata.ejb.test.schedule")
+ public void testScheduleOnMDB()
+ {
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ JBoss50Creator creator = new JBoss50Creator(finder);
+ Collection<Class<?>> classes = PackageScanner.loadClasses();
+ JBossMetaData metaData = creator.create(classes);
+ assertNotNull("Metadata not created", metaData);
+
+ // get hold of the bean
+ JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(MDBWithSchedule.class.getSimpleName());
+ assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossMessageDrivenBean31MetaData.class,
+ (enterpriseBean instanceof JBossMessageDrivenBean31MetaData));
+ JBossMessageDrivenBean31MetaData mdb = (JBossMessageDrivenBean31MetaData) enterpriseBean;
+
+ // get the timers
+ List<TimerMetaData> timers = mdb.getTimers();
+
+ // check the metadata for validity
+ Assert.assertNotNull("Timer metadata not found on bean " + mdb.getName(), timers);
+ Assert.assertEquals("Unexpected number of timers found on bean " + mdb.getName(), 1, timers.size());
+
+ TimerMetaData timerMetaData = timers.get(0);
+ Assert.assertTrue("Info object was expected to be empty", timerMetaData.getInfo().isEmpty());
+ Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+
+ // get hold of the schedule and validate it
+ ScheduleMetaData schedule = timerMetaData.getSchedule();
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "*", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "1", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+
+ // test the timeout method
+ NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+ Assert.assertNotNull("Timeout method is null", timeoutMethod);
+ Assert.assertEquals("Unexpected timeout method", "someMethod", timeoutMethod.getMethodName());
+ MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+ Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+ Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+ String timeoutMethodParam = timeoutMethodParams.get(0);
+ Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+
+ }
+
+ /**
+ * Tests that a Singleton bean which has a method marked with {@link Schedule} is
+ * processed correctly for metadata
+ */
+ @Test
+ @ScanPackage("org.jboss.metadata.ejb.test.schedule")
+ public void testScheduleOnSingleton()
+ {
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ JBoss50Creator creator = new JBoss50Creator(finder);
+ Collection<Class<?>> classes = PackageScanner.loadClasses();
+ JBossMetaData metaData = creator.create(classes);
+ assertNotNull("Metadata not created", metaData);
+
+ // get hold of the bean
+ JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(SingletonWithSchedule.class
+ .getSimpleName());
+ assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossSessionBean31MetaData.class,
+ (enterpriseBean instanceof JBossSessionBean31MetaData));
+ JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBean;
+ Assert.assertTrue(sessionBean.getName() + " is not a singleton", sessionBean.isSingleton());
+
+ // get the timers
+ List<TimerMetaData> timers = sessionBean.getTimers();
+
+ // check the metadata for validity
+ Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
+ Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 1, timers.size());
+
+ TimerMetaData timerMetaData = timers.get(0);
+ Assert.assertEquals("Unexpected info on timer metadata", SingletonWithSchedule.INFO_FOR_SCHEDULE, timerMetaData
+ .getInfo());
+ Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+ Assert.assertEquals("Unexpected timezone on timer metadata", "IST", timerMetaData.getTimezone());
+
+ // get hold of the schedule and validate it
+ ScheduleMetaData schedule = timerMetaData.getSchedule();
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "10", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "12", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+
+ // test the timeout method
+ NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+ Assert.assertNotNull("Timeout method is null", timeoutMethod);
+ Assert.assertEquals("Unexpected timeout method", "scheduleTimeout", timeoutMethod.getMethodName());
+ MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+ Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+ Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+ String timeoutMethodParam = timeoutMethodParams.get(0);
+ Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+ }
+
+ /**
+ * Tests that a SLSB configured for timer through ejb-jar.xml is processed correctly for metadata
+ */
+ @Test
+ public void testScheduleForSLSBInEjbJarXml() throws Exception
+ {
+ EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class, "/org/jboss/metadata/ejb/test/schedule/ejb-jar.xml");
+ assertNotNull(jarMetaData);
+
+ EnterpriseBeanMetaData enterpriseBean = jarMetaData.getEnterpriseBean("SLSBInEjbJarXml");
+ assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + SessionBean31MetaData.class,
+ (enterpriseBean instanceof SessionBean31MetaData));
+ SessionBean31MetaData sessionBean = (SessionBean31MetaData) enterpriseBean;
+
+ // get the timers
+ List<TimerMetaData> timers = sessionBean.getTimers();
+
+ // check the metadata for validity
+ Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
+ Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 1, timers.size());
+
+ TimerMetaData timerMetaData = timers.get(0);
+ Assert.assertNull("Unexpected info on timer metadata", timerMetaData.getInfo());
+ Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+
+ // get hold of the schedule and validate it
+ ScheduleMetaData schedule = timerMetaData.getSchedule();
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "Wed", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+
+ // test the timeout method
+ NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+ Assert.assertNotNull("Timeout method is null", timeoutMethod);
+ Assert.assertEquals("Unexpected timeout method", "dummySLSBMethod", timeoutMethod.getMethodName());
+ MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+ Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+ Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+ String timeoutMethodParam = timeoutMethodParams.get(0);
+ Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+
+ }
+
+ /**
+ * Tests that a MDB configured for timer through ejb-jar.xml is processed correctly for metadata
+ */
+ @Test
+ public void testScheduleForMDBInEjbJarXml() throws Exception
+ {
+ EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class, "/org/jboss/metadata/ejb/test/schedule/ejb-jar.xml");
+ assertNotNull(jarMetaData);
+
+ EnterpriseBeanMetaData enterpriseBean = jarMetaData.getEnterpriseBean("MDBInEjbJarXml");
+ assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + MessageDrivenBean31MetaData.class,
+ (enterpriseBean instanceof MessageDrivenBean31MetaData));
+ MessageDrivenBean31MetaData mdb = (MessageDrivenBean31MetaData) enterpriseBean;
+
+ // get the timers
+ List<TimerMetaData> timers = mdb.getTimers();
+
+ // check the metadata for validity
+ Assert.assertNotNull("Timer metadata not found on bean " + mdb.getName(), timers);
+ Assert.assertEquals("Unexpected number of timers found on bean " + mdb.getName(), 1, timers.size());
+
+ TimerMetaData timerMetaData = timers.get(0);
+ Assert.assertEquals("Unexpected info on timer metadata", "SomeInfoInXml", timerMetaData.getInfo());
+ Assert.assertFalse("Timer was expected to be persistent", timerMetaData.isPersistent());
+
+ // get hold of the schedule and validate it
+ ScheduleMetaData schedule = timerMetaData.getSchedule();
+ Assert.assertEquals("Unexpected seconds in schedule", "5", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "4", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "3", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "2", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "1", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "Jan", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+
+ // test the timeout method
+ NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+ Assert.assertNotNull("Timeout method is null", timeoutMethod);
+ Assert.assertEquals("Unexpected timeout method", "dummyMDBMethod", timeoutMethod.getMethodName());
+ MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+ Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+ Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+ String timeoutMethodParam = timeoutMethodParams.get(0);
+ Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+
+ }
+
+ /**
+ * Tests that a Singleton bean configured for timer through ejb-jar.xml is processed correctly for metadata
+ */
+ @Test
+ public void testScheduleForSingletonInEjbJarXml() throws Exception
+ {
+ EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class, "/org/jboss/metadata/ejb/test/schedule/ejb-jar.xml");
+ assertNotNull(jarMetaData);
+
+ EnterpriseBeanMetaData enterpriseBean = jarMetaData.getEnterpriseBean("SingletonInEjbJarXml");
+ assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + SessionBean31MetaData.class,
+ (enterpriseBean instanceof SessionBean31MetaData));
+ SessionBean31MetaData sessionBean = (SessionBean31MetaData) enterpriseBean;
+ Assert.assertTrue(sessionBean.getName() + " was not considered a singleton bean", sessionBean.isSingleton());
+
+ // get the timers
+ List<TimerMetaData> timers = sessionBean.getTimers();
+
+ // check the metadata for validity
+ Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
+ Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 1, timers.size());
+
+ TimerMetaData timerMetaData = timers.get(0);
+ Assert.assertNull("Unexpected info on timer metadata", timerMetaData.getInfo());
+ Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+
+ // get hold of the schedule and validate it
+ ScheduleMetaData schedule = timerMetaData.getSchedule();
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "2009", schedule.getYear());
+
+ // test the timeout method
+ NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+ Assert.assertNotNull("Timeout method is null", timeoutMethod);
+ Assert.assertEquals("Unexpected timeout method", "dummySingletonMethod", timeoutMethod.getMethodName());
+ MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+ Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+ Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+ String timeoutMethodParam = timeoutMethodParams.get(0);
+ Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+
+ }
+
+ /**
+ * Tests that a Singleton bean which has methods marked with {@link Schedules} is
+ * processed correctly for metadata
+ */
+ @Test
+ @ScanPackage("org.jboss.metadata.ejb.test.schedule")
+ public void testMultipleSchedulesOnSingleton()
+ {
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ JBoss50Creator creator = new JBoss50Creator(finder);
+ Collection<Class<?>> classes = PackageScanner.loadClasses();
+ JBossMetaData metaData = creator.create(classes);
+ assertNotNull("Metadata not created", metaData);
+
+ // get hold of the bean
+ JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(SingletonWithMultipleSchedules.class
+ .getSimpleName());
+ assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossSessionBean31MetaData.class,
+ (enterpriseBean instanceof JBossSessionBean31MetaData));
+ JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBean;
+ Assert.assertTrue(sessionBean.getName() + " is not a singleton", sessionBean.isSingleton());
+
+ // get the timers
+ List<TimerMetaData> timers = sessionBean.getTimers();
+
+ // check the metadata for validity
+ Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
+ Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 4, timers.size());
+
+ for (int i = 0; i < timers.size(); i++)
+ {
+ TimerMetaData timerMetaData = timers.get(i);
+ String info = timerMetaData.getInfo();
+ Assert.assertNotNull("Info not present on timer metadata", timerMetaData.getInfo());
+
+ int infoVal = Integer.parseInt(info);
+
+ NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+ Assert.assertNotNull("Timeout method not present on timer metadata", timeoutMethod);
+ MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+ Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+ Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+ String timeoutMethodParam = timeoutMethodParams.get(0);
+ Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+
+ String timeoutMethodName = timeoutMethod.getMethodName();
+ ScheduleMetaData schedule = timerMetaData.getSchedule();
+ switch (infoVal)
+ {
+ case 1 :
+ Assert.assertEquals("Unexpected timeout method", "schedule", timeoutMethodName);
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+ Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+ Assert.assertEquals("Unexpected timezone on timer metadata", "CET", timerMetaData.getTimezone());
+ break;
+ case 2 :
+ Assert.assertEquals("Unexpected timeout method", "schedule", timeoutMethodName);
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+ Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+
+ break;
+ case 3 :
+ Assert.assertEquals("Unexpected timeout method", "schedule", timeoutMethodName);
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "24", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+ Assert.assertFalse("Timer was *not* expected to be persistent", timerMetaData.isPersistent());
+
+ break;
+ case 4 :
+ Assert.assertEquals("Unexpected timeout method", "anotherSchedule", timeoutMethodName);
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "*", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+ break;
+ default :
+ Assert.fail("Unexpected info " + info + " on timer metadata");
+ }
+ }
+
+ }
+
+ /**
+ * Tests that a SLSB which has methods marked with {@link Schedules} is
+ * processed correctly for metadata
+ */
+ @Test
+ @ScanPackage("org.jboss.metadata.ejb.test.schedule")
+ public void testMultipleSchedulesOnSLSB()
+ {
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ JBoss50Creator creator = new JBoss50Creator(finder);
+ Collection<Class<?>> classes = PackageScanner.loadClasses();
+ JBossMetaData metaData = creator.create(classes);
+ assertNotNull("Metadata not created", metaData);
+
+ // get hold of the bean
+ JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(SLSBWithMultipleSchedules.class
+ .getSimpleName());
+ assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossSessionBean31MetaData.class,
+ (enterpriseBean instanceof JBossSessionBean31MetaData));
+ JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBean;
+
+ // get the timers
+ List<TimerMetaData> timers = sessionBean.getTimers();
+
+ // check the metadata for validity
+ Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
+ Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 2, timers.size());
+
+ for (int i = 0; i < timers.size(); i++)
+ {
+ TimerMetaData timerMetaData = timers.get(i);
+ String info = timerMetaData.getInfo();
+ Assert.assertNotNull("Info not present on timer metadata", timerMetaData.getInfo());
+
+ int infoVal = Integer.parseInt(info);
+
+ NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+ Assert.assertNotNull("Timeout method not present on timer metadata", timeoutMethod);
+ MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+ Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+ Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+ String timeoutMethodParam = timeoutMethodParams.get(0);
+ Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+
+ String timeoutMethodName = timeoutMethod.getMethodName();
+ ScheduleMetaData schedule = timerMetaData.getSchedule();
+ switch (infoVal)
+ {
+ case 1 :
+ Assert.assertEquals("Unexpected timeout method", "schedule", timeoutMethodName);
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+ Assert.assertFalse("Timer was *not* expected to be persistent", timerMetaData.isPersistent());
+ break;
+ case 2 :
+ Assert.assertEquals("Unexpected timeout method", "schedule", timeoutMethodName);
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+ Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+ Assert.assertEquals("Unexpected timezone on timer metadata", "IST", timerMetaData.getTimezone());
+ break;
+ default :
+ Assert.fail("Unexpected info " + info + " on timer metadata");
+ }
+ }
+
+ }
+
+ /**
+ * Tests that a MDB which has methods marked with {@link Schedules} is
+ * processed correctly for metadata
+ */
+ @Test
+ @ScanPackage("org.jboss.metadata.ejb.test.schedule")
+ public void testMultipleSchedulesOnMDB()
+ {
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ JBoss50Creator creator = new JBoss50Creator(finder);
+ Collection<Class<?>> classes = PackageScanner.loadClasses();
+ JBossMetaData metaData = creator.create(classes);
+ assertNotNull("Metadata not created", metaData);
+
+ // get hold of the bean
+ JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(MDBWithMultipleSchedules.class
+ .getSimpleName());
+ assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossMessageDrivenBean31MetaData.class,
+ (enterpriseBean instanceof JBossMessageDrivenBean31MetaData));
+ JBossMessageDrivenBean31MetaData mdb = (JBossMessageDrivenBean31MetaData) enterpriseBean;
+
+ // get the timers
+ List<TimerMetaData> timers = mdb.getTimers();
+
+ // check the metadata for validity
+ Assert.assertNotNull("Timer metadata not found on bean " + mdb.getName(), timers);
+ Assert.assertEquals("Unexpected number of timers found on bean " + mdb.getName(), 2, timers.size());
+
+ for (int i = 0; i < timers.size(); i++)
+ {
+ TimerMetaData timerMetaData = timers.get(i);
+ String info = timerMetaData.getInfo();
+ Assert.assertNotNull("Info not present on timer metadata", timerMetaData.getInfo());
+
+ int infoVal = Integer.parseInt(info);
+
+ NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+ Assert.assertNotNull("Timeout method not present on timer metadata", timeoutMethod);
+ MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+ Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+ Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+ String timeoutMethodParam = timeoutMethodParams.get(0);
+ Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+
+ String timeoutMethodName = timeoutMethod.getMethodName();
+ ScheduleMetaData schedule = timerMetaData.getSchedule();
+ switch (infoVal)
+ {
+ case 1 :
+ Assert.assertEquals("Unexpected timeout method", "someMethod", timeoutMethodName);
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "*", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "1", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+ Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+ break;
+ case 2 :
+ Assert.assertEquals("Unexpected timeout method", "someMethod", timeoutMethodName);
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "*", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+ Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+ break;
+ default :
+ Assert.fail("Unexpected info " + info + " on timer metadata");
+ }
+ }
+
+ }
+
+ /**
+ * Tests that a Singleton bean which has methods marked as auto timeout methods in ejb-jar.xml
+ * is processed correctly for metadata
+ */
+ @Test
+ public void testMultipleSchedulesOnSingletonInEjbJarXML() throws Exception
+ {
+ EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class,
+ "/org/jboss/metadata/ejb/test/schedule/ejb-jar-with-multiple-schedules.xml");
+ assertNotNull(jarMetaData);
+
+ EnterpriseBeanMetaData enterpriseBean = jarMetaData
+ .getEnterpriseBean("SingletonWithMultipleSchedulesInEjbJarXml");
+ assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + SessionBean31MetaData.class,
+ (enterpriseBean instanceof SessionBean31MetaData));
+ SessionBean31MetaData sessionBean = (SessionBean31MetaData) enterpriseBean;
+ Assert.assertTrue(sessionBean.getName() + " was not considered a singleton bean", sessionBean.isSingleton());
+
+ // get the timers
+ List<TimerMetaData> timers = sessionBean.getTimers();
+
+ // check the metadata for validity
+ Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
+ Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 2, timers.size());
+
+ for (int i = 0; i < timers.size(); i++)
+ {
+ TimerMetaData timerMetaData = timers.get(i);
+ String info = timerMetaData.getInfo();
+ Assert.assertNotNull("Info not present on timer metadata", timerMetaData.getInfo());
+
+ int infoVal = Integer.parseInt(info);
+
+ NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+ Assert.assertNotNull("Timeout method not present on timer metadata", timeoutMethod);
+ MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+ Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+ Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+ String timeoutMethodParam = timeoutMethodParams.get(0);
+ Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+
+ String timeoutMethodName = timeoutMethod.getMethodName();
+ ScheduleMetaData schedule = timerMetaData.getSchedule();
+ switch (infoVal)
+ {
+ case 1 :
+ Assert.assertEquals("Unexpected timeout method", "dummySingletonMethod", timeoutMethodName);
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+ Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+ break;
+ case 2 :
+ Assert.assertEquals("Unexpected timeout method", "dummySingletonMethod", timeoutMethodName);
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "2010", schedule.getYear());
+ Assert.assertFalse("Timer was *not* expected to be persistent", timerMetaData.isPersistent());
+
+ break;
+
+ default :
+ Assert.fail("Unexpected info " + info + " on timer metadata");
+ }
+ }
+
+ }
+
+ /**
+ * Tests that a MDB which has methods marked as auto timeout methods in ejb-jar.xml
+ * is processed correctly for metadata
+ */
+ @Test
+ public void testMultipleSchedulesOnMDBInEjbJarXML() throws Exception
+ {
+ EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class,
+ "/org/jboss/metadata/ejb/test/schedule/ejb-jar-with-multiple-schedules.xml");
+ assertNotNull(jarMetaData);
+
+ EnterpriseBeanMetaData enterpriseBean = jarMetaData
+ .getEnterpriseBean("MDBWithMultipleSchedulesInEjbJarXml");
+ assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + MessageDrivenBean31MetaData.class,
+ (enterpriseBean instanceof MessageDrivenBean31MetaData));
+ MessageDrivenBean31MetaData mdb = (MessageDrivenBean31MetaData) enterpriseBean;
+
+ // get the timers
+ List<TimerMetaData> timers = mdb.getTimers();
+
+ // check the metadata for validity
+ Assert.assertNotNull("Timer metadata not found on bean " + mdb.getName(), timers);
+ Assert.assertEquals("Unexpected number of timers found on bean " + mdb.getName(), 2, timers.size());
+
+ for (int i = 0; i < timers.size(); i++)
+ {
+ TimerMetaData timerMetaData = timers.get(i);
+ String info = timerMetaData.getInfo();
+ Assert.assertNotNull("Info not present on timer metadata", timerMetaData.getInfo());
+
+ int infoVal = Integer.parseInt(info);
+
+ NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+ Assert.assertNotNull("Timeout method not present on timer metadata", timeoutMethod);
+ MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+ Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+ Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+ String timeoutMethodParam = timeoutMethodParams.get(0);
+ Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+
+ String timeoutMethodName = timeoutMethod.getMethodName();
+ ScheduleMetaData schedule = timerMetaData.getSchedule();
+ switch (infoVal)
+ {
+ case 1 :
+ Assert.assertEquals("Unexpected timeout method", "dummyMDBMethod", timeoutMethodName);
+ Assert.assertEquals("Unexpected seconds in schedule", "5", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "4", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "3", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "2", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "1", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "Mar", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+ Assert.assertFalse("Timer was *not* expected to be persistent", timerMetaData.isPersistent());
+ break;
+ case 2 :
+ Assert.assertEquals("Unexpected timeout method", "dummyMDBMethod", timeoutMethodName);
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+ Assert.assertFalse("Timer was *not* expected to be persistent", timerMetaData.isPersistent());
+ Assert.assertEquals("Unexpected timezone on timer metadata", "CET", timerMetaData.getTimezone());
+ break;
+
+ default :
+ Assert.fail("Unexpected info " + info + " on timer metadata");
+ }
+ }
+
+ }
+
+ /**
+ * Tests that a SLSB which has methods marked as auto timeout methods in ejb-jar.xml
+ * is processed correctly for metadata
+ */
+ @Test
+ public void testMultipleSchedulesOnSLSBInEjbJarXML() throws Exception
+ {
+ EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class,
+ "/org/jboss/metadata/ejb/test/schedule/ejb-jar-with-multiple-schedules.xml");
+ assertNotNull(jarMetaData);
+
+ EnterpriseBeanMetaData enterpriseBean = jarMetaData.getEnterpriseBean("MultipleScheduleSLSBInEjbJarXML");
+ assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + SessionBean31MetaData.class,
+ (enterpriseBean instanceof SessionBean31MetaData));
+ SessionBean31MetaData sessionBean = (SessionBean31MetaData) enterpriseBean;
+
+ // get the timers
+ List<TimerMetaData> timers = sessionBean.getTimers();
+
+ // check the metadata for validity
+ Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timers);
+ Assert.assertEquals("Unexpected number of timers found on bean " + sessionBean.getName(), 2, timers.size());
+
+ for (int i = 0; i < timers.size(); i++)
+ {
+ TimerMetaData timerMetaData = timers.get(i);
+ String info = timerMetaData.getInfo();
+ Assert.assertNotNull("Info not present on timer metadata", timerMetaData.getInfo());
+
+ int infoVal = Integer.parseInt(info);
+
+ NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+ Assert.assertNotNull("Timeout method not present on timer metadata", timeoutMethod);
+ MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+ Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+ Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+ String timeoutMethodParam = timeoutMethodParams.get(0);
+ Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+
+ String timeoutMethodName = timeoutMethod.getMethodName();
+ ScheduleMetaData schedule = timerMetaData.getSchedule();
+ switch (infoVal)
+ {
+ case 1 :
+ Assert.assertEquals("Unexpected timeout method", "dummySLSBMethod", timeoutMethodName);
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "Wed", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "1", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+ Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+ break;
+ case 2 :
+ Assert.assertEquals("Unexpected timeout method", "anotherDummyMethod", timeoutMethodName);
+ Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+ Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+ Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+ Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+ Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+ Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+ Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+ Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+
+ break;
+
+ default :
+ Assert.fail("Unexpected info " + info + " on timer metadata");
+ }
+ }
+
+ }
+
+ /**
+ * Test that {@link SessionBean31MetaData#merge(EnterpriseBeanMetaData, EnterpriseBeanMetaData)}
+ * works as expected for timer metadata
+ */
+ @Test
+ public void testSessionBeanTimerMerge()
+ {
+ TimerMetaData nonPersistentTimer = new TimerMetaData();
+ nonPersistentTimer.setPersistent(false);
+
+ TimerMetaData persistentTimer = new TimerMetaData();
+ persistentTimer.setPersistent(true);
+
+ SessionBean31MetaData original = new SessionBean31MetaData();
+ original.setEjbName("DummyBean");
+ original.addTimer(nonPersistentTimer);
+
+ SessionBean31MetaData overriden = new SessionBean31MetaData();
+ overriden.setEjbName("DummyBean");
+ overriden.addTimer(persistentTimer);
+
+ SessionBean31MetaData mergedBean = new SessionBean31MetaData();
+ mergedBean.merge(overriden, original);
+
+ List<TimerMetaData> mergedTimers = mergedBean.getTimers();
+ Assert.assertNotNull("Merged timers is null", mergedTimers);
+ Assert.assertEquals("Unexpected number of timers in merged metadata", 2, mergedTimers.size());
+
+ boolean foundPersistentTimer = false;
+ boolean foundNonPersistentTimer = false;
+
+ for (TimerMetaData timer : mergedTimers)
+ {
+ if (timer.isPersistent())
+ {
+ foundPersistentTimer = true;
+ }
+ else
+ {
+ foundNonPersistentTimer = true;
+ }
+ }
+ Assert.assertTrue("Persistent timer not found in merged metadata", foundPersistentTimer);
+ Assert.assertTrue("Non-Persistent timer not found in merged metadata", foundNonPersistentTimer);
+
+ }
+
+ /**
+ * Test that {@link SessionBean31MetaData#merge(EnterpriseBeanMetaData, EnterpriseBeanMetaData)} works as
+ * expected for timer metadata
+ */
+ @Test
+ public void testSessionBeanTimerMerge2()
+ {
+ TimerMetaData persistentTimer = new TimerMetaData();
+ persistentTimer.setPersistent(true);
+
+ SessionBean31MetaData original = new SessionBean31MetaData();
+ original.setEjbName("DummyBean");
+
+ SessionBean31MetaData overriden = new SessionBean31MetaData();
+ overriden.setEjbName("DummyBean");
+ overriden.addTimer(persistentTimer);
+
+ SessionBean31MetaData mergedBean = new SessionBean31MetaData();
+ mergedBean.merge(overriden, original);
+
+ List<TimerMetaData> mergedTimers = mergedBean.getTimers();
+ Assert.assertNotNull("Merged timers is null", mergedTimers);
+ Assert.assertEquals("Unexpected number of timers in merged metadata", 1, mergedTimers.size());
+ Assert.assertTrue("Timer in merged metadata is not persistent", mergedTimers.get(0).isPersistent());
+ }
+
+ /**
+ * Test that {@link JBossSessionBean31MetaData#merge(JBossEnterpriseBeanMetaData, JBossEnterpriseBeanMetaData)}
+ * works as expected for timer metadata
+ */
+ @Test
+ public void testJBossSessionBeanTimerMerge()
+ {
+ TimerMetaData persistentTimer = new TimerMetaData();
+ persistentTimer.setPersistent(true);
+
+ JBossSessionBean31MetaData original = new JBossSessionBean31MetaData();
+ original.setEjbName("DummyBean");
+
+ JBossSessionBean31MetaData overriden = new JBossSessionBean31MetaData();
+ overriden.setEjbName("DummyBean");
+ overriden.addTimer(persistentTimer);
+
+ JBossSessionBean31MetaData mergedBean = new JBossSessionBean31MetaData();
+ mergedBean.merge(overriden, original);
+
+ List<TimerMetaData> mergedTimers = mergedBean.getTimers();
+ Assert.assertNotNull("Merged timers is null", mergedTimers);
+ Assert.assertEquals("Unexpected number of timers in merged metadata", 1, mergedTimers.size());
+ Assert.assertTrue("Timer in merged metadata is not persistent", mergedTimers.get(0).isPersistent());
+ }
+
+ /**
+ * Test that {@link JBossMessageDrivenBean31MetaData#merge(JBossEnterpriseBeanMetaData, JBossEnterpriseBeanMetaData)}
+ * works as expected for timer metadata
+ */
+ @Test
+ public void testJBossMessageDrivenBeanTimerMerge()
+ {
+ TimerMetaData persistentTimer = new TimerMetaData();
+ persistentTimer.setPersistent(true);
+
+ JBossMessageDrivenBean31MetaData original = new JBossMessageDrivenBean31MetaData();
+ original.setEjbName("DummyBean");
+
+ JBossMessageDrivenBean31MetaData overriden = new JBossMessageDrivenBean31MetaData();
+ overriden.setEjbName("DummyBean");
+ overriden.addTimer(persistentTimer);
+
+ JBossMessageDrivenBean31MetaData mergedBean = new JBossMessageDrivenBean31MetaData();
+ mergedBean.merge(overriden, original);
+
+ List<TimerMetaData> mergedTimers = mergedBean.getTimers();
+ Assert.assertNotNull("Merged timers is null", mergedTimers);
+ Assert.assertEquals("Unexpected number of timers in merged metadata", 1, mergedTimers.size());
+ Assert.assertTrue("Timer in merged metadata is not persistent", mergedTimers.get(0).isPersistent());
+ }
+
+ /**
+ * Test that {@link MessageDrivenBean31MetaData#merge(EnterpriseBeanMetaData, EnterpriseBeanMetaData)} works
+ * as expected for timer metadata
+ */
+ @Test
+ public void testMDBTimerMerge()
+ {
+ TimerMetaData nonPersistentTimer = new TimerMetaData();
+ nonPersistentTimer.setPersistent(false);
+
+ TimerMetaData persistentTimer = new TimerMetaData();
+ persistentTimer.setPersistent(true);
+
+ MessageDrivenBean31MetaData original = new MessageDrivenBean31MetaData();
+ original.setEjbName("DummyBean");
+ original.addTimer(nonPersistentTimer);
+
+ MessageDrivenBean31MetaData overriden = new MessageDrivenBean31MetaData();
+ overriden.setEjbName("DummyBean");
+ overriden.addTimer(persistentTimer);
+
+ MessageDrivenBean31MetaData mergedBean = new MessageDrivenBean31MetaData();
+ mergedBean.merge(overriden, original);
+
+ List<TimerMetaData> mergedTimers = mergedBean.getTimers();
+ Assert.assertNotNull("Merged timers is null", mergedTimers);
+ Assert.assertEquals("Unexpected number of timers in merged metadata", 2, mergedTimers.size());
+
+ boolean foundPersistentTimer = false;
+ boolean foundNonPersistentTimer = false;
+
+ for (TimerMetaData timer : mergedTimers)
+ {
+ if (timer.isPersistent())
+ {
+ foundPersistentTimer = true;
+ }
+ else
+ {
+ foundNonPersistentTimer = true;
+ }
+ }
+ Assert.assertTrue("Persistent timer not found in merged metadata", foundPersistentTimer);
+ Assert.assertTrue("Non-Persistent timer not found in merged metadata", foundNonPersistentTimer);
+
+ }
+
+ /**
+ * Test that {@link MessageDrivenBean31MetaData#merge(EnterpriseBeanMetaData, EnterpriseBeanMetaData)} works
+ * as expected for timer metadata
+ */
+ @Test
+ public void testMDBTimerMerge2()
+ {
+ TimerMetaData persistentTimer = new TimerMetaData();
+ persistentTimer.setPersistent(true);
+
+ MessageDrivenBean31MetaData original = new MessageDrivenBean31MetaData();
+ original.setEjbName("DummyBean");
+
+ MessageDrivenBean31MetaData overriden = new MessageDrivenBean31MetaData();
+ overriden.setEjbName("DummyBean");
+ overriden.addTimer(persistentTimer);
+
+ MessageDrivenBean31MetaData mergedBean = new MessageDrivenBean31MetaData();
+ mergedBean.merge(original, overriden);
+
+ List<TimerMetaData> mergedTimers = mergedBean.getTimers();
+ Assert.assertNotNull("Merged timers is null", mergedTimers);
+ Assert.assertEquals("Unexpected number of timers in merged metadata", 1, mergedTimers.size());
+ Assert.assertTrue("Timer in merged metadata is not persistent", mergedTimers.get(0).isPersistent());
+
+
+ }
+ /**
+ * Utility method
+ * @param <T>
+ * @param type
+ * @param resource
+ * @return
+ * @throws JBossXBException
+ */
+ private static <T> T unmarshal(Class<T> type, String resource) throws JBossXBException
+ {
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+ unmarshaller.setValidation(false);
+ URL url = type.getResource(resource);
+ if (url == null)
+ throw new IllegalArgumentException("Failed to find resource " + resource);
+ return type.cast(unmarshaller.unmarshal(url.toString(), schemaBindingResolver));
+ }
+}
More information about the jboss-cvs-commits
mailing list