I've run into a snag where I've set an attribute on the context to pass along environment information to parts of my application. When I pass the attribute via the context in the constructor, the constructor can get access to the attribute but later on the getContext() method's return doesn't have that attribute. I assume that is because the "parent" context's attributes aren't available to the "current" context.
So, I'm doing something like: public PingApplication(Context context) { super(context); agentContext = new AgentContext(context); } public Restlet createRoot() { agentContext = new AgentContext(getContext()); ... In the createRoot(), the getContext() call is return a different instance. Should the attributes of the parent be available? If not, how is one suppose to pass along contextual configuration information to parts of your application. In my case, each Application instance is loaded from specific jar files and given a number of environment objects via attirbutes on the Context instance. Should I be doing this differently? A similar use case would be the "JDBC data source" in that if the application creates the data source, how does should it pass that along to arbitrary resources that use the data source? It also isn't clear what the difference between parameters and attributes of are in the context. Finally, in some situations (like my agent example where I load an jar file containing the application), I want to provide access to certain objects via, say, attributes but I don't want the Application instance to be able to change that object. Since getAttributes() and getParameters() return modifiable collections, that gets a bit complicated. I've now resorted to: Context agentContext = new Context() { Map<String,Object> attrs = Collections.unmodifiableMap(getContext().getAttributes()); public Map<String,Object> getAttributes() { return attrs; } public Uniform getDispatcher() { return getContext().getDispatcher(); } public Logger getLogger() { return getContext().getLogger(); } public Series<Parameter> getParameters() { return getContext().getParameters(); } }; but that seems like it might be useless if the context is shadowed somehow. --Alex Milowski