KickJava   Java API By Example, From Geeks To Geeks.

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


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  * TransactionSupport.java
25  *
26  * Created on September 20, 2000, 9:29 AM
27  */

28
29 package com.sun.enterprise.tools.verifier.tests.connector;
30
31 import com.sun.enterprise.tools.verifier.Result;
32 import com.sun.enterprise.deployment.ConnectorDescriptor;
33 import com.sun.enterprise.tools.verifier.tests.*;
34 import com.sun.enterprise.deployment.xml.ConnectorTagNames;
35
36 /**
37  * Verify that the Transaction Support for the ressource adapter is of an
38  * acceptable value
39  *
40  * @author Jerome Dochez
41  * @version
42  */

43 public class TransactionSupport extends ConnectorTest implements ConnectorCheck {
44
45     private final String JavaDoc[] acceptableValues = {
46         ConnectorTagNames.DD_NO_TRANSACTION,
47         ConnectorTagNames.DD_LOCAL_TRANSACTION,
48         ConnectorTagNames.DD_XA_TRANSACTION };
49                     
50     /**
51      * <p>
52      * Verifier test implementation. Check for the transaction-support
53      * deployment field which should be one of the acceptable values :
54      * NoTransaction
55      * LocalTransaction
56      * XATransaction
57      * </p>
58      *
59      * @param <code>ConnectorDescritor</code>The deployment descriptor for
60      * the connector.
61      * @return <code>Result</code> Code execution result
62      */

63     public Result check(ConnectorDescriptor descriptor) {
64         
65         Result result = getInitializedResult();
66     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
67         if(!descriptor.getOutBoundDefined())
68         {
69           result.addNaDetails(smh.getLocalString
70               ("tests.componentNameConstructor",
71                "For [ {0} ]",
72                new Object JavaDoc[] {compName.toString()}));
73           result.notApplicable(smh.getLocalString
74               ("com.sun.enterprise.tools.verifier.tests.connector.managed.notApplicableForInboundRA",
75                "Resource Adapter does not provide outbound communication"));
76           return result;
77         }
78         String JavaDoc connectorTransactionSupport =
79         descriptor.getOutboundResourceAdapter().getTransSupport();
80         
81         // No transaction support specified, this is an error
82
if (connectorTransactionSupport==null) {
83         result.addErrorDetails(smh.getLocalString
84                    ("tests.componentNameConstructor",
85                     "For [ {0} ]",
86                     new Object JavaDoc[] {compName.toString()}));
87         result.failed(smh.getLocalString
88               (getClass().getName() + ".nonexist",
89                "Error: No Transaction support specified for ressource adapter",
90                new Object JavaDoc[] {connectorTransactionSupport}));
91             return result;
92         }
93         
94         // let's loop over all acceptable values to check the declared one is valid
95
for (int i=0;i<acceptableValues.length;i++) {
96             if (connectorTransactionSupport.equals(acceptableValues[i])) {
97                     
98                 // Test passed, we found an acceptable value
99
result.addGoodDetails(smh.getLocalString
100                        ("tests.componentNameConstructor",
101                     "For [ {0} ]",
102                     new Object JavaDoc[] {compName.toString()}));
103         result.passed(smh.getLocalString
104                 (getClass().getName() + ".passed",
105                     "Transaction support [ {0} ] for ressource adapter is supported",
106                 new Object JavaDoc[] {connectorTransactionSupport}));
107                return result;
108             }
109         }
110         
111         // If we end up here, we haven't found an acceptable transaction support
112
result.addErrorDetails(smh.getLocalString
113                        ("tests.componentNameConstructor",
114                     "For [ {0} ]",
115                     new Object JavaDoc[] {compName.toString()}));
116     result.failed(smh.getLocalString
117            (getClass().getName() + ".failed",
118                 "Error: Deployment descriptor transaction-support [ {0} ] for ressource adapter is not valid",
119         new Object JavaDoc[] {connectorTransactionSupport}));
120         return result;
121     }
122 }
123
Popular Tags