alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Struts example source code file (ContentTypeHandlerManager.java)

This example Struts source code file (ContentTypeHandlerManager.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Struts tags/keywords

contenttypehandler, contenttypehandler, contenttypehandlermanager, http, httpservletresponse, io, ioexception, object, object, request, response, servlet, string, string, struts_rest_handler_override_prefix, struts_rest_handler_override_prefix

The Struts ContentTypeHandlerManager.java source code

/*
 * $Id$
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.struts2.rest;

import org.apache.struts2.rest.handler.ContentTypeHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.opensymphony.xwork2.config.entities.ActionConfig;

import java.io.IOException;

/**
 * Manages content type handlers
 */
public interface ContentTypeHandlerManager {
    String STRUTS_REST_HANDLER_OVERRIDE_PREFIX = "struts.rest.handlerOverride.";

    /**
     * Gets the handler for the request by looking at the request content type and extension
     * @param req The request
     * @return The appropriate handler
     */
    ContentTypeHandler getHandlerForRequest(HttpServletRequest req);

    /**
     * Gets the handler for the response by looking at the extension of the request
     * @param req The request
     * @return The appropriate handler
     */
    ContentTypeHandler getHandlerForResponse(HttpServletRequest req, HttpServletResponse res);

    /**
     * Handles the result using handlers to generate content type-specific content
     *
     * @param actionConfig The action config for the current request
     * @param methodResult The object returned from the action method
     * @param target The object to return, usually the action object
     * @return The new result code to process
     * @throws IOException If unable to write to the response
     */
    String handleResult(ActionConfig actionConfig, Object methodResult, Object target)
            throws IOException;
    
    /**
     * Finds the extension in the url
     * 
     * @param url The url
     * @return The extension
     */
    String findExtension(String url);
}

Other Struts examples (source code examples)

Here is a short list of links related to this Struts ContentTypeHandlerManager.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.