Cling - @UpnpAction with Custom Action X.Y

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Cling - @UpnpAction with Custom Action X.Y

iank
Hello All - I am trying to create a MediaRenderer using the examples and documentation. I am a new cling user, so am trying to get to grips with some obvious stuff (sorry in advance on this)...

One task I need to do is create a custom UpnpAction that follows the allowed naming convention [Extract from uPnP DeviceArchitecture 1.1]
<action>
<name>
REQUIRED. Name of action. MUST NOT contain a hyphen character (“-”, 2D Hex in UTF-8) nor a hash character (“#”, 23 Hex in UTF-8). Case sensitive. First character MUST be a USASCII letter (“A”-“Z”, “a”-“z”), USASCII digit (“0”-“9”), an underscore (“_”), or a non-experimental Unicode letter or digit greater than U+007F. Succeeding characters MUST be a USASCII letter (“A”-“Z”, “a”-“z”), USASCII digit (“0”-“9”), an underscore (“_”), a period (“.”), a Unicode combiningchar, an extender, or a non-experimental Unicode letter or digit greater than U+007F. The first three letters MUST NOT be “XML” in any combination of case.

[See page 51 http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf]

So, I need to create a UpnpAction as

public void My.Action(.....

When I try to do this, I get an illegal name (As shown in Eclipse editor) as the '.' is interpreted.

I have tried to escape the '.' using \.

Am I missing something or can some one recommend a way forward ?

Many Thanks
Ian
Reply | Threaded
Open this post in threaded view
|

Re: Cling - @UpnpAction with Custom Action X.Y

bergstr
uh, the UPnP spec has nothing to say about Java, and therefore has no requirements with regard to the name of the Java class that implements the action. The name UPnP cares for is given in the string constructor parameter, like in

action = new GrmblPfmpf("My.Action");
Reply | Threaded
Open this post in threaded view
|

Re: Cling - @UpnpAction with Custom Action X.Y

iank
In reply to this post by iank
Thanks.

My understanding of this is that in the server class that I am creating, the @ annotations are used by Cling to create the Action and State Variables.

I want to create an Action that is exposed in upnp as "mydomain.com_Action" or similar using the standard template - e.g from BinaryLight:

BEFORE
@UpnpAction    
public void setTarget(@UpnpInputArgument(name = "NewTargetValue")                          boolean newTargetValue) {        target = newTargetValue;        status = newTargetValue;        System.out.println("Switch is: " + status);    }

AFTER
@UpnpAction    
public void mydomain.com_setTarget(@UpnpInputArgument(name = "NewTargetValue")                          boolean newTargetValue) {        target = newTargetValue;        status = newTargetValue;        System.out.println("Switch is: " + status);    }

Am I just being silly and miss understanding how to declare the uPnP Action such that Cling can expose mydomain.com_setTarget ?

Thanks again.

Ian
Reply | Threaded
Open this post in threaded view
|

Re: Cling - @UpnpAction with Custom Action X.Y

bergstr
well, I cannot get into too much details here as I have never used the annotations myself. What I can say from a generic UPnP standpoint is that a an action is always defined on a service. There is a UpnpService annotation, so I assume that has to be tacked onto the containing class with a serviceId attribute. Cling will most likely generate everything else correctly for you, so you will not have to create names with dot notation. I.e., if you have a class marked with @UpnpService(serviceId="My"), and a method therein named doit, marked as @UpnpAction, Cling will publish this as "My.doit". Just speculating, however.
Reply | Threaded
Open this post in threaded view
|

Re: Cling - @UpnpAction with Custom Action X.Y

iank
In reply to this post by iank
I think I have stumbled upon the solution and it is so painfully obvious, it hurts...

You simply use the following notation:-

@UpnpAction(name ="MyAction.COM_Action1")
public void MyAction {.....}

The clue I needed was from the following WebSite :- http://code.google.com/p/cyberlink4java2/

Will continue down this path - Thank you all and Thank you for 'Cling'

Reply | Threaded
Open this post in threaded view
|

Re: Cling - @UpnpAction with Custom Action X.Y

Christian Bauer
Administrator
So, the actual Cling manual was just me wasting time? At least the cyberlink guy seems to have read and copied it.
Reply | Threaded
Open this post in threaded view
|

Re: Cling - @UpnpAction with Custom Action X.Y

iank
No - The manual is very detailed and very useful when you know what to look for.  But I do struggling in finding stuff using the Web Browser - Index and class Identification is great.

I am not sure if I am the only one struggling to find stuff - but I did look for it - for over 1 day. I was using the API documentation and I did not find a way to search it. Is the idea that we download the full source repro and then do a linux find or grep ? Is there an obvious way of finding things ? Please do advise as I think I may not be the only one who struggles in finding stuff.

Good to discuss this to help others who may struggle - So if there is a way to drive the Manual - please lets have a sticky post.
Reply | Threaded
Open this post in threaded view
|

Re: Cling - @UpnpAction with Custom Action X.Y

Christian Bauer
Administrator
Here are some guidelines:

1. Read the first chapter (which answers your original question...)

2. Read the next chapter.

3. Continue at step 1.
Reply | Threaded
Open this post in threaded view
|

Re: Cling - @UpnpAction with Custom Action X.Y

iank
Fair Point - and now understanding what I was looking for, its seem obvious - but it didn't at the time.

Still - thats the beauty of learning something new...

Thanks
Ian
Reply | Threaded
Open this post in threaded view
|

Re: Cling - @UpnpAction with Custom Action X.Y

lightglitch
The tests source code are always a good place to find working examples.

Mário Franco
lightglitch a.k.a Mário Franco