[cdi-dev] [JBoss JIRA] (CDI-114) Allow registration of beans at runtime

Vincent Massol (JIRA) issues at jboss.org
Mon Feb 20 03:32:00 EST 2017


    [ https://issues.jboss.org/browse/CDI-114?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13365874#comment-13365874 ] 

Vincent Massol commented on CDI-114:
------------------------------------

{quote}So you allow that your users upload some jar which you then dynamically add to you Classpath?
Or how does the XWiki container become aware of that new functionality?
Does XWiki use OSGi (which would be suited for such a dynamic reload)? 
Or do you roll your own ClassLoader system?{quote}

Yes admin users (or any user having the right permission) can install JAR extensions.

XWiki doesn't use OSGI. We asked ourselves the question initially but it was way too compex and heavy so we decided that we wouldn't be able to have several versions of the same class with different versions in XWiki. We have a simple custom Component system to manage this (the main class is here if you're curious: https://github.com/xwiki/xwiki-commons/blob/master/xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-default/src/main/java/org/xwiki/component/embed/EmbeddableComponentManager.java).

We do have our own classloader (we have one per namespace - XWiki supports multiple wikis and a namespace is for example one wiki, to provide isolation per wiki). When a JAR extension is uninstalled, we recreate the classloader, removing the JAR URL. FYI: https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-classloader/xwiki-platform-classloader-xwiki/src/main/java/org/xwiki/classloader/xwiki/internal/ContextNamespaceURLClassLoader.java and and https://github.com/xwiki/xwiki-commons/blob/master/xwiki-commons-core/xwiki-commons-classloader/xwiki-commons-classloader-api/src/main/java/org/xwiki/classloader/URIClassLoader.java (this later one is just there to overcome JDK bugs/limitations).








> Allow registration of beans at runtime
> --------------------------------------
>
>                 Key: CDI-114
>                 URL: https://issues.jboss.org/browse/CDI-114
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Beans
>    Affects Versions: 1.0
>            Reporter: Vincent Massol
>             Fix For: TBD
>
>
> I have use cases where I need to register a bean dynamically at runtime (see the forum reference link for a detailed description of the use case).



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the cdi-dev mailing list