Changes for page Resource API

Last modified by Admin on 2024/03/28 10:54

<
From version < 5.30 >
edited by Admin
on 2015/03/30 16:49
To version < 6.1 >
edited by Vincent Massol
on 2015/04/13 13:27
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.Admin
1 +xwiki:XWiki.VincentMassol
ExtensionCode.ExtensionClass[0]
Description
... ... @@ -33,11 +33,49 @@
33 33  * UC7: Handlers should work for any type of Resource (Entity Resources, Temporary Resources, Skin Resources, etc)
34 34  * UC8: It should be possible for a Handler to be registered for one Resource type, a list of Resource types or all types
35 35  
36 +=== Adding a new Resource Type Handler ===
37 +
38 +{{info}}XWiki 7.1M1{{/info}} Extensions can register a new URL Resource Type.
39 +
40 +Here's an example of a ##webjars## Resource Type that would be called for the following types of URLs: ##http:~/~/<server>/<context path>/webjars/<path/to/resource/>##.
41 +
42 +{{code language="java"}}
43 +@Component
44 +@Named("webjars")
45 +@Singleton
46 +public class WebJarsResourceReferenceHandler extends AbstractResourceReferenceHandler<ResourceType>
47 +{
48 + /**
49 + * The WebJars Type.
50 + */
51 + public static final ResourceType TYPE = new ResourceType("webjars");
52 +
53 + @Override
54 + public List<ResourceType> getSupportedResourceReferences()
55 + {
56 + return Arrays.asList(TYPE);
57 + }
58 +
59 + @Override
60 + public List<ResourceType> getSupportedResourceReferences()
61 + {
62 + return Arrays.asList(TYPE);
63 + }
64 +
65 + @Override
66 + public void handle(ResourceReference resourceReference, ResourceReferenceHandlerChain chain)
67 + throws ResourceReferenceHandlerException
68 + {
69 + [...]
70 + }
71 +}
72 +{{/code}}
73 +
36 36  === Adding a new Entity Resource Type Handler ===
37 37  
38 38  Entity Resource References are handled by a ##ResourceReferenceHandler## component with hint ##bin## (that name corresponds to the part of the URL showing that it's a URL about an Entity). That ##ResourceReferenceHandler##, in turn, looks for ##ResourceReferenceHandler## components that are registered for the ##EntityResourceAction## to execute (##view##, ##edit##, ##download##, etc) and calls them in the right priority order.
39 39  
40 -Here's an example of a ##webjars## Entity Resource Action:
78 +Here's an example of a ##webjars## Entity Resource Action that would be called for the following types of URLs: ##http:~/~/<server>/<context path>/bin/webjars/resource/path?value=<resource name>##.
41 41  
42 42  {{code language="java"}}
43 43  @Component

Get Connected