use of org.glassfish.embeddable.GlassFishProperties in project Payara by payara.
the class VerifierMain method main.
public static void main(String[] args) throws GlassFishException, IOException {
VerifierFrameworkContext verifierFrameworkContext = new Initializer(args).getVerificationContext();
// Since in gui mode, we don't get a chance to clean up, we need to install a shutdown hook
addShutdownHook();
gfr = GlassFishRuntime.bootstrap();
GlassFishProperties gfp = new GlassFishProperties();
gfp.setProperty(StartupContext.TIME_ZERO_NAME, (new Long(System.currentTimeMillis())).toString());
final String VERIFIER_MODULE = "org.glassfish.verifier";
gfp.setProperty(StartupContext.STARTUP_MODULE_NAME, VERIFIER_MODULE);
// gfp.setConfigFileURI("file:/tmp/domain.xml");
GlassFish gf = gfr.newGlassFish(gfp);
gf.start();
int failedCount = -1;
Verifier verifier = gf.getService(Verifier.class);
if (verifierFrameworkContext.isUsingGui()) {
MainFrame mf = new MainFrame(verifierFrameworkContext.getJarFileName(), true, verifier);
mf.setSize(800, 600);
mf.setVisible(true);
} else {
LocalStringManagerImpl smh = StringManagerHelper.getLocalStringsManager();
try {
verifier.init(verifierFrameworkContext);
verifier.verify();
} catch (Exception e) {
LogRecord logRecord = new LogRecord(Level.SEVERE, smh.getLocalString(verifier.getClass().getName() + // NOI18N
".verifyFailed", // NOI18N
"Could not verify successfully."));
logRecord.setThrown(e);
verifierFrameworkContext.getResultManager().log(logRecord);
}
verifier.generateReports();
failedCount = verifierFrameworkContext.getResultManager().getFailedCount() + verifierFrameworkContext.getResultManager().getErrorCount();
System.exit(failedCount);
}
}
use of org.glassfish.embeddable.GlassFishProperties in project Payara by payara.
the class MultipleSPETest method test.
@Test
public void test() throws Exception {
// 1. Bootstrap GlassFish DAS in embedded mode.
GlassFishProperties glassFishProperties = new GlassFishProperties();
glassFishProperties.setInstanceRoot(System.getenv("S1AS_HOME") + "/domains/domain1");
glassFishProperties.setConfigFileReadOnly(false);
GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish(glassFishProperties);
PrintStream sysout = System.out;
glassfish.start();
System.setOut(sysout);
// 2. Deploy the PaaS-bookstore application. Deployment should fail
File archive = new File(System.getProperty("basedir") + // TODO :: use mvn apis to get the
"/target/basic-spe-test.war");
// archive location.
Assert.assertTrue(archive.exists());
Deployer deployer = null;
String appName = null;
try {
deployer = glassfish.getDeployer();
appName = deployer.deploy(archive);
System.err.println("Deployed [" + appName + "]");
Assert.assertNull(appName);
} catch (Exception e) {
System.out.println("$$$$$$$$$$$$$$$$Exception$$$$$$");
} finally {
// 3. Register one of the plugins as the default S.P.E
ServiceLocator habitat = Globals.getDefaultHabitat();
org.glassfish.api.admin.CommandRunner commandRunner = habitat.getService(org.glassfish.api.admin.CommandRunner.class);
ActionReport report = habitat.getService(ActionReport.class);
org.glassfish.api.admin.CommandRunner.CommandInvocation invocation = commandRunner.getCommandInvocation("register-service-provisioning-engine", report);
ParameterMap parameterMap = new ParameterMap();
parameterMap.add("type", "Database");
parameterMap.add("defaultservice", "true");
parameterMap.add("DEFAULT", "org.glassfish.paas.mydbplugin.MyDBPlugin");
invocation.parameters(parameterMap).execute();
Assert.assertFalse(report.hasFailures());
System.out.println("Registered a default SPE :" + !report.hasFailures());
// 4. Deploy the application. Deployment should succeed.
appName = deployer.deploy(archive);
System.err.println("Deployed [" + appName + "]");
Assert.assertNotNull(appName);
// 5. Access the app to make sure PaaS-basic-shared-service-test app is correctly
// provisioned.
String HTTP_PORT = (System.getProperty("http.port") != null) ? System.getProperty("http.port") : "28080";
String instanceIP = getLBIPAddress(glassfish);
get("http://" + instanceIP + ":" + HTTP_PORT + "/basic-spe-test/list", "Here is a list of animals in the zoo.");
// Retrieve the port number used by the connection pool
invocation = commandRunner.getCommandInvocation("get", report);
parameterMap = new ParameterMap();
parameterMap.add("DEFAULT", "server.resources.jdbc-connection-pool.jdbc/__multiple_spe_paas_sample.property.PortNumber");
invocation.parameters(parameterMap).execute();
Assert.assertFalse(report.hasFailures());
if (appName != null) {
deployer.undeploy(appName);
System.err.println("Undeployed [" + appName + "]");
try {
boolean undeployClean = false;
CommandResult commandResult = glassfish.getCommandRunner().run("list-services");
if (commandResult.getOutput().contains("Nothing to list.")) {
undeployClean = true;
}
Assert.assertTrue(undeployClean);
} catch (Exception e) {
System.err.println("Couldn't varify whether undeploy succeeded");
}
}
commandRunner = habitat.getService(org.glassfish.api.admin.CommandRunner.class);
invocation = commandRunner.getCommandInvocation("unregister-service-provisioning-engine", report);
parameterMap = new ParameterMap();
parameterMap.add("DEFAULT", "org.glassfish.paas.mydbplugin.MyDBPlugin");
invocation.parameters(parameterMap).execute();
Assert.assertFalse(report.hasFailures());
System.out.println("Unregistered the default SPE :" + !report.hasFailures());
}
}
use of org.glassfish.embeddable.GlassFishProperties in project Payara by payara.
the class BasicPaaSServiceMetadataTest method bootstrap.
private GlassFish bootstrap() throws Exception {
GlassFishProperties glassFishProperties = new GlassFishProperties();
glassFishProperties.setInstanceRoot(System.getenv("S1AS_HOME") + "/domains/domain1");
glassFishProperties.setConfigFileReadOnly(false);
GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish(glassFishProperties);
PrintStream sysout = System.out;
glassfish.start();
System.setOut(sysout);
return glassfish;
}
use of org.glassfish.embeddable.GlassFishProperties in project solr-document-store by DBCDK.
the class Payara method getInstance.
static Payara getInstance(String port) throws GlassFishException {
if (glassfish == null) {
payaraPort = Integer.parseInt(port);
BootstrapProperties bootstrap = new BootstrapProperties();
GlassFishRuntime runtime = GlassFishRuntime.bootstrap(bootstrap);
GlassFishProperties glassfishProperties = new GlassFishProperties();
glassfishProperties.setPort("http-listener", payaraPort);
glassfish = runtime.newGlassFish(glassfishProperties);
glassfish.start();
runner = glassfish.getCommandRunner();
runner.setTerse(true);
}
return new Payara();
}
use of org.glassfish.embeddable.GlassFishProperties in project Payara by payara.
the class EJBContainerProviderImpl method createContainer.
private Locations createContainer(Map<?, ?> properties, Locations l) throws EJBException {
synchronized (lock) {
// if (container == null || !container.isOpen()) {
try {
if (runtime != null) {
// dispose of the old one
runtime.shutdown();
}
BootstrapProperties bootstrapProperties = new BootstrapProperties();
// Propagate non EJB embeddable container properties into GlassFishProperties
Properties newProps = new Properties();
if (properties != null) {
copyUserProperties(properties, newProps);
}
// Disable weaving if it is not spesified
if (newProps.getProperty(WEAVING) == null) {
newProps.setProperty(WEAVING, "false");
}
GlassFishProperties glassFishProperties = new GlassFishProperties(newProps);
if (Boolean.getBoolean(KEEP_TEMPORARY_FILES)) {
// set autodelete to false.
glassFishProperties.setProperty("org.glassfish.embeddable.autoDelete", "false");
// make sure the domain.xml is written back.
glassFishProperties.setConfigFileReadOnly(false);
}
if (l.installed_root != null && l.instance_root != null) {
// Real install
_logger.info("[EJBContainerProviderImpl] Using installation location " + l.installed_root.getCanonicalPath());
bootstrapProperties.setInstallRoot(l.installed_root.getCanonicalPath());
}
if (l.instance_root != null && l.reuse_instance_location) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("[EJBContainerProviderImpl] Reusing instance location at: " + l.instance_root);
}
_logger.info("[EJBContainerProviderImpl] Using instance location: " + l.instance_root.getCanonicalPath());
glassFishProperties.setInstanceRoot(l.instance_root.getCanonicalPath());
} else if (l.domain_file != null) {
_logger.info("[EJBContainerProviderImpl] Using config file location: " + l.domain_file.toURI().toString());
glassFishProperties.setConfigFileURI(l.domain_file.toURI().toString());
}
addWebContainerIfRequested(properties, glassFishProperties);
runtime = GlassFishRuntime.bootstrap(bootstrapProperties);
_logger.info("[EJBContainerProviderImpl] Using runtime class: " + runtime.getClass());
GlassFish server = runtime.newGlassFish(glassFishProperties);
if (l.instance_root != null && !l.reuse_instance_location) {
// XXX Start the server to get the services
server.start();
EmbeddedSecurity es = server.getService(EmbeddedSecurity.class);
ServiceLocator habitat = server.getService(ServiceLocator.class);
server.stop();
// If we are running from an existing install, copy over security files to the temp instance
if (es != null) {
es.copyConfigFiles(habitat, l.instance_root, l.domain_file);
}
}
// server is started in EJBContainerImpl constructor
container = new EJBContainerImpl(server);
validateInstanceDirectory();
archiveFactory = server.getService(ArchiveFactory.class);
Sniffer sniffer = server.getService(Sniffer.class, "Ejb");
ejbAnnotations = sniffer.getAnnotationTypes();
} catch (Exception e) {
try {
if (container != null) {
container.stop();
}
} catch (Exception e0) {
_logger.log(Level.SEVERE, e0.getMessage(), e0);
}
container = null;
throw new EJBException(e);
}
// }
}
return l;
}
Aggregations