Home » geronimo-eclipse-plugin-2.2-source-release » org.apache.geronimo.st.core.jaxb » [javadoc | source]

    1   /**
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   
   18   package org.apache.geronimo.st.core.jaxb;
   19   
   20   import java.util.HashMap;
   21   import java.util.Map;
   22   
   23   import org.apache.geronimo.st.core.internal.Trace;
   24   import org.xml.sax.Attributes;
   25   import org.xml.sax.SAXException;
   26   import org.xml.sax.XMLReader;
   27   import org.xml.sax.helpers.XMLFilterImpl;
   28   
   29   /**
   30    * <strong>NamespaceFilter</strong> is used to filter out older versions (e.g., 
   31    * v1.1) of Geronimo namespaces and replace them with the more current versions 
   32    * (e.g., v2.1)<p>
   33    * 
   34    * If this class changes, then the test version in org.apache.geronimo.jee.common
   35    * need to be updated to be kept in sync
   36    * 
   37    * @version $Rev: 671363 $ $Date: 2008-06-25 06:02:37 +0800 (Wed, 25 Jun 2008) $
   38    */
   39   public class NamespaceFilter extends XMLFilterImpl {
   40   
   41       private static Map<String, String> namespace = new HashMap<String, String>();
   42   
   43       static {
   44           // 
   45           // Convert old deployment namespaces
   46           // 
   47           namespace.put("http://geronimo.apache.org/xml/ns/deployment", 
   48                         "http://geronimo.apache.org/xml/ns/deployment-1.2");
   49           namespace.put("http://geronimo.apache.org/xml/ns/deployment-1.0", 
   50                         "http://geronimo.apache.org/xml/ns/deployment-1.2");
   51           namespace.put("http://geronimo.apache.org/xml/ns/deployment-1.1", 
   52                         "http://geronimo.apache.org/xml/ns/deployment-1.2");
   53   
   54           // 
   55           // Convert old application namespaces
   56           // 
   57           namespace.put("http://geronimo.apache.org/xml/ns/j2ee/application", 
   58                         "http://geronimo.apache.org/xml/ns/j2ee/application-2.0");
   59           namespace.put("http://geronimo.apache.org/xml/ns/j2ee/application-1.1", 
   60                         "http://geronimo.apache.org/xml/ns/j2ee/application-2.0");
   61           namespace.put("http://geronimo.apache.org/xml/ns/j2ee/application-1.2", 
   62                         "http://geronimo.apache.org/xml/ns/j2ee/application-2.0");
   63   
   64           // 
   65           // Convert old application-client namespaces
   66           // 
   67           namespace.put("http://geronimo.apache.org/xml/ns/j2ee/application-client", 
   68                         "http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0");
   69           namespace.put("http://geronimo.apache.org/xml/ns/j2ee/application-client-1.2", 
   70                         "http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0");
   71           namespace.put("http://geronimo.apache.org/xml/ns/j2ee/application-client-1.1", 
   72                         "http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0");
   73   
   74           // 
   75           // Convert old connector namespaces
   76           // 
   77           namespace.put("http://geronimo.apache.org/xml/ns/j2ee/connector", 
   78                         "http://geronimo.apache.org/xml/ns/j2ee/connector-1.2");
   79           namespace.put("http://geronimo.apache.org/xml/ns/j2ee/connector-1.0", 
   80                         "http://geronimo.apache.org/xml/ns/j2ee/connector-1.2");
   81           namespace.put("http://geronimo.apache.org/xml/ns/j2ee/connector-1.1", 
   82                         "http://geronimo.apache.org/xml/ns/j2ee/connector-1.2");
   83   
   84           // 
   85           // Convert old web namespaces
   86           // 
   87           namespace.put("http://geronimo.apache.org/xml/ns/j2ee/web", 
   88                         "http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1");
   89           namespace.put("http://geronimo.apache.org/xml/ns/j2ee/web-1.0", 
   90                         "http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1");
   91           namespace.put("http://geronimo.apache.org/xml/ns/j2ee/web-1.1", 
   92                         "http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1");
   93           namespace.put("http://geronimo.apache.org/xml/ns/j2ee/web-1.2", 
   94                         "http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1");
   95           namespace.put("http://geronimo.apache.org/xml/ns/j2ee/web-2.0", 
   96                         "http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1");
   97   
   98           // 
   99           // Convert old naming namespaces
  100           // 
  101           namespace.put("http://geronimo.apache.org/xml/ns/naming", 
  102                         "http://geronimo.apache.org/xml/ns/naming-1.2");
  103           namespace.put("http://geronimo.apache.org/xml/ns/naming-1.0", 
  104                         "http://geronimo.apache.org/xml/ns/naming-1.2");
  105           namespace.put("http://geronimo.apache.org/xml/ns/naming-1.1", 
  106                         "http://geronimo.apache.org/xml/ns/naming-1.2");
  107   
  108           // 
  109           // Convert old security namespaces
  110           // 
  111           namespace.put("http://geronimo.apache.org/xml/ns/security", 
  112                         "http://geronimo.apache.org/xml/ns/security-2.0");
  113           namespace.put("http://geronimo.apache.org/xml/ns/security-1.1", 
  114                         "http://geronimo.apache.org/xml/ns/security-2.0");
  115           namespace.put("http://geronimo.apache.org/xml/ns/security-1.2", 
  116                         "http://geronimo.apache.org/xml/ns/security-2.0");
  117   
  118           // 
  119           // Convert old openejb-jar namespaces 
  120           // 
  121           namespace.put("http://www.openejb.org/xml/ns/openejb-jar", 
  122                         "http://openejb.apache.org/xml/ns/openejb-jar-2.2");
  123           namespace.put("http://www.openejb.org/xml/ns/openejb-jar-2.1", 
  124                         "http://openejb.apache.org/xml/ns/openejb-jar-2.2");
  125           namespace.put("http://www.openejb.org/xml/ns/openejb-jar-2.2", 
  126                         "http://openejb.apache.org/xml/ns/openejb-jar-2.2");
  127           namespace.put("http://www.openejb.org/xml/ns/openejb-jar-2.3", 
  128                         "http://openejb.apache.org/xml/ns/openejb-jar-2.2");
  129           namespace.put("http://www.openejb.org/xml/ns/pkgen", 
  130                         "http://openejb.apache.org/xml/ns/pkgen-2.1");
  131           namespace.put("http://www.openejb.org/xml/ns/pkgen-2.0",
  132                         "http://openejb.apache.org/xml/ns/pkgen-2.1");
  133       }
  134   
  135       public NamespaceFilter(XMLReader xmlReader) {
  136           super(xmlReader);
  137           Trace.tracePoint("Constructor", "NamespaceFilter", xmlReader);
  138       }
  139   
  140       public void startElement(String uri, String localName, String qname, Attributes atts) throws SAXException {
  141           Trace.tracePoint("Entry", "NamespaceFilter.startElement", uri, localName, qname, atts);
  142   
  143           if (namespace.containsKey( uri )) {
  144               uri = namespace.get( uri );
  145           }
  146   
  147           Trace.tracePoint("Exit ", "NamespaceFilter.startElement", uri, localName, qname, atts);
  148           super.startElement(uri, localName, qname, atts);
  149       }
  150   }

Home » geronimo-eclipse-plugin-2.2-source-release » org.apache.geronimo.st.core.jaxb » [javadoc | source]