本文整理汇总了Java中org.fourthline.cling.binding.LocalServiceBindingException类的典型用法代码示例。如果您正苦于以下问题:Java LocalServiceBindingException类的具体用法?Java LocalServiceBindingException怎么用?Java LocalServiceBindingException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocalServiceBindingException类属于org.fourthline.cling.binding包,在下文中一共展示了LocalServiceBindingException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createDevice
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
private LocalDevice createDevice()
throws ValidationException, LocalServiceBindingException, IOException {
DeviceIdentity identity =
new DeviceIdentity(
UDN.uniqueSystemIdentifier(SmartApplianceEnabler.class.getSimpleName())
);
DeviceType type = new SmartApplianceEnablerDeviceType();
DeviceDetails details =
new DeviceDetails(
SmartApplianceEnabler.class.getSimpleName(),
new ManufacturerDetails(SmartApplianceEnabler.MANUFACTURER_NAME, URI.create(SmartApplianceEnabler.MANUFACTURER_URI)),
new ModelDetails(
SmartApplianceEnabler.class.getSimpleName(),
SmartApplianceEnabler.DESCRIPTION,
SmartApplianceEnabler.VERSION,
URI.create(SmartApplianceEnabler.MODEL_URI)
)
);
return new LocalDevice(identity, type, details, (Icon) null, (LocalService) null);
}
开发者ID:camueller,项目名称:SmartApplianceEnabler,代码行数:25,代码来源:SempDiscovery.java
示例2: appendAction
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
public Action appendAction(Map<Action, ActionExecutor> actions) throws LocalServiceBindingException {
String name;
if (getAnnotation().name().length() != 0) {
name = getAnnotation().name();
} else {
name = AnnotationLocalServiceBinder.toUpnpActionName(getMethod().getName());
}
log.fine("Creating action and executor: " + name);
List<ActionArgument> inputArguments = createInputArguments();
Map<ActionArgument<LocalService>, StateVariableAccessor> outputArguments = createOutputArguments();
inputArguments.addAll(outputArguments.keySet());
ActionArgument<LocalService>[] actionArguments =
inputArguments.toArray(new ActionArgument[inputArguments.size()]);
Action action = new Action(name, actionArguments);
ActionExecutor executor = createExecutor(outputArguments);
actions.put(action, executor);
return action;
}
开发者ID:offbye,项目名称:DroidDLNA,代码行数:25,代码来源:AnnotationActionBinder.java
示例3: read
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
public LocalService read(Class<?> clazz, ServiceId id, ServiceType type,
boolean supportsQueryStateVariables, Set<Class> stringConvertibleTypes)
throws LocalServiceBindingException {
Map<StateVariable, StateVariableAccessor> stateVariables = readStateVariables(clazz, stringConvertibleTypes);
Map<Action, ActionExecutor> actions = readActions(clazz, stateVariables, stringConvertibleTypes);
// Special treatment of the state variable querying action
if (supportsQueryStateVariables) {
actions.put(new QueryStateVariableAction(), new QueryStateVariableExecutor());
}
try {
return new LocalService(type, id, actions, stateVariables, stringConvertibleTypes, supportsQueryStateVariables);
} catch (ValidationException ex) {
log.severe("Could not validate device model: " + ex.toString());
for (ValidationError validationError : ex.getErrors()) {
log.severe(validationError.toString());
}
throw new LocalServiceBindingException("Validation of model failed, check the log");
}
}
开发者ID:offbye,项目名称:DroidDLNA,代码行数:24,代码来源:AnnotationLocalServiceBinder.java
示例4: readStringConvertibleTypes
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
protected Set<Class> readStringConvertibleTypes(Class[] declaredTypes) throws LocalServiceBindingException {
for (Class stringConvertibleType : declaredTypes) {
if (!Modifier.isPublic(stringConvertibleType.getModifiers())) {
throw new LocalServiceBindingException(
"Declared string-convertible type must be public: " + stringConvertibleType
);
}
try {
stringConvertibleType.getConstructor(String.class);
} catch (NoSuchMethodException ex) {
throw new LocalServiceBindingException(
"Declared string-convertible type needs a public single-argument String constructor: " + stringConvertibleType
);
}
}
Set<Class> stringConvertibleTypes = new HashSet(Arrays.asList(declaredTypes));
// Some defaults
stringConvertibleTypes.add(URI.class);
stringConvertibleTypes.add(URL.class);
stringConvertibleTypes.add(CSV.class);
return stringConvertibleTypes;
}
开发者ID:offbye,项目名称:DroidDLNA,代码行数:26,代码来源:AnnotationLocalServiceBinder.java
示例5: readActions
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
protected Map<Action, ActionExecutor> readActions(Class<?> clazz,
Map<StateVariable, StateVariableAccessor> stateVariables,
Set<Class> stringConvertibleTypes)
throws LocalServiceBindingException {
Map<Action, ActionExecutor> map = new HashMap();
for (Method method : Reflections.getMethods(clazz, UpnpAction.class)) {
AnnotationActionBinder actionBinder =
new AnnotationActionBinder(method, stateVariables, stringConvertibleTypes);
Action action = actionBinder.appendAction(map);
if(isActionExcluded(action)) {
map.remove(action);
}
}
return map;
}
开发者ID:offbye,项目名称:DroidDLNA,代码行数:19,代码来源:AnnotationLocalServiceBinder.java
示例6: createDefaultValue
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
protected String createDefaultValue(Datatype datatype) throws LocalServiceBindingException {
// Next, the default value of the state variable, first the declared one
if (getAnnotation().defaultValue().length() != 0) {
// The declared default value needs to match the datatype
try {
datatype.valueOf(getAnnotation().defaultValue());
log.finer("Found state variable default value: " + getAnnotation().defaultValue());
return getAnnotation().defaultValue();
} catch (Exception ex) {
throw new LocalServiceBindingException(
"Default value doesn't match datatype of state variable '" + getName() + "': " + ex.getMessage()
);
}
}
return null;
}
开发者ID:offbye,项目名称:DroidDLNA,代码行数:19,代码来源:AnnotationStateVariableBinder.java
示例7: getAllowedValues
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
protected String[] getAllowedValues(Class enumType) throws LocalServiceBindingException {
if (!enumType.isEnum()) {
throw new LocalServiceBindingException("Allowed values type is not an Enum: " + enumType);
}
log.finer("Restricting allowed values of state variable to Enum: " + getName());
String[] allowedValueStrings = new String[enumType.getEnumConstants().length];
for (int i = 0; i < enumType.getEnumConstants().length; i++) {
Object o = enumType.getEnumConstants()[i];
if (o.toString().length() > 32) {
throw new LocalServiceBindingException(
"Allowed value string (that is, Enum constant name) is longer than 32 characters: " + o.toString()
);
}
log.finer("Adding allowed value (converted to string): " + o.toString());
allowedValueStrings[i] = o.toString();
}
return allowedValueStrings;
}
开发者ID:offbye,项目名称:DroidDLNA,代码行数:22,代码来源:AnnotationStateVariableBinder.java
示例8: getAllowedRangeFromProvider
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
protected StateVariableAllowedValueRange getAllowedRangeFromProvider() throws LocalServiceBindingException {
Class provider = getAnnotation().allowedValueRangeProvider();
if (!AllowedValueRangeProvider.class.isAssignableFrom(provider))
throw new LocalServiceBindingException(
"Allowed value range provider is not of type " + AllowedValueRangeProvider.class + ": " + getName()
);
try {
AllowedValueRangeProvider providerInstance =
((Class<? extends AllowedValueRangeProvider>) provider).newInstance();
return getAllowedValueRange(
providerInstance.getMinimum(),
providerInstance.getMaximum(),
providerInstance.getStep()
);
} catch (Exception ex) {
throw new LocalServiceBindingException(
"Allowed value range provider can't be instantiated: " + getName(), ex
);
}
}
开发者ID:offbye,项目名称:DroidDLNA,代码行数:21,代码来源:AnnotationStateVariableBinder.java
示例9: createDevice
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public static LocalDevice createDevice() throws ValidationException, LocalServiceBindingException, IOException {
DeviceIdentity identity = new DeviceIdentity(UDN.uniqueSystemIdentifier("tinyMediaManager"));
DeviceType type = new UDADeviceType("MediaServer", 1);
String hostname = NetworkUtil.getMachineHostname();
if (hostname == null) {
hostname = Upnp.IP;
}
DeviceDetails details = new DeviceDetails("tinyMediaManager (" + hostname + ")",
new ManufacturerDetails("tinyMediaManager", "http://www.tinymediamanager.org/"),
new ModelDetails("tinyMediaManager", "tinyMediaManager - Media Server", ReleaseInfo.getVersion()));
LOGGER.info("Hello, i'm " + identity.getUdn().getIdentifierString());
// Content Directory Service
LocalService cds = new AnnotationLocalServiceBinder().read(ContentDirectoryService.class);
cds.setManager(new DefaultServiceManager<ContentDirectoryService>(cds, ContentDirectoryService.class));
// Connection Manager Service
LocalService<ConnectionManagerService> cms = new AnnotationLocalServiceBinder().read(ConnectionManagerService.class);
cms.setManager(new DefaultServiceManager<>(cms, ConnectionManagerService.class));
return new LocalDevice(identity, type, details, new LocalService[] { cds, cms });
}
开发者ID:tinyMediaManager,项目名称:tinyMediaManager,代码行数:25,代码来源:MediaServer.java
示例10: createDevice
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
LocalDevice createDevice() throws ValidationException, LocalServiceBindingException, IOException {
DeviceIdentity identity = new DeviceIdentity(UDN.uniqueSystemIdentifier("SensoryEffectRendererDevice"));
DeviceType type = new UDADeviceType("SensoryEffectRenderer", 1);
DeviceDetails details =
new DeviceDetails(
"LPRM - PlaySEM - Sensory Effect Renderer Device",
new ManufacturerDetails("LPRM"),
new ModelDetails(
"PlaySEM.SERendererDevice.ModelA",
"A remote Sensory Effect Renderer Device. Model A supports Light, Fan and Vibration.",
"v1"
)
);
String iconResource = "br/ufes/inf/lprm/sensoryeffect/renderer/icon.png";
Icon icon = new Icon("image/png", 48, 48, 8, "icon.png", Thread.currentThread().getContextClassLoader().getResourceAsStream(iconResource));
LocalService<SERendererService> seRendererService = new AnnotationLocalServiceBinder().read(SERendererService.class);
seRendererService.setManager(new DefaultServiceManager(seRendererService, SERendererService.class));
try {
return new LocalDevice(identity, type, details, icon, seRendererService);
}
catch (Exception e) {
System.out.print("An exception has occured: " + e.getMessage());
e.printStackTrace();
return null;
}
}
开发者ID:estevaosaleme,项目名称:PlaySEM_SERenderer,代码行数:32,代码来源:SERendererDevice.java
示例11: createDevice
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
public LocalDevice createDevice( )
throws ValidationException,
LocalServiceBindingException,
IOException {
DeviceIdentity identity = new DeviceIdentity(
UDN.uniqueSystemIdentifier(deviceIdentity));
DeviceType type = new UDADeviceType("BinaryLight", 1);
DeviceDetails details = new DeviceDetails(friendlyName,
new ManufacturerDetails(manufacturerName), new ModelDetails(
modelName, modelDescription, modelNumber));
/*Icon icon = new Icon("image/png", 48, 48, 8, getClass().getResource(
"icon.png"));*/
LocalService switchPowerService = new AnnotationLocalServiceBinder()
.read(implClass);
switchPowerService.setManager(new DefaultServiceManager(
switchPowerService, implClass));
return new LocalDevice(identity, type, details, /*icon,*/
switchPowerService);
/*
* Several services can be bound to the same device: return new
* LocalDevice( identity, type, details, icon, new LocalService[]
* {switchPowerService, myOtherService} );
*/
}
开发者ID:cyclingengineer,项目名称:UpnpHomeAutomationBridge,代码行数:34,代码来源:BinaryLightDevice.java
示例12: validateType
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
protected void validateType(StateVariable stateVariable, Class type) throws LocalServiceBindingException {
// Validate datatype as good as we can
// (for enums and other convertible types, the state variable type should be STRING)
Datatype.Default expectedDefaultMapping =
ModelUtil.isStringConvertibleType(getStringConvertibleTypes(), type)
? Datatype.Default.STRING
: Datatype.Default.getByJavaType(type);
log.finer("Expecting '" + stateVariable + "' to match default mapping: " + expectedDefaultMapping);
if (expectedDefaultMapping != null &&
!stateVariable.getTypeDetails().getDatatype().isHandlingJavaType(expectedDefaultMapping.getJavaType())) {
// TODO: Consider custom types?!
throw new LocalServiceBindingException(
"State variable '" + stateVariable + "' datatype can't handle action " +
"argument's Java type (change one): " + expectedDefaultMapping.getJavaType()
);
} else if (expectedDefaultMapping == null && stateVariable.getTypeDetails().getDatatype().getBuiltin() != null) {
throw new LocalServiceBindingException(
"State variable '" + stateVariable + "' should be custom datatype " +
"(action argument type is unknown Java type): " + type.getSimpleName()
);
}
log.finer("State variable matches required argument datatype (or can't be validated because it is custom)");
}
开发者ID:offbye,项目名称:DroidDLNA,代码行数:31,代码来源:AnnotationActionBinder.java
示例13: getAllowedValueRange
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
protected StateVariableAllowedValueRange getAllowedValueRange(long min,
long max,
long step) throws LocalServiceBindingException {
if (max < min) {
throw new LocalServiceBindingException(
"Allowed value range maximum is smaller than minimum: " + getName()
);
}
return new StateVariableAllowedValueRange(min, max, step);
}
开发者ID:offbye,项目名称:DroidDLNA,代码行数:12,代码来源:AnnotationStateVariableBinder.java
示例14: getAllowedValuesFromProvider
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
protected String[] getAllowedValuesFromProvider() throws LocalServiceBindingException {
Class provider = getAnnotation().allowedValueProvider();
if (!AllowedValueProvider.class.isAssignableFrom(provider))
throw new LocalServiceBindingException(
"Allowed value provider is not of type " + AllowedValueProvider.class + ": " + getName()
);
try {
return ((Class<? extends AllowedValueProvider>) provider).newInstance().getValues();
} catch (Exception ex) {
throw new LocalServiceBindingException(
"Allowed value provider can't be instantiated: " + getName(), ex
);
}
}
开发者ID:offbye,项目名称:DroidDLNA,代码行数:15,代码来源:AnnotationStateVariableBinder.java
示例15: startMediaServer
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
public void startMediaServer() {
createUpnpService();
try {
this.upnpService.getRegistry().addDevice(MediaServer.createDevice());
}
catch (RegistrationException | LocalServiceBindingException | ValidationException | IOException e) {
LOGGER.warn("could not start UPNP MediaServer!", e);
}
}
开发者ID:tinyMediaManager,项目名称:tinyMediaManager,代码行数:10,代码来源:Upnp.java
示例16: createDevice
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
public LocalDevice createDevice( )
throws ValidationException,
LocalServiceBindingException,
IOException {
DeviceIdentity identity = new DeviceIdentity(
UDN.uniqueSystemIdentifier(deviceIdentity));
DeviceType type = new UDADeviceType("HVAC_System", 1);
DeviceDetails details = new DeviceDetails(friendlyName,
new ManufacturerDetails(manufacturerName), new ModelDetails(
modelName, modelDescription, modelNumber));
/*Icon icon = new Icon("image/png", 48, 48, 8, getClass().getResource(
"icon.png"));*/
// we have to have a ZoneUserMode HVAC_OperatingMode service
LocalService zoneUserModeLocalService =
new AnnotationLocalServiceBinder().read(systemUserModeServiceClass);
zoneUserModeLocalService.setManager(
new DefaultServiceManager(
zoneUserModeLocalService, systemUserModeServiceClass
)
);
serviceList.add(zoneUserModeLocalService);
LocalService[] serviceArray = new LocalService[ serviceList.size() ];
serviceList.toArray(serviceArray);
// create embedded devices
ArrayList<LocalDevice> embeddedLocalDeviceList = new ArrayList<LocalDevice>();
for (UpnpDevice d : embeddedDevicesList) {
embeddedLocalDeviceList.add(d.createDevice());
}
LocalDevice[] embeddedDeviceArray = new LocalDevice[ embeddedDevicesList.size() ];
embeddedLocalDeviceList.toArray(embeddedDeviceArray);
return new LocalDevice(identity, type, details, /*icon,*/
serviceArray,embeddedDeviceArray);
}
开发者ID:cyclingengineer,项目名称:UpnpHomeAutomationBridge,代码行数:43,代码来源:HvacSystemDevice.java
示例17: createDevice
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
public abstract LocalDevice createDevice( )
throws ValidationException,
LocalServiceBindingException,
IOException;
开发者ID:cyclingengineer,项目名称:UpnpHomeAutomationBridge,代码行数:5,代码来源:UpnpDevice.java
示例18: createDevice
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
public LocalDevice createDevice( )
throws ValidationException,
LocalServiceBindingException,
IOException {
DeviceIdentity identity = new DeviceIdentity(
UDN.uniqueSystemIdentifier(deviceIdentity));
DeviceType type = new UDADeviceType("HVAC_ZoneThermostat", 1);
DeviceDetails details = new DeviceDetails(friendlyName,
new ManufacturerDetails(manufacturerName), new ModelDetails(
modelName, modelDescription, modelNumber));
/*Icon icon = new Icon("image/png", 48, 48, 8, getClass().getResource(
"icon.png"));*/
// we have to have a ZoneUserMode HVAC_OperatingMode service
LocalService zoneUserModeLocalService =
new AnnotationLocalServiceBinder().read(zoneUserModeServiceClass);
zoneUserModeLocalService.setManager(
new DefaultServiceManager(
zoneUserModeLocalService, zoneUserModeServiceClass
)
);
serviceList.add(zoneUserModeLocalService);
LocalService[] serviceArray = new LocalService[ serviceList.size() ];
serviceList.toArray(serviceArray);
// create embedded devices
ArrayList<LocalDevice> embeddedLocalDeviceList = new ArrayList<LocalDevice>();
for (UpnpDevice d : embeddedDevicesList) {
embeddedLocalDeviceList.add(d.createDevice());
}
LocalDevice[] embeddedDeviceArray = new LocalDevice[ embeddedDevicesList.size() ];
embeddedLocalDeviceList.toArray(embeddedDeviceArray);
return new LocalDevice(identity, type, details, /*icon,*/
serviceArray,embeddedDeviceArray);
}
开发者ID:cyclingengineer,项目名称:UpnpHomeAutomationBridge,代码行数:43,代码来源:HvacZoneThermostatDevice.java
示例19: createInputArguments
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
protected List<ActionArgument> createInputArguments() throws LocalServiceBindingException {
List<ActionArgument> list = new ArrayList();
// Input arguments are always method parameters
int annotatedParams = 0;
Annotation[][] params = getMethod().getParameterAnnotations();
for (int i = 0; i < params.length; i++) {
Annotation[] param = params[i];
for (Annotation paramAnnotation : param) {
if (paramAnnotation instanceof UpnpInputArgument) {
UpnpInputArgument inputArgumentAnnotation = (UpnpInputArgument) paramAnnotation;
annotatedParams++;
String argumentName =
inputArgumentAnnotation.name();
StateVariable stateVariable =
findRelatedStateVariable(
inputArgumentAnnotation.stateVariable(),
argumentName,
getMethod().getName()
);
if (stateVariable == null) {
throw new LocalServiceBindingException(
"Could not detected related state variable of argument: " + argumentName
);
}
validateType(stateVariable, getMethod().getParameterTypes()[i]);
ActionArgument inputArgument = new ActionArgument(
argumentName,
inputArgumentAnnotation.aliases(),
stateVariable.getName(),
ActionArgument.Direction.IN
);
list.add(inputArgument);
}
}
}
// A method can't have any parameters that are not annotated with @UpnpInputArgument - we wouldn't know what
// value to pass when we invoke it later on... unless the last parameter is of type RemoteClientInfo
if (annotatedParams < getMethod().getParameterTypes().length
&& !RemoteClientInfo.class.isAssignableFrom(method.getParameterTypes()[method.getParameterTypes().length-1])) {
throw new LocalServiceBindingException("Method has parameters that are not input arguments: " + getMethod().getName());
}
return list;
}
开发者ID:offbye,项目名称:DroidDLNA,代码行数:53,代码来源:AnnotationActionBinder.java
示例20: createOutputArguments
import org.fourthline.cling.binding.LocalServiceBindingException; //导入依赖的package包/类
protected Map<ActionArgument<LocalService>, StateVariableAccessor> createOutputArguments() throws LocalServiceBindingException {
Map<ActionArgument<LocalService>, StateVariableAccessor> map = new LinkedHashMap(); // !!! Insertion order!
UpnpAction actionAnnotation = getMethod().getAnnotation(UpnpAction.class);
if (actionAnnotation.out().length == 0) return map;
boolean hasMultipleOutputArguments = actionAnnotation.out().length > 1;
for (UpnpOutputArgument outputArgumentAnnotation : actionAnnotation.out()) {
String argumentName = outputArgumentAnnotation.name();
StateVariable stateVariable = findRelatedStateVariable(
outputArgumentAnnotation.stateVariable(),
argumentName,
getMethod().getName()
);
// Might-just-work attempt, try the name of the getter
if (stateVariable == null && outputArgumentAnnotation.getterName().length() > 0) {
stateVariable = findRelatedStateVariable(null, null, outputArgumentAnnotation.getterName());
}
if (stateVariable == null) {
throw new LocalServiceBindingException(
"Related state variable not found for output argument: " + argumentName
);
}
StateVariableAccessor accessor = findOutputArgumentAccessor(
stateVariable,
outputArgumentAnnotation.getterName(),
hasMultipleOutputArguments
);
log.finer("Found related state variable for output argument '" + argumentName + "': " + stateVariable);
ActionArgument outputArgument = new ActionArgument(
argumentName,
stateVariable.getName(),
ActionArgument.Direction.OUT,
!hasMultipleOutputArguments
);
map.put(outputArgument, accessor);
}
return map;
}
开发者ID:offbye,项目名称:DroidDLNA,代码行数:51,代码来源:AnnotationActionBinder.java
注:本文中的org.fourthline.cling.binding.LocalServiceBindingException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论