Menu

Feature Request: Extend Bean Serializer/ TraverserProcessor for Immutable classes

Hannes
2016-04-07
2016-09-30
  • Hannes

    Hannes - 2016-04-07

    Hi,

    derived from but somewhat seperate from the other topic in help forum there is a feature I see as generally interesting:
    We are often using immutable data classes, these follow the bean standard in that they declare getters for all fields, but they obviously don't have setters. Instead all field can be set in the constructor as arguments in the exact same order as the getters.
    Thus it should be possible to configure the bean processor(s) to use exactly that mechanic.

    Also: Is the java.beans.Transient annotation respected? That would also be handy :)

    For now we will either restrain from using immutable dataclasses in service invocations or implement our own processors for these cases where it can't be avoided. For those interested: the details of how to implement specific processors (for the current version) is in the aforementioned post (https://sourceforge.net/p/jadex/discussion/274112/thread/cab655b0/?limit=25#f152).

    kind regards
    Hannes

     

    Last edit: Hannes 2016-04-07
  • Hannes

    Hannes - 2016-05-09

    Hi all,

    there is two more requests. I put them in here since they are rather small, but would you prefer having each in its own thread?

    1) Support of service inheritance:

    SServiceProvider.getDeclaredService(external, service.class)
    

    does not seem to support inheritance, so when having

    interface A extends B {}
    
    @Service
    @ProvidedServices({@ProvidedService(type = A.class)})
    class C implements A {}
    
    SServiceProvider.getDeclaredService(cExternalAccess, B.class)
    

    throws a ServiceNotFoundException: B.class
    As far as I can see there shouldn't be much in the way to enable that.

    2) It would be sweet if there was a method to check which Services an IExternalAccess exhibits, something like:

    SServiceProvider.checkDeclaredService(external, service.class)
    

    or

    SServiceProvider.getAllDeclaredServices(external)
    

    I needed that first functionality and was thrown back to a try {} catch(ServiceNotFoundException) which is naturally slow. Is there a way of testing it that I didn't see?


    These requests might be somewhat unusual, I just post them here for your evaluation of their usefulness and don't expect them to be incorporated. If they do make it into future versions it would be nice if you could answer here accordingly.

    Regards
    Hannes

     
  • Lars Braubach

    Lars Braubach - 2016-05-26

    Hi Hannes,

    sorry for the late reply.

    1) Service inheritance is supported. An example is provided in applications-micro/testcases/serviceinheritance

    2) There is a corresponding method in SServiceProvider. You can use exta.scheduleStep() to execute it you only have the external access.
    /**

     *  Get all declared services of the given provider.
     *  @return The corresponding services.
     */
    public static IIntermediateFuture<IService> getDeclaredServices(IInternalAccess component)
    

    Feel free to explain more what you exactly need.

    Best
    Lars

     
  • Hannes

    Hannes - 2016-09-27

    Hello Jadex Team,

    another small feature request: Could you implement a proper equals method for External Access? I was using them as keys in a map (after receiving them through a service call) and assumed the entries would be overridden properly. That had me searching for a while.
    I built a workaround for now.
    Or if there is a reason why no proper equals method can be implemented I'd be curious to know.

    Thanks and regards
    Hannes

     
  • Lars Braubach

    Lars Braubach - 2016-09-30

    Hi Hannes,

    good point and strange that it does not have equals/hashcode. A little bit a problem is that using the component id might not be 100% correct. In case component ids can be reclaimed after a component termination there could be two external accesses belonging to different components that are equal. One of those is of course invalid then. I will implement this despite this issue.

    Kind regards
    Lars

     

Log in to post a comment.

MongoDB Logo MongoDB