1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package example.messagebox;
16
17 import org.fourthline.cling.binding.annotations.AnnotationLocalServiceBinder;
18 import org.fourthline.cling.binding.annotations.UpnpAction;
19 import org.fourthline.cling.binding.annotations.UpnpInputArgument;
20 import org.fourthline.cling.binding.annotations.UpnpService;
21 import org.fourthline.cling.binding.annotations.UpnpServiceId;
22 import org.fourthline.cling.binding.annotations.UpnpServiceType;
23 import org.fourthline.cling.binding.annotations.UpnpStateVariable;
24 import org.fourthline.cling.binding.annotations.UpnpStateVariables;
25 import org.fourthline.cling.model.DefaultServiceManager;
26 import org.fourthline.cling.model.meta.DeviceDetails;
27 import org.fourthline.cling.model.meta.DeviceIdentity;
28 import org.fourthline.cling.model.meta.LocalDevice;
29 import org.fourthline.cling.model.meta.LocalService;
30 import org.fourthline.cling.model.types.DeviceType;
31 import org.fourthline.cling.model.types.UDN;
32
33
34
35
36 public class MessageBoxSampleData {
37
38 public static LocalService readService(Class<?> serviceClass) throws Exception {
39 LocalService service = new AnnotationLocalServiceBinder().read(serviceClass);
40 service.setManager(
41 new DefaultServiceManager(service, serviceClass)
42 );
43 return service;
44 }
45
46 public static LocalDevice createDevice(Class<?> serviceClass) throws Exception {
47 return new LocalDevice(
48 new DeviceIdentity(new UDN("1111")),
49 new DeviceType("samsung.com", "PersonalMessageReceiver"),
50 new DeviceDetails("My TV"),
51 readService(serviceClass)
52 );
53 }
54
55 @UpnpService(
56 serviceId = @UpnpServiceId(namespace = "samsung.com", value = "MessageBoxService"),
57 serviceType = @UpnpServiceType(namespace = "samsung.com", value = "MessageBoxService")
58 )
59 @UpnpStateVariables({
60 @UpnpStateVariable(name ="A_ARG_TYPE_MessageID", datatype = "string", sendEvents = false),
61 @UpnpStateVariable(name ="A_ARG_TYPE_MessageType", datatype = "string", sendEvents = false, defaultValue = "text/xml; charset=\"utf-8\""),
62 @UpnpStateVariable(name ="A_ARG_TYPE_Message", datatype = "string", sendEvents = false)
63 })
64 public static class MessageBoxService {
65
66 @UpnpAction
67 public void addMessage(@UpnpInputArgument(name = "MessageID") String id,
68 @UpnpInputArgument(name = "MessageType") String type,
69 @UpnpInputArgument(name = "Message") String messageText) {
70 checkMessage(id, type, messageText);
71 }
72
73 protected void checkMessage(String id, String type, String messageText) {
74
75 }
76
77 }
78 }