KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > webservice > deployment > MetaDataRegistry


1 /**
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.webservice.deployment;
8
9 // $Id: MetaDataRegistry.java,v 1.2.4.3 2004/11/17 10:51:34 tdiesler Exp $
10

11 import org.jboss.logging.Logger;
12
13 import javax.xml.namespace.QName JavaDoc;
14 import java.util.HashMap JavaDoc;
15
16 /**
17  * A registry that holds typeMapping child elements.
18  * <p/>
19  * For example the ws4ee-deployment.xml may contain a typeMapping like this, then
20  * the <typeDesc> element will be registered under the qname {http://MarshallTest.org/xsd}AllStruct
21  * <p/>
22  * <typeMapping
23  * qname='ns1:AllStruct' xmlns:ns1='http://MarshallTest.org/xsd'
24  * type='java:org.jboss.ws4ee.test.marshalltest.rpcenc.AllStruct'
25  * serializer='org.jboss.ws4ee.test.marshalltest.rpcenc.ser.AllStructSerializerFactory'
26  * deserializer='org.jboss.ws4ee.test.marshalltest.rpcenc.ser.AllStructDeserializerFactory'
27  * encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
28  * <typeDesc >
29  * <elementDesc fieldName="varBase64Binary" xmlName="varBase64Binary" xmlType="xsd:base64Binary"/>
30  * <elementDesc fieldName="varHexBinary" xmlName="varHexBinary" xmlType="xsd:hexBinary"/>
31  * <elementDesc fieldName="varSoapString" xmlName="varSoapString" xmlType="soapenc:string"/>
32  * <elementDesc fieldName="varSoapBoolean" xmlName="varSoapBoolean" xmlType="soapenc:boolean"/>
33  * <elementDesc fieldName="varSoapFloat" xmlName="varSoapFloat" xmlType="soapenc:float"/>
34  * <elementDesc fieldName="varSoapDouble" xmlName="varSoapDouble" xmlType="soapenc:double"/>
35  * <elementDesc fieldName="varSoapDecimal" xmlName="varSoapDecimal" xmlType="soapenc:decimal"/>
36  * <elementDesc fieldName="varSoapInt" xmlName="varSoapInt" xmlType="soapenc:int"/>
37  * <elementDesc fieldName="varSoapShort" xmlName="varSoapShort" xmlType="soapenc:short"/>
38  * <elementDesc fieldName="varSoapByte" xmlName="varSoapByte" xmlType="soapenc:byte"/>
39  * <elementDesc fieldName="varSoapBase64" xmlName="varSoapBase64" xmlType="soapenc:base64"/>
40  * </typeDesc>
41  * </typeMapping>
42  *
43  * @author thomas.diesler@jboss.org
44  * @since 08-June-2004
45  */

46 public class MetaDataRegistry
47 {
48    // provide logging
49
private final Logger log = Logger.getLogger(MetaDataRegistry.class);
50
51    private HashMap JavaDoc typeMappingMetaData = new HashMap JavaDoc();
52
53    public void registerTypeMappingMetaData(TypeMappingDescription typeMapping)
54    {
55       QName JavaDoc qname = typeMapping.getTypeQName();
56       BeanXMLMetaData metaData = typeMapping.getMetaData();
57       if (metaData == null)
58          throw new IllegalArgumentException JavaDoc("Cannot register null meta data");
59
60       if (isTypeMappingMetaDataRegisterd(qname) == false || typeMapping.isUserDefined())
61       {
62          log.debug("Register type mapping meta data for: " + qname);
63          typeMappingMetaData.put(qname, metaData);
64       }
65       else
66       {
67          log.debug("Ignore register type mapping meta data for: " + qname);
68       }
69    }
70
71    public BeanXMLMetaData getTypeMappingMetaData(QName JavaDoc typeName)
72    {
73       return (BeanXMLMetaData)typeMappingMetaData.get(typeName);
74    }
75
76    public boolean isTypeMappingMetaDataRegisterd(QName JavaDoc typeName)
77    {
78       return typeMappingMetaData.get(typeName) != null;
79    }
80
81    public void unregisterTypeMappingMetaData(QName JavaDoc typeName)
82    {
83       typeMappingMetaData.remove(typeName);
84    }
85 }
86
Popular Tags