1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.component.internal; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Named; |
24 |
|
|
25 |
|
import org.xwiki.component.internal.multi.ComponentManagerManager; |
26 |
|
import org.xwiki.component.manager.ComponentManager; |
27 |
|
import org.xwiki.model.EntityType; |
28 |
|
import org.xwiki.model.reference.EntityReference; |
29 |
|
import org.xwiki.model.reference.EntityReferenceResolver; |
30 |
|
import org.xwiki.model.reference.EntityReferenceSerializer; |
31 |
|
|
32 |
|
|
33 |
|
@link |
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 2 |
Complexity Density: 0.25 |
|
38 |
|
public abstract class AbstractEnityComponentManagerFactory extends AbstractComponentManagerFactory |
39 |
|
{ |
40 |
|
@Inject |
41 |
|
@Named("explicit") |
42 |
|
private EntityReferenceResolver<String> resolver; |
43 |
|
|
44 |
|
@Inject |
45 |
|
private EntityReferenceSerializer<String> serializer; |
46 |
|
|
47 |
|
@Inject |
48 |
|
private ComponentManagerManager manager; |
49 |
|
|
50 |
|
protected abstract EntityType getEntityType(); |
51 |
|
|
|
|
| 80% |
Uncovered Elements: 2 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
52 |
8 |
@Override... |
53 |
|
public ComponentManager createComponentManager(String namespace, ComponentManager parentComponentManager) |
54 |
|
{ |
55 |
|
|
56 |
8 |
EntityReference reference = |
57 |
|
this.resolver.resolve(namespace.substring(getEntityType().getLowerCase().length() + 1), getEntityType()); |
58 |
|
|
59 |
|
|
60 |
8 |
EntityReference parentReference = reference.getParent(); |
61 |
|
|
62 |
8 |
ComponentManager parent; |
63 |
8 |
if (parentReference != null) { |
64 |
|
|
65 |
8 |
String parentNamespace = |
66 |
|
parentReference.getType().getLowerCase() + ':' + this.serializer.serialize(parentReference); |
67 |
|
|
68 |
|
|
69 |
8 |
parent = this.manager.getComponentManager(parentNamespace, true); |
70 |
|
} else { |
71 |
0 |
parent = parentComponentManager; |
72 |
|
} |
73 |
|
|
74 |
8 |
return this.defaultFactory.createComponentManager(namespace, parent); |
75 |
|
|
76 |
|
} |
77 |
|
} |