-
Notifications
You must be signed in to change notification settings - Fork 0
/
FDRX.java
51 lines (40 loc) · 1.36 KB
/
FDRX.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package fd_rx;
import java.io.DataOutputStream;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.freedesktop.dbus.connections.impl.DBusConnection;
import org.freedesktop.dbus.exceptions.DBusException;
public class FDRX implements FDInterface {
private static final Logger logger = LogManager.getLogger();
private DBusConnection m_conn;
FDRX() throws DBusException{
m_conn = DBusConnection.getConnection( DBusConnection.DBusBusType.SESSION );
m_conn.requestBusName( "test.filedescriptor" );
m_conn.exportObject( "/", this );
logger.debug( "Waiting for incoming data" );
}
@Override
public void setFileDescriptor(FileDescriptor fd) {
logger.debug( "Got the file descriptor. Valid? {}", fd.valid() );
try{
DataOutputStream dos = new DataOutputStream( new FileOutputStream( fd ) );
dos.writeChars( "hi" );
}catch( IOException ex ){
logger.error( "IOException: ", ex );
}
}
@Override
public boolean isRemote() {
return false;
}
@Override
public String getObjectPath() {
return "/";
}
public static void main(String[] args ) throws DBusException {
new FDRX();
}
}