You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Jiang Ning <ni...@iona.com> on 2006/09/29 09:51:42 UTC
About the user defined configuration file
Hi Andrea,
In current cxf user defined configuration file name was passed by System
Properity
-Dcxf.config.file=user_defined_configuration
This user defined configuration file name will be treat as
ClassPathResource.
public ConfigurerImpl(String cfgFile) {
if (null == cfgFile) {
cfgFile = System.getProperty(USER_CFG_FILE_PROPERTY_NAME);
}
if (null == cfgFile) {
cfgFile = DEFAULT_USER_CFG_FILE;
}
ClassPathResource cpr = new ClassPathResource(cfgFile);
if (cpr.exists()) {
try {
ApplicationContext ac = new
JaxbClassPathXmlApplicationContext(cfgFile);
setApplicationContext(ac);
} catch (BeansException ex) {
LogUtils.log(LOG, Level.WARNING,
"APP_CONTEXT_CREATION_FAILED_MSG", ex, (Object[])null);
}
} else {
LOG.log(Level.INFO, new
Message("USER_CFG_FILE_NOT_FOUND_MSG", LOG, cfgFile).toString());
}
}
There is an issue about the user defined configuration. If the
user_defined_configuration file name is same as cxf.xml in the classpath
or the user_defined_configuration file not in the classpath. The
user_defined_configuration file would not be loaded rightly.
My suggestion is configurer treats the user_defined_configuration file
as URL like Celtix had done before, to make sure the configuration file
right there.
Any other thought?
Willem.
Re: About the user defined configuration file
Posted by Andrea Smyth <an...@iona.com>.
Jiang Ning wrote:
> Hi Andrea,
>
> Sorry for my confusing cxf.xml definition.
> My means of 'same as cxf.xml on the classpath' is the cfgFile which is
> passed to ConfigurerImple by System properties is same as the
> DEFAULT_USER_CFG_FILE.
> Here is the real error, if the cfgFile passed by System properties was
> an URL string like "file:///local/customer_cxf.xml", the below code
> can't work.
No, obviously we do expect a resource name here - a documentation issue.
We could use multiple properties: cxf.config.file.url,
cxf.config.file.location, cxf.config.file.resourcename, ...
But as I said, such system properties are fallbacks, and corresponding
factory methods should be provided, e.g. createBus(URL cfgFileUrl), or
createBus(Map<String, Object> properties) (we don't have the latter yet
for the Spring bus).
> And we mostly want to pass the configuration file's absolute path to CXF.
Do we? Personally I think classpath resources are a more flexible- and
absolute paths should be avoided where possible.
Andrea.
>
> Thanks,
>
> Willem.
>
> Andrea Smyth wrote:
>
>> Jiang Ning wrote:
>>
>>> Hi Andrea,
>>> In current cxf user defined configuration file name was passed by
>>> System Properity
>>> -Dcxf.config.file=user_defined_configuration
>>> This user defined configuration file name will be treat as
>>> ClassPathResource.
>>>
>>> public ConfigurerImpl(String cfgFile) {
>>> if (null == cfgFile) {
>>> cfgFile = System.getProperty(USER_CFG_FILE_PROPERTY_NAME);
>>> }
>>> if (null == cfgFile) {
>>> cfgFile = DEFAULT_USER_CFG_FILE;
>>> }
>>> ClassPathResource cpr = new ClassPathResource(cfgFile);
>>> if (cpr.exists()) {
>>> try {
>>> ApplicationContext ac = new
>>> JaxbClassPathXmlApplicationContext(cfgFile);
>>> setApplicationContext(ac);
>>> } catch (BeansException ex) {
>>> LogUtils.log(LOG, Level.WARNING,
>>> "APP_CONTEXT_CREATION_FAILED_MSG", ex, (Object[])null);
>>> }
>>> } else {
>>> LOG.log(Level.INFO, new
>>> Message("USER_CFG_FILE_NOT_FOUND_MSG", LOG, cfgFile).toString());
>>> }
>>> }
>>>
>>> There is an issue about the user defined configuration. If the
>>> user_defined_configuration file name is same as cxf.xml in the
>>> classpath
>>> or the user_defined_configuration file not in the classpath. The
>>> user_defined_configuration file would not be loaded rightly.
>>
>>
>>
>> Hi Willem,
>>
>> What do you mean with 'same as cxf.xml on the classpath'? The
>> default user cfg file (cxf.xml) is not the same as
>> META-INF/cxf/cxf.xml.
>> I don't see a problem as there is no cxf.xml on the classpath unless
>> a user puts one there.
>>
>> Andrea.
>>
>>>
>>> My suggestion is configurer treats the user_defined_configuration
>>> file as URL like Celtix had done before, to make sure the
>>> configuration file right there.
>>> Any other thought?
>>>
>>> Willem.
>>>
>>
>>
>
>
Re: About the user defined configuration file
Posted by Jiang Ning <ni...@iona.com>.
Hi Andrea,
Sorry for my confusing cxf.xml definition.
My means of 'same as cxf.xml on the classpath' is the cfgFile which is
passed to ConfigurerImple by System properties is same as the
DEFAULT_USER_CFG_FILE.
Here is the real error, if the cfgFile passed by System properties was
an URL string like "file:///local/customer_cxf.xml", the below code
can't work.
And we mostly want to pass the configuration file's absolute path to CXF.
Thanks,
Willem.
Andrea Smyth wrote:
> Jiang Ning wrote:
>
>> Hi Andrea,
>> In current cxf user defined configuration file name was passed by
>> System Properity
>> -Dcxf.config.file=user_defined_configuration
>> This user defined configuration file name will be treat as
>> ClassPathResource.
>>
>> public ConfigurerImpl(String cfgFile) {
>> if (null == cfgFile) {
>> cfgFile = System.getProperty(USER_CFG_FILE_PROPERTY_NAME);
>> }
>> if (null == cfgFile) {
>> cfgFile = DEFAULT_USER_CFG_FILE;
>> }
>> ClassPathResource cpr = new ClassPathResource(cfgFile);
>> if (cpr.exists()) {
>> try {
>> ApplicationContext ac = new
>> JaxbClassPathXmlApplicationContext(cfgFile);
>> setApplicationContext(ac);
>> } catch (BeansException ex) {
>> LogUtils.log(LOG, Level.WARNING,
>> "APP_CONTEXT_CREATION_FAILED_MSG", ex, (Object[])null);
>> }
>> } else {
>> LOG.log(Level.INFO, new
>> Message("USER_CFG_FILE_NOT_FOUND_MSG", LOG, cfgFile).toString());
>> }
>> }
>>
>> There is an issue about the user defined configuration. If the
>> user_defined_configuration file name is same as cxf.xml in the classpath
>> or the user_defined_configuration file not in the classpath. The
>> user_defined_configuration file would not be loaded rightly.
>
>
> Hi Willem,
>
> What do you mean with 'same as cxf.xml on the classpath'? The default
> user cfg file (cxf.xml) is not the same as META-INF/cxf/cxf.xml.
> I don't see a problem as there is no cxf.xml on the classpath unless a
> user puts one there.
>
> Andrea.
>
>>
>> My suggestion is configurer treats the user_defined_configuration
>> file as URL like Celtix had done before, to make sure the
>> configuration file right there.
>> Any other thought?
>>
>> Willem.
>>
>
>
--
Willem Jiang
Software Engineer
IONA Asia Pacific Software Development Center
2/F, Unit A, Information Center
Zhongguancun Software Park Haidian District,
Beijing, P.R.China (100094)
Tel: +86-10-82825151 - 523
Fax: +86-10-82825210
Email: ning.jiang@iona.com
Re: About the user defined configuration file
Posted by Andrea Smyth <an...@iona.com>.
Jiang Ning wrote:
> Hi Andrea,
> In current cxf user defined configuration file name was passed by
> System Properity
> -Dcxf.config.file=user_defined_configuration
> This user defined configuration file name will be treat as
> ClassPathResource.
>
> public ConfigurerImpl(String cfgFile) {
> if (null == cfgFile) {
> cfgFile = System.getProperty(USER_CFG_FILE_PROPERTY_NAME);
> }
> if (null == cfgFile) {
> cfgFile = DEFAULT_USER_CFG_FILE;
> }
> ClassPathResource cpr = new ClassPathResource(cfgFile);
> if (cpr.exists()) {
> try {
> ApplicationContext ac = new
> JaxbClassPathXmlApplicationContext(cfgFile);
> setApplicationContext(ac);
> } catch (BeansException ex) {
> LogUtils.log(LOG, Level.WARNING,
> "APP_CONTEXT_CREATION_FAILED_MSG", ex, (Object[])null);
> }
> } else {
> LOG.log(Level.INFO, new
> Message("USER_CFG_FILE_NOT_FOUND_MSG", LOG, cfgFile).toString());
> }
> }
>
> There is an issue about the user defined configuration. If the
> user_defined_configuration file name is same as cxf.xml in the classpath
> or the user_defined_configuration file not in the classpath. The
> user_defined_configuration file would not be loaded rightly.
Hi Willem,
What do you mean with 'same as cxf.xml on the classpath'? The default
user cfg file (cxf.xml) is not the same as META-INF/cxf/cxf.xml.
I don't see a problem as there is no cxf.xml on the classpath unless a
user puts one there.
Andrea.
>
> My suggestion is configurer treats the user_defined_configuration file
> as URL like Celtix had done before, to make sure the configuration
> file right there.
> Any other thought?
>
> Willem.
>