KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > connector > messageinflow > CheckActivationSpecClass


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  * CheckActivationSpecClass.java
25  *
26  * Created on August 29, 2002
27  */

28
29 package com.sun.enterprise.tools.verifier.tests.connector.messageinflow;
30
31 import com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest;
32 import com.sun.enterprise.tools.verifier.tests.connector.ConnectorCheck;
33 import com.sun.enterprise.tools.verifier.Result;
34 import com.sun.enterprise.tools.verifier.*;
35 import com.sun.enterprise.deployment.ConnectorDescriptor;
36 import com.sun.enterprise.deployment.InboundResourceAdapter;
37 import com.sun.enterprise.deployment.MessageListener;
38 import com.sun.enterprise.tools.verifier.tests.*;
39 import java.util.Iterator JavaDoc;
40 import java.util.Set JavaDoc;
41
42 /**
43  * Test for each message-listener , that "activationspec-class"
44  * implements "javax.resource.spi.ActivationSpec".
45  *
46  * @author Anisha Malhotra
47  * @version
48  */

49 public class CheckActivationSpecClass
50 extends ConnectorTest
51 implements ConnectorCheck
52 {
53
54   /** <p>
55    * Test for each message-listener , that "activationspec-class"
56    * implements "javax.resource.spi.ActivationSpec".
57    * </p>
58    *
59    * @param descriptor deployment descriptor for the rar file
60    * @return result object containing the result of the individual test
61    * performed
62    */

63   public Result check(ConnectorDescriptor descriptor) {
64
65     Result result = getInitializedResult();
66     ComponentNameConstructor compName =
67       getVerifierContext().getComponentNameConstructor();
68     if(!descriptor.getInBoundDefined())
69     {
70       result.addNaDetails(smh.getLocalString
71           ("tests.componentNameConstructor",
72            "For [ {0} ]",
73            new Object JavaDoc[] {compName.toString()}));
74       result.notApplicable(smh.getLocalString
75           ("com.sun.enterprise.tools.verifier.tests.connector.messageinflow.notApp",
76            "Resource Adapter does not provide inbound communication"));
77       return result;
78     }
79     InboundResourceAdapter ra = descriptor.getInboundResourceAdapter();
80     Set JavaDoc msgListeners = ra.getMessageListeners();
81     boolean oneFailed = false;
82     Iterator JavaDoc iter = msgListeners.iterator();
83     while(iter.hasNext())
84     {
85       MessageListener msgListener = (MessageListener) iter.next();
86       String JavaDoc impl = msgListener.getActivationSpecClass();
87       Class JavaDoc implClass = null;
88       try
89       {
90         implClass = Class.forName(impl, false, getVerifierContext().getClassLoader());
91       }
92       catch(ClassNotFoundException JavaDoc e)
93       {
94         result.addErrorDetails(smh.getLocalString
95             ("tests.componentNameConstructor",
96              "For [ {0} ]",
97              new Object JavaDoc[] {compName.toString()}));
98         result.failed(smh.getLocalString
99             ("com.sun.enterprise.tools.verifier.tests.connector.messageinflow.nonexist",
100              "Error: The class [ {0} ] as defined under activationspec-class in the deployment descriptor does not exist",
101              new Object JavaDoc[] {impl}));
102         return result;
103       }
104       if(!isImplementorOf(implClass, "javax.resource.spi.ActivationSpec"))
105       {
106         oneFailed = true;
107         result.addErrorDetails(smh.getLocalString
108             ("tests.componentNameConstructor",
109              "For [ {0} ]",
110              new Object JavaDoc[] {compName.toString()}));
111         result.failed(smh.getLocalString(getClass().getName() + ".failed",
112               "Error: activationspec-class [ {0} ] does not implement javax.resource.spi.ActivationSpec.",
113               new Object JavaDoc[] {impl}));
114         return result;
115       }
116     }
117     if(!oneFailed)
118     {
119       result.addGoodDetails(smh.getLocalString
120           ("tests.componentNameConstructor",
121            "For [ {0} ]",
122            new Object JavaDoc[] {compName.toString()}));
123       result.passed(smh.getLocalString(getClass().getName() + ".passed",
124             "Success: all activationspec-class implement javax.resource.spi.ActivationSpec"));
125     }
126     return result;
127   }
128 }
129
Popular Tags