Download Nuxeo Enterprise Platform
Transcript
Nuxeo Runtime Example of a component declaring two extension points: 1. listeners 2. asyncListeners <?xml version="1.0"?> <component name="org.nuxeo.runtime.EventService"> <implementation class="org.nuxeo.runtime.services.event.EventService"/> <extension-point name="listeners"> <object class="org.nuxeo.runtime.services.event.ListenerDescriptor"/> </extension-point> <extension-point name="asyncListeners"> <object class="org.nuxeo.runtime.services.event.AsyncListenerDescriptor"/> </extension-point> </component> 25.6.2.3.2. Contributing an extension Once a component declaring some extension points has been activated, other components may contribute extensions to that extension point. To declare an extension, the extension tag is used. This tag must contains a target and a point attribute. 1. target The target attribute specifies the name of the component providing the extension point 2. point The point attribute is the extension point name. The extension element may contain arbitrary XML. The actual XML content is recognized only by the extension point to where the extension is contributed. This means you should know the correct format for the extension XML. For this reason, it is important for components to document their extension points. If the extension point is using XMap to map XML to Java objects, then you can use annotations existing on the contribution object class to know the XML format. These annotations are easy to understand and can be used as well as a documentation for the XML extension format. If you are familiar with Eclipse extension points, you may wonder why Nuxeo Runtime is not using an XSD schema to define the content of an XML extensions. The reason is simple: because inside our ECM project we need to be able to define any type of XML content - even configuration files from external tools we use like for example a Jackrabbit repository configuration. Defining and maintaining XSD schemas for this kind of extensions would be painful. Anyway, using XMap to map extensions to real Java objects makes it easy to use extensions. Here is an example on how a component is declaring some contributions to the previously defined extension points: <?xml version="1.0"?> <component name="my.component"> <implementation class=”MyComponent"/> <extension target="org.nuxeo.runtime.EventService" point="listeners"> <listener class="org.nuxeo.runtime.jboss.RepositoryAdapter"> <topic>repository</topic> </listener> <listener class="org.nuxeo.runtime.jboss.ServiceAdapter"> <topic>service</topic> </listener> </extension> </component> Nuxeo EP 5.1 / 5.2 171