JaxbTypeFactory.java
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one
00003  * or more contributor license agreements.  See the NOTICE file
00004  * distributed with this work for additional information
00005  * regarding copyright ownership.  The ASF licenses this file
00006  * to you under the Apache License, Version 2.0 (the
00007  * "License"); you may not use this file except in compliance
00008  * with the License.  You may obtain a copy of the License at
00009  *
00010  *   http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing,
00013  * software distributed under the License is distributed on an
00014  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00015  * KIND, either express or implied.  See the License for the
00016  * specific language governing permissions and limitations
00017  * under the License.    
00018  */
00019 package org.apache.xmlrpc.jaxb;
00020 
00021 import javax.xml.bind.Element;
00022 import javax.xml.bind.JAXBContext;
00023 
00024 import org.apache.ws.commons.util.NamespaceContextImpl;
00025 import org.apache.xmlrpc.common.TypeFactoryImpl;
00026 import org.apache.xmlrpc.common.XmlRpcController;
00027 import org.apache.xmlrpc.common.XmlRpcStreamConfig;
00028 import org.apache.xmlrpc.parser.TypeParser;
00029 import org.apache.xmlrpc.serializer.TypeSerializer;
00030 import org.apache.xmlrpc.serializer.XmlRpcWriter;
00031 import org.xml.sax.SAXException;
00032 
00033 
00036 public class JaxbTypeFactory extends TypeFactoryImpl {
00037         private final JAXBContext context;
00038         private final JaxbSerializer serializer; 
00039 
00046         public JaxbTypeFactory(XmlRpcController pController, JAXBContext pContext) {
00047                 super(pController);
00048                 context = pContext;
00049                 serializer = new JaxbSerializer(context);
00050         }
00051 
00052         public TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI, String pLocalName) {
00053                 TypeParser tp = super.getParser(pConfig, pContext, pURI, pLocalName);
00054                 if (tp == null) {
00055                         if (XmlRpcWriter.EXTENSIONS_URI.equals(pURI)  &&  JaxbSerializer.JAXB_TAG.equals(pLocalName)) {
00056                                 return new JaxbParser(context);
00057                         }
00058                 }
00059                 return tp;
00060         }
00061 
00062         public TypeSerializer getSerializer(XmlRpcStreamConfig pConfig, Object pObject) throws SAXException {
00063                 TypeSerializer ts = super.getSerializer(pConfig, pObject);
00064                 if (ts == null) {
00065                         if (pObject instanceof Element) {
00066                                 return serializer;
00067                         }
00068                 }
00069                 return ts;
00070         }
00071 }


rosjava_core
Author(s):
autogenerated on Wed Aug 26 2015 16:06:49