当前位置: 首页>>代码示例>>Java>>正文


Java DBusException类代码示例

本文整理汇总了Java中org.freedesktop.dbus.exceptions.DBusException的典型用法代码示例。如果您正苦于以下问题:Java DBusException类的具体用法?Java DBusException怎么用?Java DBusException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DBusException类属于org.freedesktop.dbus.exceptions包,在下文中一共展示了DBusException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dbusConnect

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
@Override
public void dbusConnect(final String busName, final String busPath, DBusInterface iface) throws DBusException {
  this.busPath = busPath;

  connection = DBusConnection.getConnection(AgileObjectInterface.DEFAULT_DBUS_CONNECTION);

  connection.requestBusName(busName);
  connection.exportObject(busPath, iface);

  // ensure DBus object is unregistered
  Runtime.getRuntime().addShutdownHook(new Thread() {
    public void run() {
      try {
        connection.releaseBusName(busName);
        dbusDisconnect();
      } catch (DBusException ex) {
      }
    }
  });

}
 
开发者ID:Agile-IoT,项目名称:agile-api-spec,代码行数:22,代码来源:AbstractAgileObject.java

示例2: findAdapterPath

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
/**
 * Search for a Adapter that has GattManager1 and LEAdvertisement1 interfaces, otherwise return null.
 * @return
 * @throws DBusException
 */
public static String findAdapterPath() throws DBusException {
	DBusConnection dbusConnection = DBusConnection.getConnection(DBusConnection.SYSTEM);
	ObjectManager bluezObjectManager = (ObjectManager) dbusConnection.getRemoteObject(BLUEZ_DBUS_BUSNAME, "/", ObjectManager.class);
	if(bluezObjectManager == null) { return null; }
	
	Map<Path, Map<String, Map<String, Variant>>> bluezManagedObject = bluezObjectManager.GetManagedObjects();
	if(bluezManagedObject == null) { return null; }
	
	for (Path path : bluezManagedObject.keySet()) {
		Map<String, Map<String, Variant>> value = bluezManagedObject.get(path);
		boolean hasGattManager = false;
		boolean hasAdvManager = false;
		
		for(String key : value.keySet()) {
			if(key.equals(BLUEZ_GATT_INTERFACE)) { hasGattManager = true; }
			if(key.equals(BLUEZ_LE_ADV_INTERFACE)) { hasAdvManager = true; }
			
			if(hasGattManager && hasAdvManager) { return path.toString(); }
		}
	}
	
	return null;
}
 
开发者ID:tongo,项目名称:ble-java,代码行数:29,代码来源:BleApplication.java

示例3: wrap

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
private ServerPlayerWrapper wrap( String name, String service )
{
    try
    {
        ServerPlayerWrapper player = new ServerPlayerWrapper ( m_dbus_conn, name, service );

        m_players.put ( player.busname (), player );
        m_player_info.add ( player.info ().refresh () );

        if (m_dbus.NameHasOwner ( player.busname () ))
        {
            m_owners.put ( m_dbus.GetNameOwner ( player.busname () ), player );
        }

        return player;
    }
    catch (DBusException de)
    {
        de.printStackTrace ();
        return null;
    }
}
 
开发者ID:arfbtwn,项目名称:MPRIS2-Remote,代码行数:23,代码来源:PlayerManager.java

示例4: Daemon

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
public Daemon ( int threads,
                String svc_type,
                String name,
                int port,
                ServerPlayerWrapper.BootstrapPlayerInfo[] players )
        throws IOException, DBusException
{
    m_server_name = name;
    m_service_type = svc_type;

    m_gson = new GsonBuilder ().create ();
    m_commands = new QueueRunner <> ( new ArrayDeque < TransactionWrapper > (), m_act_command );
    m_responses = new QueueRunner <> ( new ArrayDeque < TransactionWrapper > (), m_act_response );
    m_minions = new ArrayList <> ();
    m_exection_pool = Executors.newFixedThreadPool ( threads );

    // Open Port
    m_socket_connection = new ServerSocket ( port );

    // Enumerate Media Players
    m_dbus_connection = DBusConnection.getConnection ( DBusConnection.SESSION );
    m_players = new PlayerManager ( m_dbus_connection, players );
    m_players.addListener ( m_listen_players );
}
 
开发者ID:arfbtwn,项目名称:MPRIS2-Remote,代码行数:25,代码来源:Daemon.java

示例5: createInstance

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
/**
 * Create a new {@link DeviceManager} instance using the given DBus address (e.g. tcp://127.0.0.1:13245)
 * @param _address address to connect to
 * @throws DBusException on error
 *
 * @return {@link DeviceManager}
 */
public static DeviceManager createInstance(String _address) throws DBusException {
    if (_address == null) {
        throw new DBusException("Null is not a valid address");
    }
    if (_address.contains("unix://")) {
        loadLibrary();
    }
    INSTANCE = new DeviceManager(DBusConnection.getConnection(_address));
    return INSTANCE;
}
 
