org.cogchar.app.puma.registry.PumaRegistryClientFinder Maven / Gradle / Ivy
/*
* Copyright 2012 by The Cogchar Project (www.cogchar.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.cogchar.app.puma.registry;
import org.appdapter.api.facade.FacadeSpec;
import org.appdapter.subreg.SubsystemHandle;
import org.appdapter.subreg.BasicSubsystemHandle;
import org.appdapter.subreg.FacadeHandle;
import org.cogchar.blob.emit.SubsystemHandleFinder;
/**
* @author Stu B.
*
* IOC scaffolding
*/
public class PumaRegistryClientFinder {
protected enum PFKind {
PUMA_REG_CLIENT
}
protected static class PFSpec extends FacadeSpec {
PFSpec(PFKind kind, Class sClz, boolean extFlag) {
super(kind, sClz, extFlag);
}
}
protected static PFSpec THE_PUMA_REGISTRY_CLIENT_Spec;
static {
// true = "external" - explicit registration pattern
THE_PUMA_REGISTRY_CLIENT_Spec = new PFSpec(PFKind.PUMA_REG_CLIENT, PumaRegistryClient.class, true);
}
public void registerPumaRegClient(PumaRegistryClient prcFacade, String optOverrideName, Class optCredClaz) {
PFSpec regClientFSpec = THE_PUMA_REGISTRY_CLIENT_Spec;
SubsystemHandle shand = SubsystemHandleFinder.getSubsystemHandle(SubsystemHandleFinder.SUBSYS_REG_PUMA(), regClientFSpec, optCredClaz);
shand.registerExternalFacade(regClientFSpec, prcFacade, optOverrideName);
}
public PumaRegistryClient getPumaRegClientOrNull(String optOverrideName, Class optCredClaz) {
PumaRegistryClient pumaRegClient = null;
PFSpec regClientFSpec = THE_PUMA_REGISTRY_CLIENT_Spec;
SubsystemHandle shand = SubsystemHandleFinder.getSubsystemHandle(SubsystemHandleFinder.SUBSYS_REG_PUMA(), regClientFSpec, optCredClaz);
FacadeHandle prcHandle = shand.findExternalFacade(regClientFSpec, optOverrideName);
if (prcHandle.isReady()) {
pumaRegClient = prcHandle.getOrElse(null);
}
return pumaRegClient;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy