When extending an existing Portal Container, the name of the portal in the Extension's configuration happens to be the same as the name of the existing Portal Container. The configuration (and other aspects) of the existing Portal Container can thus be shadowed by the Extension. Using this approach, many aspects of an available Portal Container can be customized, such as:
How the Shadowing Mechanism Works
A schematic representation of the shadowing mechanism can be seen in the following diagram:
portalextensionstructure
The principal role in the extension mechanism is played by the definition of the Portal Container which happens in conf/configuration.xml of the Extension EAR. Consider the following snippet coming from Portal Extension Quickstart. Note that the name parameter of the PortalContainerDefinition is set to "portal". Since a Portal Container called "portal" already exists in the default GateIn Portal installation, we actually redefine that existing Portal Container here:
configuration.xml
19. <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20. xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd http://www.exoplaform.org/xml/ns/kernel_1_2.xsd" xmlns="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd">
21. <external-component-plugins>
22. <!-- The full qualified name of the PortalContainerConfig -->
23. <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
24. <component-plugin>
25. <!-- The name of the plugin -->
26. <name>Add PortalContainer Definitions</name>
27. <!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
28. <set-method>registerPlugin</set-method>
29. <!-- The full qualified name of the PortalContainerDefinitionPlugin -->
30. <type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
31. <init-params>
32. <object-param>
33. <name>portal</name>
34. <object type="org.exoplatform.container.definition.PortalContainerDefinition">
35. <!-- The name of the Portal Container: note that a Portal Container called "portal"
36. already exists in the default GateIn installation. Therefore, we actually redefine
37. that existing Portal Container here. -->
38. <field name="name">
39. <string>portal</string>
40. </field>
41. <!-- The name of the context name of the rest web application -->
42. <field name="restContextName">
43. <string>rest</string>
44. </field>
45. <!-- The name of the realm -->
46. <field name="realmName">
47. <string>gatein-domain</string>
48. </field>
49. <field name="externalSettingsPath">
50. <string>configuration.properties</string>
51. </field>
52. <!--
53. The list of all the context names that are needed to initialize the Portal Container properly.
54. The order of the dependencies will define the initialization order and also the order for
55. loading resources. When a resource with the same path, say /dir/subdir/resource, is available
56. in more than one of the listed contexts, the one from the context closest to the end of this list
57. will be chosen. Here we want the resources available in gatein-portal-extension to win over all
58. other resources. Therefore we have added gatein-portal-extension as the last element of the list.
59. -->
60. <field name="dependencies">
61. <collection type="java.util.ArrayList">
62. <value>
63. <string>eXoResources</string>
64. </value>
65. <value>
66. <string>portal</string>
67. </value>
68. <value>
69. <string>dashboard</string>
70. </value>
71. <value>
72. <string>exoadmin</string>
73. </value>
74. <value>
75. <string>eXoGadgets</string>
76. </value>
77. <value>
78. <string>gwtGadgets</string>
79. </value>
80. <value>
81. <string>eXoGadgetServer</string>
82. </value>
83. <value>
84. <string>rest</string>
85. </value>
86. <value>
87. <string>web</string>
88. </value>
89. <value>
90. <string>gatein-portal-extension</string>
91. </value>
92. </collection>
93. </field>
94. </object>
95. </object-param>
96. </init-params>
97. </component-plugin>
98. </external-component-plugins>
99. </configuration>
Other resources available in an existing Portal Container can be customized in a similar way. Please refer to the following sections for more details.