开发者ID:hypfvieh,项目名称:bluez-dbus,代码行数:18,代码来源:DeviceManager.java

示例6: getTyped

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
/**
 * Helper to get a value of a DBus property.
 * @param _field DBus property key
 * @param _type expected return type of DBus property
 * @param <T> class of the expected result
 * @return value of _field as _type class or null
 */
@SuppressWarnings("unchecked")
protected <T> T getTyped(String _field, Class<T> _type) {
    try {
        SignalAwareProperties remoteObject = dbusConnection.getRemoteObject("org.bluez", dbusPath, SignalAwareProperties.class);
        Object obj = remoteObject.Get(getInterfaceClass().getName(), _field);
        if (ClassUtils.isAssignable(_type, obj.getClass())) {
            return (T) obj;
        }

    } catch (DBusException _ex) {
    }
    return null;
}
 
开发者ID:hypfvieh,项目名称:bluez-dbus,代码行数:21,代码来源:AbstractBluetoothObject.java

示例7: setTyped

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
/**
 * Helper to set a value on a DBus property.
 *
 * @param _field DBus property key
 * @param _value value to set
 */
protected void setTyped(String _field, Object _value) {
    try {
        SignalAwareProperties remoteObject = dbusConnection.getRemoteObject("org.bluez", dbusPath, SignalAwareProperties.class);
        remoteObject.Set(Adapter1.class.getName(), _field, _value);
    } catch (DBusException _ex) {
    }
}
 
开发者ID:hypfvieh,项目名称:bluez-dbus,代码行数:14,代码来源:AbstractBluetoothObject.java

示例8: getRemoteObject

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
/**
 * Creates an java object from a bluez dbus response.
 * @param _connection Dbus connection to use
 * @param _path dbus request path
 * @param _objClass interface class to use
 * @param <T> some class/interface implementing/extending {@link DBusInterface}
 * @return the created object or null on error
 */
public static <T extends DBusInterface> T getRemoteObject(DBusConnection _connection, String _path, Class<T> _objClass) {
    try {
        return _connection.getRemoteObject("org.bluez", _path, _objClass);
    } catch (DBusException _ex) {
        LOGGER.warn("Error while converting dbus response to object.", _ex);
    }
    return null;
}
 
开发者ID:hypfvieh,项目名称:bluez-dbus,代码行数:17,代码来源:DbusHelper.java

示例9: InterfacesAdded

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
public InterfacesAdded(String path, DBusInterface objectPath,
        Map<String, Map<String, Variant>> interfacesAndProperties)
        throws DBusException {
    super(path, objectPath, interfacesAndProperties);
    this.objectPath = objectPath;
    this.interfacesAndProperties = interfacesAndProperties;
}
 
开发者ID:mwylde,项目名称:scala-bluetooth,代码行数:8,代码来源:ObjectManager.java

示例10: PropertiesChanged

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
public PropertiesChanged(String path,
                         String dbusInterface,
                         Map<String, Variant> changedProperties,
                         List<String> invalidatedProperties) throws DBusException {
    super(path, changedProperties, invalidatedProperties);
    this.changedProperties = changedProperties;
    this.invalidatedProperties = invalidatedProperties;
}
 
开发者ID:mwylde,项目名称:scala-bluetooth,代码行数:9,代码来源:PropertiesChangedSignal.java

示例11: start

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
/**
 * First of all the method power-on the adapter.
 * Then publish the service with their characteristic and start the advertisement (only primary service can advertise).
 * @throws DBusException
 * @throws InterruptedException
 */
public void start() throws DBusException, InterruptedException {
	DBusConnection dbusConnection = DBusConnection.getConnection(DBusConnection.SYSTEM);
	
	adapterPath = findAdapterPath();
	if(adapterPath == null) { throw new RuntimeException("No BLE adapter found"); }
	
	this.export(dbusConnection);
	
	Properties adapterProperties = (Properties) dbusConnection.getRemoteObject(BLUEZ_DBUS_BUSNAME, adapterPath, Properties.class);
	adapterProperties.Set(BLUEZ_ADAPTER_INTERFACE, "Powered", new Variant<Boolean>(true));
	if(adapterAlias != null) {
		adapterProperties.Set(BLUEZ_ADAPTER_INTERFACE, "Alias", new Variant<String>(adapterAlias));
	}
	
	GattManager1 gattManager = (GattManager1) dbusConnection.getRemoteObject(BLUEZ_DBUS_BUSNAME, adapterPath, GattManager1.class);
	
	LEAdvertisingManager1 advManager = (LEAdvertisingManager1) dbusConnection.getRemoteObject(BLUEZ_DBUS_BUSNAME, adapterPath, LEAdvertisingManager1.class);

	String advPath = path + "/advertisement";
	adv = new BleAdvertisement(BleAdvertisement.ADVERTISEMENT_TYPE_PERIPHERAL, advPath);
	for (BleService service : servicesList) {
		if(service.isPrimary()) {
			advService = service;
			adv.addService(service);
			break;
		}
	}
	adv.export(dbusConnection);
	
	Map<String, Variant> advOptions = new HashMap<String, Variant>();
	advManager.RegisterAdvertisement(adv, advOptions);
	
	Map<String, Variant> appOptions = new HashMap<String, Variant>();
	gattManager.RegisterApplication(this, appOptions);
	
	initInterfacesHandler();
}
 
