You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "Thomas Herzog (JIRA)" <ji...@apache.org> on 2012/07/05 21:12:35 UTC

[jira] [Created] (DELTASPIKE-222) Add possibility to set base path

Thomas Herzog created DELTASPIKE-222:
----------------------------------------

             Summary: Add possibility to set base path
                 Key: DELTASPIKE-222
                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-222
             Project: DeltaSpike
          Issue Type: New Feature
          Components: I18n-Module
    Affects Versions: 0.2-incubating
            Reporter: Thomas Herzog
             Fix For: 0.3-incubating


Add the possibility to set the base path, means the path to the properties file.
Now they are assumed to be at same level as the @MessageResource annotated interface is, in fact within the same package.

Maybe someone wants to put his resource bundles at /META-INF/resources/*.properties.

With cal10n it was possible to set the Base with @Base("/META-INF/resources")

--
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

        

[jira] [Commented] (DELTASPIKE-222) Add possibility to set base path

Posted by "Thomas Herzog (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DELTASPIKE-222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13408740#comment-13408740 ] 

Thomas Herzog commented on DELTASPIKE-222:
------------------------------------------

The possibilty for setting the property path via MessageBundle sounds nice, i took cal10n as example, they define it via @BasePath.
An own custom resolver, only because the path of the property file is different, would be overhead for me, because a default implementation of a MessageResoulver would be suitable for mor than 50% of the usecase, i think. We do not have many special usecases where it is different to get the localized message. 
I would do no error handling if property was nout found, this should result in an exception, because at least at deployment time, it should be sure that there is every key defined in @MessageBunfdl annotated type present in the property files, otherwise the application should not be deployable.

An maven or ant taks to check for consistency of the property files would also be fine.
                
> Add possibility to set base path
> --------------------------------
>
>                 Key: DELTASPIKE-222
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-222
>             Project: DeltaSpike
>          Issue Type: New Feature
>          Components: I18n-Module
>    Affects Versions: 0.2-incubating
>            Reporter: Thomas Herzog
>             Fix For: 0.3-incubating
>
>
> Add the possibility to set the base path, means the path to the properties file.
> Now they are assumed to be at same level as the @MessageResource annotated interface is, in fact within the same package.
> Maybe someone wants to put his resource bundles at /META-INF/resources/*.properties.
> With cal10n it was possible to set the Base with @Base("/META-INF/resources")

--
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

        

[jira] [Commented] (DELTASPIKE-222) Add possibility to set base path

Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DELTASPIKE-222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13408277#comment-13408277 ] 

Mark Struberg commented on DELTASPIKE-222:
------------------------------------------

I'm not sure if BasePath is the right way, but having an optional property 'bundleName' in @MessageBundle would be really nice.

@MessageBundle(bundleName="company/messages.properties",...)
                
> Add possibility to set base path
> --------------------------------
>
>                 Key: DELTASPIKE-222
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-222
>             Project: DeltaSpike
>          Issue Type: New Feature
>          Components: I18n-Module
>    Affects Versions: 0.2-incubating
>            Reporter: Thomas Herzog
>             Fix For: 0.3-incubating
>
>
> Add the possibility to set the base path, means the path to the properties file.
> Now they are assumed to be at same level as the @MessageResource annotated interface is, in fact within the same package.
> Maybe someone wants to put his resource bundles at /META-INF/resources/*.properties.
> With cal10n it was possible to set the Base with @Base("/META-INF/resources")

--
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

        

[jira] [Commented] (DELTASPIKE-222) Add possibility to set base path

Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DELTASPIKE-222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13408769#comment-13408769 ] 

Mark Struberg commented on DELTASPIKE-222:
------------------------------------------

A String is a String is a String - no matter what. I have no clue why we need an own MessageSource interface which just returns this simple String...

Imo the Interface provides no benefit. It is just more complex to understand and harder to write for an end-user.
                
> Add possibility to set base path
> --------------------------------
>
>                 Key: DELTASPIKE-222
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-222
>             Project: DeltaSpike
>          Issue Type: New Feature
>          Components: I18n-Module
>    Affects Versions: 0.2-incubating
>            Reporter: Thomas Herzog
>             Fix For: 0.3-incubating
>
>
> Add the possibility to set the base path, means the path to the properties file.
> Now they are assumed to be at same level as the @MessageResource annotated interface is, in fact within the same package.
> Maybe someone wants to put his resource bundles at /META-INF/resources/*.properties.
> With cal10n it was possible to set the Base with @Base("/META-INF/resources")

--
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

        

[jira] [Commented] (DELTASPIKE-222) Add possibility to set base path

Posted by "Gerhard Petracek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DELTASPIKE-222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13408240#comment-13408240 ] 

Gerhard Petracek commented on DELTASPIKE-222:
---------------------------------------------

i'm not sure if we really need it - we already have:

@MessageBundle
@MessageContextConfig(messageResolver = CustomMessageResolver.class)

needs a bit more to write, but you can resolve the messages from any source and you can do the error handling on your own.
                
> Add possibility to set base path
> --------------------------------
>
>                 Key: DELTASPIKE-222
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-222
>             Project: DeltaSpike
>          Issue Type: New Feature
>          Components: I18n-Module
>    Affects Versions: 0.2-incubating
>            Reporter: Thomas Herzog
>             Fix For: 0.3-incubating
>
>
> Add the possibility to set the base path, means the path to the properties file.
> Now they are assumed to be at same level as the @MessageResource annotated interface is, in fact within the same package.
> Maybe someone wants to put his resource bundles at /META-INF/resources/*.properties.
> With cal10n it was possible to set the Base with @Base("/META-INF/resources")

--
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

        

[jira] [Resolved] (DELTASPIKE-222) Add possibility to set base path

Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DELTASPIKE-222?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Struberg resolved DELTASPIKE-222.
--------------------------------------

    Resolution: Fixed
      Assignee: Mark Struberg

added documentation as well now.
                
> Add possibility to set base path
> --------------------------------
>
>                 Key: DELTASPIKE-222
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-222
>             Project: DeltaSpike
>          Issue Type: New Feature
>          Components: I18n-Module
>    Affects Versions: 0.2-incubating
>            Reporter: Thomas Herzog
>            Assignee: Mark Struberg
>             Fix For: 0.3-incubating
>
>
> Add the possibility to set the base path, means the path to the properties file.
> Now they are assumed to be at same level as the @MessageResource annotated interface is, in fact within the same package.
> Maybe someone wants to put his resource bundles at /META-INF/resources/*.properties.
> With cal10n it was possible to set the Base with @Base("/META-INF/resources")

--
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

        

[jira] [Commented] (DELTASPIKE-222) Add possibility to set base path

Posted by "Thomas Herzog (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DELTASPIKE-222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13409244#comment-13409244 ] 

Thomas Herzog commented on DELTASPIKE-222:
------------------------------------------

Thank you for implementing it.
:)
                
> Add possibility to set base path
> --------------------------------
>
>                 Key: DELTASPIKE-222
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-222
>             Project: DeltaSpike
>          Issue Type: New Feature
>          Components: I18n-Module
>    Affects Versions: 0.2-incubating
>            Reporter: Thomas Herzog
>            Assignee: Mark Struberg
>             Fix For: 0.3-incubating
>
>
> Add the possibility to set the base path, means the path to the properties file.
> Now they are assumed to be at same level as the @MessageResource annotated interface is, in fact within the same package.
> Maybe someone wants to put his resource bundles at /META-INF/resources/*.properties.
> With cal10n it was possible to set the Base with @Base("/META-INF/resources")

--
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

        

[jira] [Commented] (DELTASPIKE-222) Add possibility to set base path

Posted by "Gerhard Petracek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DELTASPIKE-222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13408875#comment-13408875 ] 

Gerhard Petracek commented on DELTASPIKE-222:
---------------------------------------------

basically agreed and as i said i'm ok with it since you (usually) don't have a lot of different (simple) message-sources and also inheritance for a fallback-lookup won't be needed extensively.
what i mentioned in my previous comment: using classes for it also allows further features - e.g. we could provide JsfApplicationMessageBundle (#getKey would delegate to the faces-context to resolve it), BeanValidationMessages, DeltaSpikeMessages,...
that means users don't have to know where it comes from and with std. java-ide support they can find such bundles easily.
however, for sure you can do most of it with a custom message-resolver.

since there is no #config in the fluent-api any longer (which indicates that it is a part of the config of the context), we just have to document it carefully to avoid that people start doing e.g.:
this.messageContext.messageSource("msgsX.properties", "msgsY.properties") .message().template("{msgX}").toString();

however, as mentioned at the very beginning it's a bit more complex and i'm ok with the latest change - we need a nice documentation in any case.
                
> Add possibility to set base path
> --------------------------------
>
>                 Key: DELTASPIKE-222
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-222
>             Project: DeltaSpike
>          Issue Type: New Feature
>          Components: I18n-Module
>    Affects Versions: 0.2-incubating
>            Reporter: Thomas Herzog
>             Fix For: 0.3-incubating
>
>
> Add the possibility to set the base path, means the path to the properties file.
> Now they are assumed to be at same level as the @MessageResource annotated interface is, in fact within the same package.
> Maybe someone wants to put his resource bundles at /META-INF/resources/*.properties.
> With cal10n it was possible to set the Base with @Base("/META-INF/resources")

--
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

        

[jira] [Commented] (DELTASPIKE-222) Add possibility to set base path

Posted by "Gerhard Petracek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DELTASPIKE-222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13408773#comment-13408773 ] 

Gerhard Petracek commented on DELTASPIKE-222:
---------------------------------------------

we could change it back to a string which is called e.g. MessageSourceIdentifier or ResourceIdentifier -> to keep the resource-keys in a single place you would need a public static var.
i'm ok with changing it to a simpler identifier instead, but we should document that it is useful to keep the identifier in one place and that the ide support doesn't help to find existing identifiers provided e.g. by a jar (which would be possible with the current prototype).
                
> Add possibility to set base path
> --------------------------------
>
>                 Key: DELTASPIKE-222
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-222
>             Project: DeltaSpike
>          Issue Type: New Feature
>          Components: I18n-Module
>    Affects Versions: 0.2-incubating
>            Reporter: Thomas Herzog
>             Fix For: 0.3-incubating
>
>
> Add the possibility to set the base path, means the path to the properties file.
> Now they are assumed to be at same level as the @MessageResource annotated interface is, in fact within the same package.
> Maybe someone wants to put his resource bundles at /META-INF/resources/*.properties.
> With cal10n it was possible to set the Base with @Base("/META-INF/resources")

--
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

        

[jira] [Commented] (DELTASPIKE-222) Add possibility to set base path

Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DELTASPIKE-222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13408814#comment-13408814 ] 

Mark Struberg commented on DELTASPIKE-222:
------------------------------------------

I don't yet get the use case. This is purely for giving the user the option to 'name' additional resource 'locations'.

If it gets more complicated, e.g. in JSF, then you need an own MessageResolver anyway. Thats what we will provide for sure in the JSF module. A MessageResolver which first looks in all the JSF registered resource locations, and then delegates further to the DefaultResourceResolver...

Such functionality would be much too complex for a 'MessageSource' implementation anyway.
                
> Add possibility to set base path
> --------------------------------
>
>                 Key: DELTASPIKE-222
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-222
>             Project: DeltaSpike
>          Issue Type: New Feature
>          Components: I18n-Module
>    Affects Versions: 0.2-incubating
>            Reporter: Thomas Herzog
>             Fix For: 0.3-incubating
>
>
> Add the possibility to set the base path, means the path to the properties file.
> Now they are assumed to be at same level as the @MessageResource annotated interface is, in fact within the same package.
> Maybe someone wants to put his resource bundles at /META-INF/resources/*.properties.
> With cal10n it was possible to set the Base with @Base("/META-INF/resources")

--
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

        

[jira] [Commented] (DELTASPIKE-222) Add possibility to set base path

Posted by "Gerhard Petracek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DELTASPIKE-222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13408766#comment-13408766 ] 

Gerhard Petracek commented on DELTASPIKE-222:
---------------------------------------------

i pushed a prototype for a type-safe message-source.

advantages:
 allows the type-safe usage with @MessageContextConfig and the fluent MessageContext api (and to implement fine-grained message-interfaces which use the same message-source).

disadvantage:
 a bit more to do - but only once (and for easy prototyping we have the convention already) -> shouldn't be a big issue

e.g.:

@MessageBundle
@MessageContextConfig(messageSource = AppResourceBundle.class)
public interface Messages
{
    String msgX(String name);
}
 
@MessageBundle
@MessageContextConfig(messageSource = {UiResourceBundle.class, AppResourceBundle.class})
public interface Labels
{
    String labelX();
}

//...
public class AppResourceBundle implements MessageSource
{
    @Override
    public String getKey()
    {
        return "company/app_messages.properties";
    }
}

//...
public class UiResourceBundle implements MessageSource
{
    @Override
    public String getKey()
    {
        return "app/ui/labels.properties";
    }
}

and you can also use it with the fluent-api easily (and in a type-safe way) - e.g.:


String messageText = this.messageContext.messageSource(AppResourceBundle.class)
                .message().template("{msgX}").toString();
                
> Add possibility to set base path
> --------------------------------
>
>                 Key: DELTASPIKE-222
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-222
>             Project: DeltaSpike
>          Issue Type: New Feature
>          Components: I18n-Module
>    Affects Versions: 0.2-incubating
>            Reporter: Thomas Herzog
>             Fix For: 0.3-incubating
>
>
> Add the possibility to set the base path, means the path to the properties file.
> Now they are assumed to be at same level as the @MessageResource annotated interface is, in fact within the same package.
> Maybe someone wants to put his resource bundles at /META-INF/resources/*.properties.
> With cal10n it was possible to set the Base with @Base("/META-INF/resources")

--
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