fr.velossity.sample.device.Device类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中fr.velossity.sample.device.Device类的一些代码示例,展示了Device类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Device类的具体详情如下:
包路径:fr.velossity.sample.device.Device
类名称:Device

Device介绍

[英]Device Main interface for your OSGi platform.
[中]OSGi平台的设备主界面。

代码示例

代码示例来源:origin: fr.velossity.osgi/ExtenderServiceRequester

/**
 * @see DeviceHandler#handle(Device)
 */
public void handle(Device newDevice) {
  System.out.println("I found a mock device with identifer= " + newDevice.getIdentifier());	
}

代码示例来源:origin: fr.velossity.osgi/ServiceProvider1

/**
 * @see BundleActivator#start(BundleContext)
 */
public void start(BundleContext context) throws Exception {
  
  // Set meta-data properties for the device
  Dictionary<String, String> properties = new Hashtable<String, String>();
  properties.put(Device.DEVICE_PROPERTY_IDENTIFIER, myDevice.getIdentifier());
  properties.put(Device.DEVICE_PROPERTY_TYPE, myDevice.getType());
  
  // PUBLISHES the Device service
  context.registerService(Device.class, myDevice, properties);
}

代码示例来源:origin: fr.velossity.osgi/ServiceProvider

/**
 * @see BundleActivator#start(BundleContext)
 */
public void start(BundleContext context) throws Exception {
  
  // Set meta-data properties for the device
  Dictionary<String, String> properties = new Hashtable<String, String>();
  properties.put("type", myDevice.getType());
  
  // PUBLISHES the Device service
  context.registerService(Device.class, myDevice, properties);
}

代码示例来源:origin: fr.velossity.osgi/iPOJOConsumerAP

/**
 * @see Runnable#run()
 */
