Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
FilesystemExportContextProvider | 40 | 6 | 0% | 2 | 0 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.url.internal.filesystem; | |
21 | ||
22 | import javax.inject.Inject; | |
23 | import javax.inject.Provider; | |
24 | import javax.inject.Singleton; | |
25 | ||
26 | import org.xwiki.component.annotation.Component; | |
27 | import org.xwiki.context.Execution; | |
28 | import org.xwiki.context.ExecutionContext; | |
29 | import org.xwiki.url.filesystem.FilesystemExportContext; | |
30 | ||
31 | /** | |
32 | * Creates a new or returns an existing {@link FilesystemExportContext}. If a new one is created it's put in the | |
33 | * Execution Context and when it exists it's retrieved from the Execution Context. | |
34 | * | |
35 | * @version $Id: 5b6278af6e9ae87d7e43e7c6c15752e6a9eb9bbf $ | |
36 | * @since 7.2M1 | |
37 | */ | |
38 | @Component | |
39 | @Singleton | |
40 | public class FilesystemExportContextProvider implements Provider<FilesystemExportContext> | |
41 | { | |
42 | private static final String CONTEXT_KEY = "filesystemExportContext"; | |
43 | ||
44 | @Inject | |
45 | private Execution execution; | |
46 | ||
47 | 3 | ![]() |
48 | public FilesystemExportContext get() | |
49 | { | |
50 | 3 | ExecutionContext ec = this.execution.getContext(); |
51 | 3 | FilesystemExportContext exportContext = (FilesystemExportContext) ec.getProperty(CONTEXT_KEY); |
52 | 3 | if (exportContext == null) { |
53 | 2 | exportContext = new FilesystemExportContext(); |
54 | 2 | ec.newProperty(CONTEXT_KEY) |
55 | .inherited() | |
56 | .initial(exportContext) | |
57 | .declare(); | |
58 | } | |
59 | 3 | return exportContext; |
60 | } | |
61 | } |