XWiki uses a component architecture based on its own interfaces to enable code reuse and changing behaviors at runtime. Initially it used Plexus but later developed its own implementation using JSR330 annotations. This allows components to be installed and uninstalled dynamically at runtime. While OSGi and other solutions were considered, they were too complex or not standard enough. The custom solution has served XWiki well but it hopes to adopt a standard like CDI 1.1 in the future if dynamic registration is possible.
3. XWiki Platform
... for developing (collaborative) web applications
Copyright (c) Vincent Massol - 2011
Wednesday, September 21, 11
4. Needs (1/2)
• XWiki is a runtime development platform
• Need solution for code reuse
• Need solution to change behaviors
• Ability to install extensions transitively at
runtime
• As standard as possible
Copyright (c) Vincent Massol - 2011
Wednesday, September 21, 11
5. Needs (2/2)
• Ability to change implementation without
changing existing components
Copyright (c) Vincent Massol - 2011
Wednesday, September 21, 11
6. Discarded Solutions
• Warning: Choice done 2 years ago
• OSGi: too complex
• Resin Pomegranate: not standard enough
• Guice: static binding only
• CDI 1.0: static binding only
Copyright (c) Vincent Massol - 2011
Wednesday, September 21, 11
7. Chosen Solution (1/2)
• XWiki’s own interfaces
• Implemented using Plexus initially
• Custom implementation after Plexus was
EOLed
• Using JSR330’s annotations
• First focus: have components for everything
Copyright (c) Vincent Massol - 2011
Wednesday, September 21, 11
8. Chosen Solution (2/2)
@ComponentRole
public interface Macro
{
List<Block> execute();
}
@Component
@Named("message")
@Singleton
public class MessageMacro implements Macro
{
@Inject
private Execution execution;
@Inject
@Named("box")
private Macro boxMacro;
public List<Block> execute()
{
...
}
}
META-INF/components.txt
org.xwiki.rendering.internal.macro.message.MessageMacro
Copyright (c) Vincent Massol - 2011
Wednesday, September 21, 11
9. Lessons Learnt
• XWiki’s own interfaces have served us well
• Allowed us to switch from Plexus to our
own implementation
• But... ready to use a standard as soon as
one emerges!
• Would love to have CDI with OSGi
classloading separation ;)
Copyright (c) Vincent Massol - 2011
Wednesday, September 21, 11
10. Future
• Several possibilities
• Use CDI 1.1 when it’s out
• If it’s possible to perform dynamic bean
registration/unregistration
• Use JDK’s proposed solution (JavaSE 8?)
• We have time...
Copyright (c) Vincent Massol - 2011
Wednesday, September 21, 11