You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

There are several types of Plugins, each with their own distinct features. The "B" in WCB stands for "Bundle", which means that the different features can be bundled together in one WCB. This page explains how to combine different types.

Make sure your WCBs are created from an archetype. To learn how to do this,  take a look at the WCB Development - Quickstart document. By starting your WCBs based on archetypes, you always have the most clean example code available. Merging WCBs basically means merging the "Activator.java" files and the directory structures of all your WCB's.

Below you see the steps that need to taken to complete the merge.

1. Examine your current situation: what's the current status of the WCB's you're about to merge? If you're still in development (eg: there's no real content for this WCB), the strategy below could be followed. When you do have real content, another strategy is needed because content that is written to the JCR by a WCB is linked to it's WCB ID. Changing the WCB ID this WCB would loose all it's JCR content. If the WCB is already in use, go to step  2b. Existing WCB.

2a. New WCB

Create a "generic" WCB with a common package and bundle name, so that the functionality you're about to merge fits this name. For example: when you have a BookReviewMediaItem and a BookReviewElement, the common package name "Books" could be plausible. Keep in mind that a new WCB id is created now.

Go to step 3.

2b. Existing WCB

When you have an existing WCB (with real content), where functionality needs to be added to, you have another situation. Use the original root package/domain, to ensure backwards compatibility.

3. Now add the source files of the WCB's step by step, starting with the following:

  • Java packages in /src/main/java
  • JSPFs in editpresentation & JSPFs plus XMLs (descriptor files) in showpresentation / presentationtype (check for identical names!)
  • Static files in /static/backend

4. Now the "difficult" part needs to be done: merging files. The following files need to be merged:

  • Activator.java -> read below 1. Activator.java
  • Messages in /src/main/resources/messages
  • WCBConstants.java in /src/main/java/.../api
  • Online Help files in /src/main/resources/help.*
  • POM files (dependencies have to be added). Remember to re-run the Maven eclipse:eclipse command to let Eclipse know something changed.

5. In Eclipse you will still notice some errors, because certain classes cannot be found anymore. Therefore packages have to be renamed, so that they will fit in the new package.
Example: the new "generic" package is named: com.gxwebmanager.solutions.books
The "old" WCB package name was: com.gxwebmanager.solutions.bookreviewmediaitem

The latter has to refactored through Eclipse, to the following:
com.gxwebmanager.solutions.books.bookreviewmediaitem

6. The last thing you need to do, is the use the "organize import" functionality in Eclipse, to update references. O, and don't forget to manually update the implementation class, Eclipse might not fix that for you.

Example: @Interfaces("com.gxwebmanager.solutions.bookreviewmediaitem.api.ReviewMediaItemMediaItemVersion")

Has to be changed to:

@Interfaces("com.gxwebmanager.solutions.books.api.ReviewMediaItemMediaItemVersion")

1. Activator.java
First: all your WCBs have a file named "Activator.java". This file is responsible for setting up the WCB and allows WebManager to 'know' what is inside the WCB and how to interact with it. Choose one WCB that you want to merge the others into and examine its "Activator.java" file. In particular, examine the "getBundleDefinition()" method as it sums up the component definitions.

34  /**
35   * Creates and returns the bundle definition of the WebManager component bundle
36   * @return the bundle definition of the WebManager component bundle
37   */
38  @Override
39  protected ComponentBundleDefinition getBundleDefinition() {
40      ComponentBundleDefinitionImpl componentBundleDefinition = new ComponentBundleDefinitionImpl();
41      componentBundleDefinition.setId(BUNDLE_DEFINITION_ID);
42      componentBundleDefinition.setName("Presentation " + WCB_ID);
43      componentBundleDefinition.setDescription("WCB containing presentation " + WCB_ID);
44      ComponentDefinition[] componentDefinitions = new ComponentDefinition[]{getPresentationComponentDefinition()};
45      componentBundleDefinition.setComponentDefinitions(componentDefinitions);
46      return componentBundleDefinition;
47  }
48  /**
49   * Returns the component definition for the presentation component
50   * @return The component definition for the presentation component
51   */
52  protected ComponentDefinition getPresentationComponentDefinition() {
53      PresentationComponentDefinitionImpl definition = new PresentationComponentDefinitionImpl(false);
54      definition.setId(COMPONENT_DEFINITION_ID);
55      definition.setName(WCB_ID + " presentation");
56      definition.setDescription("Implements the " + WCB_ID + " presentation");
57      definition.setTypeId(PresentationComponentType.class.getName());
58      definition.setProperties(new Hashtable<String, String>());
59      definition.setImplementationClassName(SimplePresentationComponent.class.getName());
60      definition.setInterfaceClassNames(new String[]{PresentationComponent.class.getName()});
61      definition.setDependencies(new ComponentDependency[]{});
62      definition.setWrapperClassNames(new String[]{});
63      return definition;
64  }

 

On line 44, all component definitions are summed up in the componentDefinitions array. If you want to bundle more WCBs, you have to expand that array.

Line 48 - 64 contain the component definition of one WCB, in this case a presentation WCB. Copy the definition methods from the other "Activator.java" files that you want to merge after this method "getPresentationComponentDefinition()".

Next, expand the "componentDefinitions" array on line 44 by using all your definition methods, e.g. like below:

44  ComponentDefinition[] componentDefinitions = new ComponentDefinition[] {
45      getPresentationComponentDefinition(),
46      getElementComponentDefinition(),
47      getServiceComponentDefinition()
48  };
  • No labels