Use case
--------------
MS F/W should support at least two bean lifecycle methods so that one
method get call during the service start-up while other one get call just
before the service shutdown. We already have following use cases but this
should be a much lengthy list when implementing real world use cases.

1) Service stat publishing - During the service start-up, it should be
possible to initialize DAS agents and make connections, then during the
service shutdown it should be possible to terminate DAS agents properly and
close any connection remains.

2.) Metadata publishing - During the service start-up, it should be
possible to publish service and endpoint metadata into a centralized
metadata repository such as G-Reg and during the service shutdown it should
be possible to remove/deactivate service or endpoint metadata on metadata
repository.

3.) Handle connection establishment and termination for data sources such
as RSBMS, LDAPs , legacy systems etc.


Solution
--------------

Instead of introducing our own proprietary approaches we could use
@PostConstruct[1]  and @PreDestroy[2]  annotations available with JDK.
Users just need to annotate their init and termination methods as follows.
Additionally this is a natural choice for those who familiar with
JAX-WS/JAX-RS programming models where above annotation are used for same
purpose.

    @PostConstruct
    public void init() {
        LOG.info("Helloworld :: calling PostConstruct method");
    }

    @PreDestroy
    public void close() {
        LOG.info("Helloworld :: calling PreDestroy method");
    }


I have added above 2 annotation support to MS trunk, please refer following
working sample[3].


@IsuruP , since we have service lifecycle support now, we need to refactor
your analytics sample to use proper annotations and it will become a real
world sample as well, [3] is too simple to demonstrate real world use
cases.


[1] -
https://docs.oracle.com/javaee/5/api/javax/annotation/PostConstruct.html
[2] - https://docs.oracle.com/javaee/5/api/javax/annotation/PreDestroy.html
[3] - https://github.com/wso2/product-mss/tree/master/samples/lifecycle


Thanks !
-- 
Sagara Gunathunga

Architect; WSO2, Inc.;  http://wso2.com
V.P Apache Web Services;    http://ws.apache.org/
Linkedin; http://www.linkedin.com/in/ssagara
Blog ;  http://ssagara.blogspot.com
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to