1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.fourthline.cling.test.data;
17
18 import org.fourthline.cling.model.meta.Action;
19 import org.fourthline.cling.model.meta.Service;
20 import org.fourthline.cling.model.meta.StateVariable;
21 import org.fourthline.cling.model.types.ServiceId;
22 import org.fourthline.cling.model.types.ServiceType;
23
24 import java.lang.reflect.Constructor;
25 import java.net.URI;
26
27
28
29
30 public abstract class SampleService {
31
32 public abstract ServiceType getServiceType();
33 public abstract ServiceId getServiceId();
34 public abstract URI getDescriptorURI();
35 public abstract URI getControlURI();
36 public abstract URI getEventSubscriptionURI();
37 public abstract Action[] getActions();
38 public abstract StateVariable[] getStateVariables();
39
40 public <S extends Service> S newInstanceLocal(Constructor<S> ctor) {
41 try {
42 return ctor.newInstance(
43 getServiceType(), getServiceId(),
44 getActions(), getStateVariables()
45 );
46 } catch (Exception ex) {
47 throw new RuntimeException(ex);
48 }
49 }
50
51 public <S extends Service> S newInstanceRemote(Constructor<S> ctor) {
52 try {
53 return ctor.newInstance(
54 getServiceType(), getServiceId(),
55 getDescriptorURI(), getControlURI(), getEventSubscriptionURI(),
56 getActions(), getStateVariables()
57 );
58 } catch (Exception ex) {
59 throw new RuntimeException(ex);
60 }
61 }
62
63 }