Package javax.activation

Examples of javax.activation.DataContentHandler


                .trace("Could not find a writer for {} and {}. Try to find JAF DataSourceProvider", //$NON-NLS-1$
                       entity.getClass().getName(),
                       responseMediaType);
        }

        DataContentHandler dataContentHandler = null;
        // Write Entity with ASF DataContentHandler

        // try to find a data handler using JavaBeans Activation Framework, if
        // found use DataSourceProvider
        dataContentHandler =
            CommandMap
                .getDefaultCommandMap()
                .createDataContentHandler(responseMediaType.getType() + "/" + responseMediaType.getSubtype()); //$NON-NLS-1$
        if (dataContentHandler == null) {
            if (logger.isErrorEnabled()) {
                logger.error(Messages.getMessage("noWriterOrDataSourceProvider", entity.getClass() //$NON-NLS-1$
                    .getName(), responseMediaType));
            }
            throw new WebApplicationException(500);
        }

        if (logger.isTraceEnabled()) {
            logger
                .trace("Serialization using data content handler {}", dataContentHandler.getClass() //$NON-NLS-1$
                    .getName());
        }

        FlushHeadersOutputStream outputStream =
            new FlushHeadersOutputStream(httpResponse, httpHeaders, responseMediaType);
        if (logger.isTraceEnabled()) {
            logger.trace("{}@{}.writeTo({}, {}, {}) being called", new Object[] { //$NON-NLS-1$
                         dataContentHandler.getClass().getName(),
                             Integer.toHexString(System.identityHashCode(dataContentHandler)),
                             entity, responseMediaType.toString(), outputStream});
        }
        dataContentHandler
            .writeTo(entity,
                     responseMediaType.getType() + "/" + responseMediaType.getSubtype(), outputStream); //$NON-NLS-1$
        logger.trace("Flushing headers if not written"); //$NON-NLS-1$
        outputStream.flushHeaders();
    }
View Full Code Here


   
    static final class EnhancedMailcapCommandMap extends MailcapCommandMap {
        @Override
        public synchronized DataContentHandler createDataContentHandler(
                String mimeType) {
            DataContentHandler dch = super.createDataContentHandler(mimeType);
            if (dch == null) {
                dch = DEFAULT_COMMAND_MAP.createDataContentHandler(mimeType);
            }
            return dch;
        }
View Full Code Here

        }

        @Override
        public DataContentHandler createDataContentHandler(String mimeType,
                DataSource ds) {
            DataContentHandler dch = super.createDataContentHandler(mimeType);
            if (dch == null) {
                dch = DEFAULT_COMMAND_MAP.createDataContentHandler(mimeType, ds);
            }
            return dch;
        }
View Full Code Here

   
    static final class EnhancedMailcapCommandMap extends MailcapCommandMap {
        @Override
        public synchronized DataContentHandler createDataContentHandler(
                String mimeType) {
            DataContentHandler dch = super.createDataContentHandler(mimeType);
            if (dch == null) {
                dch = DEFAULT_COMMAND_MAP.createDataContentHandler(mimeType);
            }
            return dch;
        }
View Full Code Here

        }

        @Override
        public DataContentHandler createDataContentHandler(String mimeType,
                DataSource ds) {
            DataContentHandler dch = super.createDataContentHandler(mimeType);
            if (dch == null) {
                dch = DEFAULT_COMMAND_MAP.createDataContentHandler(mimeType, ds);
            }
            return dch;
        }
View Full Code Here

/*    */   }
/*    */
/*    */   private static void registerContentHandler(Class contentHandler)
/*    */   {
/*    */     MailcapCommandMap mailcap;
/*    */     DataContentHandler handler;
/*    */     try {
/* 70 */       mailcap = (MailcapCommandMap)CommandMap.getDefaultCommandMap();
/* 71 */       handler = (DataContentHandler)contentHandler.newInstance();
/*    */     }
/*    */     catch (Exception e)
/*    */     {
/* 75 */       throw new RuntimeException("Can not register content handler:" + e.getMessage());
/*    */     }
/*    */
/* 78 */     DataFlavor[] flavors = handler.getTransferDataFlavors();
/* 79 */     if (flavors == null) {
/* 80 */       return;
/*    */     }
/* 82 */     for (int i = 0; i < flavors.length; i++)
/*    */     {
View Full Code Here

   
    static final class EnhancedMailcapCommandMap extends MailcapCommandMap {
        @Override
        public synchronized DataContentHandler createDataContentHandler(
                String mimeType) {
            DataContentHandler dch = super.createDataContentHandler(mimeType);
            if (dch == null) {
                dch = DEFAULT_COMMAND_MAP.createDataContentHandler(mimeType);
            }
            return dch;
        }
View Full Code Here

        }

        @Override
        public DataContentHandler createDataContentHandler(String mimeType,
                DataSource ds) {
            DataContentHandler dch = super.createDataContentHandler(mimeType);
            if (dch == null) {
                dch = DEFAULT_COMMAND_MAP.createDataContentHandler(mimeType, ds);
            }
            return dch;
        }
View Full Code Here

TOP

Related Classes of javax.activation.DataContentHandler

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.