public void run() {
  Thread mg = measureGetter;
  while (measureGetter == mg) {
    // INVOKES the service
    newMeasure(myDevice.getLastMeasure());
    try {
      synchronized (this) {
        wait(10000);	
      }                
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}

代码示例来源:origin: fr.velossity.osgi/SCRServiceRequester

/**
 * SCR callback, called when new device is registered.
 */
public void addProvider(Device newDevice) {
  System.out.println("I found a mock device with identifer= " + newDevice.getIdentifier());
}

代码示例来源:origin: fr.velossity.osgi/ServiceProvider2

/**
 * @see BundleActivator#start(BundleContext)
 */
public void start(BundleContext context) throws Exception {
  
  // Set meta-data properties for the device
  Dictionary<String, String> properties = new Hashtable<String, String>();
  properties.put(Device.DEVICE_PROPERTY_IDENTIFIER, myDevice.getIdentifier());
  properties.put(Device.DEVICE_PROPERTY_TYPE, myDevice.getType());
  
  // PUBLISHES the Device service
  context.registerService(Device.class, myDevice, properties);
}

代码示例来源:origin: fr.velossity.osgi/SCRServiceRequester

/**
 * SCR callback, called when device is disappearing.
 */
public void removeProvider(Device theDevice) {
  System.out.println("Mock device [" + theDevice.getIdentifier() + "] is unregistering");
}

代码示例来源:origin: fr.velossity.osgi/NativeAdapter

/**
 * @see ServiceTracker#addingService(ServiceReference)
 */
public ServiceRegistration<Device> addingService(ServiceReference<AdapteeDevice> ref) {
  AdapteeDevice adaptee = context.getService(ref);
  Device adapter = new DeviceAdapterImpl(adaptee);
  
  // REGISTERS with mandatory properties 
  Dictionary<String, String> properties = new Hashtable<String, String>();
  properties.put(Device.DEVICE_PROPERTY_IDENTIFIER, adapter.getIdentifier());
  properties.put(Device.DEVICE_PROPERTY_TYPE, adapter.getType());
  return context.registerService(Device.class, adapter, properties);
}

代码示例来源:origin: fr.velossity.osgi/ExtenderServiceRequester

/**
 * @see DeviceHandler#free(Device)
 */
public void free(Device aDevice) {
  System.out.println("Mock device [" + aDevice.getIdentifier() + "] is unregistering");
}

代码示例来源:origin: fr.velossity.osgi/iPOJOServiceRequester

/**
 * iPOJO callback, called when new device is registered.
 */
public void addProvider(Device newDevice) {
    System.out.println("I found a mock device with identifer= " + newDevice.getIdentifier());
}

代码示例来源:origin: fr.velossity.osgi/iPOJOServiceRequester

/**
   * iPOJO callback, called when device is disappearing.
   */
  public void removeProvider(Device theDevice) {
      System.out.println("Mock device [" + theDevice.getIdentifier() + "] is unregistering");
  }
}

代码示例来源:origin: fr.velossity.osgi/ServiceAPI4EAStep4

private static Dictionary<String, Object> setProperties(Device source, float value,
    String unit, long timestamp) {
  Dictionary<String, Object> dico = new Hashtable<String, Object>();
  dico.put("identifier", source.getIdentifier());
  dico.put("source", source);
  dico.put("value", Float.toString(value));
  dico.put("unit", unit);
  dico.put("timestamp", Long.toString(timestamp));
  return dico;
}

代码示例来源:origin: fr.velossity.osgi/ServiceRequester1

/**
 * @see BundleActivator#start(BundleContext)
 */
public void start(BundleContext context) throws Exception {
  
  // REQUESTS a service implementing a Device service of type Mock 
  Collection<ServiceReference<Device>> sr = context.getServiceReferences(Device.class, "(type=Mock)");
  if(sr != null && !sr.isEmpty()) {
    
    // BINDS to the service provider
    Device myDevice = context.getService(sr.iterator().next());
    
    // INVOKES the service
    System.out.println("I found a mock device with identifer= " + myDevice.getIdentifier());
  
  } else {
    System.out.println("I found no mock device at that time");
  }    }

代码示例来源:origin: fr.velossity.osgi/ServiceRequester2

/**
 * @see BundleActivator#start(BundleContext)
 */
public void start(BundleContext context) throws Exception {
  
  myContext = context;
  
  // Adds itself as a Registry listener for OSGi services
  context.addServiceListener(this, "(" + Constants.OBJECTCLASS + "=" + Device.class.getName() + ")");
      
  // REQUESTS a service implementing a Device service of type Mock 
  Collection<ServiceReference<Device>> sr = context.getServiceReferences(Device.class, "(type=Mock)");
  if(sr != null && !sr.isEmpty()) {
    
    // BINDS to the service provider
    Device myDevice = context.getService(sr.iterator().next());
    
    // INVOKES the service
    System.out.println("I found a mock device with identifer= " + myDevice.getIdentifier());
  
  } else {
    System.out.println("I found no mock device at that time");
  }
}

代码示例来源:origin: fr.velossity.osgi/ServiceAPI4EAStep4

public Measurement(Device source, float value, String unit, long timestamp) {
  super("fr/velossity/measures/" + source.getIdentifier() , setProperties(source, value, unit, timestamp));
}

代码示例来源:origin: fr.velossity.osgi/ServiceRequester2

/**
 * NOTIFICATION for device services.
 * OSGi callback to be notified of providers arrival and departure.
 * @see ServiceListener#serviceChanged(ServiceEvent)
 */
public void serviceChanged(ServiceEvent event) {		
  ServiceReference<?> sr = event.getServiceReference();
  // BINDS to the service provider
  Device myDevice = (Device) myContext.getService(sr);
  if(event.getType() == ServiceEvent.REGISTERED) {
    // INVOKES the service
    System.out.println("I found a mock device with identifer= " + myDevice.getIdentifier());
  }
  if(event.getType() == ServiceEvent.UNREGISTERING) {
    // INVOKES the service
    System.out.println("Mock device [" + myDevice.getIdentifier() + "] is unregistering");
  }
}

代码示例来源:origin: fr.velossity.osgi/iPOJOConsumerAP

/**
   * Just echoing the measurement to the console.
   */
  private void newMeasure(final Measurement measurement) {
    if(measurement != null) { // It can be null if the Producer service is declared before setting the measurement
      System.out.println("New measure [" + measurement.getSource().getIdentifier() + "]= " + measurement.getValue() + " " + measurement.getUnit());
    }
  }
}

代码示例来源:origin: fr.velossity.osgi/ConsumerEL

/**
 * @see MeasurementListener#newMeasure(Measurement)
 */
public void newMeasure(final Measurement measurement) {
  System.out.println("New measure [" + measurement.getSource().getIdentifier() + "]= " + measurement.getValue() + " " + measurement.getUnit());		
}

代码示例来源:origin: fr.velossity.osgi/iPOJOConsumerWB

/**
 * @see MeasurementHandler#newMeasure(Measurement)
 */
public void newMeasure(final Measurement measurement) {
  System.out.println("New measure [" + measurement.getSource().getIdentifier() + "]= " + measurement.getValue() + " " + measurement.getUnit());		
}

相关文章