本文整理了Java中org.restlet.Request.getAttributes
方法的一些代码示例,展示了Request.getAttributes
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getAttributes
方法的具体详情如下:
包路径:org.restlet.Request
类名称:Request
方法名:getAttributes
暂无
代码示例来源:origin: uber/chaperone
@Override
@Get
public Representation get() {
final String opt = (String) getRequest().getAttributes().get("opt");
if ("disable_autobalancing".equalsIgnoreCase(opt)) {
_helixMirrorMakerManager.disableAutoBalancing();
LOGGER.info("Disabled autobalancing!");
return new StringRepresentation("Disabled autobalancing!\n");
} else if ("enable_autobalancing".equalsIgnoreCase(opt)) {
_helixMirrorMakerManager.enableAutoBalancing();
LOGGER.info("Enabled autobalancing!");
return new StringRepresentation("Enabled autobalancing!\n");
}
LOGGER.info("No valid input!");
return new StringRepresentation("No valid input!\n");
}
代码示例来源:origin: uber/chaperone
@Override
@Get
public Representation get() {
final String option = (String) getRequest().getAttributes().get("option");
if ("srcKafka".equals(option)) {
if (_srcKafkaValidationManager == null) {
LOGGER.warn("SourceKafkaClusterValidationManager is null!");
return new StringRepresentation("SrcKafkaValidationManager is not been initialized!");
}
LOGGER.info("Trying to call validation on source kafka cluster!");
return new StringRepresentation(_srcKafkaValidationManager.validateSourceKafkaCluster());
} else {
LOGGER.info("Trying to call validation on current cluster!");
return new StringRepresentation(_validationManager.validateExternalView());
}
}
代码示例来源:origin: uber/chaperone
@Override
@Delete
public Representation delete() {
final String topicName = (String) getRequest().getAttributes().get("topicName");
if (_autoTopicWhitelistingManager != null) {
_autoTopicWhitelistingManager.addIntoBlacklist(topicName);
}
if (!_helixMirrorMakerManager.isTopicExisted(topicName)) {
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation(
String.format("Failed to delete not existed topic: %s", topicName));
}
try {
_helixMirrorMakerManager.deleteTopicInMirrorMaker(topicName);
return new StringRepresentation(
String.format("Successfully finished delete topic: %s", topicName));
} catch (Exception e) {
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
LOGGER.error("Failed to delete topic: {}, with exception: {}", topicName, e);
return new StringRepresentation(
String.format("Failed to delete topic: %s, with exception: %s", topicName, e));
}
}
代码示例来源:origin: uber/chaperone
@Override
@Get
public Representation get() {
final String topicName = (String) getRequest().getAttributes().get("topicName");
if (topicName == null) {
List<String> topicLists = _helixMirrorMakerManager.getTopicLists();
代码示例来源:origin: uber/chaperone
public Representation post(Representation entity) {
try {
final String topicName = (String) getRequest().getAttributes().get("topicName");
String jsonRequest = entity.getText();
TopicPartition topicPartitionInfo = null;
代码示例来源:origin: org.restlet.jse/org.restlet.example
@Override
public void handle(Request request, Response response) {
// Print the user name of the requested orders
String message = "Order \""
+ request.getAttributes().get("order")
+ "\" for user \""
+ request.getAttributes().get("user") + "\"";
response.setEntity(message, MediaType.TEXT_PLAIN);
}
};
代码示例来源:origin: org.restlet.jee/org.restlet.ext.apispark
@Override
protected int beforeHandle(Request request, Response response) {
request.getAttributes().put("org.restlet.startTime", getTimeMillis());
return CONTINUE;
}
代码示例来源:origin: org.restlet.jse/org.restlet.example
@Override
public void handle(Request request, Response response) {
// Print the user name of the requested orders
String message = "Orders of user \""
+ request.getAttributes().get("user") + "\"";
response.setEntity(message, MediaType.TEXT_PLAIN);
}
};
代码示例来源:origin: org.restlet.osgi/org.restlet
@Override
public void handle(Request request, Response response) {
request.getAttributes().put("org.restlet.directory", this);
super.handle(request, response);
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs
/**
* Returns the attributes of the current Restlet {@link org.restlet.Request}
* .
*
* @return the attributes of the current Restlet Request, but never null
*/
private Map<String, Object> getRequestAttributes() {
return org.restlet.Request.getCurrent().getAttributes();
}
代码示例来源:origin: org.restlet.jse/org.restlet.ext.platform
@Override
protected int beforeHandle(Request request, Response response) {
request.getAttributes().put("org.restlet.startTime", getTimeMillis());
return CONTINUE;
}
代码示例来源:origin: org.restlet.gae/org.restlet.ext.platform
@Override
protected int beforeHandle(Request request, Response response) {
request.getAttributes().put("org.restlet.startTime", getTimeMillis());
return CONTINUE;
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.apispark
@Override
protected void afterHandle(Request request, Response response) {
long startTime = (Long) request.getAttributes().get(
"org.restlet.startTime");
int duration = (int) (getTimeMillis() - startTime);
analyticsHandler.addCallLogToBuffer(request, response, duration,
startTime);
}
代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.rest-server
protected void setResourceValidity( EntityComposite entity )
{
Request request = Request.getCurrent();
ResourceValidity validity = new ResourceValidity( entity, spi, request );
request.getAttributes().put( RESOURCE_VALIDITY, validity );
}
代码示例来源:origin: org.restlet.jse/org.restlet.example
@Override
protected void doInit() throws ResourceException {
// Get the "itemName" attribute value taken from the URI template
// /items/{itemName}.
this.itemName = (String) getRequest().getAttributes().get("itemName");
if (itemName != null) {
// Get the item directly from the "persistence layer".
this.item = getItems().get(itemName);
}
setExisting(this.item != null);
}
代码示例来源:origin: jtalks-org/jcommune
private void addHeaderAttribute(ClientResource clientResource, String attrName, String attrValue) {
ConcurrentMap<String, Object> attrs = clientResource.getRequest().getAttributes();
Series<Header> headers = (Series<Header>) attrs.get(HeaderConstants.ATTRIBUTE_HEADERS);
if (headers == null) {
headers = new Series<>(Header.class);
Series<Header> prev = (Series<Header>) attrs.putIfAbsent(HeaderConstants.ATTRIBUTE_HEADERS, headers);
if (prev != null) {
headers = prev;
}
}
headers.add(attrName, attrValue);
}
代码示例来源:origin: org.restlet.jse/org.restlet.example
@Override
protected void doInit() throws ResourceException {
// Get the "itemName" attribute value taken from the URI template
// /items/{itemName}.
this.itemName = (String) getRequest().getAttributes().get("itemName");
// Get the item directly from the "persistence layer".
this.item = getItems().get(itemName);
setExisting(this.item != null);
}
代码示例来源:origin: org.daisy.libs/com.xmlcalabash
@Override
protected Representation delete(Variant variant) {
String id = (String) getRequest().getAttributes().get("id");
if (!getPipelines().containsKey(id)) {
return badRequest(Status.CLIENT_ERROR_NOT_FOUND, "no pipeline: " + pipelineUri(id), variant.getMediaType());
}
getPipelines().remove(id);
setStatus(Status.SUCCESS_OK);
return new EmptyRepresentation();
}
}
代码示例来源:origin: org.daisy.libs/com.xmlcalabash
@Override
protected Representation post(Representation entity, Variant variant) {
String id = (String) getRequest().getAttributes().get("id");
if (!getPipelines().containsKey(id)) {
return badRequest(Status.CLIENT_ERROR_NOT_FOUND, "no pipeline: " + pipelineUri(id), variant.getMediaType());
}
PipelineConfiguration pipeconfig = getPipelines().get(id);
XPipeline xpipeline = pipeconfig.pipeline;
pipeconfig.reset();
xpipeline.reset();
return okResponse("Pipeline reset", variant.getMediaType());
}
代码示例来源:origin: com.xmlcalabash/xmlcalabash
@Override
protected Representation post(Representation entity, Variant variant) {
String id = (String) getRequest().getAttributes().get("id");
if (!getPipelines().containsKey(id)) {
return badRequest(Status.CLIENT_ERROR_NOT_FOUND, "no pipeline: " + pipelineUri(id), variant.getMediaType());
}
PipelineConfiguration pipeconfig = getPipelines().get(id);
XPipeline xpipeline = pipeconfig.pipeline;
pipeconfig.reset();
xpipeline.reset();
return okResponse("Pipeline reset", variant.getMediaType());
}
内容来源于网络,如有侵权,请联系作者删除!