本文整理了Java中org.restlet.Context.getAttributes()
方法的一些代码示例,展示了Context.getAttributes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getAttributes()
方法的具体详情如下:
包路径:org.restlet.Context
类名称:Context
方法名:getAttributes
[英]Returns a modifiable attributes map that can be used by developers to save information relative to the context. This is a convenient means to provide common objects to all the Restlets and Resources composing an Application.
In addition, this map is a shared space between the developer and the Restlet implementation. For this purpose, all attribute names starting with "org.restlet" are reserved. Currently the following attributes are used: Attribute nameClass nameDescriptionorg.restlet.applicationorg.restlet.ApplicationThe parent application providing this context, if any.
[中]返回可修改的属性映射,开发人员可以使用该映射保存与上下文相关的信息。这是向构成应用程序的所有RESTlet和资源提供公共对象的方便方法。
此外,此映射是开发人员和Restlet实现之间的共享空间。为此,保留以“org.restlet”开头的所有属性名称。当前使用了以下属性:属性nameClass nameScriptionorg。restlet。应用程序源。restlet。应用程序提供此上下文的父应用程序(如果有)。
代码示例来源:origin: uber/chaperone
public AdminRestletResource() {
_helixMirrorMakerManager = (HelixMirrorMakerManager) getApplication().getContext()
.getAttributes().get(HelixMirrorMakerManager.class.toString());
}
代码示例来源:origin: uber/chaperone
public TopicManagementRestletResource() {
getVariants().add(new Variant(MediaType.TEXT_PLAIN));
getVariants().add(new Variant(MediaType.APPLICATION_JSON));
setNegotiated(false);
_helixMirrorMakerManager = (HelixMirrorMakerManager) getApplication().getContext()
.getAttributes().get(HelixMirrorMakerManager.class.toString());
_autoTopicWhitelistingManager = (AutoTopicWhitelistingManager) getApplication().getContext()
.getAttributes().get(AutoTopicWhitelistingManager.class.toString());
if (getApplication().getContext().getAttributes()
.containsKey(KafkaBrokerTopicObserver.class.toString())) {
_srcKafkaBrokerTopicObserver = (KafkaBrokerTopicObserver) getApplication().getContext()
.getAttributes().get(KafkaBrokerTopicObserver.class.toString());
} else {
_srcKafkaBrokerTopicObserver = null;
}
}
代码示例来源:origin: uber/chaperone
public ValidationRestletResource() {
getVariants().add(new Variant(MediaType.TEXT_PLAIN));
getVariants().add(new Variant(MediaType.APPLICATION_JSON));
setNegotiated(false);
_validationManager = (ValidationManager) getApplication().getContext()
.getAttributes().get(ValidationManager.class.toString());
if (getApplication().getContext().getAttributes()
.containsKey(SourceKafkaClusterValidationManager.class.toString())) {
_srcKafkaValidationManager =
(SourceKafkaClusterValidationManager) getApplication().getContext()
.getAttributes().get(SourceKafkaClusterValidationManager.class.toString());
} else {
_srcKafkaValidationManager = null;
}
}
代码示例来源:origin: uber/chaperone
applicationContext.getAttributes().put(ControllerConf.class.toString(), _config);
applicationContext.getAttributes().put(HelixMirrorMakerManager.class.toString(), _helixMirrorMakerManager);
applicationContext.getAttributes().put(ValidationManager.class.toString(), _validationManager);
applicationContext.getAttributes().put(SourceKafkaClusterValidationManager.class.toString(),
_srcKafkaValidationManager);
applicationContext.getAttributes().put(KafkaBrokerTopicObserver.class.toString(),
_kafkaBrokerTopicObserverMap.get(SRC_KAFKA_CLUSTER));
applicationContext.getAttributes().put(AutoTopicWhitelistingManager.class.toString(),
_autoTopicWhitelistingManager);
代码示例来源:origin: org.sonatype.nexus/nexus-rest-api
/**
* For file uploads we are using commons-fileupload integration with restlet.org. We are storing one FileItemFactory
* instance in context. This method simply encapsulates gettting it from Resource context.
*
* @return
*/
protected FileItemFactory getFileItemFactory( Context context )
{
return (FileItemFactory) context.getAttributes().get( NexusApplication.FILEITEM_FACTORY );
}
代码示例来源:origin: org.restlet.osgi/org.restlet.ext.oauth
private boolean isLocalAcessOnly() {
String lo = (String) getContext().getAttributes()
.get(LOCAL_ACCESS_ONLY);
return (lo != null) && (lo.length() > 0) && Boolean.parseBoolean(lo);
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
private static boolean isLocalAcessOnly() {
String lo = (String) getResourceContext().getAttributes()
.get(LOCAL_ACCESS_ONLY);
return (lo != null) && (lo.length() > 0) && Boolean.parseBoolean(lo);
}
代码示例来源:origin: uber/uReplicator
public AdminRestletResource() {
_helixMirrorMakerManager = (HelixMirrorMakerManager) getApplication().getContext()
.getAttributes().get(HelixMirrorMakerManager.class.toString());
}
代码示例来源:origin: org.restlet.osgi/org.restlet.ext.oauth
@Override
protected void doInit() throws ResourceException {
super.doInit();
Context ctx = getContext();
ConcurrentMap<String, Object> attribs = ctx.getAttributes();
clients = (ClientManager) attribs.get(ClientManager.class.getName());
tokens = (TokenManager) attribs.get(TokenManager.class.getName());
getLogger().fine("Found client store = " + clients);
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Returns the hostname verifier by looking up the "hostnameVerifier"
* attribute of the client's context.
*
* @return The hostname verifier or null.
*/
public HostnameVerifier getHostnameVerifier() {
return (HostnameVerifier) ((getContext() == null) ? null : getContext()
.getAttributes().get("hostnameVerifier"));
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.net
/**
* Returns the hostname verifier by looking up the "hostnameVerifier"
* attribute of the client's context.
*
* @return The hostname verifier or null.
*/
public HostnameVerifier getHostnameVerifier() {
return (HostnameVerifier) ((getContext() == null) ? null : getContext()
.getAttributes().get("hostnameVerifier"));
}
代码示例来源:origin: org.restlet.osgi/org.restlet.ext.oauth
/**
* Unget current authorization session.
*/
protected void ungetAuthSession() {
String sessionId = getCookies().getFirstValue(ClientCookieID);
// cleanup cookie.
if (sessionId != null && sessionId.length() > 0) {
ConcurrentMap<String, Object> attribs = getContext()
.getAttributes();
attribs.remove(sessionId);
}
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
/**
* Unget current authorization session.
*/
protected static void ungetAuthSession() {
String sessionId = getResourceCookies().getFirstValue(ClientCookieID);
// cleanup cookie.
if (sessionId != null && sessionId.length() > 0) {
ConcurrentMap<String, Object> attribs = getResourceContext()
.getAttributes();
attribs.remove(sessionId);
}
}
代码示例来源:origin: uber/uReplicator
public TopicManagementRestletResource() {
getVariants().add(new Variant(MediaType.TEXT_PLAIN));
getVariants().add(new Variant(MediaType.APPLICATION_JSON));
setNegotiated(false);
_conf = (ManagerConf) getApplication().getContext().getAttributes().get(ManagerConf.class.toString());
_helixMirrorMakerManager = (ControllerHelixManager) getApplication().getContext()
.getAttributes().get(ControllerHelixManager.class.toString());
SourceKafkaClusterValidationManager srcKafkaValidationManager = (SourceKafkaClusterValidationManager) getApplication()
.getContext().getAttributes().get(SourceKafkaClusterValidationManager.class.toString());
_clusterToObserverMap = srcKafkaValidationManager.getClusterToObserverMap();
}
代码示例来源:origin: org.restlet.osgi/org.restlet.ext.oauth
private void validateState(Request request, Form params) throws Exception {
String sessionId = request.getCookies().getFirstValue("_state");
String state = (String) getContext().getAttributes().get(sessionId);
if (state != null && state.equals(params.getFirstValue(STATE))) {
return;
}
// CSRF detected
throw new Exception("The state does not match.");
}
代码示例来源:origin: org.restlet.osgi/org.restlet.ext.oauth
private String setupState(Response response) {
String sessionId = UUID.randomUUID().toString();
byte[] secret = new byte[20];
random.nextBytes(secret);
String state = Base64.encode(secret, false);
CookieSetting cs = new CookieSetting("_state", sessionId);
response.getCookieSettings().add(cs);
getContext().getAttributes().put(sessionId, state);
return state;
}
代码示例来源:origin: uber/uReplicator
public AdminRestletResource() {
getVariants().add(new Variant(MediaType.TEXT_PLAIN));
getVariants().add(new Variant(MediaType.APPLICATION_JSON));
setNegotiated(false);
_helixMirrorMakerManager = (ControllerHelixManager) getApplication().getContext()
.getAttributes().get(ControllerHelixManager.class.toString());
}
代码示例来源:origin: apache/helix
StringRepresentation getStateModelRepresentation(String clusterName, String modelName)
throws JsonGenerationException, JsonMappingException, IOException {
Builder keyBuilder = new PropertyKey.Builder(clusterName);
ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
String message =
ClusterRepresentationUtil.getClusterPropertyAsString(zkClient, clusterName,
keyBuilder.stateModelDef(modelName), MediaType.APPLICATION_JSON);
StringRepresentation representation =
new StringRepresentation(message, MediaType.APPLICATION_JSON);
return representation;
}
代码示例来源:origin: apache/helix
StringRepresentation getControllerStatusUpdateRepresentation(String zkServerAddress,
String clusterName, String sessionId, String messageType, String messageId)
throws JsonGenerationException, JsonMappingException, IOException {
Builder keyBuilder = new PropertyKey.Builder(clusterName);
ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
String message =
ClusterRepresentationUtil.getPropertyAsString(zkClient, clusterName,
keyBuilder.controllerTaskStatus(messageType, messageId), MediaType.APPLICATION_JSON);
StringRepresentation representation =
new StringRepresentation(message, MediaType.APPLICATION_JSON);
return representation;
}
}
代码示例来源:origin: stackoverflow.com
Router router = new Router(); // Remove final from this.
router.attachDefault(HttpListener.class);
Component component = new Component();
Context ctx = component.getApplication().getContext().createChildContext(); // Remove final
ctx.getAttributes().put("mysharedobj", new MySharedObj());
org.restlet.Application myApp = new org.restlet.Application(ctx) {
@Override
public org.restlet.Restlet createInboundRoot() {
return router;
};
};
内容来源于网络,如有侵权,请联系作者删除!