Examples of XMLContext


Examples of org.eclipse.persistence.oxm.XMLContext

        return createContext(classesToBeBound, properties, loader);
    }

    public static javax.xml.bind.JAXBContext createContext(Class[] classesToBeBound, java.util.Map properties, ClassLoader classLoader) throws JAXBException {
        javax.xml.bind.JAXBContext jaxbContext = null;
        XMLContext xmlContext = null;
        JaxbClassLoader loader = new JaxbClassLoader(classLoader);
        Generator generator = new Generator(new JavaModelInputImpl(classesToBeBound, new JavaModelImpl(loader)));
        try {
            Project proj = generator.generateProject();
            ConversionManager conversionManager = null;
            if (classLoader != null) {
                conversionManager = new ConversionManager();
                conversionManager.setLoader(loader);
            } else {
                conversionManager = ConversionManager.getDefaultManager();
            }
            // need to make sure that the java class is set properly on each
            // descriptor when using java classname - req'd for JOT api implementation
            for (Iterator<ClassDescriptor> descriptorIt = proj.getOrderedDescriptors().iterator(); descriptorIt.hasNext();) {
                ClassDescriptor descriptor = descriptorIt.next();
                if (descriptor.getJavaClass() == null) {
                    descriptor.setJavaClass(conversionManager.convertClassNameToClass(descriptor.getJavaClassName()));
                }
            }
            xmlContext = new XMLContext(proj, loader);
            jaxbContext = new org.eclipse.persistence.jaxb.JAXBContext(xmlContext, generator);
        } catch (Exception ex) {
            throw new JAXBException(ex);
        }
        return jaxbContext;

Examples of org.eclipse.persistence.oxm.XMLContext

    }

    public static javax.xml.bind.JAXBContext createContext(String contextPath, ClassLoader classLoader) throws JAXBException {
        try {
            XMLContext xmlContext = new XMLContext(contextPath, classLoader);
            return new org.eclipse.persistence.jaxb.JAXBContext(xmlContext);
        } catch (ValidationException vex) {
            if(vex.getErrorCode() != ValidationException.NO_SESSIONS_XML_FOUND) {
                //If something went wrong other than not finding a sessions.xml re-throw the exception
                throw new JAXBException(vex);

Examples of org.eclipse.persistence.oxm.XMLContext

                            XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform();
                            String url = xmlPlatform.resolveNamespacePrefix(next, prefix);
                            frag.setNamespaceURI(url);
                            schemaTypeQName = new QName(url, frag.getLocalName());
                        }
                        XMLContext xmlContext = nestedRecord.getUnmarshaller().getXMLContext();
                        referenceDescriptor = xmlContext.getDescriptorByGlobalType(frag);
                    }
                    if (referenceDescriptor == null) {
                        try {
                            QName qname = new QName(nestedRecord.getNamespaceURI(), nestedRecord.getLocalName());
                            referenceDescriptor = getDescriptor(nestedRecord, session, qname);

Examples of org.eclipse.persistence.oxm.XMLContext

    protected XMLDescriptor getDescriptor(XMLRecord xmlRecord, AbstractSession session, QName rootQName) throws XMLMarshalException {
        if (rootQName == null) {
            rootQName = new QName(xmlRecord.getNamespaceURI(), xmlRecord.getLocalName());
        }
        XMLContext xmlContext = xmlRecord.getUnmarshaller().getXMLContext();
        XMLDescriptor xmlDescriptor = xmlContext.getDescriptor(rootQName);
        if (null == xmlDescriptor) {
            throw XMLMarshalException.noDescriptorWithMatchingRootElement(xmlRecord.getLocalName());
        }
        return xmlDescriptor;
    }

Examples of org.eclipse.persistence.oxm.XMLContext

        }
        return container;
    }

    protected XMLDescriptor getDescriptor(XMLRecord xmlRecord, AbstractSession session) throws XMLMarshalException {
        XMLContext xmlContext = xmlRecord.getUnmarshaller().getXMLContext();
        QName rootQName = new QName(xmlRecord.getNamespaceURI(), xmlRecord.getLocalName());
        XMLDescriptor xmlDescriptor = xmlContext.getDescriptor(rootQName);
        if (null == xmlDescriptor) {
            throw XMLMarshalException.noDescriptorWithMatchingRootElement(xmlRecord.getLocalName());
        }
        return xmlDescriptor;
    }

Examples of org.eclipse.persistence.oxm.XMLContext

                }
            }

            XMLPlatform platform = new SAXPlatform();
            platform.getConversionManager().setLoader(loader);
            XMLContext xmlContext = new XMLContext((Project)proj, loader, sessionEventListeners());

            ((XMLLogin)xmlContext.getSession().getDatasourceLogin()).setEqualNamespaceResolvers(true);

          
            JAXBContextState contextState = new JAXBContextState(xmlContext, generator, typesToBeBound, properties);
           
            for(TypeMappingInfo typeMappingInfo : typesToBeBound) {

Examples of org.exolab.castor.xml.XMLContext

  public NamedQuery() throws Exception {
    Mapping mapping = new Mapping();
    InputSource input = new InputSource(getClass().getResourceAsStream("/com/jada/xml/query/NamedQueriesMapping.xml"));
    mapping.loadMapping(input);
   
    XMLContext context = new XMLContext();
    context.addMapping(mapping);
   
    InputStream stream = getClass().getResourceAsStream("/com/jada/xml/query/Query.xml");
      BufferedReader reader = new BufferedReader(new InputStreamReader(stream));

      Unmarshaller unmarshaller = context.createUnmarshaller();
      unmarshaller.setClass(NamedQueries.class);
     
      namedQueries = (NamedQueries) unmarshaller.unmarshal(reader);
  }

Examples of org.hibernate.cfg.annotations.reflection.XMLContext

  }

  protected JPAOverridenAnnotationReader getReader(Class<?> entityClass, String fieldName, String ormResourceName)
      throws Exception {
    AnnotatedElement el = getAnnotatedElement( entityClass, fieldName );
    XMLContext xmlContext = getContext( ormResourceName );
    JPAOverridenAnnotationReader reader = new JPAOverridenAnnotationReader( el, xmlContext );
    return reader;
  }

