Search in sources :

Example 51 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class AtmosphereWebSocketJettyDestination method activate.

protected void activate() {
    super.activate();
    if (handler.getServletContext().getAttribute("org.eclipse.jetty.util.DecoratedObjectFactory") == null) {
        try {
            Class<?> dcc = ClassUtils.forName("org.eclipse.jetty.util.DecoratedObjectFactory", getClass().getClassLoader());
            handler.getServletContext().setAttribute("org.eclipse.jetty.util.DecoratedObjectFactory", dcc.newInstance());
        } catch (ClassNotFoundException | LinkageError | InstantiationException | IllegalAccessException e) {
        // ignore, old version of Jetty
        }
    }
    ServletConfig config = new VoidServletConfig(initParams) {

        @Override
        public ServletContext getServletContext() {
            return handler.getServletContext();
        }
    };
    try {
        framework.init(config);
    } catch (ServletException e) {
        throw new Fault(new Message("Could not initialize WebSocket Framework", LOG, e.getMessage()), e);
    }
}
Also used : ServletException(javax.servlet.ServletException) VoidServletConfig(org.atmosphere.util.VoidServletConfig) Message(org.apache.cxf.common.i18n.Message) ServletConfig(javax.servlet.ServletConfig) VoidServletConfig(org.atmosphere.util.VoidServletConfig) Fault(org.apache.cxf.interceptor.Fault)

Example 52 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class AbstractCommonBindingHandler method unassertPolicy.

protected void unassertPolicy(Assertion assertion, String reason) {
    if (assertion == null) {
        return;
    }
    if (LOG.isLoggable(Level.FINE)) {
        LOG.log(Level.FINE, "Not asserting " + assertion.getName() + ": " + reason);
    }
    AssertionInfoMap aim = message.get(AssertionInfoMap.class);
    Collection<AssertionInfo> ais = aim.get(assertion.getName());
    if (ais != null) {
        for (AssertionInfo ai : ais) {
            if (ai.getAssertion() == assertion) {
                ai.setNotAsserted(reason);
            }
        }
    }
    if (!assertion.isOptional()) {
        throw new PolicyException(new Message(reason, LOG));
    }
}
Also used : AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) Message(org.apache.cxf.common.i18n.Message) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) PolicyException(org.apache.cxf.ws.policy.PolicyException) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Example 53 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class AbstractCommonBindingHandler method unassertPolicy.

protected void unassertPolicy(Assertion assertion, Exception reason) {
    if (assertion == null) {
        return;
    }
    if (LOG.isLoggable(Level.FINE)) {
        LOG.log(Level.FINE, "Not asserting " + assertion.getName() + ": " + reason);
    }
    AssertionInfoMap aim = message.get(AssertionInfoMap.class);
    Collection<AssertionInfo> ais = aim.get(assertion.getName());
    if (ais != null) {
        for (AssertionInfo ai : ais) {
            if (ai.getAssertion() == assertion) {
                ai.setNotAsserted(reason.getMessage());
            }
        }
    }
    if (!assertion.isOptional()) {
        throw new PolicyException(new Message(reason.getMessage(), LOG), reason);
    }
}
Also used : AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) Message(org.apache.cxf.common.i18n.Message) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) PolicyException(org.apache.cxf.ws.policy.PolicyException) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Example 54 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class JettyHTTPServerEngine method addServant.

/**
 * Register a servant.
 *
 * @param url the URL associated with the servant
 * @param handler notified on incoming HTTP requests
 */
