[appengine-java] Re: Is there a recommended way to differentiate between production and dev GAE environments?

2009-12-21 Thread Jorge
I found this in the Programming GAE book by Dan Sanderson, O'Reilly,
2010:

An app can determine whether it is running on AppEngine or in the
development server from the servlet info string in the srvlet context,
returned by this.getServletContext()getServletInfo(). This string
starts with Google App Engine Development when running in the
development server...

Jorge Gonzalez


On Nov 28, 7:34 am, Guillaume Laforge glafo...@gmail.com wrote:
 Another approach I've just found is doing something like:

 ApiProxy.getCurrentEnvironment().getClass().getName().contains
 (LocalHttpRequestEnvironment)

 Not sure in the end what's the best approach of them all.

 On 24 nov, 16:29, Marcel Overdijk marceloverd...@gmail.com wrote:

  Or use a Listener as described 
  herehttp://marceloverdijk.blogspot.com/2009/10/determining-runtime-enviro...

  On 23 nov, 15:58, Nacho Coloma icol...@gmail.com wrote:

   To answer my own question, this has been my best shot this far:

   SecurityManager sm = System.getSecurityManager();
   localDevelopmentEnvironment = sm == null ||
   com.google.appengine.tools.development.DevAppServerFactory
   $CustomSecurityManager.equals(sm.getClass().getName());

   If anyone has a better way, I will be glad to hear.

   On Nov 23, 1:17 pm, Nacho Coloma icol...@gmail.com wrote:

Hi all,

I was considering options, but I first wanted to ask: is there a
recommended way to differentiate between my localdevelopment
environment and the realGAEserver? This far, the only options I can
think of are:

* adding a -Dtest=true to my eclipse launcher

* looking up for any test environment classes (Class.forName) but it's
not reliable as they could get included by mistake in any WAR release.

* I have been searching for instanceof alternatives i.e.:
DatastoreServiceFactory.getService() instanceof LocalDatastoreService
but I could not find any such expression that could possibly work.

Ideas? What are people using out there?

Nacho.

--

You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




Re: [appengine-java] Re: Is there a recommended way to differentiate between production and dev GAE environments?

2009-12-21 Thread Yasuo Higa
Hi all,

App Engine officially supports a way to differentiate
between production and development as follows:

String env = System.getProperty(com.google.appengine.runtime.environment);
if (Development.equals(env)) {
...
} else if (Production.equals(env)) {
...
}

See http://code.google.com/p/googleappengine/wiki/SdkForJavaReleaseNotes

Hope this helps,

Yasuo Higa

--

You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




[appengine-java] Re: Is there a recommended way to differentiate between production and dev GAE environments?

2009-11-28 Thread Guillaume Laforge
Another approach I've just found is doing something like:

ApiProxy.getCurrentEnvironment().getClass().getName().contains
(LocalHttpRequestEnvironment)

Not sure in the end what's the best approach of them all.

On 24 nov, 16:29, Marcel Overdijk marceloverd...@gmail.com wrote:
 Or use a Listener as described 
 herehttp://marceloverdijk.blogspot.com/2009/10/determining-runtime-enviro...

 On 23 nov, 15:58, Nacho Coloma icol...@gmail.com wrote:



  To answer my own question, this has been my best shot this far:

  SecurityManager sm = System.getSecurityManager();
  localDevelopmentEnvironment = sm == null ||
  com.google.appengine.tools.development.DevAppServerFactory
  $CustomSecurityManager.equals(sm.getClass().getName());

  If anyone has a better way, I will be glad to hear.

  On Nov 23, 1:17 pm, Nacho Coloma icol...@gmail.com wrote:

   Hi all,

   I was considering options, but I first wanted to ask: is there a
   recommended way to differentiate between my local development
   environment and the real GAE server? This far, the only options I can
   think of are:

   * adding a -Dtest=true to my eclipse launcher

   * looking up for any test environment classes (Class.forName) but it's
   not reliable as they could get included by mistake in any WAR release.

   * I have been searching for instanceof alternatives i.e.:
   DatastoreServiceFactory.getService() instanceof LocalDatastoreService
   but I could not find any such expression that could possibly work.

   Ideas? What are people using out there?

   Nacho.

--

You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




[appengine-java] Re: Is there a recommended way to differentiate between production and dev GAE environments?