Examples of org.hibernate.reflection.java.xml.XMLContext

  public void testAll() throws Exception {
    XMLHelper xmlHelper = new XMLHelper();
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    InputStream is = cl.getResourceAsStream( "org/hibernate/test/reflection/java/xml/orm.xml" );
    assertNotNull( "ORM.xml not found", is );
    XMLContext context = new XMLContext();
    List errors = new ArrayList();
    SAXReader saxReader = xmlHelper.createSAXReader( "XML InputStream", errors, EJB3DTDEntityResolver.INSTANCE );
    //saxReader.setValidation( false );
    try {
      saxReader.setFeature( "http://apache.org/xml/features/validation/schema", true );
    }
    catch (SAXNotSupportedException e) {
      saxReader.setValidation( false );
    }
    org.dom4j.Document doc;
    try {
      doc = saxReader
          .read( new InputSource( new BufferedInputStream( is ) ) );
    }
    finally {
      try {
        is.close();
      }
      catch (IOException ioe) {
        //log.warn( "Could not close input stream", ioe );
      }
    }
    assertEquals( 0, errors.size() );
    context.addDocument( doc );
  }

Examples of org.teiid.query.processor.xml.XMLContext

public class TestXMLContext extends TestCase {
    static String resultSetName = "ResultSet"; //$NON-NLS-1$
   
    public void testGetCurrentRow() throws Exception{

        XMLContext context = new XMLContext();
       
        List[] rows = new List[] {
             Arrays.asList( new Object[] { "Lamp", new Integer(5), null } ),         //$NON-NLS-1$
             Arrays.asList( new Object[] { "Screwdriver", new Integer(100), null } ),         //$NON-NLS-1$
             Arrays.asList( new Object[] { "Goat", new Integer(4), null } )         //$NON-NLS-1$
        };
       
        FakePlanExecutor executor = new FakePlanExecutor(resultSetName, rows);
        context.setResultSet(resultSetName, executor);
       
        List currentRow = context.getCurrentRow(resultSetName);

        // this is only behaviour of the Fake Plan executor
        assertNull(currentRow);
       
        // move cursor forward
        currentRow = context.getNextRow(resultSetName);
        assertEquals(Arrays.asList( new Object[] { "Lamp", new Integer(5), null } ), currentRow); //$NON-NLS-1$
       
        // check the cursor again should be same as previous.
        currentRow = context.getCurrentRow(resultSetName);
        assertEquals(Arrays.asList( new Object[] { "Lamp", new Integer(5), null } ), currentRow); //$NON-NLS-1$
       
        // check the cursor 2nd again, make sure it is not moved
        currentRow = context.getCurrentRow(resultSetName);
        assertEquals(Arrays.asList( new Object[] { "Lamp", new Integer(5), null } ), currentRow); //$NON-NLS-1$
       
        // test remove
        context.removeResultSet(resultSetName);
        try {
            currentRow = context.getCurrentRow(resultSetName);
            fail("must have failed because the results are removed."); //$NON-NLS-1$
        }catch(TeiidComponentException e) {
        }
    }   
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.