public synchronized void addServant(URL url, JettyHTTPHandler handler) {
    if (shouldCheckUrl(handler.getBus())) {
        checkRegistedContext(url);
    }
    initializeContexts();
    SecurityHandler securityHandler = null;
    if (server == null) {
        DefaultHandler defaultHandler = null;
        // create a new jetty server instance if there is no server there
        server = createServer();
        addServerMBean();
        if (connector == null) {
            connector = createConnector(getHost(), getPort(), handler.getBus());
            if (LOG.isLoggable(Level.FINER)) {
                logConnector((ServerConnector) connector);
            }
        }
        server.addConnector(connector);
        setupThreadPool();
        /*
             * The server may have no handler, it might have a collection handler,
             * it might have a one-shot. We need to add one or more of ours.
             *
             */
        int numberOfHandlers = 1;
        if (handlers != null) {
            numberOfHandlers += handlers.size();
        }
        Handler existingHandler = server.getHandler();
        HandlerCollection handlerCollection = null;
        boolean existingHandlerCollection = existingHandler instanceof HandlerCollection;
        if (existingHandlerCollection) {
            handlerCollection = (HandlerCollection) existingHandler;
        }
        if (!existingHandlerCollection && (existingHandler != null || numberOfHandlers > 1)) {
            handlerCollection = new HandlerCollection();
            if (existingHandler != null) {
                handlerCollection.addHandler(existingHandler);
            }
            server.setHandler(handlerCollection);
        }
        /*
             * At this point, the server's handler is a collection. It was either
             * one to start, or it is now one containing only the single handler
             * that was there to begin with.
             */
        if (handlers != null && !handlers.isEmpty()) {
            for (Handler h : handlers) {
                // which should not be added at this point.
                if (h instanceof DefaultHandler) {
                    defaultHandler = (DefaultHandler) h;
                } else {
                    if ((h instanceof SecurityHandler) && ((SecurityHandler) h).getHandler() == null) {
                        // if h is SecurityHandler(such as ConstraintSecurityHandler)
                        // then it need be on top of JettyHTTPHandler
                        // set JettyHTTPHandler as inner handler if
                        // inner handler is null
                        ((SecurityHandler) h).setHandler(handler);
                        securityHandler = (SecurityHandler) h;
                    } else {
                        handlerCollection.addHandler(h);
                    }
                }
            }
        }
        /*
             * handlerCollection may be null here if is only one handler to deal with.
             * Which in turn implies that there can't be a 'defaultHander' to deal with.
             */
        if (handlerCollection != null) {
            handlerCollection.addHandler(contexts);
            if (defaultHandler != null) {
                handlerCollection.addHandler(defaultHandler);
            }
        } else {
            server.setHandler(contexts);
        }
        try {
            server.start();
        } catch (Exception e) {
            LOG.log(Level.SEVERE, "START_UP_SERVER_FAILED_MSG", new Object[] { e.getMessage(), port });
            // problem starting server
            try {
                server.stop();
                server.destroy();
            } catch (Exception ex) {
            // ignore - probably wasn't fully started anyway
            }
            server = null;
            throw new Fault(new Message("START_UP_SERVER_FAILED_MSG", LOG, e.getMessage(), port), e);
        }
    }
    String contextName = HttpUriMapper.getContextName(url.getPath());
    ContextHandler context = new ContextHandler();
    context.setContextPath(contextName);
    // bind the jetty http handler with the context handler
    if (isSessionSupport) {
        SessionHandler sh = configureSession();
        if (securityHandler != null) {
            // use the securityHander which already wrap the jetty http handler
            sh.setHandler(securityHandler);
        } else {
            sh.setHandler(handler);
        }
        context.setHandler(sh);
    } else {
        // otherwise, just the one.
        if (securityHandler != null) {
            // use the securityHander which already wrap the jetty http handler
            context.setHandler(securityHandler);
        } else {
            context.setHandler(handler);
        }
    }
    contexts.addHandler(context);
    ServletContext sc = context.getServletContext();
    handler.setServletContext(sc);
    final String smap = getHandlerName(url, context);
    handler.setName(smap);
    if (contexts.isStarted()) {
        try {
            context.start();
        } catch (Exception ex) {
            LOG.log(Level.WARNING, "ADD_HANDLER_FAILED_MSG", new Object[] { ex.getMessage() });
        }
    }
    registedPaths.add(url.getPath());
    ++servantCount;
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) SecurityHandler(org.eclipse.jetty.security.SecurityHandler) Message(org.apache.cxf.common.i18n.Message) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler) ErrorHandler(org.eclipse.jetty.server.handler.ErrorHandler) SecurityHandler(org.eclipse.jetty.security.SecurityHandler) Handler(org.eclipse.jetty.server.Handler) ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) SessionHandler(org.eclipse.jetty.server.session.SessionHandler) Fault(org.apache.cxf.interceptor.Fault) ServletException(javax.servlet.ServletException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler) ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) ServletContext(javax.servlet.ServletContext) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection)

Example 55 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class SequenceFaultFactory method createInvalidAcknowledgementFault.

SequenceFault createInvalidAcknowledgementFault(SequenceAcknowledgement ack) {
    Message msg = new Message("INVALID_ACK_EXC", BUNDLE);
    SequenceFault fault = new SequenceFault(msg.toString());
    fault.setDetail(ack);
    fault.setSender(true);
    fault.setFaultCode(constants.getInvalidAcknowledgmentFaultCode());
    return fault;
}
Also used : Message(org.apache.cxf.common.i18n.Message)

Aggregations

Message (org.apache.cxf.common.i18n.Message)201 ToolException (org.apache.cxf.tools.common.ToolException)69 IOException (java.io.IOException)45 QName (javax.xml.namespace.QName)42 Fault (org.apache.cxf.interceptor.Fault)34 XMLStreamException (javax.xml.stream.XMLStreamException)27 JAXBException (javax.xml.bind.JAXBException)23 ArrayList (java.util.ArrayList)19 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)17 Element (org.w3c.dom.Element)17 File (java.io.File)16 WSDLException (javax.wsdl.WSDLException)15 Method (java.lang.reflect.Method)14 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)13 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)12 InputStream (java.io.InputStream)11 HashMap (java.util.HashMap)11 List (java.util.List)11 Map (java.util.Map)11 ServiceConstructionException (org.apache.cxf.service.factory.ServiceConstructionException)11