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);
}
}
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));
}
}
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);
}
}
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;
}
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;
}
Aggregations