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

org.appdapter.api.facade.FacadeRegistry Maven / Gradle / Ivy

There is a newer version: 1.2.4
Show newest version
/*
 *  Copyright 2012 by The Appdapter Project (www.appdapter.org).
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.appdapter.api.facade;

import org.appdapter.registry.basic.BasicRegistry;

/**
 * @author Stu B. 
 */

public class FacadeRegistry extends BasicRegistry {
	

	public  OT  findOrMakeUniqueNamedObject(Class objClaz, String objName, Maker maker) {
		return MakableObjectHelpFuncs.findOrMakeUniqueNamedObject(this, objClaz, objName, maker);
	}
	public  OT  findOrMakeUniqueNamedObjectWithDefCons(final Class objClaz, final String objName) {	
		return MakableObjectHelpFuncs.findOrMakeUniqueNamedObjectWithDefCons(this, objClaz, objName);
	}
	public  String chooseBestLocalFacadeName(FacadeSpec fs, String optOverrideName) {
		String actualName = fs.getNameString();
		if (optOverrideName != null) {
			actualName = optOverrideName;
		}
		return actualName;
	}
	public  IFT  findOrMakeInternalFacade(FacadeSpec fs, String optOverrideName ) {	
		Class facadeClaz   = fs.getFacadeClass();
		String actualName = chooseBestLocalFacadeName(fs, optOverrideName);
		return findOrMakeUniqueNamedObjectWithDefCons(facadeClaz, actualName);
	}
	/**
	 * Paired with findExternalFacade, used for objects supplied from outside, mainly from JME3:
	 * 
	 * 
  1. AssetManager
  2. *
  3. root node
  4. *
  5. flat GUI node
  6. *
*/ public void registerExternalFacade(FacadeSpec fs, EFT facade, String optOverrideName) { String actualName = chooseBestLocalFacadeName(fs, optOverrideName); registerNamedObject(facade, actualName); } /** * Paired with registerExternalFacade, used for external objects, like JME3 assetManager, rootNode, guiNode. * * @param * @param objClaz * @param objName * @return */ public EFT findExternalFacade(FacadeSpec fs, String optOverrideName) { Class facadeClaz = fs.getFacadeClass(); String actualName = chooseBestLocalFacadeName(fs, optOverrideName); EFT result = null; try { result = findOptionalUniqueNamedObject(facadeClaz, actualName); } catch (Throwable t) { logError("Problem finding object: " + actualName + " of class: " + facadeClaz); } return result; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy