Java Code Examples for org.restlet.Restlet.getContext()

The following are Jave code examples for showing how to use getContext() of the org.restlet.Restlet class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: restlet-framework   File: ClientResource.java   Source Code and License Vote up 5 votes
/**
 * Sets the next handler such as a Restlet or a Filter.
 * 
 * In addition, this method will set the context of the next Restlet if it
 * is null by passing a reference to its own context.
 * 
 * @param next
 *            The next handler.
 */
public void setNext(org.restlet.Uniform next) {
    if (next instanceof Restlet) {
        Restlet nextRestlet = (Restlet) next;

        if (nextRestlet.getContext() == null) {
            nextRestlet.setContext(getContext());
        }
    }

    this.next = next;

    // If true, it must be updated after calling this method
    this.nextCreated = false;
}
 
Example 2
Project: restlet-framework   File: InternalRouter.java   Source Code and License Vote up 5 votes
@Override
public TemplateRoute attach(Restlet target) {
    if (target.getContext() == null) {
        target.setContext(getContext().createChildContext());
    }

    return super.attach(target);
}
 
Example 3
Project: restlet-framework   File: InternalRouter.java   Source Code and License Vote up 5 votes
@Override
public TemplateRoute attach(String uriPattern, Restlet target) {
    if (target.getContext() == null) {
        target.setContext(getContext().createChildContext());
    }

    return super.attach(uriPattern, target);
}
 
Example 4
Project: restlet-framework   File: InternalRouter.java   Source Code and License Vote up 5 votes
@Override
public TemplateRoute attachDefault(Restlet defaultTarget) {
    if (defaultTarget.getContext() == null) {
        defaultTarget.setContext(getContext().createChildContext());
    }

    return super.attachDefault(defaultTarget);
}
 
Example 5
Project: restlet-framework   File: Filter.java   Source Code and License Vote up 3 votes
/**
 * Sets the next Restlet.
 * 
 * In addition, this method will set the context of the next Restlet if it
 * is null by passing a reference to its own context.
 * 
 * @param next
 *            The next Restlet.
 */
public void setNext(Restlet next) {
    if ((next != null) && (next.getContext() == null)) {
        next.setContext(getContext());
    }

    this.next = next;
}
 
Example 6
Project: restlet-framework   File: VirtualHost.java   Source Code and License Vote up 2 votes
/**
 * Checks the context and sets it if necessary.
 * 
 * @param target
 *            The target Restlet.
 */
protected void checkContext(Restlet target) {
    if ((target.getContext() == null) && (this.parentContext != null)) {
        target.setContext(this.parentContext.createChildContext());
    }
}
 
Example 7
Project: restlet-framework   File: Route.java   Source Code and License Vote up 2 votes
/**
 * Constructor.
 * 
 * @param router
 *            The parent router.
 * @param next
 *            The next Restlet.
 */
public Route(Router router, Restlet next) {
    super((router != null) ? router.getContext() : (next != null) ? next
            .getContext() : null, next);
    this.router = router;
}