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

org.webswing.toolkit.util.Services Maven / Gradle / Ivy

There is a newer version: 20.2.4
Show newest version
package org.webswing.toolkit.util;

import org.webswing.ext.services.DirectDrawService;
import org.webswing.ext.services.ImageService;
import org.webswing.ext.services.JsLinkService;
import org.webswing.ext.services.PdfService;
import org.webswing.ext.services.ServerConnectionService;
import org.webswing.ext.services.SwingClassLoaderFactoryService;
import org.webswing.ext.services.ToolkitFXService;

public class Services {

	private static ImageService imageService;
	private static PdfService pdfService;
	private static ServerConnectionService serverService;
	private static SwingClassLoaderFactoryService classloaderService;
	private static DirectDrawService directDrawService;
	private static JsLinkService jsLinkService;
	private static ToolkitFXService toolkitFXService;

	public static void initialize(ImageService imageServiceImpl, PdfService pdfServiceImpl, ServerConnectionService serverServiceImpl, SwingClassLoaderFactoryService classloaderServiceImpl, DirectDrawService directDrawServiceImpl, JsLinkService jsLinkServiceImpl) {
		imageService = imageServiceImpl;
		pdfService = pdfServiceImpl;
		serverService = serverServiceImpl;
		classloaderService = classloaderServiceImpl;
		directDrawService = directDrawServiceImpl;
		jsLinkService = jsLinkServiceImpl;
	}

	public static ImageService getImageService() {
		if (imageService == null) {
			Logger.fatal("ImageService has not been initialize. Exiting...");
			System.exit(1);
		}
		return imageService;
	}

	public static PdfService getPdfService() {
		if (pdfService == null) {
			Logger.fatal("PdfService has not been initialize. Exiting...");
			System.exit(1);
		}
		return pdfService;
	}

	public static ServerConnectionService getConnectionService() {
		if (serverService == null) {
			Logger.fatal("Connection service has not been initialize. Exiting...");
			System.exit(1);
		}
		return serverService;
	}

	public static SwingClassLoaderFactoryService getClassLoaderService() {
		if (classloaderService == null) {
			Logger.fatal("Classloader service has not been initialize. Exiting...");
			System.exit(1);
		}
		return classloaderService;
	}

	public static DirectDrawService getDirectDrawService() {
		if (directDrawService == null) {
			Logger.fatal("DirectDraw service has not been initialize. Exiting...");
			System.exit(1);
		}
		return directDrawService;
	}

	public static JsLinkService getJsLinkService() {
		if (jsLinkService == null) {
			Logger.fatal("JsLinkService service has not been initialize. Exiting...");
			System.exit(1);
		}
		return jsLinkService;
	}
	
	public static ToolkitFXService getToolkitFXService() {
		if (toolkitFXService == null) {
			Logger.debug("ToolkitFXService service has not been initialized. Ignoring...");
		}
		return toolkitFXService;
	}
	
	public static void initializeToolkitFXService(ToolkitFXService toolkitFXService) {
		Services.toolkitFXService = toolkitFXService;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy