All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liferay.portal.kernel.util.ResourceBundleLoaderUtil Maven / Gradle / Ivy

Go to download

Contains interfaces for the portal services. Interfaces are only loaded by the global class loader and are shared by all plugins.

There is a newer version: 141.0.0
Show newest version
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.liferay.portal.kernel.util;

import com.liferay.registry.ServiceReference;
import com.liferay.registry.collections.ServiceReferenceMapper;
import com.liferay.registry.collections.ServiceTrackerCollections;
import com.liferay.registry.collections.ServiceTrackerMap;

/**
 * @author     Carlos Sierra Andrés
 * @deprecated As of Athanasius (7.3.x), replaced by {@link
 *             com.liferay.portal.kernel.resource.bundle.ResourceBundleLoaderUtil}
 */
@Deprecated
public class ResourceBundleLoaderUtil {

	public static ResourceBundleLoader getPortalResourceBundleLoader() {
		return _portalResourceBundleLoader;
	}

	public static ResourceBundleLoader
		getResourceBundleLoaderByBundleSymbolicName(String bundleSymbolicName) {

		return _bundleSymbolicNameServiceTrackerMap.getService(
			bundleSymbolicName);
	}

	public static ResourceBundleLoader
		getResourceBundleLoaderByServletContextName(String servletContextName) {

		return _servletContextNameServiceTrackerMap.getService(
			servletContextName);
	}

	public static void setPortalResourceBundleLoader(
		ResourceBundleLoader resourceBundleLoader) {

		_portalResourceBundleLoader = resourceBundleLoader;
	}

	private ResourceBundleLoaderUtil() {
	}

	private static final ServiceTrackerMap
		_bundleSymbolicNameServiceTrackerMap;
	private static ResourceBundleLoader _portalResourceBundleLoader;
	private static final ServiceTrackerMap
		_servletContextNameServiceTrackerMap;

	static {
		_bundleSymbolicNameServiceTrackerMap =
			ServiceTrackerCollections.openSingleValueMap(
				ResourceBundleLoader.class, "bundle.symbolic.name");
		_servletContextNameServiceTrackerMap =
			ServiceTrackerCollections.openSingleValueMap(
				ResourceBundleLoader.class, "servlet.context.name");
	}

	private static class ServiceTrackerHolder {

		private static final ServiceTrackerMap
			_servletContextNameAndBaseNameServiceTrackerMap;

		static {
			_servletContextNameAndBaseNameServiceTrackerMap =
				ServiceTrackerCollections.openSingleValueMap(
					ResourceBundleLoader.class,
					"(&(resource.bundle.base.name=*)(servlet.context.name=*))",
					new ServiceReferenceMapper() {

						@Override
						public void map(
							ServiceReference
								serviceReference,
							Emitter emitter) {

							Object baseName = serviceReference.getProperty(
								"resource.bundle.base.name");
							Object servletContextName =
								serviceReference.getProperty(
									"servlet.context.name");

							emitter.emit(baseName + "#" + servletContextName);
						}

					});
		}

	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy