On 8/12/09 4:28 PM, Bill Shannon wrote:
> Ludovic Champenois wrote on 8/12/09 3:56 PM:
>
>> On 8/12/09 3:29 PM, Bill Shannon wrote:
>>
>>> I'm writing some code that runs in the server and needs to create a file
>>> in the config directory for the current domain. What's the right way to
>>> get a String or File object representing the config directory?
>>>
>>>
>>>
>> I think
>> @Inject org.glassfish.server.ServerEnvironmentImpl env;
>> ...
>> String rootFolder =
>> env.getProps().get(com.sun.enterprise.util.SystemPropertyConstants.INSTANCE_ROOT_PROPERTY)
>> ;
>> should gives you the domain dir, then /config is under it.
>>
> Thanks, that was the hint I needed. I ended up with:
>
> @Inject ServerEnvironment env;
>
> and used
>
> env.getConfigDirPath()
>
>
> Next question...
>
> If I want to define a public constant for the name of the file in the
> config directory, where should I define it? In SystemPropertyConstants?
>
No real opinion, but it's not a 'systemproperty' :-) (unless you want
this to be configurable, which I don't recommend)
Maybe there is a better place? Don't know
But greping for "domain.xml" shows hardcoded string in many places...
Ludo
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>
>