Search in sources :

Example 1 with Localizer

use of com.sun.istack.localization.Localizer in project metro-jax-ws by eclipse-ee4j.

the class WSServletDelegate method getLocalizerFor.

protected Localizer getLocalizerFor(ServletRequest request) {
    Locale locale = request.getLocale();
    if (locale.equals(defaultLocalizer.getLocale())) {
        return defaultLocalizer;
    }
    synchronized (localizerMap) {
        Localizer localizer = localizerMap.get(locale);
        if (localizer == null) {
            localizer = new Localizer(locale);
            localizerMap.put(locale, localizer);
        }
        return localizer;
    }
}
Also used : Locale(java.util.Locale) Localizer(com.sun.istack.localization.Localizer)

Example 2 with Localizer

use of com.sun.istack.localization.Localizer in project metro-jax-ws by eclipse-ee4j.

the class ModelerExceptionTest method testLocalizability.

public void testLocalizability() {
    String msg = "Try localizing me";
    ModelerException pe = new ModelerException(msg);
    Localizer localizer = new Localizer();
    assertEquals(msg, localizer.localize(pe));
}
Also used : ModelerException(com.sun.tools.ws.processor.modeler.ModelerException) Localizer(com.sun.istack.localization.Localizer)

Example 3 with Localizer

use of com.sun.istack.localization.Localizer in project metro-jax-ws by eclipse-ee4j.

the class WSServletDelegate method doGet.

public void doGet(HttpServletRequest request, HttpServletResponse response, ServletContext context) throws ServletException {
    try {
        ServletAdapter target = getTarget(request);
        if (target != null) {
            if (logger.isLoggable(Level.FINEST)) {
                logger.finest(WsservletMessages.SERVLET_TRACE_GOT_REQUEST_FOR_ENDPOINT(target.name));
            }
            final String path = request.getContextPath() + target.getValidPath();
            probe.startedEvent(path);
            target.invokeAsync(context, request, response, new HttpAdapter.CompletionCallback() {

                @Override
                public void onCompletion() {
                    probe.endedEvent(path);
                }
            });
        } else {
            Localizer localizer = getLocalizerFor(request);
            writeNotFoundErrorPage(localizer, response, "Invalid Request");
        }
    } catch (JAXWSExceptionBase e) {
        logger.log(Level.SEVERE, defaultLocalizer.localize(e), e);
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (Throwable e) {
        if (e instanceof Localizable) {
            logger.log(Level.SEVERE, defaultLocalizer.localize((Localizable) e), e);
        } else {
            logger.log(Level.SEVERE, "caught throwable", e);
        }
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}
Also used : HttpAdapter(com.sun.xml.ws.transport.http.HttpAdapter) JAXWSExceptionBase(com.sun.xml.ws.util.exception.JAXWSExceptionBase) Localizer(com.sun.istack.localization.Localizer) Localizable(com.sun.istack.localization.Localizable)

Example 4 with Localizer

use of com.sun.istack.localization.Localizer in project metro-jax-ws by eclipse-ee4j.

the class WSServletDelegate method doPut.

/**
 * Handles HTTP PUT for XML/HTTP binding based endpoints
 * @param request the HTTP request object
 * @param response the HTTP response object
 * @param context the Servlet context object
 * @throws ServletException for errors
 */
public void doPut(HttpServletRequest request, HttpServletResponse response, ServletContext context) throws ServletException {
    // TODO: unify this into doGet.
    try {
        ServletAdapter target = getTarget(request);
        if (target != null) {
            if (logger.isLoggable(Level.FINEST)) {
                logger.finest(WsservletMessages.SERVLET_TRACE_GOT_REQUEST_FOR_ENDPOINT(target.name));
            }
        } else {
            Localizer localizer = getLocalizerFor(request);
            writeNotFoundErrorPage(localizer, response, "Invalid request");
            return;
        }
        Binding binding = target.getEndpoint().getBinding();
        if (binding instanceof HTTPBinding) {
            target.handle(context, request, response);
        } else {
            response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
        }
    } catch (JAXWSExceptionBase e) {
        logger.log(Level.SEVERE, defaultLocalizer.localize(e), e);
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (Throwable e) {
        if (e instanceof Localizable) {
            logger.log(Level.SEVERE, defaultLocalizer.localize((Localizable) e), e);
        } else {
            logger.log(Level.SEVERE, "caught throwable", e);
        }
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}
Also used : Binding(jakarta.xml.ws.Binding) HTTPBinding(jakarta.xml.ws.http.HTTPBinding) JAXWSExceptionBase(com.sun.xml.ws.util.exception.JAXWSExceptionBase) Localizer(com.sun.istack.localization.Localizer) HTTPBinding(jakarta.xml.ws.http.HTTPBinding) Localizable(com.sun.istack.localization.Localizable)

Example 5 with Localizer

use of com.sun.istack.localization.Localizer in project metro-jax-ws by eclipse-ee4j.

the class ProcessorExceptionTest method testLocalizability.

public void testLocalizability() {
    String msg = "Try localizing me";
    ProcessorException pe = new ProcessorException(msg);
    Localizer localizer = new Localizer();
    assertEquals(msg, localizer.localize(pe));
}
Also used : ProcessorException(com.sun.tools.ws.processor.ProcessorException) Localizer(com.sun.istack.localization.Localizer)

Aggregations

Localizer (com.sun.istack.localization.Localizer)5 Localizable (com.sun.istack.localization.Localizable)2 JAXWSExceptionBase (com.sun.xml.ws.util.exception.JAXWSExceptionBase)2 ProcessorException (com.sun.tools.ws.processor.ProcessorException)1 ModelerException (com.sun.tools.ws.processor.modeler.ModelerException)1 HttpAdapter (com.sun.xml.ws.transport.http.HttpAdapter)1 Binding (jakarta.xml.ws.Binding)1 HTTPBinding (jakarta.xml.ws.http.HTTPBinding)1 Locale (java.util.Locale)1