polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@hedhman.org>
Subject POLYGENE-129 @PostConstruct & PreDestroy
Date Tue, 11 Apr 2017 07:53:09 GMT
There is a concrete proposal for 3.0

 1. Support these annotations in 3.0
 2. Deprecate LifeCycle and Initalizable in 3.0
 3. Remove LifeCycle and Initalizable in 4.0

The implementation of @PostConstruct and PreDestroy is somewhat unclear.

We have InjectedMethodsModel, which describes what needs to be injected in
a method, say

void abc( @Structure Module module, @Service MyService service);

and we are very flexible on this point, and that is done for constructors,
and also in other cases (not sure when). It would be most natural to use
this mechanism, BUT javax.annotation spec says otherwise;

<quote>
 The method on which the PostConstruct annotation is applied MUST fulfill
all of the following criteria:


   - The method MUST NOT have any parameters except in the case of
   interceptors in which case it takes an InvocationContext object as defined
   by the Interceptors specification.
   - The method defined on an interceptor class MUST HAVE one of the
   following signatures:
   - void <METHOD>(InvocationContext)
      - Object <METHOD>(InvocationContext) throws Exception

Note: A PostConstruct interceptor method must not throw application
exceptions, but it may be declared to throw checked exceptions including
the java.lang.Exception if the same interceptor method interposes on
business or timeout methods in addition to lifecycle events. If a
PostConstruct interceptor method returns a value, it is ignored by the
container.


   - The method defined on a non-interceptor class MUST HAVE the following
   signature:
   - void <METHOD>()
   - The method on which PostConstruct is applied MAY be public, protected,
   package private or private.
   - The method MUST NOT be static except for the application client.
   - The method MAY be final.
   - If the method throws an unchecked exception the class MUST NOT be put
   into service except in the case of EJBs where the EJB can handle exceptions
   and even recover from them.

</quote>


This spec is in my opinion not compatible with Polygene, and I suggestthat
POLYGENE-129 is closed as WONTFIX.


WDYT?


Cheers
-- 
Niclas Hedhman, Software Developer
http://polygene.apache.org - New Energy for Java

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message