Package org.eclipse.persistence.jaxb

Examples of org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput


     * @see org.eclipse.persistence.oxm.XMLContext
     * @throws IllegalArgumentException
     */
    public static <T> T unwrap(javax.xml.bind.JAXBContext jaxbContext, Class<T> clazz) throws IllegalArgumentException {
        try {
            JAXBContext jaxbContextImpl = (JAXBContext) jaxbContext;
            if (clazz == org.eclipse.persistence.jaxb.JAXBContext.class) {
                return (T) jaxbContextImpl;
            }
            if (clazz == XMLContext.class) {
                return (T) jaxbContextImpl.getXMLContext();
            }
            throw new IllegalArgumentException(ExceptionLocalization
                    .buildMessage("jaxb_helper_invalid_target_for_jaxbcontext", new Object[] { clazz }));
        } catch (ClassCastException e) {
            throw new IllegalArgumentException(ExceptionLocalization
View Full Code Here


        return Status.BAD_REQUEST;
    }

    private String marshallErrorResponse(ErrorResponse errorResponse, String mediaType) {
        try {
            JAXBContext context = (JAXBContext) JAXBContextFactory.createContext(new Class[] { ErrorResponse.class }, null);
            Marshaller marshaller = context.createMarshaller();

            marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, mediaType);
            marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, Boolean.FALSE);
            marshaller.setProperty(MarshallerProperties.JSON_REDUCE_ANY_ARRAYS, true);
View Full Code Here

     * Create a JAXBContext based on the EntityManagerFactory for this PersistenceContext.
     * @param session
     * @return
     */
    protected JAXBContext createDynamicJAXBContext(AbstractSession session) throws JAXBException, IOException {
        JAXBContext jaxbContext = (JAXBContext) session.getProperty(JAXBContext.class.getName());
        if (jaxbContext != null) {
            return jaxbContext;
        }

        Map<String, Object> properties = createJAXBProperties(session);
View Full Code Here

     * @return the string
     * @throws JAXBException the jAXB exception
     */
    protected String marshallMetadata(Object metadata, String mediaType) throws JAXBException {
        Class<?>[] jaxbClasses = new Class[] { Link.class, Attribute.class, Descriptor.class, LinkTemplate.class, PersistenceUnit.class, Query.class, LinkList.class, QueryList.class };
        JAXBContext context = (JAXBContext) JAXBContextFactory.createContext(jaxbClasses, null);
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, Boolean.FALSE);
        marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, mediaType);
        marshaller.setProperty(MarshallerProperties.JSON_REDUCE_ANY_ARRAYS, true);

        StringWriter writer = new StringWriter();
View Full Code Here

            xsdQName = sdoType.getQName();
        }
        listWrappers = new WeakHashMap<Property, ListWrapper>();
        XPathFragment xPathFragment = new XPathFragment(xsdQName.getLocalPart());
        xPathFragment.setNamespaceURI(xsdQName.getNamespaceURI());
        JAXBContext jaxbContext = (JAXBContext) jaxbHelperContext.getJAXBContext();
        this.descriptor = jaxbContext.getXMLContext().getDescriptorByGlobalType(xPathFragment);
        if (null == this.descriptor) {
            this.descriptor = jaxbContext.getXMLContext().getDescriptor(xsdQName);
            if (null == this.descriptor) {
                throw SDOException.sdoJaxbNoDescriptorForType(sdoType.getQName(), xsdQName);
            }
        }
        this.entity = descriptor.getInstantiationPolicy().buildNewInstance();
View Full Code Here

    }

    public JAXBValueStore(JAXBHelperContext aJAXBHelperContext, Object anEntity) {
        this.jaxbHelperContext = aJAXBHelperContext;
        this.listWrappers = new WeakHashMap<Property, ListWrapper>();
        JAXBContext jaxbContext = (JAXBContext) jaxbHelperContext.getJAXBContext();
        this.descriptor = (XMLDescriptor) jaxbContext.getXMLContext().getSession(anEntity).getDescriptor(anEntity);
        this.entity = anEntity;
    }
View Full Code Here

    public JAXBListWrapper(JAXBValueStore theJAXBValueStore, SDOProperty theProperty) {
        super(theJAXBValueStore.getDataObject(), theProperty);

        this.jaxbValueStore = theJAXBValueStore;
        JAXBContext jaxbContext = (JAXBContext) jaxbValueStore.getJAXBHelperContext().getJAXBContext();
        this.session = jaxbContext.getXMLContext().getSession(jaxbValueStore.getEntity().getClass());
        this.mapping = jaxbValueStore.getJAXBMappingForProperty(theProperty);
        this.containerPolicy = mapping.getContainerPolicy();
        this.elements = mapping.getAttributeValueFromObject(jaxbValueStore.getEntity());
        if(this.elements == null) {
            this.elements = containerPolicy.containerInstance();
View Full Code Here

        return Status.BAD_REQUEST;
    }

    private String marshallErrorResponse(ErrorResponse errorResponse, String mediaType) {
        try {
            JAXBContext context = (JAXBContext) JAXBContextFactory.createContext(new Class[] { ErrorResponse.class }, null);
            Marshaller marshaller = context.createMarshaller();

            marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, mediaType);
            marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, Boolean.FALSE);
            marshaller.setProperty(MarshallerProperties.JSON_REDUCE_ANY_ARRAYS, true);
View Full Code Here

        }
    }

    private SessionBeanCall unmarshallSessionBeanCall(InputStream data) throws JAXBException {
        Class<?>[] jaxbClasses = new Class[] { SessionBeanCall.class };
        JAXBContext context = (JAXBContext) JAXBContextFactory.createContext(jaxbClasses, null);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, Boolean.FALSE);
        unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, MediaType.APPLICATION_JSON);
        StreamSource ss = new StreamSource(data);
        return unmarshaller.unmarshal(ss, SessionBeanCall.class).getValue();
    }
View Full Code Here

     * @return the string
     * @throws JAXBException the jAXB exception
     */
    protected String marshallMetadata(Object metadata, String mediaType) throws JAXBException {
        Class<?>[] jaxbClasses = new Class[] { Link.class, Attribute.class, Descriptor.class, LinkTemplate.class, PersistenceUnit.class, Query.class, LinkList.class, QueryList.class };
        JAXBContext context = (JAXBContext) JAXBContextFactory.createContext(jaxbClasses, null);
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, Boolean.FALSE);
        marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, mediaType);
        marshaller.setProperty(MarshallerProperties.JSON_REDUCE_ANY_ARRAYS, true);

        StringWriter writer = new StringWriter();
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput

Copyright © 2018 www.massapicom. 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.