本文整理汇总了Java中org.osgi.service.dal.Function类的典型用法代码示例。如果您正苦于以下问题:Java Function类的具体用法?Java Function怎么用?Java Function使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Function类属于org.osgi.service.dal包,在下文中一共展示了Function类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFunctionService
import org.osgi.service.dal.Function; //导入依赖的package包/类
public ServiceRegistration createFunctionService(IAppliance appliance, Integer endPointId, IAppliancesProxy appliancesProxy) {
Dictionary d=new Hashtable();
d.put(Function.SERVICE_DEVICE_UID, IDConverters.getDeviceUid(appliance.getPid(), appliance.getConfiguration()));
d.put(Function.SERVICE_UID, getFunctionUID(appliance));
d.put(Function.SERVICE_OPERATION_NAMES,
new String[]{
PowerProfileFunction.OPERATION_SCHEDULEENRGYPHASES});
d.put(Function.SERVICE_PROPERTY_NAMES, new String[]{
PowerProfileFunction.PROPERTY_ENERGYREMOTE,
PowerProfileFunction.PROPERTY_MULTIPLESCHEDULING,
PowerProfileFunction.PROPERTY_SCHEDULEMODE,
PowerProfileFunction.PROPERTY_TOTALPROFILENUM,
PowerProfileFunction.PROPERTY_CONSTRAINTS,
PowerProfileFunction.PROPERTY_STATE,
PowerProfileFunction.PROPERTY_POWEPROFILEPHASES
});
return FrameworkUtil.getBundle(this.getClass()).getBundleContext().registerService(
new String[]{Function.class.getName(),PowerProfileFunction.class.getName()},
new PowerProfileDALAdapter(appliance.getPid(), endPointId, appliancesProxy),
d);
}
示例2: createFunctionService
import org.osgi.service.dal.Function; //导入依赖的package包/类
public ServiceRegistration createFunctionService(IAppliance appliance, Integer endPointId, IAppliancesProxy appliancesProxy) {
Dictionary d=new Hashtable();
d.put(Function.SERVICE_DEVICE_UID, IDConverters.getDeviceUid(appliance.getPid(), appliance.getConfiguration()));
d.put(Function.SERVICE_UID, getFunctionUID(appliance));
d.put(Function.SERVICE_OPERATION_NAMES, new String[]{
BooleanControl.OPERATION_REVERSE,
BooleanControl.OPERATION_SET_TRUE,
BooleanControl.OPERATION_SET_FALSE});
d.put(Function.SERVICE_PROPERTY_NAMES, new String[]{BooleanControl.PROPERTY_DATA});
return FrameworkUtil.getBundle(this.getClass()).getBundleContext().registerService(
new String[]{Function.class.getName(),BooleanControl.class.getName()},
new BooleanControlDALAdapter(appliance.getPid(), endPointId, appliancesProxy),
d);
}
示例3: createFunctionService
import org.osgi.service.dal.Function; //导入依赖的package包/类
public ServiceRegistration createFunctionService(IAppliance appliance, Integer endPointId, IAppliancesProxy appliancesProxy) {
Dictionary d=new Hashtable();
d.put(Function.SERVICE_DEVICE_UID, IDConverters.getDeviceUid(appliance.getPid(), appliance.getConfiguration()));
d.put(Function.SERVICE_UID, getFunctionUID(appliance));
d.put(Function.SERVICE_OPERATION_NAMES, new String[]{
WindowCovering.OPERATION_OPEN,
WindowCovering.OPERATION_CLOSE});
d.put(Function.SERVICE_PROPERTY_NAMES, new String[]{WindowCovering.PROPERTY_STATUS});
return FrameworkUtil.getBundle(this.getClass()).getBundleContext().registerService(
new String[]{Function.class.getName(),WindowCovering.class.getName()},
new WindowCoveringDALAdapter(appliance.getPid(), endPointId, appliancesProxy),
d);
}
示例4: createFunctionService
import org.osgi.service.dal.Function; //导入依赖的package包/类
public ServiceRegistration createFunctionService(IAppliance appliance, Integer endPointId, IAppliancesProxy appliancesProxy) {
Dictionary d=new Hashtable();
d.put(Function.SERVICE_DEVICE_UID, IDConverters.getDeviceUid(appliance.getPid(), appliance.getConfiguration()));
d.put(Function.SERVICE_UID, getFunctionUID(appliance));
d.put(Function.SERVICE_OPERATION_NAMES, new String[]{
DoorLock.OPERATION_OPEN,
DoorLock.OPERATION_CLOSE});
d.put(Function.SERVICE_PROPERTY_NAMES, new String[]{DoorLock.PROPERTY_STATUS});
return FrameworkUtil.getBundle(this.getClass()).getBundleContext().registerService(
new String[]{Function.class.getName(),DoorLock.class.getName()},
new DoorLockDALAdapter(appliance.getPid(), endPointId, appliancesProxy),
d);
}
示例5: createFunctionService
import org.osgi.service.dal.Function; //导入依赖的package包/类
public ServiceRegistration createFunctionService(IAppliance appliance, Integer endPointId, IAppliancesProxy appliancesProxy) {
Dictionary d=new Hashtable();
d.put(Function.SERVICE_DEVICE_UID, IDConverters.getDeviceUid(appliance.getPid(), appliance.getConfiguration()));
d.put(Function.SERVICE_UID, getFunctionUID(appliance));
d.put(Function.SERVICE_OPERATION_NAMES, new String[]{});
d.put(Function.SERVICE_PROPERTY_NAMES, new String[]{MultiLevelControl.PROPERTY_DATA});
return FrameworkUtil.getBundle(this.getClass()).getBundleContext().registerService(
new String[]{Function.class.getName(),MultiLevelControl.class.getName()},
new LevelControlDALAdapter(appliance.getPid(), endPointId, appliancesProxy),
d);
}
示例6: createFunctionService
import org.osgi.service.dal.Function; //导入依赖的package包/类
public ServiceRegistration createFunctionService(IAppliance appliance, Integer endPointId, IAppliancesProxy appliancesProxy) {
Dictionary d=new Hashtable();
d.put(Function.SERVICE_DEVICE_UID, IDConverters.getDeviceUid(appliance.getPid(), appliance.getConfiguration()));
d.put(Function.SERVICE_UID, getFunctionUID(appliance));
d.put(Function.SERVICE_OPERATION_NAMES, new String[0]);
d.put(Function.SERVICE_PROPERTY_NAMES, new String[]{MultiLevelSensor.PROPERTY_DATA});
return FrameworkUtil.getBundle(this.getClass()).getBundleContext().registerService(
new String[]{Function.class.getName(),MultiLevelSensor.class.getName()},
new TemperatureMeterDALAdapter(appliance.getPid(), endPointId, appliancesProxy),
d);
}
示例7: createFunctionService
import org.osgi.service.dal.Function; //导入依赖的package包/类
public ServiceRegistration createFunctionService(IAppliance appliance, Integer endPointId, IAppliancesProxy appliancesProxy) {
Dictionary d=new Hashtable();
d.put(Function.SERVICE_DEVICE_UID, IDConverters.getDeviceUid(appliance.getPid(), appliance.getConfiguration()));
d.put(Function.SERVICE_UID, getFunctionUID(appliance));
d.put(Function.SERVICE_OPERATION_NAMES, new String[0]);
d.put(Function.SERVICE_PROPERTY_NAMES, new String[]{Meter.PROPERTY_CURRENT,Meter.PROPERTY_TOTAL});
switch(getCategory(appliance))
{
case 14: //it's a PV meter
d.put(Meter.SERVICE_FLOW, Meter.FLOW_OUT);
break;
default:
d.put(Meter.SERVICE_FLOW, Meter.FLOW_IN);
}
EnergyMeterDALAdapter adapter=new EnergyMeterDALAdapter(appliance.getPid(), endPointId, appliancesProxy);
adapter.setServiceProperties(d);
return FrameworkUtil.getBundle(this.getClass()).getBundleContext().registerService(
new String[]{Function.class.getName(),Meter.class.getName()},
adapter,
d);
}
示例8: createFunctionService
import org.osgi.service.dal.Function; //导入依赖的package包/类
public ServiceRegistration createFunctionService(IAppliance appliance, Integer endPointId, IAppliancesProxy appliancesProxy) {
Dictionary d=new Hashtable();
d.put(Function.SERVICE_DEVICE_UID, IDConverters.getDeviceUid(appliance.getPid(), appliance.getConfiguration()));
d.put(Function.SERVICE_UID, getFunctionUID(appliance));
d.put(Function.SERVICE_OPERATION_NAMES, new String[]{});
d.put(Function.SERVICE_PROPERTY_NAMES, new String[]{ColorControl.PROPERTY_HS});
return FrameworkUtil.getBundle(this.getClass()).getBundleContext().registerService(
new String[]{Function.class.getName(),ColorControl.class.getName()},
new ColorControlDALAdapter(appliance.getPid(), endPointId, appliancesProxy),
d);
}
示例9: represent
import org.osgi.service.dal.Function; //导入依赖的package包/类
@Get
public String represent() {
Gson gson = new Gson();
InvokeResponse resp = new InvokeResponse();
resp.setCode(200);
// Get device uid parameter
String device_uid_prop = (String) getRequest().getAttributes().get("device_uid");
// Get function services matching with device uid
BundleContext bc = FrameworkUtil.getBundle(FunctionsDeviceResource.class).getBundleContext();
ServiceReference[] functionRefs = null;
try {
LOG.debug("Device uid property: {}", device_uid_prop);
String filterString = "(" + Function.SERVICE_DEVICE_UID + "=" + URLDecoder.decode(device_uid_prop, "UTF-8") + ")";
Filter filter = bc.createFilter(filterString);
LOG.info("Filter: {}", filter);
functionRefs = (ServiceReference[]) bc.getServiceReferences(Function.class.getName(), filterString);
if (null == functionRefs) {
LOG.error("No service function reference with deviceUID: {}", device_uid_prop);
resp.setResult(new Vector());
return gson.toJson(resp); // no such services
}
LOG.info("Found {} service references", functionRefs.length);
for (int i = 0; i < functionRefs.length; i++) {
LOG.info("Service Reference: {}", functionRefs[i]);
}
} catch (Exception e) {
LOG.error("Erro getting service references: {}", e);
resp.setCode(500);
resp.setMessage("Error getting function references: " + e.getMessage());
return gson.toJson(resp);
}
// prepare a map of found functions
List<Map<String, Object>> functions = new LinkedList<Map<String, Object>>();
for (int i = 0; i < functionRefs.length; i++) {
Map<String, Object> propMap = new HashMap<String, Object>();
for (int j = 0; j < functionRefs[i].getPropertyKeys().length; j++) {
propMap.put(functionRefs[i].getPropertyKeys()[j], functionRefs[i].getProperty(functionRefs[i].getPropertyKeys()[j]));
bc.ungetService(functionRefs[i]);
}
functions.add(propMap);
}
this.addCustomHeaders();
resp.setResult(functions);
// write the map back to the client
return gson.toJson(resp);
}
示例10: represent
import org.osgi.service.dal.Function; //导入依赖的package包/类
@Get
public String represent() {
Gson gson = new Gson();
InvokeResponse resp=new InvokeResponse();
resp.setCode(200);
//Get device uid parameter
String device_uid_prop=(String) getRequest().getAttributes().get("device_uid");
//Get function services matching with device uid
BundleContext bc = FrameworkUtil.getBundle(FunctionsDeviceResource.class).getBundleContext();
ServiceReference[] functionRefs = null;
try {
LOG.debug("Device uid property: {}",device_uid_prop);
String filterString = "("+Function.SERVICE_DEVICE_UID+"="+URLDecoder.decode(device_uid_prop,"UTF-8")+")";
Filter filter=bc.createFilter(filterString);
LOG.info("Filter: {}",filter);
functionRefs = (ServiceReference[]) bc.getServiceReferences(
Function.class.getName(),
filterString);
if (null == functionRefs) {
LOG.error("No service function reference with deviceUID: {}",device_uid_prop);
resp.setResult(new Vector());
return gson.toJson(resp); // no such services
}
LOG.info("Found {} service references",functionRefs.length);
for (int i = 0; i < functionRefs.length; i++) {
LOG.info("Service Reference: {}",functionRefs[i]);
}
} catch (Exception e) {
LOG.error("Erro getting service references: {}",e);
resp.setCode(500);
resp.setMessage("Error getting function references: "+e.getMessage());
return gson.toJson(resp);
}
//prepare a map of found functions
List<Map<String,Object>> functions=new LinkedList<Map<String,Object>>();
for(int i=0;i<functionRefs.length;i++)
{
Map<String,Object> propMap=new HashMap<String,Object>();
for(int j=0;j<functionRefs[i].getPropertyKeys().length;j++)
{
propMap.put(functionRefs[i].getPropertyKeys()[j], functionRefs[i].getProperty(functionRefs[i].getPropertyKeys()[j]));
bc.ungetService(functionRefs[i]);
}
functions.add(propMap);
}
this.addCustomHeaders();
resp.setResult(functions);
//write the map back to the client
return gson.toJson(resp);
}
示例11: execSignalStateNotification
import org.osgi.service.dal.Function; //导入依赖的package包/类
public void execSignalStateNotification(short ApplianceStatus, short RemoteEnableFlags, int ApplianceStatus2,
IEndPointRequestContext context) throws ApplianceException, ServiceClusterException {
try {
IAppliance appliance=context.getPeerEndPoint().getAppliance();
//the WG ApplianceControlServer calls the GW applianceControlClient
//so a Function implementing interactions with ApplianceControlServer
//must be resolved
String clusterName=ApplianceControlServer.class.getName();
//now get the function implementing service
String functionUid=this.factories.get(clusterName).getFunctionUID(appliance);
String filterString = "("+Function.SERVICE_UID+"="+functionUid+")";
ServiceReference[] functionRefs;
functionRefs = (ServiceReference[]) componentContext.getBundleContext().getServiceReferences(
Function.class.getName(),
filterString);
if (null == functionRefs)
{
LOG.error("No function reference found");
return; // no such services
}
if(functionRefs.length!=1)
{
LOG.error("Invalid size ("+functionRefs.length+") for list of service references to function with UID:"+functionUid);
return;
}
//get the service
ClusterDALAdapter adapter= (ClusterDALAdapter) componentContext.getBundleContext().getService(functionRefs[0]);
//invoke method that create FunctionData according to received property and post the event
FunctionData applianceStatusValue=adapter.getDataFromClusterNotification("ApplianceStatus", new Short(ApplianceStatus));
if(applianceStatusValue!=null)
{
postEvent(functionUid, "ApplianceStatus", applianceStatusValue );
}
FunctionData remoteControlFlagValue=adapter.getDataFromClusterNotification("RemoteControl", new Short(RemoteEnableFlags));
if(applianceStatusValue!=null)
{
postEvent(functionUid, "RemoteControl", remoteControlFlagValue );
}
componentContext.getBundleContext().ungetService(functionRefs[0]);
} catch (Throwable e) {
LOG.error("Error receivign appliance status and remote control flags, {}",e);
}
}