You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2022/04/05 05:16:00 UTC
[struts-site] branch extension-points updated: Adds section about defining extension points using plugins
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch extension-points
in repository https://gitbox.apache.org/repos/asf/struts-site.git
The following commit(s) were added to refs/heads/extension-points by this push:
new a316d823e Adds section about defining extension points using plugins
a316d823e is described below
commit a316d823e71cb4fcbecebcc57de8662cf7dad9b6
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Tue Apr 5 07:15:55 2022 +0200
Adds section about defining extension points using plugins
---
source/plugins/plugins-architecture.md | 35 ++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/source/plugins/plugins-architecture.md b/source/plugins/plugins-architecture.md
index cabc74def..8acb3c9f0 100644
--- a/source/plugins/plugins-architecture.md
+++ b/source/plugins/plugins-architecture.md
@@ -299,6 +299,41 @@ struts.date.formatter=myDateTimeFormatter
### Extension point provided by a plugin
+It's very the like as above except that the plugin must provide a `bean-selection` configuration option in `struts-plugin.xml`.
+The `bean-selection` option represents an implementation of a class `org.apache.struts2.config.AbstractBeanSelectionProvider`
+with _no-arguments_ constructor:
+
+```java
+public class VelocityBeanSelectionProvider extends AbstractBeanSelectionProvider {
+
+ @Override
+ public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
+ alias(VelocityManager.class, VelocityConstants.STRUTS_VELOCITY_MANAGER_CLASSNAME, builder, props);
+ }
+
+}
+```
+
+The class defines extension points by implementing `register()` method and using `alias()` method to register them.
+
+And finally it must be added to the `struts-plugin.xml`:
+
+```xml
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE struts PUBLIC
+ "-//Apache Software Foundation//DTD Struts Configuration 2.6//EN"
+ "http://struts.apache.org/dtds/struts-2.6.dtd">
+
+<struts>
+ ...
+
+ <bean-selection name="velocityBeans" class="org.apache.struts2.views.velocity.VelocityBeanSelectionProvider"/>
+
+</struts>
+```
+
+And now other plugins or user application can use the new extension point represented by `VelocityConstants.STRUTS_VELOCITY_MANAGER_CLASSNAME`.
+
## Plugin Registry
> For a list of bundled plugins, see the [Plugin Reference Documentation](index). For more about bundled and third-party