Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.tiogasolutions.dev.jerseyspring;
  
  import java.io.*;
  import javax.inject.*;
  import javax.servlet.*;
  import javax.ws.rs.core.*;
The CustomJsp* Jersey classes exist only to support custom jsp suffix (such as jspf).
 
Determines the supported extensions by looking at the CustomJspMvcFeature.SUPPORTED_EXTENSIONS property in the Jersey configuration. If none found uses "jsp".

Parameters:
config
Returns:
 
   private static String[] determineSupportedExtensions(Configuration config) {
     Object supportedExtensionProperty = config.getProperty(.);
 
     // If nothing identified in config use defaults.
     if (supportedExtensionProperty == null) {
       return new String[]{"jsp"};
     } else {
       String[] extensions = supportedExtensionProperty.toString().split(",");//  StringUtil.tokenize(, ',');
       for (int i=0; i<extensions.lengthi++) {
         extensions[i] = extensions[i].trim();
       }
       return extensions;
     }
   }
 
   @Inject
   @Inject
   @Inject
Create an instance of this processor with injected config and (optional) servlet context.

Parameters:
config configuration to configure this processor from.
servletContext (optional) servlet context to obtain template resources from.
 
   @Inject
   public TiogaJspTemplateProcessor(final Configuration configfinal ServletContext servletContext) {
     super(configservletContext"jsp"determineSupportedExtensions(config));
   }
 
   @Override
   protected String resolve(final String templatePathfinal Reader readerthrows Exception {
     return templatePath;
   }
 
 
   @Override
   public void writeTo(String templateReferenceViewable viewableMediaType mediaTypeMultivaluedMap<StringObjecthttpHeadersfinal OutputStream outthrows IOException {
     TracingLogger tracingLogger = TracingLogger.getInstance(.get().getPropertiesDelegate());
     if (tracingLogger.isLogEnabled(.)) {
       tracingLogger.log(.templateReferenceviewable.getModel());
     }
 
     final RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(templateReference);
     if (dispatcher == null) {
       throw new ContainerException(LocalizationMessages.NO_REQUEST_DISPATCHER_FOR_RESOLVED_PATH(templateReference));
     }
 
     final RequestDispatcher wrapper = new TiogaRequestDispatcherWrapper(dispatchergetBasePath(), viewable);
 
     // OutputStream and Writer for HttpServletResponseWrapper.
     final ServletOutputStream responseStream = new ServletOutputStream() {
       @Override
       public boolean isReady() {
         return true;
       }
       @Override
       public void setWriteListener(WriteListener writeListener) {
         // new to Servlet 3.1, don't know what to put here.
       }
       @Override
       public void write(final int bthrows IOException {
         out.write(b);
       }
     };
     final PrintWriter responseWriter = new PrintWriter(new OutputStreamWriter(responseStream));
 
     try {
 
        @Override
        public ServletOutputStream getOutputStream() throws IOException {
          return responseStream;
        }
        @Override
        public PrintWriter getWriter() throws IOException {
          return responseWriter;
        }
      });
    } catch (Exception e) {
      throw new ContainerException(e);
    } finally {
      responseWriter.flush();
    }
  }

  
MVC-JSP side tracing events.
  private static enum MvcJspEvent implements TracingLogger.Event {
    JSP_FORWARD(.."MVC""Forwarding view to JSP page [%s], model %s");
    private final TracingLogger.Level level;
    private final String category;
    private final String messageFormat;
    private MvcJspEvent(TracingLogger.Level levelString categoryString messageFormat) {
      this. = level;
      this. = category;
      this. = messageFormat;
    }
    @Override
    public String category() {
      return ;
    }
    @Override
    public TracingLogger.Level level() {
      return ;
    }
    @Override
    public String messageFormat() {
      return ;
    }
  }
New to GrepCode? Check out our FAQ X