use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.
the class AnnotatedEndpointConfigTest method startEnv.
@BeforeClass
public static void startEnv() throws Exception {
// Server
server = new Server();
ServerConnector connector = new ServerConnector(server);
server.addConnector(connector);
handler = new EchoHandler();
ContextHandler context = new ContextHandler();
context.setContextPath("/");
context.setHandler(handler);
server.setHandler(context);
// Start Server
server.start();
String host = connector.getHost();
if (host == null) {
host = "localhost";
}
int port = connector.getLocalPort();
serverUri = new URI(String.format("ws://%s:%d/", host, port));
// Connect client
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
socket = new AnnotatedEndpointClient();
session = container.connectToServer(socket, serverUri);
Assert.assertThat("Session", session, notNullValue());
config = socket.config;
Assert.assertThat("EndpointConfig", config, notNullValue());
Assert.assertThat("EndpointConfig", config, instanceOf(ClientEndpointConfig.class));
ceconfig = (ClientEndpointConfig) config;
Assert.assertThat("EndpointConfig", ceconfig, notNullValue());
}
use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.
the class AbstractHandlerMBean method getObjectContextBasis.
/* ------------------------------------------------------------ */
@Override
public String getObjectContextBasis() {
if (_managed != null) {
String basis = null;
if (_managed instanceof ContextHandler) {
ContextHandler handler = (ContextHandler) _managed;
String context = getContextName(handler);
if (context == null)
context = handler.getDisplayName();
if (context != null)
return context;
} else if (_managed instanceof AbstractHandler) {
AbstractHandler handler = (AbstractHandler) _managed;
Server server = handler.getServer();
if (server != null) {
ContextHandler context = AbstractHandlerContainer.findContainerOf(server, ContextHandler.class, handler);
if (context != null)
basis = getContextName(context);
}
}
if (basis != null)
return basis;
}
return super.getObjectContextBasis();
}
use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.
the class ContextHandlerMBean method removeContextAttribute.
@ManagedOperation(value = "Remove context attribute", impact = "ACTION")
public void removeContextAttribute(@Name(value = "name", description = "attribute name") String name) {
Attributes attrs = ((ContextHandler) _managed).getAttributes();
attrs.removeAttribute(name);
}
use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.
the class ContextHandlerMBean method setContextAttribute.
@ManagedOperation(value = "Set context attribute", impact = "ACTION")
public void setContextAttribute(@Name(value = "name", description = "attribute name") String name, @Name(value = "value", description = "attribute value") String value) {
Attributes attrs = ((ContextHandler) _managed).getAttributes();
attrs.setAttribute(name, value);
}
use of org.eclipse.jetty.server.handler.ContextHandler in project jetty.project by eclipse.
the class ContextHandlerMBean method getContextAttributes.
@ManagedAttribute("Map of context attributes")
public Map<String, Object> getContextAttributes() {
Map<String, Object> map = new HashMap<String, Object>();
Attributes attrs = ((ContextHandler) _managed).getAttributes();
Enumeration<String> en = attrs.getAttributeNames();
while (en.hasMoreElements()) {
String name = (String) en.nextElement();
Object value = attrs.getAttribute(name);
map.put(name, value);
}
return map;
}
Aggregations