KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > io > PersistenceDeploymentDescriptorFile


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.deployment.io;
26
27 import com.sun.enterprise.deployment.node.RootXMLNode;
28 import com.sun.enterprise.deployment.node.PersistenceNode;
29 import com.sun.enterprise.deployment.*;
30
31 /**
32  * @author Sanjeeb.Sahoo@Sun.COM
33  */

34 public class PersistenceDeploymentDescriptorFile extends DeploymentDescriptorFile {
35     public String JavaDoc getDeploymentDescriptorPath() {
36         return DescriptorConstants.PERSISTENCE_DD_ENTRY;
37     }
38
39     public RootXMLNode getRootXMLNode(Descriptor descriptor) {
40         // This method is called from SaxParserHandler.startElement() method
41
// as well as DeploymentDescriptorFile.getDefaultSchemaSource().
42
// When it is called from former method, descriptor is non-null,
43
// but when it is called later method, descriptor is null.
44
if(descriptor==null ||
45                 descriptor instanceof Application ||
46                 descriptor instanceof ApplicationClientDescriptor ||
47                 descriptor instanceof EjbBundleDescriptor ||
48                 descriptor instanceof WebBundleDescriptor) {
49             return new PersistenceNode(new PersistenceUnitsDescriptor());
50         } else {
51             throw new IllegalArgumentException JavaDoc(descriptor.getClass().getName()+
52                     "is not allowed to contain persistence.xml file");
53         }
54     }
55
56     /**
57      * The returned string is used to set up the schema location in SaxParser.
58      * @return returns a string with format similar to what is used in
59      * schemaLocation attribute in XML docs. i.e. it returns a list of pairs,
60      * where each pair consists of a namespace and url pointing to the schema
61      * doc.
62      */

63     @Override JavaDoc protected String JavaDoc getDefaultSchemaSource() {
64         // This method is overridden because the implementation in
65
// super class is not correctly implemented. See bug#6340561
66
PersistenceNode rootXMLNode =
67                 PersistenceNode.class.cast(getRootXMLNode(null));
68         return rootXMLNode.getNameSpace() + " " + rootXMLNode.getSystemID();
69     }
70 }
71
Popular Tags