There is any way to get by code the application name on Java GAE?
I need to configure some objects according with my application instance (production or development), and I want to build a automatic way.
String ID = SystemProperty.applicationId.get();
You can find more details at the following URL
https://developers.google.com/appengine/docs/java/#Java_The_environment
Try using App Identity
Calling:
String serviceAccountName = AppIdentityServiceFactory.getAppIdentityService().getServiceAccountName();
The serviceAccountName will be set as <app name>#appspot.gserviceaccount.com
This gives you the app id:
ApiProxy.getCurrentEnvironment().getAppId()
https://cloud.google.com/appengine/docs/java/appidentity/?csw=1#Java_Identifying_itself
Related
I think the header explains it all: Is there a nice way to create and load offline snapshots of database schema using SchemaCrawler without using command line? If yes, can you provide some example code / link please? If not, some example java code to use command line options would be helpful too (I don't have much experience with that)!
Thanks for any kind of help!
PS: I managed to create offline snapshot with this code:
final SchemaCrawlerOptions options = new SchemaCrawlerOptions();
// Set what details are required in the schema - this affects the
// time taken to crawl the schema
options.setSchemaInfoLevel(SchemaInfoLevelBuilder.standard());
options.setRoutineInclusionRule(new ExcludeAll());
options.setSchemaInclusionRule(new RegularExpressionInclusionRule(/* some regex here*/));
options.setTableInclusionRule(new RegularExpressionExclusionRule(/*some regex here*/));
outputOptions.setCompressedOutputFile(Paths.get("./test_db_snapshot.xml"));
final String command = "serialize";
final Executable executable = new SchemaCrawlerExecutable(command);
executable.setSchemaCrawlerOptions(options);
executable.setOutputOptions(outputOptions);
executable.execute(getConnection());
Not sure how to connect to it though.
You need to use the schemacrawler.tools.offline.OfflineSnapshotExecutable along with an schemacrawler.tools.offline.jdbc.OfflineConnection to "connect" to your database snapshoot.
Please take a look at the following code:
OfflineSnapshotTest.offlineSnapshotExecutable()
And #ZidaneT, to load an offline snapshot, use code like that in LoadSnapshotTest.java
Sualeh Fatehi, SchemaCrawler
I am launching a JNLP java application from a native client app (i.e. not a browser). When the JNLP finishes it's task, I need it to return a string to the calling app? How can I do this? Is it possible to return a value to a calling app - or do I need to have the calling app listen on a port and have the JNLP app write the value to that port through sockets?
Answering my own question!
I write to stdout from the child process (the JNLP)
The parent launches the child process
Process::Start
Read stdout from Parent
string ret = process.StandardOutput.ReadToEnd();
Process::WaitForExit();
Anyone sees any problem in this?
I like your idea to use sockets and think this is could be an easy solution.
It is not possible to get return values from a WebStart-application. Just see the help message from
javaws --help
There is no return-code available. (Sorry)
Have you thougth on a temporary file instead of the sockets?
It's a bit old but as fas as i know this is the exiting options to intercommunicate two process link.
I think the easiest way to solve your problem is use rmi, or jmx if you can, or just a simple socket
If the all-permissions element is specified, you could try to set an environment variable which you can read from your C# application.
Set environment variable in Java:
System.getenv().put("returnValue", "yourValue");
Read environment variable in C#:
ProcessStartInfo p = new ProcessStartInfo("start ....");
....
string returnValue = p.EnvironmentVariables["returnValue"];
I am trying to create an entire project on Testlink using the br.eti.kinoshita.testlinkjavaapi library.
The only thing I didn't manage to do is to create a new Platform.
I tried:
`api=new TestLinkAPI(new URL("http://"localhost/testlink/lib/api/xmlrpc/v1/xmlrpc.php),devKey);
//where devKey was taken from my testlink environment
Platform platform=new Platform(1,platformName,platformDescription);
api.addPlatformToTestPlan(projectId, testPlanId, platformName);
//projectId and testPlanId are directly taken from testlink and are both integer
//platformDescription is a String which looks like "a simple description"
// the "1" corresponds to the ID I want to give to my platform (I put 1 because none ID is already present on my project)
`
But this code is not efficient, and I get the error:
platformName does not exists.
I think the problem is that I have to first add the platform to the project but I can't find any method to do that...
Do you have any idea?
How can we load logback.xml via jvm argument if this is not present in project classpath?
I'm using
-Dlogback.configuration=file:C:\logbacs\logback.xml
but this is not working.
I found the solution
-Dlogging.config="C:\logbacs\logback.xml"
is working fine for me.
Updated because the previous answer was obsolete
If you're not using SpringBoot the above won't work.
I'm using the ch.qos.logback.logback-classic library, and in this case the solution is
-Dlogback.configurationFile=file:/app/logback.xml
I've found this property in ch.qos.logback.classic.util.ContextInitializer:
final public static String CONFIG_FILE_PROPERTY = "logback.configurationFile"
The original answer to this question doesn't appear to be working anymore as it produces this warning instead:
o.s.b.l.logback.LogbackLoggingSystem : Ignoring 'logback.configurationFile' system property. Please use 'logging.config' instead.
Therefore, you would want to use something like this:
-Dlogging.config="C:\logbacs\logback.xml"
For me it works only with this property:
-Dconfig.dir= "YOUR PATH TO CONFIG FILE"
As per https://logback.qos.ch/manual/configuration.html, use -Dlogback.configurationFile
java -Dlogback.configurationFile=/path/to/config.xml chapters.configuration.MyApp1
I have researched this quite heavily but have been unable to find a solution. I have created the simplest unit test to fetch a single entity but am still receiving the "Unable to find converter" exception. I have included the org.restlet.ext.servlet.jar,org.json.jar and org.restlet.ext.net.jar in my class path. I am also able to see the json returned and have been able to print using the cr.get(MediaType.APPLICATION_JSON) method.
ClientResource cr = new ClientResource("http://localhost:8888/r/establishment/29");
Establishment est = cr.get(Establishment.class);
System.out.println("Establishment name is " + est.getName());
I am using restlet-gae-2.1rc6 on GAE vs 1.7.1
You need to register a converter. Example:
Engine.getInstance().getRegisteredConverters().add(new JacksonConverter());
See a question with the same solution but a different problem: Android to gae restlet example doesn't work on the Android side
I found the solution here: https://stackoverflow.com/a/5205993/435605