Simon Kitching wrote:
Murray Altheim schrieb:
[...]Using the existing feature of the ClassUtil (without modification), you
add your class mappings to ClassUtil's classmappings.xml file:
public static final String MAPPINGS = "/ini/classmappings.xml";
then let WikiEngine instantiate them using the existing code:
m_authenticationManager = (AuthenticationManager)
ClassUtil.getMappedObject(AuthenticationManager.class.getName());
m_authorizationManager = (AuthorizationManager)
ClassUtil.getMappedObject(
AuthorizationManager.class.getName());
I don't see how a modification of ClassUtil is necessary here. The real
grunt work is rewriting the two AA classes. But so far as I understand
your requirements, the existing machinery permits this.
As you show above, the WikiEngine class explicitly casts the returned
object to class AuthenticationManager. So I must *subclass*
AuthenticationManager or this code will throw a ClassCastException at
runtime. But I cannot subclass AuthenticationManager because it is
final, and so are many of its important methods.
No, please read again either what I wrote, the ClassUtil code, or the
contents of /etc/ini/classmappings.xml. ClassUtil receives a Class
name, but that's *not* the class it will use if there is an
alternative mapping set up in ClassUtil.MAPPINGS. If you modify
classmappings.xml you can instantiate your own classes, e.g.:
<classmappings>
<mapping>
<requestedClass>com.ecyrd.jspwiki.auth.AuthenticationManager</requestedClass>
<mappedClass>com.acme.auth.MyAuthenticationManager</mappedClass>
</mapping>
<mapping>
<requestedClass>com.ecyrd.jspwiki.render.AuthorizationManager</requestedClass>
<mappedClass>com.acme.auth.MyAuthorizationManager</mappedClass>
</mapping>
</classmappings>
There's no need to modify anything in JSPWiki's code, nor use the same
package names as JSPWiki to obtain the behaviour you want. Just map
to your desired, custom classes and your good to go. That's what
ClassUtil does.
Murray
...........................................................................
Murray Altheim <murray07 at altheim.com> === = =
http://www.altheim.com/murray/ = = ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk = = = =
Boundless wind and moon - the eye within eyes,
Inexhaustible heaven and earth - the light beyond light,
The willow dark, the flower bright - ten thousand houses,
Knock at any door - there's one who will respond.
-- The Blue Cliff Record