Bill,
We could do this in AMX. AMX DomainRoot has:
/**
@return the directory for the domain
@since Glassfish V3
*/
@ManagedAttribute
public String getDomainDir();
/**
@return the configuration directory, typically 'config'
subdirectory of {_at_link #getDomainDir}
@since Glassfish V3
*/
@ManagedAttribute
public String getConfigDir();
/**
@return the installation directory
@since Glassfish V3
*/
@ManagedAttribute
@Description("the installation directory")
public String getInstallDir();
Lloyd
On Aug 12, 2009, at 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?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>
Lloyd Chambers
lloyd.chambers_at_sun.com
GlassFish Team