开发者ID:tongo,项目名称:ble-java,代码行数:44,代码来源:BleApplication.java

示例12: stop

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
/**
 * Stop the advertisement and unpublish the service.
 * @throws DBusException
 * @throws InterruptedException
 */
public void stop() throws DBusException, InterruptedException {
	if(adapterPath == null) { return; }
	DBusConnection dbusConnection = DBusConnection.getConnection(DBusConnection.SYSTEM);
	GattManager1 gattManager = (GattManager1) dbusConnection.getRemoteObject(BLUEZ_DBUS_BUSNAME, adapterPath, GattManager1.class);
	LEAdvertisingManager1 advManager = (LEAdvertisingManager1) dbusConnection.getRemoteObject(BLUEZ_DBUS_BUSNAME, adapterPath, LEAdvertisingManager1.class);
	
	if(adv != null) { advManager.UnregisterAdvertisement(adv); }
	gattManager.UnregisterApplication(this);
	
	dbusConnection.removeSigHandler(InterfacesAdded.class, interfacesAddedSignalHandler);
	dbusConnection.removeSigHandler(InterfacesRemoved.class, interfacesRemovedSignalHandler);
	dbusConnection.disconnect();
}
 
开发者ID:tongo,项目名称:ble-java,代码行数:19,代码来源:BleApplication.java

示例13: initInterfacesHandler

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
protected void initInterfacesHandler() throws DBusException {
	DBusConnection dbusConnection = DBusConnection.getConnection(DBusConnection.SYSTEM);
	DBus dbus = dbusConnection.getRemoteObject(DBUS_BUSNAME, "/or/freedesktop/DBus", DBus.class);
	String bluezDbusBusName = dbus.GetNameOwner(BLUEZ_DBUS_BUSNAME);
	ObjectManager bluezObjectManager = (ObjectManager) dbusConnection.getRemoteObject(BLUEZ_DBUS_BUSNAME, "/", ObjectManager.class);
	
	interfacesAddedSignalHandler = new DBusSigHandler<InterfacesAdded>() {
		@Override
		public void handle(InterfacesAdded signal) {
			Map<String, Variant> iamap = signal.getInterfacesAdded().get(BLUEZ_DEVICE_INTERFACE);
			if(iamap != null) {
				Variant<String> address = iamap.get("Address");
				System.out.println("Device address: " + address.getValue());
				System.out.println("Device added path: " + signal.getObjectPath().toString());
				hasDeviceConnected = true;
				if(listener != null) { listener.deviceConnected(); }
			}
		}
	};

	interfacesRemovedSignalHandler = new DBusSigHandler<InterfacesRemoved>() {
		@Override
		public void handle(InterfacesRemoved signal) {
			List<String> irlist = signal.getInterfacesRemoved();
			for (String ir : irlist) {
				if(BLUEZ_DEVICE_INTERFACE.equals(ir)) {
					System.out.println("Device Removed path: " + signal.getObjectPath().toString());
					hasDeviceConnected = false;
					if(listener != null) { listener.deviceDisconnected(); }
				}
			}
		}
	};

	dbusConnection.addSigHandler(InterfacesAdded.class, bluezDbusBusName, bluezObjectManager, interfacesAddedSignalHandler);
	dbusConnection.addSigHandler(InterfacesRemoved.class, bluezDbusBusName, bluezObjectManager, interfacesRemovedSignalHandler);
}
 
开发者ID:tongo,项目名称:ble-java,代码行数:38,代码来源:BleApplication.java

示例14: export

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
/**
 * Export the application in Dbus system.
 * @param dbusConnection
 * @throws DBusException
 */
private void export(DBusConnection dbusConnection) throws DBusException {
	for (BleService service : servicesList) {
		service.export(dbusConnection);
	}
	dbusConnection.exportObject(path, this);
}
 
开发者ID:tongo,项目名称:ble-java,代码行数:12,代码来源:BleApplication.java

示例15: main

import org.freedesktop.dbus.exceptions.DBusException; //导入依赖的package包/类
public static void main(String[] args) throws DBusException, InterruptedException {
		ExampleMain example = new ExampleMain();
		System.out.println("");
//		Thread t = new Thread(example);
//		t.start();
//		Thread.sleep(15000);
//		example.notifyBle("woooooo");
//		Thread.sleep(15000);
//		t.notify();
	}
 
开发者ID:tongo,项目名称:ble-java,代码行数:11,代码来源:ExampleMain.java


注:本文中的org.freedesktop.dbus.exceptions.DBusException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。