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

Mark Struberg commented on DELTASPIKE-215:
------------------------------------------

Folks, we have 2 ways to do the trick:

In both cases we need to extract the property files pickup logic from the 
DefaultConfigSourceProvider to an own EnvironmentPropertyConfigSourceProvider 
class which takes the name of the properties files as ct param.
Please see the attached file.

The options we have beyond this is to 

A.) move all the needed classes to core-api spi package:
EnvironmentPropertyConfigSourceProvider + BaseConfigSource + 
EnvironmentPropertyConfigSource

A user could then simply write something like 

{code}
MyPropertyConfig extends EnvironmentPropertyConfigSourceProvider {
  MyPropertyConfig() {
    super("META-INF/myproject.properties");
  }
}
{code}

and register it via META-INF/services.

con: 
 * that would be quite some impl details in the public spi.
 * the user would still need to write the service provider file in 
META-INF/services

pro: 
 * that would also work for configuring Extensions!
 * BaseConfigSource is nice to have in the spi anyway, as this shows pretty 
well how the ordinal stuff could be done.


B.) The second option is easier for users. We would introduce a new interface:

{code}
public interface PropertyConfigSource
{
    String getPropertyFileName();
}
{code}

which a user can implement. We would @Observes 
ProcessAnnotatedType<PropertyConfigSource> and call the 
EnvironmentPropertyConfigSourceProvider for each of them. 

con: 
 * only works for runtime stuff, not usable in CDI extensions
 * in the AfterBeanValidation phase we would need to add those additional 
ConfigSources and clean the config. This means that after the boot the config 
might change. This is misconfiguration and we might be able to detect it, but 
this means that we need to code more to make it fools-safe.

pro:
 * easier for users
 * much less stuff in the spi
                
> Add a new annotation to override the location of the 
> apache-deltaspike.properties file
> --------------------------------------------------------------------------------------
>
>                 Key: DELTASPIKE-215
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-215
>             Project: DeltaSpike
>          Issue Type: New Feature
>            Reporter: Charles Moulliard
>         Attachments: DELTASPIKE-215-interface.patch
>
>
> I don't see a property (or annotation) that we can use to override the name 
> to be used to load the properties file 
> (META-INF/apache-deltaspike.properties) and its location like we can do with 
> Spring (@ContextConfiguration(locations = { "classpath:mycontext.xml" })).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to