esa / CCSDS_MO_APIS

Holds the generated Java APIs for the CCSDS MO services
Other
2 stars 6 forks source link

How to deinit a whole Area? #11

Open gbonnefille opened 7 years ago

gbonnefille commented 7 years ago

The generated helpers (i.e. MALHelper) offer a init function to register all data types into the ElementFactory. But when called twice, an exception occurs.

org.ccsds.moims.mo.mal.MALException: Service already included in area
        at org.ccsds.moims.mo.mal.MALArea.addService(MALArea.java:166)

Is there a function providing the opposite behavior of init?

SamCooper commented 7 years ago

There is not unfortunately.

The whole init approach is something we are going to look at replacing in the next version of the Java MAL API as it is quite inflexible (as you have found).

gbonnefille commented 7 years ago

IMO, the idea of a whole init is a good idea, but it reclaims the opposite function.

I can easily imagine a project involving the Java MAL API in an OSGi context. In such context, the project will certainly want to create an Activator registering and unregistering the types embedded in a module when the bundle is loaded and unloaded. By this way, the platform is ready to use immediately, without any action of the end user.

SamCooper commented 7 years ago

Yes, true, but I am concerned about multiple registrations and deregistrations.

I have a feeling there is a better approach to this problem that avoids situations like this.

gbonnefille commented 7 years ago

Oh... OK. Nice to read you have other solutions.

SamCooper commented 7 years ago

Well I wouldn't go as far as saying we have a solution! But we do feel your pain and we have aims to fix it in a future release. See

https://github.com/SamCooper/JAVA_SPEC_RIDS/issues/20