KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > connectors > util > ResourceAdapterConfigParserImpl


1
2 /*
3  * The contents of this file are subject to the terms
4  * of the Common Development and Distribution License
5  * (the License). You may not use this file except in
6  * compliance with the License.
7  *
8  * You can obtain a copy of the license at
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
10  * glassfish/bootstrap/legal/CDDLv1.0.txt.
11  * See the License for the specific language governing
12  * permissions and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL
15  * Header Notice in each file and include the License file
16  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
17  * If applicable, add the following below the CDDL Header,
18  * with the fields enclosed by brackets [] replaced by
19  * you own identifying information:
20  * "Portions Copyrighted [year] [name of copyright owner]"
21  *
22  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23  */

24
25 package com.sun.enterprise.connectors.util;
26
27 import com.sun.enterprise.deployment.*;
28 import com.sun.enterprise.config.serverbeans.ElementProperty;
29 import com.sun.enterprise.connectors.*;
30 import com.sun.enterprise.util.*;
31 import com.sun.logging.LogDomains;
32 import java.util.logging.*;
33 import java.util.*;
34 import java.lang.*;
35 import java.lang.reflect.*;
36 import java.io.IOException JavaDoc;
37 import org.xml.sax.SAXParseException JavaDoc;
38
39 /**
40  * This is Resource Adapter configuration parser. It parses the
41  * ra.xml file for the Resources adapter javabean properties
42  *
43  * @author Srikanth P
44  *
45  */

46
47 public class ResourceAdapterConfigParserImpl implements ConnectorConfigParser {
48
49     static Logger _logger = LogDomains.getLogger(LogDomains.RSR_LOGGER);
50     
51     /**
52      * Default constructor.
53      *
54      */

55
56     public ResourceAdapterConfigParserImpl() {
57
58     }
59
60     /** Parses the ra.xml for the Resource Adapter javabean properties.
61      * Here the second parameter connectionDefName is not used and can
62      * be null or any value.
63      *
64      * It throws ConnectorRuntimeException if module dir is null or
65      * corresponing rar is not deployed i.e invalid moduleDir parameter.
66      *
67      * @param desc ConnectorDescriptor pertaining to rar.
68      * @param Not used. Can be null or any value,
69      * @return Javabean properties with the propety names and values
70      * of propeties. The property values will be the values
71      * mentioned in ra.xml if present. Otherwise it will be the
72      * default values obtained by introspecting the javabean.
73      * In both the case if no value is present, empty String is
74      * returned as the value.
75      * @throws ConnectorRuntimeException if moduleDir is null .
76      * If corresponding rar is not deployed i.e moduleDir is invalid.
77      */

78
79     public Properties getJavaBeanProps(ConnectorDescriptor desc,
80               String JavaDoc connectionDefName, String JavaDoc rarName) throws ConnectorRuntimeException
81     {
82
83         if(desc == null) {
84             throw new ConnectorRuntimeException("Invalid arguments");
85         }
86
87         /* ddVals -> Properties present in ra.xml
88         * introspectedVals -> All properties with values
89         * obtained by introspection of resource
90         * adapter javabean
91         * mergedVals -> merged props of raConfigPros and
92         * allraConfigPropsWithDefVals
93         */

94
95         Set ddVals = desc.getConfigProperties();
96         Properties mergedVals = null;
97         String JavaDoc className = desc.getResourceAdapterClass();
98         Properties introspectedVals = null;
99         if(className != null && className.length() != 0) {
100             introspectedVals=configParserUtil.introspectJavaBean(
101                                        className,ddVals);
102             mergedVals = configParserUtil.mergeProps(ddVals,introspectedVals);
103         }
104         return mergedVals;
105     }
106
107 }
108
Popular Tags