本文整理汇总了Java中org.fourthline.cling.model.meta.Action类的典型用法代码示例。如果您正苦于以下问题:Java Action类的具体用法?Java Action怎么用?Java Action使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Action类属于org.fourthline.cling.model.meta包,在下文中一共展示了Action类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: browse
import org.fourthline.cling.model.meta.Action; //导入依赖的package包/类
private void browse(DeviceDisplay device, String id) {
mBrowsingDevices = id == null;
updateTitleAndDescription();
if (mBrowsingDevices) {
mParentIdMap.clear();
mListView.setAdapter(mListAdapter);
} else {
Service foundService = null;
for (Service s : device.getDevice().getServices())
for (Action a : s.getActions())
if ("browse".equalsIgnoreCase(a.getName())) {
foundService = s;
break;
}
if (foundService != null) {
mUpnpService.getControlPoint().execute(
new BrowseCallback(foundService, id, BrowseFlag.DIRECT_CHILDREN));
}
}
}
示例2: appendAction
import org.fourthline.cling.model.meta.Action; //导入依赖的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;
}
示例3: read
import org.fourthline.cling.model.meta.Action; //导入依赖的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");
}
}
示例4: readActions
import org.fourthline.cling.model.meta.Action; //导入依赖的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;
}
示例5: readOutputArgumentValues
import org.fourthline.cling.model.meta.Action; //导入依赖的package包/类
/**
* Reads the output arguments after an action execution using accessors.
*
* @param action The action of which the output arguments are read.
* @param instance The instance on which the accessors will be invoked.
* @return <code>null</code> if the action has no output arguments, a single instance if it has one, an
* <code>Object[]</code> otherwise.
* @throws Exception
*/
protected Object readOutputArgumentValues(Action<LocalService> action, Object instance) throws Exception {
Object[] results = new Object[action.getOutputArguments().length];
log.fine("Attempting to retrieve output argument values using accessor: " + results.length);
int i = 0;
for (ActionArgument outputArgument : action.getOutputArguments()) {
log.finer("Calling acccessor method for: " + outputArgument);
StateVariableAccessor accessor = getOutputArgumentAccessors().get(outputArgument);
if (accessor != null) {
log.fine("Calling accessor to read output argument value: " + accessor);
results[i++] = accessor.read(instance);
} else {
throw new IllegalStateException("No accessor bound for: " + outputArgument);
}
}
if (results.length == 1) {
return results[0];
}
return results.length > 0 ? results : null;
}
示例6: testRendererGetProtocolInfo
import org.fourthline.cling.model.meta.Action; //导入依赖的package包/类
public void testRendererGetProtocolInfo(){
waitForService();
LocalDevice rendererDevice = getService().getUpnpClient().getRegistry().getLocalDevice(new UDN(YaaccUpnpServerService.MEDIA_RENDERER_UDN_ID),false);
LocalService connectionService = rendererDevice.findService(new ServiceId(UDAServiceId.DEFAULT_NAMESPACE,"ConnectionManager"));
Action action = connectionService.getAction("GetProtocolInfo");
ActionInvocation<LocalService> actionInvocation = new ActionInvocation<LocalService>(action);
connectionService.getExecutor(action).execute(actionInvocation);
if(actionInvocation.getFailure() != null){
throw new RuntimeException(actionInvocation.getFailure().fillInStackTrace());
}
}
示例7: testServerGetProtocolInfo
import org.fourthline.cling.model.meta.Action; //导入依赖的package包/类
public void testServerGetProtocolInfo(){
waitForService();
LocalDevice serverDevice = getService().getUpnpClient().getRegistry().getLocalDevice(new UDN(YaaccUpnpServerService.MEDIA_SERVER_UDN_ID),false);
LocalService connectionService = serverDevice.findService(new ServiceId(UDAServiceId.DEFAULT_NAMESPACE,"ConnectionManager"));
Action action = connectionService.getAction("GetProtocolInfo");
ActionInvocation<LocalService> actionInvocation = new ActionInvocation<LocalService>(action);
connectionService.getExecutor(action).execute(actionInvocation);
if(actionInvocation.getFailure() != null){
throw new RuntimeException(actionInvocation.getFailure().fillInStackTrace());
}
}
示例8: getConnectionInfos
import org.fourthline.cling.model.meta.Action; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private void getConnectionInfos(UpnpClient upnpClient,
final List<Device<?, ?, ?>> devices) throws Exception {
for (Device<?, ?, ?> device : devices) {
Service service = device.findService(new UDAServiceId(
"ConnectionManager"));
if (service != null) {
Action getCurrentConnectionIds = service
.getAction("GetCurrentConnectionIDs");
assertNotNull(getCurrentConnectionIds);
ActionInvocation getCurrentConnectionIdsInvocation = new ActionInvocation(
getCurrentConnectionIds);
ActionCallback getCurrentConnectionCallback = new ActionCallback(
getCurrentConnectionIdsInvocation) {
@Override
public void success(ActionInvocation invocation) {
ActionArgumentValue[] connectionIds = invocation
.getOutput();
for (ActionArgumentValue connectionId : connectionIds) {
Log.d(getClass().getName(), connectionId.getValue().toString());
}
}
@Override
public void failure(ActionInvocation actioninvocation,
UpnpResponse upnpresponse, String s) {
Log.d(getClass().getName(),"Failure:" + upnpresponse);
}
};
upnpClient.getUpnpService().getControlPoint()
.execute(getCurrentConnectionCallback);
}
}
myWait();
}
示例9: createActions
import org.fourthline.cling.model.meta.Action; //导入依赖的package包/类
public Action[] createActions() {
Action[] array = new Action[actions.size()];
int i = 0;
for (MutableAction action : actions) {
array[i++] = action.build();
}
return array;
}
示例10: generateActionList
import org.fourthline.cling.model.meta.Action; //导入依赖的package包/类
private void generateActionList(Service serviceModel, Document descriptor, Element scpdElement) {
Element actionListElement = appendNewElement(descriptor, scpdElement, ELEMENT.actionList);
for (Action action : serviceModel.getActions()) {
if (!action.getName().equals(QueryStateVariableAction.ACTION_NAME))
generateAction(action, descriptor, actionListElement);
}
}
示例11: generateAction
import org.fourthline.cling.model.meta.Action; //导入依赖的package包/类
private void generateAction(Action action, Document descriptor, Element actionListElement) {
Element actionElement = appendNewElement(descriptor, actionListElement, ELEMENT.action);
appendNewElementIfNotNull(descriptor, actionElement, ELEMENT.name, action.getName());
if (action.hasArguments()) {
Element argumentListElement = appendNewElement(descriptor, actionElement, ELEMENT.argumentList);
for (ActionArgument actionArgument : action.getArguments()) {
generateActionArgument(actionArgument, descriptor, argumentListElement);
}
}
}
示例12: OutgoingActionResponseMessage
import org.fourthline.cling.model.meta.Action; //导入依赖的package包/类
public OutgoingActionResponseMessage(UpnpResponse.Status status, Action action) {
super(new UpnpResponse(status));
if (action != null) {
if (action instanceof QueryStateVariableAction) {
this.actionNamespace = Constants.NS_UPNP_CONTROL_10;
} else {
this.actionNamespace = action.getService().getServiceType().toString();
}
}
addHeaders();
}
示例13: RemoteActionInvocation
import org.fourthline.cling.model.meta.Action; //导入依赖的package包/类
public RemoteActionInvocation(Action action,
ActionArgumentValue[] input,
ActionArgumentValue[] output,
RemoteClientInfo remoteClientInfo) {
super(action, input, output, null);
this.remoteClientInfo = remoteClientInfo;
}
示例14: ActionInvocation
import org.fourthline.cling.model.meta.Action; //导入依赖的package包/类
public ActionInvocation(Action<S> action,
ActionArgumentValue<S>[] input,
ActionArgumentValue<S>[] output,
ClientInfo clientInfo) {
if (action == null) {
throw new IllegalArgumentException("Action can not be null");
}
this.action = action;
setInput(input);
setOutput(output);
this.clientInfo = clientInfo;
}
示例15: buildActionInvocation
import org.fourthline.cling.model.meta.Action; //导入依赖的package包/类
private static ActionInvocation buildActionInvocation(Service service) {
// not really a A_ARG_TYPE_Result type but close enough
ActionArgument argument = new ActionArgument("FeatureList", "A_ARG_TYPE_Result", ActionArgument.Direction.OUT);
Action action = new Action("X_GetFeatureList", new ActionArgument[]{argument});
try {
// package method must be reflected
Method m = Action.class.getDeclaredMethod("setService", Service.class);
m.setAccessible(true);
m.invoke(action, service);
} catch (Exception e) {
e.printStackTrace();
}
return new ActionInvocation(action);
}