KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > appclient > PUTransactionType


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.appclient;
26
27 import com.sun.enterprise.deployment.ApplicationClientDescriptor;
28 import com.sun.enterprise.deployment.BundleDescriptor;
29 import com.sun.enterprise.deployment.Descriptor;
30 import com.sun.enterprise.deployment.EntityManagerFactoryReferenceDescriptor;
31 import com.sun.enterprise.deployment.EntityManagerReferenceDescriptor;
32 import com.sun.enterprise.deployment.Application;
33 import com.sun.enterprise.deployment.PersistenceUnitDescriptor;
34 import com.sun.enterprise.deployment.PersistenceUnitsDescriptor;
35 import com.sun.enterprise.tools.verifier.tests.VerifierCheck;
36 import com.sun.enterprise.tools.verifier.tests.VerifierTest;
37 import com.sun.enterprise.tools.verifier.Result;
38 import java.util.List JavaDoc;
39 import java.util.ArrayList JavaDoc;
40 import java.net.URI JavaDoc;
41 import java.net.URISyntaxException JavaDoc;
42
43 /**
44  * Assertions :
45  *
46  * 1) A persistence unit with JTA transaction type is not supported in application client.
47  * 2) Reference to a PU whose transaction type is JTA is not supported in application client.
48  *
49  * @author bshankar@sun.com
50  */

51
52 public class PUTransactionType extends VerifierTest implements VerifierCheck {
53     
54     public Result check(Descriptor descriptor) {
55         ApplicationClientDescriptor appClient = (ApplicationClientDescriptor) descriptor;
56         Result result = getInitializedResult();
57         addErrorDetails(result, getVerifierContext().getComponentNameConstructor());
58         result.setStatus(Result.PASSED); // default status is PASSED
59

60         for(PersistenceUnitsDescriptor pus : appClient.getPersistenceUnitsDescriptors()) {
61             for(PersistenceUnitDescriptor nextPU : pus.getPersistenceUnitDescriptors()) {
62                 if("JTA".equals(nextPU.getTransactionType())) {
63                     result.failed(smh.getLocalString(getClass().getName() + ".puName",
64                             "Found a persistence unit by name [ {0} ] in persistence unit root [ {1} ] with JTA transaction type.",
65                             new Object JavaDoc[]{nextPU.getName(), nextPU.getPuRoot()}));
66                 }
67             }
68         }
69         
70         for(EntityManagerFactoryReferenceDescriptor emfRef : appClient.getEntityManagerFactoryReferenceDescriptors()) {
71             String JavaDoc unitName = emfRef.getUnitName();
72             PersistenceUnitDescriptor nextPU = appClient.findReferencedPU(unitName);
73             if(nextPU == null) continue;
74             if("JTA".equals(nextPU.getTransactionType())) {
75                 result.failed(smh.getLocalString(getClass().getName() + ".puRefName",
76                         "Found a reference to a persistence unit by name [ {0} ] in persistence unit root [ {1} ] with JTA transaction type.",
77                         new Object JavaDoc[]{nextPU.getName(), nextPU.getPuRoot()}));
78             }
79         }
80         
81         return result;
82     }
83     
84 }
85
Popular Tags