Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

What does @Context consist of?

Dana
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2013

Please refer me to the documentation to investigate which services I could retrive from @Context annotation in REST.

In detail.

I have POST function like this:

@POST
    @Produces(RestUtils.APPLICATION_JSON_UTF8)
public String postFunc( @Context Settings settings) {
pluginSettings.add(settings.getString("some-key"));
        return <some String>;

    }

I want to retrive smth like Settings or RepositoryHookContext, how could I achieve it?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
ThomasA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

Hi Dana,

The @Context annotation is used to lookup Stash objects based on the URL. For example "@Context Project project" will lookup the project based on the URL "projects/{projectKey}".

All of the items which Stash provides for use with the @Context annotation extend the class com.atlassian.stash.internal.rest.inject.AbstractResourceInjectable if you want to take a look to see what is injectable.

For adding your own injectable you would need to write your own Jersey InjectableProvider. Note that this would be a low level change and not part of the Stash public API and so is subject to change/breakage in the future.

I would suggest it would be easier to just supply plain parameters to your REST endpoints and do your lookups in the service layer.

Regards,

Tom.

TAGS
AUG Leaders

Atlassian Community Events