金曜日 11 14, 2008
金曜日 11 14, 2008
It's about to release GlassFish v3 Prelude ML (Multi-Language) so I think this is a good time to summarize how this modular product is localized (so I don't forget). From localizaton point of view, v3 consists of 3 parts:. Server runtime, administration GUI, and administration CLI. 3, because we use different techniques for localizing each. BTW, localization packages are already available through Update Center so if you are already using Prelude (download) and want GUI and CLI localized, go ahead and try them by running updatetool.
OSGi Fragment Bundles.v3 runtime is based on OSGi. We are utilizing OSGi fragment bundles (spec) for localizing this part. For each components need localization, we create resource bundle as a fragment bundle and that will be attached to host component at runtime. Nice thing about using fragments is that changes such as adding dependencies or classpath is not necessary in base product. Felix didn't support fragments in early stage of v3, but thanks to Richard it now supports fragments and making localization pretty simple. In the pom.xml, we use maven-bundle-plugin which generates OSGi manifest file.
// l10n/admingui/core/kernel/pom.xml
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<!-- Enable the plugin for hk2-jar packaging type -->
<supportedProjectTypes>
<supportedProjectType>hk2-jar</supportedProjectType>
<supportedProjectType>jar</supportedProjectType>
<supportedProjectType>bundle</supportedProjectType>
</supportedProjectTypes>
<instructions>
<!-- _include does not work. See Felix-620.
<_include>osgi.bundle</_include>
-->
<Export-Package>
com.sun.enterprise.admin
</Export-Package>
<Fragment-Host>
org.glassfish.core.kernel
</Fragment-Host>
</instructions>
</configuration>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.sun.enterprise</groupId>
<artifactId>hk2-maven-plugin</artifactId>
<version>${hk2.plugin.version}</version>
<configuration>
<archive>
<!-- Use the manifest.mf produced by maven-bundle-plugin;manifest -->
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
Admingui Plug-in. Administration GUI is a JSF web application and has plug-in capabilities so that it can be used to manage modular runtime. For this, we utilized this pluggable feature to attach localization. GUI already has several features such as JDBC as plug-ins so we have multiple localization plug-ins. Plug-in files looks like following.
// l10n/admingui/core/src/main/java/org/glassfish/locale/admingui/LocaleConsolePlugin.java
import org.glassfish.api.admingui.ConsoleProvider;
import org.jvnet.hk2.annotations.Service;
@Service
public class LocaleConsolePlugin implements ConsoleProvider {
public URL getConfiguration(){
return null;
}
}
This points to default console-config, which is empty.
// l10n/admingui/core/src/main/resources/META-INF/admingui/console-config.xml <console-config id="" />Supported locales are specified in plug-ins so this is convenient when adding addtional locales.
// l10n/admingui/core/src/main/resources/META-INF/faces-config.xml
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">
<application>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>de</supported-locale>
<supported-locale>sv</supported-locale>
<supported-locale>fr</supported-locale>
<supported-locale>ko</supported-locale>
<supported-locale>ja</supported-locale>
<supported-locale>zh</supported-locale>
<supported-locale>es</supported-locale>
</locale-config>
</application>
</faces-config>
Finally, CLI commands are simple. It is a plain Java program, doesn't run on OSGi, no special framework. So we localize it in traditional way. Create resource bundle jar, add it in the classpath by modifying manifest of localizing jar file.
// classpath entry in admin-cli manifest file
Class-Path: cli-framework.jar cli-optional.jar glassfish.jar server-mg
mt.jar common-util.jar admin-util.jar launcher.jar realms.jar backup.
jar amx-api.jar javax.xml.stream.jar wstx-asl.jar admin-cli-l10n.jar
If you have any comments, please let me or g11n [at] dev.java.net know. We welcome your feedback and also welcome anyone interested in localizing the product into your language. Currently Prelude is localized in 7 languages: German, Spanish, French, Japanese, Korean, Simplified and Traditional Chinese. I had written several entries regarding v3 localization in the past. Since I am not covering all the details in this entry, please also refer to them if necessary.
I should point out that Felix doesn't support all features of fragments as defined by the OSGi spec. Currently, it only supports extending the host bundle's class path, which is all that is necessary for localization.
Posted by Richard S. Hall on 11月 15, 2008 at 01:16 午後 JST #
Thanks for clarification. Yes I should have mention that so people don't get confused.
Posted by ogino on 11月 17, 2008 at 02:52 午後 JST #