Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rest server on Android

 
Antonio Foglia
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to put a Rest Server on my Android device. Is it possible? I've checked other questions but i am a little bit confused. I wish to use Jersey framework to expose rest services for a client running on JBoss. Can anyone show me some documentatios or some good tutorial? I don't want the code but i'm new in android and i don't know where to start and which http server to use. Thank you
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jersey (and probably any JAX-RS implementation) needs a standards-compliant servlet container - I doubt such a beast exists for Android. There may be other REST libraries that have fewer requirements.

I would question the overall approach, though. It's just so much easier to get data from a device to a server than the other way around, and that's before considering that mobile networks don't route incoming TCP/IP traffic to a device. If this is only supposed to work on a company WLAN it might be a different matter.

As an alternative suggestion, how about having the server use GCM to notify the device if it needs some particular piece of data, and then the device can send that to the server?
 
Antonio Foglia
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes i have to work on a WLAN company. In a first moment i have to do some tests.
Working with GCM seems easier. I've read some complete guides.. my only question is if i really need to register my device to google.

Thank you! Any seggestion is welcome. I'm looking also for other communication method between a java component and android. The only problem is that the device needs to offer information periodically.. and rest service seemed to me a good solutions cause i wish to do polling on the device that expose data i nedd
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you implement GCM, your app would register the device with Google, but that's an anonymous process - it's the device ID being registered, not the account that you're using.

Android is not made for acting as a server, that's just not the nature of mobile devices. But GCM notifications are delivered extremely fast (sub-second), so if your app responds to those quickly, the elapsed turnaround time can be very small.
 
Antonio Foglia
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
yes, GCM seems more suitable and lightweight for my application
i can use GCM to notify the device that i need its position, and then i want to start the alarm manager to send periodically this information
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another option is something like MQTT, a light weight messaging protocol (look at mosquitto.org for an implementation). It is another bit of infrastructure (a broker both the computer and mobile device talk to) but you install and run the broker yourself, so your data doesn't go through 'the cloud'. It also allows two way communication (computer posts a message requesting info, then starts listening on a topic to receive it, mobile listens for the request and posts info on another topic) and is cross-platform - there is a Java client (Eclipse Paho) which works well on Android, there are C (which works with iOS) and Python clients as well.
 
Antonio Foglia
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:Another option is something like MQTT, a light weight messaging protocol (look at mosquitto.org for an implementation). It is another bit of infrastructure (a broker both the computer and mobile device talk to) but you install and run the broker yourself, so your data doesn't go through 'the cloud'. It also allows two way communication (computer posts a message requesting info, then starts listening on a topic to receive it, mobile listens for the request and posts info on another topic) and is cross-platform - there is a Java client (Eclipse Paho) which works well on Android, there are C (which works with iOS) and Python clients as well.


Thanks
I'm reading the specification, is a publish/subscribe model right? So if i got more than one device registered as subcriber they all receive the same message?
Is it compatible with JBOSS?
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is correct. I see no reason why you couldn't use it with JBoss, the Java client is rather simple, with no pre-reqs that are standard Java. A quick google brought up JBoss Fuse which appears to have an MQTT layer, but I am not exactly sure what Fuse actually is. But it does indicate they are compatible I think. I think you would be using a separate broker.
 
Antonio Foglia
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:Yes, that is correct. I see no reason why you couldn't use it with JBoss, the Java client is rather simple, with no pre-reqs that are standard Java. A quick google brought up JBoss Fuse which appears to have an MQTT layer, but I am not exactly sure what Fuse actually is. But it does indicate they are compatible I think. I think you would be using a separate broker.

Thanks again.
But now 'm not sure if it's model it's good for my application, cause i want to choose which device to forward the mesage. I don't want to push the message to all subscribed devices.
However i'll read all the documentation.
And if it can be interesting i've found another framework that can be useful for this scenario: openmobster (Open source Mbaas), "This Provides a mobile platform-independent Cloud-initiated Push Notification System.( In Android, the push mechanism is based an a persistent socket connection)"
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic