Package org.apache.openejb.jee

Examples of org.apache.openejb.jee.LocaleEncodingMappingList


    public void postProcessWebXmlElement(WebApp webApp, MergeContext context) throws DeploymentException {
    }

    @Override
    public void preProcessWebXmlElement(WebApp webApp, MergeContext context) throws DeploymentException {
        LocaleEncodingMappingList targetLocaleEncodingMappingList = null;
        for (LocaleEncodingMappingList list: webApp.getLocaleEncodingMappingList()) {
            if (targetLocaleEncodingMappingList == null) {
                targetLocaleEncodingMappingList = list;
            } else {
                targetLocaleEncodingMappingList.getLocaleEncodingMapping().addAll(list.getLocaleEncodingMapping());
            }
        }
        if (targetLocaleEncodingMappingList != null) {
            webApp.getLocaleEncodingMappingList().clear();
            webApp.getLocaleEncodingMappingList().add(targetLocaleEncodingMappingList);
            for (LocaleEncodingMapping localeEncodingMapping : targetLocaleEncodingMappingList.getLocaleEncodingMapping()) {
                context.setAttribute(createLocaleEncodingMappingKey(localeEncodingMapping.getLocale()), new MergeItem(localeEncodingMapping.getEncoding(), null, ElementSource.WEB_XML));
            }
        }
    }
View Full Code Here


*/
public class LocaleEncodingMappingListMergeHandler implements WebFragmentMergeHandler<WebFragment, WebApp> {

    @Override
    public void merge(WebFragment webFragment, WebApp webApp, MergeContext mergeContext) throws DeploymentException {
        LocaleEncodingMappingList targetLocaleEncodingMappingList = webApp.getLocaleEncodingMappingList().isEmpty() ? null: webApp.getLocaleEncodingMappingList().get(0);
        for (LocaleEncodingMappingList localeEncodingMappingList : webFragment.getLocaleEncodingMappingList()) {
            for (LocaleEncodingMapping localeEncodingMapping : localeEncodingMappingList.getLocaleEncodingMapping()) {
                String localeEncodingMappingKey = createLocaleEncodingMappingKey(localeEncodingMapping.getLocale());
                MergeItem mergeItem = (MergeItem) mergeContext.getAttribute(localeEncodingMappingKey);
                if (mergeItem != null && mergeItem.isFromWebFragment() && !mergeItem.getValue().equals(localeEncodingMapping.getEncoding())) {
                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateKeyValueMessage("locale-encoding-mapping", "locale", localeEncodingMapping.getLocale(), "encoding",
                            (String) mergeItem.getValue(), mergeItem.getBelongedURL(), localeEncodingMapping.getLocale(), mergeContext.getCurrentJarUrl()));
                }
                if (targetLocaleEncodingMappingList == null) {
                    targetLocaleEncodingMappingList = new LocaleEncodingMappingList();
                    webApp.getLocaleEncodingMappingList().add(targetLocaleEncodingMappingList);
                }
                targetLocaleEncodingMappingList.getLocaleEncodingMapping().add(localeEncodingMapping);
                mergeContext.setAttribute(localeEncodingMappingKey, new MergeItem(localeEncodingMapping.getEncoding(), mergeContext.getCurrentJarUrl(), ElementSource.WEB_FRAGMENT));
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.openejb.jee.LocaleEncodingMappingList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.