本文整理了Java中org.ogema.core.application.ApplicationManager.getResourcePatternAccess()
方法的一些代码示例,展示了ApplicationManager.getResourcePatternAccess()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationManager.getResourcePatternAccess()
方法的具体详情如下:
包路径:org.ogema.core.application.ApplicationManager
类名称:ApplicationManager
方法名:getResourcePatternAccess
暂无
代码示例来源:origin: org.smartrplace.sim/resource-simulation
@Override
public void start(ApplicationManager appManager) {
this.appMan = appManager;
appManager.getResourcePatternAccess().addPatternDemand(ConfigPattern.class, this, AccessPriority.PRIO_LOWEST);
}
代码示例来源:origin: org.smartrplace.sim/resource-simulation
@Override
public void stop(AppStopReason reason) {
final ApplicationManager appMan = this.appMan;
if (appMan != null) {
try {
appMan.getResourcePatternAccess().removePatternDemand(ConfigPattern.class, this);
} catch (Exception ignore) {}
}
for (ResourceSimulation sim : simulations.values())
sim.close();
simulations.clear();
simulationTemplates.clear();
this.appMan = null;
this.bundle = null;
}
代码示例来源:origin: org.smartrplace.sim/resource-simulation
@Override
public void patternAvailable(ConfigPattern pattern) {
newConfig(pattern);
appMan.getResourcePatternAccess().addPatternChangeListener(pattern, this, ConfigPattern.class);
}
代码示例来源:origin: org.ogema.drivers/remote-rest-connector
@Override
public void patternAvailable(RestConnectionPattern pattern) {
connectionAdded(pattern);
appMan.getResourcePatternAccess().addPatternChangeListener(pattern, this, RestConnectionPattern.class);
}
代码示例来源:origin: org.ogema.drivers/remote-rest-connector
@Override
public void patternUnavailable(RestConnectionPattern pattern) {
connectionRemoved(pattern);
appMan.getResourcePatternAccess().removePatternChangeListener(pattern, this);
}
代码示例来源:origin: org.smartrplace.sim/resource-simulation
@Override
public void patternUnavailable(ConfigPattern pattern) {
configGone(pattern);
appMan.getResourcePatternAccess().removePatternChangeListener(pattern, this);
}
代码示例来源:origin: org.ogema.widgets/widget-extended
private P getPattern(final String path, OgemaHttpRequest req) throws NoSuchMethodException, SecurityException,
InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Resource res = AccessController.doPrivileged(new PrivilegedAction<Resource>() {
@Override
public Resource run() {
return am.getResourceAccess().getResource(path);
}
});
if (res == null)
throw new RuntimeException("Pattern resource is null... this should not happen;");
if (res.isTopLevel())
return am.getResourcePatternAccess().createResource(path, pattern);
else {
Resource parent = res.getParent();
return am.getResourcePatternAccess().addDecorator(parent, res.getName(), pattern);
}
}
代码示例来源:origin: org.ogema.drivers/channel-mapper-v2
@Override
public void patternAvailable(ChannelMapperConfigPattern pattern) {
logger.info("New channel mapper configuration found: {}",pattern.model);
newPattern(pattern);
appMan.getResourcePatternAccess().addPatternChangeListener(pattern, this, ChannelMapperConfigPattern.class);
// TODO register channel with channel access
}
代码示例来源:origin: org.ogema.drivers/channel-mapper-v2
@Override
public void patternUnavailable(ChannelMapperConfigPattern pattern) {
logger.info("Channel mapper configuration removed: {}",pattern.model);
appMan.getResourcePatternAccess().removePatternChangeListener(pattern, this);
patternGone(pattern);
}
代码示例来源:origin: org.ogema.widgets/widget-extended
@Override
public List<P> run() {
List<P> result = new ArrayList<>();
for (R res: resources) {
try {
P pattern = type.getConstructor(Resource.class).newInstance(res);
if (!allowIncompletePattern) {
boolean satisfied = am.getResourcePatternAccess().isSatisfied(pattern, type);
if (!satisfied) {
am.getLogger().info("Found an incomplete pattern in page initialization - ignoring this: {}",pattern);
continue;
}
}
result.add(pattern);
} catch (Exception e) {
am.getLogger().warn("Could not initalize page with pattern type {} for resource {}",type.getName(),res,e);
}
}
return result;
}
});
代码示例来源:origin: org.smartrplace.sim/resource-simulation
@Override
public void onGET(OgemaHttpRequest req) {
final boolean existing = resSelectorCheckbox.getCheckboxList(req).get(0).isChecked();
if (!existing) {
update(Collections.emptyList(), req);
disable(req);
return;
}
enable(req);
final Class<? extends SingleValueResource> type = typeSelector.getSelectedItem(req);
final List<ConfigPattern> configs = appMan.getResourcePatternAccess().getPatterns(ConfigPattern.class, AccessPriority.PRIO_LOWEST);
final List<SingleValueResource> resources = appMan.getResourceAccess().getResources(type).stream()
.filter(resource -> !configs.stream().filter(cfg -> cfg.target.equalsLocation(resource)).findAny().isPresent())
.collect(Collectors.toList());
update(resources, req);
}
代码示例来源:origin: org.ogema.widgets/widget-extended
@Override
public void onGET(OgemaHttpRequest req) {
Collection<DropdownOption> opt = getSelected(req);
Set<String> selected = new HashSet<String>();
if (opt != null) {
for (DropdownOption op : opt) {
selected.add(op.id());
}
}
Set<DropdownOption> options;
List patterns = am.getResourcePatternAccess().getPatterns(targetType, AccessPriority.PRIO_LOWEST); // cannot work with type arguments here...
options = getPatternOptions(patterns,selected,req);
setOptions(options, req);
}
代码示例来源:origin: org.ogema.widgets/widget-extended
@Override
public P run() {
try {
P pattern = type.getConstructor(Resource.class).newInstance(res);
if (!allowIncompletePattern) {
boolean satisfied = am.getResourcePatternAccess().isSatisfied(pattern, type);
if (!satisfied) {
am.getLogger().info("Page has been initialized with an incomplete pattern - ignoring this: {}",pattern);
return null;
}
}
return pattern;
} catch (Exception e) {
am.getLogger().warn("Could not initalize page with pattern {} of type {}",selected,type.getName(),e);
return null;
}
}
});
代码示例来源:origin: org.ogema.drivers/remote-rest-connector
@Override
public void start(ApplicationManager appManager) {
this.appMan = appManager;
this.logger = appManager.getLogger();
this.executor = Executors.newSingleThreadExecutor();
// appMan.getResourceAccess().addResourceDemand(RestConnection.class, connectionListener);
appManager.getResourcePatternAccess().addPatternDemand(RestConnectionPattern.class, this, AccessPriority.PRIO_LOWEST);
// timing interval will be reset when a connection becomes available
t = appMan.createTimer(1000000, new TimerListener() {
@Override
public void timerElapsed(Timer timer) {
taskSchedulerStep();
}
});
t.stop();
//testSetup();
logger.info("{} started", getClass().getName());
}
代码示例来源:origin: org.ogema.drivers/hm-hl
public Thermostat(HM_hlDriver driver, ApplicationManager appManager, HM_hlConfig config) {
super(driver, appManager, config);
patAcc = appManager.getResourcePatternAccess();
device = patAcc.createResource(appManager.getResourceManagement().getUniqueResourceName(
hm_hlConfig.resourceName), ThermostatPattern.class);
activate(device); // does not activate value resources
}
代码示例来源:origin: org.ogema.drivers/channel-mapper-v2
@SuppressWarnings("unchecked")
@Override
public void start(ApplicationManager appManager) {
Objects.requireNonNull(ctx);
this.logger = appManager.getLogger();
this.appMan = appManager;
this.ca = appManager.getChannelAccess();
this.configs = appManager.getResourceManagement().createResource("channelMapperConfigurations", ResourceList.class);
configs.setElementType(ChannelMapperConfiguration.class);
configs.activate(false);
appManager.getResourcePatternAccess().addPatternDemand(ChannelMapperConfigPattern.class, this, AccessPriority.PRIO_LOWEST);
this.sreg = ctx.registerService(ChannelMapper.class, this, null);
}
代码示例来源:origin: org.ogema.tools/resource-manipulators
@Override
@Deprecated
public void start(ApplicationManager applicationManager) {
appMan = applicationManager;
resMan = applicationManager.getResourceManagement();
resAcc = applicationManager.getResourceAccess();
patAcc = applicationManager.getResourcePatternAccess();
logger = applicationManager.getLogger();
ownName = applicationManager.getAppID().getIDString();
// add a pattern demand with "device specific": No one else should modify this, except perhaps an administrator who knows what he is doing.
patAcc.addPatternDemand(patternClass, this, AccessPriority.PRIO_DEVICESPECIFIC);
}
代码示例来源:origin: org.ogema.widgets/widget-extended
/**
* @param page
* @param id
* @param am
* @param itemsClass
* @param containerClass
* @param iconService
* @param nameService
*/
public PatternDragDropAssign(WidgetPage<?> page, String id, ApplicationManager am, Class<T> itemsClass, Class<R> containerClass, IconService iconService, NameService nameService) {
super(page, id, null, true);
this.ddata = new DragDropData();
// setData(ddata, null); // this is problematic, since it will prevent the setDefault... methods inherited from OgemaWidget to fail
setDefaultData(ddata);
// this.patternList = patternList;
// this.containerList = containerList;
// this.itemsManagement = new ResourcePatternManagement(am, itemsClass, null);
// this.containerManagement = new ResourcePatternManagement(am, containerClass, null);
this.am =am;
this.rpa = am.getResourcePatternAccess();
this.itemsClass = itemsClass;
this.containerClass = containerClass;
this.unassigned = new Container("unassigned", "Unassigned", "/ogema/widget/dragdropassign/icons/unassignedContainer2.svg");
this.iconService = iconService;
this.nameService = nameService;
}
代码示例来源:origin: org.ogema.drivers/hm-hl
public Thermostat(HM_hlDriver driver, ApplicationManager appManager, DeviceLocator deviceLocator) {
super(driver, appManager, deviceLocator);
patAcc = appManager.getResourcePatternAccess();
device = patAcc.createResource(appManager.getResourceManagement().getUniqueResourceName(
hm_hlConfig.resourceName), ThermostatPattern.class);
activate(device);// does not activate value resources
// device.model.activate(true);
addMandatoryChannels();
}
代码示例来源:origin: org.ogema.widgets/widget-extended
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void onGET(OgemaHttpRequest req) {
// DropdownOption opt = getSelected(req);
// String selected =null;
// if (opt != null) {
// selected = opt.getValue();
// }
String selected = getSelectedValue(req);
Set<DropdownOption> options;
if (patternType == null) {
List<R> resources = am.getResourceAccess().getResources(targetType);
options = getTargetOptions((Collection<Resource>) resources,selected,req);
}
else {
List patterns = am.getResourcePatternAccess().getPatterns(patternType, AccessPriority.PRIO_LOWEST); // cannot work with type arguments here...
options = getPatternOptions(patterns,selected,req);
}
setOptions(options, req);
}
内容来源于网络,如有侵权,请联系作者删除!