Search in sources :

Example 1 with RuntimeBuilder

use of org.glassfish.embeddable.spi.RuntimeBuilder in project Payara by payara.

the class GlassFishRuntime method _bootstrap.

private static synchronized GlassFishRuntime _bootstrap(BootstrapProperties bootstrapProperties, ClassLoader cl) throws GlassFishException {
    if (me != null) {
        throw new GlassFishException("Already bootstrapped", null);
    }
    RuntimeBuilder runtimeBuilder = getRuntimeBuilder(bootstrapProperties, cl != null ? cl : GlassFishRuntime.class.getClassLoader());
    me = runtimeBuilder.build(bootstrapProperties);
    return me;
}
Also used : RuntimeBuilder(org.glassfish.embeddable.spi.RuntimeBuilder)

Example 2 with RuntimeBuilder

use of org.glassfish.embeddable.spi.RuntimeBuilder in project Payara by payara.

the class GlassFishRuntime method getRuntimeBuilder.

private static RuntimeBuilder getRuntimeBuilder(BootstrapProperties bootstrapProperties, ClassLoader cl) throws GlassFishException {
    // StringBuilder sb = new StringBuilder("Launcher Class Loader = " + cl);
    // if (cl instanceof URLClassLoader) {
    // sb.append("has following Class Path: ");
    // for (URL url : URLClassLoader.class.cast(cl).getURLs()) {
    // sb.append(url).append(", ");
    // }
    // }
    // System.out.println(sb);
    Iterator<RuntimeBuilder> runtimeBuilders = ServiceLoader.load(RuntimeBuilder.class, cl).iterator();
    while (runtimeBuilders.hasNext()) {
        try {
            RuntimeBuilder builder = runtimeBuilders.next();
            logger.logp(Level.FINE, "GlassFishRuntime", "getRuntimeBuilder", "builder = {0}", new Object[] { builder });
            if (builder.handles(bootstrapProperties)) {
                return builder;
            }
        } catch (ServiceConfigurationError sce) {
            // Ignore the exception and move ahead to the next builder.
            logger.logp(Level.FINE, "GlassFishRuntime", "getRuntimeBuilder", "Ignoring", sce);
        } catch (NoClassDefFoundError ncdfe) {
            // On IBM JDK, we seem to be getting NoClassDefFoundError instead of ServiceConfigurationError
            // when OSgiRuntimeBuilder is not able to be loaded in non-OSGi mode because of absence of
            // OSGi classes in classpath. So, we need to catch it and ignore.
            logger.logp(Level.FINE, "GlassFishRuntime", "getRuntimeBuilder", "Ignoring", ncdfe);
        }
    }
    throw new GlassFishException("No runtime builder available for this configuration: " + bootstrapProperties.getProperties(), null);
}
Also used : ServiceConfigurationError(java.util.ServiceConfigurationError) RuntimeBuilder(org.glassfish.embeddable.spi.RuntimeBuilder)

Aggregations

RuntimeBuilder (org.glassfish.embeddable.spi.RuntimeBuilder)2 ServiceConfigurationError (java.util.ServiceConfigurationError)1