Trying to experiment a bit with Embedded GF and I can get it to work but
it appears to never stop(I am running from with NB 6.5) so perhaps I am
missing something obvious that someone might see that i am missing.
Any thoughts on why this might not allow the app to stop in NB?
Also, did the JDBC work get completed and does anyone have an example?
thank you
-Lance
package demo;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.glassfish.embed.Application;
import org.glassfish.embed.EmbeddedException;
import org.glassfish.embed.Server;
/**
*
* @author Owner
*/
public class GFEmbeddedDemo {
private String warFilePath =
"C:\\Netbeans\\SimpleWebAppEmbeddedDemo\\dist\\SimpleWebAppEmbeddedDemo.war";
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
GFEmbeddedDemo demo = new GFEmbeddedDemo();
demo.runDemo(6689);
System.out.println("****Returned from runDemo method");
}
public void runDemo(int port) {
try {
Server myGF = new Server(port);
System.out.println("Deploying:" + warFilePath);
Application app = myGF.deploy(new File(warFilePath));
System.out.println("***App Deployed to Glassfish");
String webURL = "
http://localhost:" + port +
"/GFEmbeddedDemo/HelloEmbeddedGF";
//String webURL = "
http://localhost:" + port + "/"+
this.getClass().getName() + "/HelloEmbeddedGF";
System.out.println("Accessing:" + webURL);
URL url = new URL(webURL);
BufferedReader br = new BufferedReader(
new InputStreamReader(
url.openConnection().getInputStream()));
String result= br.readLine();
System.out.println("Read:" + result);
assert("Wow, I'm embedded!".equals( result));
br.close();
myGF.stop();
System.out.println("***after stop of Glassfish");
} catch (IOException io) {
Logger.getLogger(GFEmbeddedDemo.class.getName()).log(Level.SEVERE, null,
io);
} catch (EmbeddedException ex) {
Logger.getLogger(GFEmbeddedDemo.class.getName()).log(Level.SEVERE, null,
ex);
}
}
}