You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Arne Stabenau <st...@gmail.com> on 2010/12/16 14:16:22 UTC
Convention Plugin, Inheriting from existing projects action
Hello,
We are developing here a fairly generic web tool, which for many of our projects
we just want to customize a little. We are using the convention
plugin, since I have
a little dislike of XML config files and want to keep them to a minimum.
Ideally I would like a way to just include the base project into my
classpath and when
I want to customize an action, just subclass it and implement either a
new method
for the action or overwrite some method in the original action to do
the customization.
Well, I tried this and sometimes the subclass is used as action,
sometimes the original,
and I can't really figure out why is that. I was expecting an error
message for re-using
the same action-name (actually a warning log entry).
-- from convention plugin ---
//check if an action with the same name exists on that package
(from XML config probably)
700 PackageConfig existingPkg =
configuration.getPackageConfig(pkgCfg.getName());
701 if (existingPkg != null) {
702 // there is a package already with that name, check action
703 ActionConfig existingActionConfig =
existingPkg.getActionConfigs().get(actionName);
704 if (existingActionConfig != null && LOG.isWarnEnabled())
705 LOG.warn("Duplicated action definition in package
[#0] with name [#1].", pkgCfg.getName(), actionName);
706 }
Can it be done? With reasonable modification of the struts framework maybe?
Thanks for reading,
Arne
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Convention Plugin, Inheriting from existing projects action
Posted by Arne Stabenau <st...@gmail.com>.
Ok, after a little more code reading I think I understand a bit better.
Action names are checked for duplicates only for pre-existing configuration,
which probably means the XML config. If I annotate in the same class with
the same action name, again that is checked. Only (and this is what I think
I am doing) if I use the same Action name in different classes, no check is
performed and the second name is put in a map on top of the first name ...
bummer.
I think what I want is a check which class is more specialized
(subclass) and only use
that in the package config. So I try to put one in.
If it works, I'll post again :-)
Arne
On 16 December 2010 15:16, Arne Stabenau <st...@gmail.com> wrote:
> Hello,
>
> We are developing here a fairly generic web tool, which for many of our projects
> we just want to customize a little. We are using the convention
> plugin, since I have
> a little dislike of XML config files and want to keep them to a minimum.
>
> Ideally I would like a way to just include the base project into my
> classpath and when
> I want to customize an action, just subclass it and implement either a
> new method
> for the action or overwrite some method in the original action to do
> the customization.
>
> Well, I tried this and sometimes the subclass is used as action,
> sometimes the original,
> and I can't really figure out why is that. I was expecting an error
> message for re-using
> the same action-name (actually a warning log entry).
>
> -- from convention plugin ---
>
> //check if an action with the same name exists on that package
> (from XML config probably)
> 700 PackageConfig existingPkg =
> configuration.getPackageConfig(pkgCfg.getName());
> 701 if (existingPkg != null) {
> 702 // there is a package already with that name, check action
> 703 ActionConfig existingActionConfig =
> existingPkg.getActionConfigs().get(actionName);
> 704 if (existingActionConfig != null && LOG.isWarnEnabled())
> 705 LOG.warn("Duplicated action definition in package
> [#0] with name [#1].", pkgCfg.getName(), actionName);
> 706 }
>
> Can it be done? With reasonable modification of the struts framework maybe?
>
> Thanks for reading,
>
> Arne
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org