Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1040589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:14:34+00:00 2026-05-16T15:14:34+00:00

I have multiple plug-ins in my RCP-based project. I want to be able to

  • 0

I have multiple plug-ins in my RCP-based project. I want to be able to define @XMLElements in one plug-in that can then be marshaled / un-marshaled from the core plugin. To do so, I report the classes that are serializable as soon as the plug-in is loaded. However, dynamically adding classes seems to be not supported by the JAXBContext. I implemented a work-around by holding all classes in a list and creating a new JAXBContext every time some new classes are reported based on that list, but this solution is not really nice.

Is there a better way to do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:14:35+00:00Added an answer on May 16, 2026 at 3:14 pm

    You definitely can not add classes dynamically to a JAXBContext. This has to do with maintaining the thread safety of JAXBContext.

    I have recently posted an example on my blog explaining how to leverage the @XmlAnyElement annotation to generate a generic message that could have different payloads:

    • http://bdoughan.blogspot.com/2010/08/using-xmlanyelement-to-build-generic.html

    Root Object

    The root element for the body property will be controlled by that objects @XmlRootElement.

    package message;   
    
    import javax.xml.bind.annotation.*;   
    
    @XmlRootElement@XmlAccessorType(XmlAccessType.FIELD) 
    public class Message {
        @XmlAttribute
        private String to;       
    
        @XmlAttribute    
        private String from;       
    
        @XmlAnyElement    
        private Object body;   
    }
    

    Creating the JAXBContext

    Instead of creating the JAXBContext on an array of classes, the JAXBContext could be created on a context path:

    JAXBContext.newInstance("message:customer:product"); 
    

    This context path includes 3 package names seperated by the colon ‘:’ character. In each of these packages we need to include a file named jaxb.index with a list of files. Below is an example of the jaxb.index file in the customer package:

    Address
    Customer 
    

    When we want to add a model to represent orders to our framework we would extend our JAXBContext creation to like (this String could be passed in as a variable):

    JAXBContext.newInstance("message:customer:product:order"); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a single maven project that has multiple main classes. I want to
I have multiple URLs that returns zip files. Most of the files, I'm able
I have tried multiple plug-ins for ads and for each page refresh they all
I have a multiple user/location RCP application that currently utilizes several user configurable options.
I am developing an open-source emulator project, and it has multiple, customizable native plug-ins.
On my web page, I have multiple independent plug-ins (for lack of a better
I have a project in PHP that uses multiple tabs on a single page,
I have multiple JavaScript draggable DIV windows. When clicking a DIV, I want the
I have multiple applications that share a config file that sets up NLog partially
I have multiple column headers that spans of multiple column and I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.