[jira] [Commented] (DELTASPIKE-1444) Create POJO and Record based Config

2021-12-08 Thread ASF subversion and git services (Jira)


[ 
https://issues.apache.org/jira/browse/DELTASPIKE-1444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17456019#comment-17456019
 ] 

ASF subversion and git services commented on DELTASPIKE-1444:
-

Commit 422a78a3c1c25b8040fa4516dfa080da0baa7ed8 in deltaspike's branch 
refs/heads/master from Mark Struberg
[ https://gitbox.apache.org/repos/asf?p=deltaspike.git;h=422a78a ]

DELTASPIKE-1444 make BeanConverter a non-static factory

otherwise we might create mem leaks, as rightfully noted by rmannibucau


> Create POJO and Record based Config
> ---
>
> Key: DELTASPIKE-1444
> URL: https://issues.apache.org/jira/browse/DELTASPIKE-1444
> Project: DeltaSpike
>  Issue Type: New Feature
>  Security Level: public(Regular issues) 
>  Components: Configuration
>Affects Versions: 1.9.5
>Reporter: Mark Struberg
>Assignee: Mark Struberg
>Priority: Major
> Fix For: 1.9.6
>
>
> Right now we only support Interface based configuration with the 
> {{@Configuration}} annotation. We could also support injecting POJOs directly 
> and even Java14 Records.
> E.g. a class 
> {code}
> public record Endpoint(String host, Integer port, String path){}
> {code}
> or with a parameter ct:
> {code}
> public class Endpoint {
>  private final String host;
>  ... 
> public Endpoint(
> @ConfigProperty(name="host") String host, 
> @ConfigProperty(name="port") Integer port, 
> @ConfigProperty(name="path") String path){
> this.host = host;
> 
> }
> }
> {code}
> Note that the {{@ConfigProperty}} annotation might get omitted if the class 
> gets compiled with the {{javac -parameters}} option.
> or with a default ct and field parameters:
> {code}
> public class Endpoint {
>  private String host;
>  private Integer port;
>  private String path;
>  ... 
> }
> {code}
> Resolving of all the required properties must be performed atomically.
> The solution might either be done via the built-in algorithms as shown above, 
> in which case the following call might be used to denote that a bean should 
> get resolved which consists of mulitple attributes:
> {code}
> ServerEndpointPojoWithCt someServer = 
> ConfigResolver.resolve("myapp.some.server")
> .asBean(ServerEndpointPojoWithCt.class)
> .getValue();
> {code} 
> or via an explicit Converter function:
> {code}
> final ServerEndpointPojoWithCt someServer = 
> ConfigResolver.resolve("myapp.some.server")
> .asBean(ServerEndpointPojoWithCt.class, (cfg, key) -> new 
> ServerEndpointPojoWithCt(
> cfg.resolve(key + ".host").getValue(),
> cfg.resolve(key + ".port").as(Integer.class).getValue(),
> cfg.resolve(key + ".path").getValue());)
> .getValue();
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (DELTASPIKE-1444) Create POJO and Record based Config

2021-12-08 Thread ASF subversion and git services (Jira)


[ 
https://issues.apache.org/jira/browse/DELTASPIKE-1444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17456018#comment-17456018
 ] 

ASF subversion and git services commented on DELTASPIKE-1444:
-

Commit facacde41ded50f3f98499354680356283fb3a99 in deltaspike's branch 
refs/heads/master from Mark Struberg
[ https://gitbox.apache.org/repos/asf?p=deltaspike.git;h=facacde ]

DELTASPIKE-1444 add POJO based Config


> Create POJO and Record based Config
> ---
>
> Key: DELTASPIKE-1444
> URL: https://issues.apache.org/jira/browse/DELTASPIKE-1444
> Project: DeltaSpike
>  Issue Type: New Feature
>  Security Level: public(Regular issues) 
>  Components: Configuration
>Affects Versions: 1.9.5
>Reporter: Mark Struberg
>Assignee: Mark Struberg
>Priority: Major
> Fix For: 1.9.6
>
>
> Right now we only support Interface based configuration with the 
> {{@Configuration}} annotation. We could also support injecting POJOs directly 
> and even Java14 Records.
> E.g. a class 
> {code}
> public record Endpoint(String host, Integer port, String path){}
> {code}
> or with a parameter ct:
> {code}
> public class Endpoint {
>  private final String host;
>  ... 
> public Endpoint(
> @ConfigProperty(name="host") String host, 
> @ConfigProperty(name="port") Integer port, 
> @ConfigProperty(name="path") String path){
> this.host = host;
> 
> }
> }
> {code}
> Note that the {{@ConfigProperty}} annotation might get omitted if the class 
> gets compiled with the {{javac -parameters}} option.
> or with a default ct and field parameters:
> {code}
> public class Endpoint {
>  private String host;
>  private Integer port;
>  private String path;
>  ... 
> }
> {code}
> Resolving of all the required properties must be performed atomically.
> The solution might either be done via the built-in algorithms as shown above, 
> in which case the following call might be used to denote that a bean should 
> get resolved which consists of mulitple attributes:
> {code}
> ServerEndpointPojoWithCt someServer = 
> ConfigResolver.resolve("myapp.some.server")
> .asBean(ServerEndpointPojoWithCt.class)
> .getValue();
> {code} 
> or via an explicit Converter function:
> {code}
> final ServerEndpointPojoWithCt someServer = 
> ConfigResolver.resolve("myapp.some.server")
> .asBean(ServerEndpointPojoWithCt.class, (cfg, key) -> new 
> ServerEndpointPojoWithCt(
> cfg.resolve(key + ".host").getValue(),
> cfg.resolve(key + ".port").as(Integer.class).getValue(),
> cfg.resolve(key + ".path").getValue());)
> .getValue();
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (DELTASPIKE-1444) Create POJO and Record based Config

2021-12-07 Thread Mark Struberg (Jira)


[ 
https://issues.apache.org/jira/browse/DELTASPIKE-1444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17454832#comment-17454832
 ] 

Mark Struberg commented on DELTASPIKE-1444:
---

Pull request for review is up here 
https://github.com/struberg/deltaspike/tree/DELTASPIKE-1444

> Create POJO and Record based Config
> ---
>
> Key: DELTASPIKE-1444
> URL: https://issues.apache.org/jira/browse/DELTASPIKE-1444
> Project: DeltaSpike
>  Issue Type: New Feature
>  Security Level: public(Regular issues) 
>  Components: Configuration
>Affects Versions: 1.9.5
>Reporter: Mark Struberg
>Assignee: Mark Struberg
>Priority: Major
> Fix For: 1.9.6
>
>
> Right now we only support Interface based configuration with the 
> {{@Configuration}} annotation. We could also support injecting POJOs directly 
> and even Java14 Records.
> E.g. a class 
> {code}
> public record Endpoint(String host, Integer port, String path){}
> {code}
> or with a parameter ct:
> {code}
> public class Endpoint {
>  private final String host;
>  ... 
> public Endpoint(
> @ConfigProperty(name="host") String host, 
> @ConfigProperty(name="port") Integer port, 
> @ConfigProperty(name="path") String path){
> this.host = host;
> 
> }
> }
> {code}
> Note that the {{@ConfigProperty}} annotation might get omitted if the class 
> gets compiled with the {{javac -parameters}} option.
> or with a default ct and field parameters:
> {code}
> public class Endpoint {
>  private String host;
>  private Integer port;
>  private String path;
>  ... 
> }
> {code}
> Resolving of all the required properties must be performed atomically.
> The solution might either be done via the built-in algorithms as shown above, 
> in which case the following call might be used to denote that a bean should 
> get resolved which consists of mulitple attributes:
> {code}
> ServerEndpointPojoWithCt someServer = 
> ConfigResolver.resolve("myapp.some.server")
> .asBean(ServerEndpointPojoWithCt.class)
> .getValue();
> {code} 
> or via an explicit Converter function:
> {code}
> final ServerEndpointPojoWithCt someServer = 
> ConfigResolver.resolve("myapp.some.server")
> .asBean(ServerEndpointPojoWithCt.class, (cfg, key) -> new 
> ServerEndpointPojoWithCt(
> cfg.resolve(key + ".host").getValue(),
> cfg.resolve(key + ".port").as(Integer.class).getValue(),
> cfg.resolve(key + ".path").getValue());)
> .getValue();
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)