KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > clientbeans > ClientBeansResolver


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 package com.sun.enterprise.config.clientbeans;
25
26 import org.xml.sax.helpers.DefaultHandler JavaDoc;
27 import org.xml.sax.SAXParseException JavaDoc;
28 import org.xml.sax.InputSource JavaDoc;
29 import org.xml.sax.SAXException JavaDoc;
30 import java.io.FileInputStream JavaDoc;
31 import java.io.File JavaDoc;
32 import java.io.InputStream JavaDoc;
33
34 import java.util.logging.Logger JavaDoc;
35 import java.util.logging.Level JavaDoc;
36
37 //The RelativePathResolver is used to translate relative paths containing
38
//embedded system properties (e.g. ${com.sun.aas.instanceRoot}/applications)
39
//into absolute paths
40
import com.sun.enterprise.util.RelativePathResolver;
41
42 public class ClientBeansResolver extends DefaultHandler JavaDoc {
43
44        
45     public static final String JavaDoc SUN_ACC_DTD_PATH =
46         "/sun-application-client-container_1_2.dtd";
47     
48   
49     //===========================================================
50
// Resolver methods
51
//===========================================================
52

53     public InputSource JavaDoc resolveEntity(String JavaDoc publicID, String JavaDoc systemID)
54       throws SAXException JavaDoc {
55         InputSource JavaDoc is = null;
56         try {
57             InputStream JavaDoc i = this.getClass().getResourceAsStream(SUN_ACC_DTD_PATH );
58             if( i!= null ) {
59             return new InputSource JavaDoc(i);
60             }
61             is = new InputSource JavaDoc(
62                new FileInputStream JavaDoc(
63                new File JavaDoc(new java.net.URI JavaDoc(
64                    RelativePathResolver.resolvePath(systemID)))));
65         } catch(Exception JavaDoc e) {
66             throw new SAXException JavaDoc("Cannot resolve ", e);
67         }
68         return is;
69     }
70 }
71
72
73
74
Popular Tags