KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > timer > ImplementsTimedObjectTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25 package com.sun.enterprise.tools.verifier.tests.ejb.timer;
26
27 import com.sun.enterprise.deployment.EjbDescriptor;
28 import com.sun.enterprise.deployment.EjbEntityDescriptor;
29 import com.sun.enterprise.deployment.EjbSessionDescriptor;
30 import com.sun.enterprise.tools.verifier.Result;
31 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
32 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
33
34 /**
35  * Checks if the EJB class implements the TimedObject interface
36  *
37  * @version
38  * @author Anisha Malhotra
39  */

40 public class ImplementsTimedObjectTest extends EjbTest {
41
42     ComponentNameConstructor compName = null;
43     /**
44      * Checks if the EJB class implements the TimedObject interface
45      *
46      * @param descriptor the Enterprise Java Bean deployment descriptor
47      *
48      * @return <code>Result</code> the results for this assertion
49      */

50     public Result check(EjbDescriptor descriptor) {
51         Result result = getInitializedResult();
52         ComponentNameConstructor compName =
53                 getVerifierContext().getComponentNameConstructor();
54         boolean isEjb30 = descriptor.getEjbBundleDescriptor().getSpecVersion().equalsIgnoreCase("3.0");
55         if(descriptor.isTimedObject()) {
56             //Timers can be created for stateless session beans, message-driven beans,
57
//and 2.1 entity beans.Timers cannot be created for stateful session beans or EJB 3.0 entities.
58
if(((descriptor instanceof EjbEntityDescriptor) && isEjb30)
59                     || ( (descriptor instanceof EjbSessionDescriptor) &&
60                     ((((EjbSessionDescriptor)descriptor).getSessionType()).equals
61                     (EjbSessionDescriptor.STATEFUL)) )) {
62                 addErrorDetails(result, compName);
63                 result.failed(smh.getLocalString(getClass().getName()+
64                         ".failed1", "[ {0} ] must not implement the TimedObject interface." +
65                         "Only 2.1 entity beans or stateless session beans may " +
66                         "implement the TimedObject interface" ,
67                         new Object JavaDoc[] {descriptor.getEjbClassName()}));
68             }
69         }
70         if(result.getStatus() != Result.FAILED) {
71             addGoodDetails(result, compName);
72             result.passed(smh.getLocalString (getClass().getName()+".passed",
73                     "[ {0} ] properly implements the TimedObject interface",
74                     new Object JavaDoc[] {descriptor.getEjbClassName()}));
75
76         }
77         return result;
78     }
79 }
80
Popular Tags