2009-11-25 Thread Jorge
My approach is quite simpler. I keep a configuration file where  I
setup a different webBaseURL depending on the environment, development
VS production. One could a a boolean isProduction and make webBaseURL
a function of that. The thing to remember is to setup the config file
before uploading to GAE and then resetting it back to the development
config.

public class Config {

// True or false the UI actions (buttons) and the http servicce
requests
// are logged.
private static boolean isLogOn = true;

// Web base URL
/private static String webBaseURL = http://
wcondominios.appspot.com/;
private static String webBaseURL = http://localhost:8080/;;

/**
 * @return True or false the the UI actions (buttons) and the http
 * servicce requests are logged.
 */
public static boolean isLogOn() {return isLogOn;}

/**
 * @return The Web base URL
 */
public static String getWebBaseURL() {return webBaseURL;}

}

Jorge Gonzalez

On Nov 24, 8:11 pm, Rusty Wright rwright.li...@gmail.com wrote:
 The filesystem is read only on app engine; would trying to create a file, in 
 WEB-INF for example, work?  I'm wondering if there are corner cases I'm not 
 thinking of where that might fail and falsely report that you're on app 
 engine; for example, if you were doing integration tests under Hudson.

 Nacho Coloma wrote:
  Thanks! I searched a lot but didn't get to this thread.

  On Nov 23, 4:13 pm, leszek leszek.ptokar...@gmail.com wrote:
  Follow that thread:

 http://groups.google.co.uk/group/google-appengine-java/browse_frm/thr...

  --

  You received this message because you are subscribed to the Google Groups 
  Google App Engine for Java group.
  To post to this group, send email to google-appengine-j...@googlegroups.com.
  To unsubscribe from this group, send email to 
  google-appengine-java+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/google-appengine-java?hl=.

--

You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




[appengine-java] Re: Is there a recommended way to differentiate between production and dev GAE environments?

2009-11-24 Thread Marcel Overdijk
Or use a Listener as described here
http://marceloverdijk.blogspot.com/2009/10/determining-runtime-environment-on.html

On 23 nov, 15:58, Nacho Coloma icol...@gmail.com wrote:
 To answer my own question, this has been my best shot this far:

 SecurityManager sm = System.getSecurityManager();
 localDevelopmentEnvironment = sm == null ||
 com.google.appengine.tools.development.DevAppServerFactory
 $CustomSecurityManager.equals(sm.getClass().getName());

 If anyone has a better way, I will be glad to hear.

 On Nov 23, 1:17 pm, Nacho Coloma icol...@gmail.com wrote:



  Hi all,

  I was considering options, but I first wanted to ask: is there a
  recommended way to differentiate between my local development
  environment and the real GAE server? This far, the only options I can
  think of are:

  * adding a -Dtest=true to my eclipse launcher

  * looking up for any test environment classes (Class.forName) but it's
  not reliable as they could get included by mistake in any WAR release.

  * I have been searching for instanceof alternatives i.e.:
  DatastoreServiceFactory.getService() instanceof LocalDatastoreService
  but I could not find any such expression that could possibly work.

  Ideas? What are people using out there?

  Nacho.

--

You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




Re: [appengine-java] Re: Is there a recommended way to differentiate between production and dev GAE environments?

2009-11-24 Thread Rusty Wright
The filesystem is read only on app engine; would trying to create a file, in 
WEB-INF for example, work?  I'm wondering if there are corner cases I'm not 
thinking of where that might fail and falsely report that you're on app engine; 
for example, if you were doing integration tests under Hudson.


Nacho Coloma wrote:
 Thanks! I searched a lot but didn't get to this thread.
 
 On Nov 23, 4:13 pm, leszek leszek.ptokar...@gmail.com wrote:
 Follow that thread:

 http://groups.google.co.uk/group/google-appengine-java/browse_frm/thr...
 
 --
 
 You received this message because you are subscribed to the Google Groups 
 Google App Engine for Java group.
 To post to this group, send email to google-appengine-j...@googlegroups.com.
 To unsubscribe from this group, send email to 
 google-appengine-java+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/google-appengine-java?hl=.
 
 

--

You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




[appengine-java] Re: Is there a recommended way to differentiate between production and dev GAE environments?

2009-11-23 Thread leszek
Follow that thread:

http://groups.google.co.uk/group/google-appengine-java/browse_frm/thread/8145f547cbaff99e/453847dda0217e71?q=#453847dda0217e71

--

You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=.