Camel as a web server or Camel as part of a web server?

2009-04-07 Thread huntc

Hey there,

Does anyone have thoughts on using a stand-alone Camel application as a web
server, or do people generally prefer packaging the Camel application in a
WAR file?

My use-case is that I have a web service provided by Camel and using the
jetty component. This works nicely. However I want to serve up some static
resources associated with the web service. The only way I have found to do
this is by creating a producer for every static resource to be provided
e.g.:

my web service:

jetty:http://0.0.0.0:9080/GPSTrackerCollectionService/GPSTrackerCollection/gpsTrackers/GPSTracker/history

one (of the many) associated resources:

jetty:http://0.0.0.0:9080/GPSTrackerCollectionService/GPSTrackerCollection/gpsTrackers/GPSTracker/styles.kml

Kind regards,
Christopher
-- 
View this message in context: 
http://www.nabble.com/Camel-as-a-web-server-or-Camel-as-part-of-a-web-server--tp22922660p22922660.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.



Re: Camel as a web server or Camel as part of a web server?

2009-04-07 Thread Willem Jiang
Hi,

I think it depends on your requirement.

If you have lots of static resource or you need to set the http server's
port and context path at the deployment time, packaging the Camel
application into a WAR is your best choice.

If your Camel application is under developing, or you just want to run
it from a simple Java Main, you may using a stand-alone Camel
application as a web server.

Willem

huntc wrote:
 Hey there,
 
 Does anyone have thoughts on using a stand-alone Camel application as a web
 server, or do people generally prefer packaging the Camel application in a
 WAR file?
 
 My use-case is that I have a web service provided by Camel and using the
 jetty component. This works nicely. However I want to serve up some static
 resources associated with the web service. The only way I have found to do
 this is by creating a producer for every static resource to be provided
 e.g.:
 
 my web service:
 
 jetty:http://0.0.0.0:9080/GPSTrackerCollectionService/GPSTrackerCollection/gpsTrackers/GPSTracker/history
 
 one (of the many) associated resources:
 
 jetty:http://0.0.0.0:9080/GPSTrackerCollectionService/GPSTrackerCollection/gpsTrackers/GPSTracker/styles.kml
 
 Kind regards,
 Christopher



Re: Camel as a web server or Camel as part of a web server?

2009-04-07 Thread Claus Ibsen
Just a side note. There should be a new option in Camel 2.0 -
matchOnUriPrefix that can allow you to match wildcard URIs.


On Tue, Apr 7, 2009 at 9:28 AM, Willem Jiang willem.ji...@gmail.com wrote:
 Hi,

 I think it depends on your requirement.

 If you have lots of static resource or you need to set the http server's
 port and context path at the deployment time, packaging the Camel
 application into a WAR is your best choice.

 If your Camel application is under developing, or you just want to run
 it from a simple Java Main, you may using a stand-alone Camel
 application as a web server.

 Willem

 huntc wrote:
 Hey there,

 Does anyone have thoughts on using a stand-alone Camel application as a web
 server, or do people generally prefer packaging the Camel application in a
 WAR file?

 My use-case is that I have a web service provided by Camel and using the
 jetty component. This works nicely. However I want to serve up some static
 resources associated with the web service. The only way I have found to do
 this is by creating a producer for every static resource to be provided
 e.g.:

 my web service:

 jetty:http://0.0.0.0:9080/GPSTrackerCollectionService/GPSTrackerCollection/gpsTrackers/GPSTracker/history

 one (of the many) associated resources:

 jetty:http://0.0.0.0:9080/GPSTrackerCollectionService/GPSTrackerCollection/gpsTrackers/GPSTracker/styles.kml

 Kind regards,
 Christopher





-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration


Re: Camel as a web server or Camel as part of a web server?

2009-04-07 Thread huntc

Great! Just what I was looking for!

Thanks to both of you.

On a side note for those who are interested in an example of serving up
static resources in 1.x:


from(
jetty:http://0.0.0.0:9080/images/plotdot9-ls.png;)
.to(direct:getPNG);
from(
jetty:http://0.0.0.0:9080/images/plotdot9.png;)
.to(direct:getPNG);

from(direct:getPNG).process(new Processor() {
  public void process(Exchange exchange) throws Exception {
HttpExchange httpExchange = (HttpExchange) exchange;
String uri = httpExchange.getRequest().getRequestURI();
int fileLocn = uri.lastIndexOf('/');
String filename = uri.substring(fileLocn);
exchange.getOut().setHeader(Content-Type, image/png);
exchange.getOut().setBody(
this.getClass().getResourceAsStream(
/images + filename));
  }
});



Claus Ibsen-2 wrote:
 
 Just a side note. There should be a new option in Camel 2.0 -
 matchOnUriPrefix that can allow you to match wildcard URIs.
 
 

-- 
View this message in context: 
http://www.nabble.com/Camel-as-a-web-server-or-Camel-as-part-of-a-web-server--tp22922660p22924385.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.