Skip to content

Commit c344082

Browse files
author
oleg
committed
added simplified access to resource bundles, used by CredentialsDataSource subsystem in the embedder
1 parent 8161d09 commit c344082

File tree

3 files changed

+87
-2
lines changed

3 files changed

+87
-2
lines changed

pom.xml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,35 @@
77
<modelVersion>4.0.0</modelVersion>
88
<artifactId>plexus-i18n</artifactId>
99
<name>Plexus I18N Component</name>
10-
<version>1.0-beta-8-SNAPSHOT</version>
10+
<version>1.0-beta-9-SNAPSHOT</version>
11+
<build>
12+
<plugins>
13+
<plugin>
14+
<groupId>org.codehaus.plexus</groupId>
15+
<artifactId>plexus-maven-plugin</artifactId>
16+
<version>1.3.5</version>
17+
<executions>
18+
<execution>
19+
<goals>
20+
<goal>descriptor</goal>
21+
</goals>
22+
</execution>
23+
</executions>
24+
</plugin>
25+
<plugin>
26+
<artifactId>maven-compiler-plugin</artifactId>
27+
<configuration>
28+
<source>1.5</source>
29+
<target>1.5</target>
30+
</configuration>
31+
</plugin>
32+
</plugins>
33+
</build>
1134
<dependencies>
1235
<dependency>
1336
<groupId>org.codehaus.plexus</groupId>
1437
<artifactId>plexus-utils</artifactId>
15-
<version>1.4.1</version>
38+
<version>1.4.5</version>
1639
</dependency>
1740
</dependencies>
1841
</project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package org.codehaus.plexus.i18n;
2+
3+
import java.util.Locale;
4+
import java.util.ResourceBundle;
5+
6+
public class Language
7+
{
8+
public static String DEFAULT_NAME = "Messages";
9+
10+
private Class clazz;
11+
ResourceBundle rb;
12+
13+
public Language()
14+
{
15+
}
16+
17+
public Language( Class clazz )
18+
{
19+
this( clazz, Locale.getDefault() );
20+
}
21+
22+
public Language( Class clazz, Locale locale )
23+
{
24+
this.clazz = clazz;
25+
rb = ResourceBundle.getBundle( clazz.getPackage().getName()+"."+DEFAULT_NAME, locale, clazz.getClassLoader() );
26+
}
27+
28+
public String getMessage( String key )
29+
throws LanguageException
30+
{
31+
if( rb == null )
32+
throw new LanguageException("resourceBundle not initialized for "+(clazz==null?"null":clazz.getName() ) );
33+
34+
return rb.getString(key);
35+
}
36+
37+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.codehaus.plexus.i18n;
2+
3+
public class LanguageException extends Exception
4+
{
5+
6+
public LanguageException()
7+
{
8+
}
9+
10+
public LanguageException(String message)
11+
{
12+
super(message);
13+
}
14+
15+
public LanguageException(Throwable cause)
16+
{
17+
super(cause);
18+
}
19+
20+
public LanguageException(String message, Throwable cause)
21+
{
22+
super(message, cause);
23+
}
24+
25+
}

0 commit comments

Comments
 (0)