This how-to considers you master the creation of the Java plug-in, and you know where to create a Java class. Otherwise please refer to the page How to create an empty bundle or use Nuxeo CLI.
The main steps to override a Seam component are:
- Look for the name of the Seam component you want to override. The name is the value of the annotation
@name
. - Add an empty file named
seam.properties
under the foldersrc/main/resources
of your plug-in. - Create a Java class in your plug-in. It's recommended to use a custom name for your own classes, to avoid having duplicated files in your IDE for instance. But it's not mandatory providing the package containing your class is different from the default one.
Overriding the default Seam component now implies three actions:
- Reuse the same
name
you found in the@name
annotation, - Reuse the same
scope
, unless you know what you are doing, - Indicate that your component will be loaded after the default one: this is done with the annotation
@Install
and the valueInstall.DEPLOYMENT
(because the default component should have no value for this annotation, or valueInstall.FRAMEWORK
).
You should get a class structured like below:
package org.nuxeo.sample.howto; import org.jboss.seam.annotations.Install; import org.jboss.seam.annotations.Name; import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.webapp.helpers.StartupHelper; @Name("startupHelper") @Scope(SESSION) @Install(precedence = Install.DEPLOYMENT) public class MyStartupHelper extends StartupHelper { private static final long serialVersionUID = 1L; @Override public String initServerAndFindStartupPage() throws ClientException { return super.initServerAndFindStartupPage(); } }
- Reuse the same
In this example, we overrode the startupHelper component to write our own version of the method initServerAndFindStartupPage
.
Related How-Tos
Related Documentation