Search in sources :

Example 1 with AppClientContainer

use of org.glassfish.appclient.client.acc.AppClientContainer in project Payara by payara.

the class AppClientFacade method createContainerForClassName.

private static AppClientContainer createContainerForClassName(final Builder builder, final String className) throws Exception, UserError {
    /*
         * Place "." on the class path so that when we convert the class file
         * path to a fully-qualified class name and try to load it, we'll find
         * it.
         */
    ClassLoader loader = prepareLoaderToFindClassFile(Thread.currentThread().getContextClassLoader());
    Thread.currentThread().setContextClassLoader(loader);
    Class mainClass = Class.forName(className, true, loader);
    AppClientContainer result = builder.newContainer(mainClass);
    return result;
}
Also used : AppClientContainer(org.glassfish.appclient.client.acc.AppClientContainer) URLClassLoader(java.net.URLClassLoader) ACCClassLoader(org.glassfish.appclient.client.acc.ACCClassLoader)

Example 2 with AppClientContainer

use of org.glassfish.appclient.client.acc.AppClientContainer in project Payara by payara.

the class AppClientFacade method prepareACC.

public static void prepareACC(String agentArgsText, Instrumentation inst) throws UserError, MalformedURLException, URISyntaxException, JAXBException, FileNotFoundException, ParserConfigurationException, SAXException, IOException, Exception {
    if (!JDK.isRunningLTSJDK()) {
        logger.warning("You are running the product on an unsupported JDK version and might see unexpected results or exceptions.");
    }
    /*
         * Analyze the agent argument string.
         */
    AgentArguments agentArgs = AgentArguments.newInstance(agentArgsText);
    /*
         * The agent arguments that correspond to the ones that we want to
         * pass to the ACC are the ones with the "arg=" keyword prefix.  These
         * will include arguments with meaning to the ACC (-textauth for example)
         * as well as arguments to be passed on to the client's main method.
         */
    appClientCommandArgs = AppclientCommandArguments.newInstance(agentArgs.namedValues("arg"));
    if (appClientCommandArgs.isUsage()) {
        usage(0);
    } else if (appClientCommandArgs.isHelp()) {
        help();
    }
    /*
         * Examine the agent arguments for settings about how to launch the
         * client.
         */
    launchInfo = CommandLaunchInfo.newInstance(agentArgs);
    if (launchInfo.getClientLaunchType() == ClientLaunchType.UNKNOWN) {
        usage(1);
    }
    /*
         * Handle the legacy env. variable APPCPATH.
         */
    ACCClassLoader loader = initClassLoader((inst == null));
    Thread.currentThread().setContextClassLoader(loader);
    isJWS = Boolean.getBoolean("appclient.is.jws");
    /*
         * The installRoot property will be set by the ServerEnvironment
         * initialization using the ACC start-up context.  That happens during
         * the ACCModulesManager warm-up.
         */
    /*
         * Load the ACC configuration XML file.
         */
    ClientContainer clientContainer = readConfig(appClientCommandArgs.getConfigFilePath(), loader);
    /*
         * Decide what target servers to use.  This combines any
         * specified on the command line with any in the config file's
         * target-server elements as well as any set in the properties
         * of the config file.
         */
    final TargetServer[] targetServers = TargetServerHelper.targetServers(clientContainer, appClientCommandArgs.getTargetServer());
    /*
         * Get the builder.  Doing so correctly involves merging
         * the configuration file data with some of the command line and
         * agent arguments.
         */
    final AppClientContainer.Builder builder = createBuilder(targetServers, clientContainer, appClientCommandArgs);
    /*
         * Create the ACC.  Again, precisely how we create it depends on some
         * of the command line arguments and agent arguments.
         */
    final AppClientContainer newACC = createContainer(builder, launchInfo, appClientCommandArgs);
    /*
         * Because the JMV might invoke the client's main class, the agent
         * needs to prepare the container.  (This is done as part of the
         * AppClientContainer.start() processing in the public API.
         */
    newACC.prepare(inst);
    acc = newACC;
}
Also used : Builder(org.glassfish.appclient.client.acc.AppClientContainer.Builder) ACCClassLoader(org.glassfish.appclient.client.acc.ACCClassLoader) ClientContainer(org.glassfish.appclient.client.acc.config.ClientContainer) AppClientContainer(org.glassfish.appclient.client.acc.AppClientContainer) AppClientContainer(org.glassfish.appclient.client.acc.AppClientContainer) AgentArguments(org.glassfish.appclient.client.acc.AgentArguments) TargetServer(org.glassfish.appclient.client.acc.config.TargetServer)

Example 3 with AppClientContainer

use of org.glassfish.appclient.client.acc.AppClientContainer in project Payara by payara.

the class AppClientFacade method createContainer.

private static AppClientContainer createContainer(final Builder builder, final CommandLaunchInfo launchInfo, final AppclientCommandArguments appClientArgs) throws Exception, UserError {
    /*
         * The launchInfo already knows something about how to conduct the
         * launch.
         */
    ClientLaunchType launchType = launchInfo.getClientLaunchType();
    AppClientContainer container;
    switch(launchType) {
        case JAR:
        case DIR:
            /*
                 * The client name in the launch info is a file path for the
                 * directory or JAR to launch.
                 */
            container = createContainerForAppClientArchiveOrDir(builder, launchInfo.getClientName(), appClientArgs.getMainclass(), appClientArgs.getName());
            break;
        case URL:
            container = createContainerForJWSLaunch(builder, launchInfo.getClientName(), appClientArgs.getMainclass(), appClientArgs.getName());
            break;
        case CLASS:
            container = createContainerForClassName(builder, launchInfo.getClientName());
            break;
        case CLASSFILE:
            container = createContainerForClassFile(builder, launchInfo.getClientName());
            break;
        default:
            container = null;
    }
    if (container == null) {
        throw new IllegalArgumentException("cannot choose app client launch type");
    }
    return container;
}
Also used : AppClientContainer(org.glassfish.appclient.client.acc.AppClientContainer) ClientLaunchType(org.glassfish.appclient.client.acc.CommandLaunchInfo.ClientLaunchType)

Aggregations

AppClientContainer (org.glassfish.appclient.client.acc.AppClientContainer)3 ACCClassLoader (org.glassfish.appclient.client.acc.ACCClassLoader)2 URLClassLoader (java.net.URLClassLoader)1 AgentArguments (org.glassfish.appclient.client.acc.AgentArguments)1 Builder (org.glassfish.appclient.client.acc.AppClientContainer.Builder)1 ClientLaunchType (org.glassfish.appclient.client.acc.CommandLaunchInfo.ClientLaunchType)1 ClientContainer (org.glassfish.appclient.client.acc.config.ClientContainer)1 TargetServer (org.glassfish.appclient.client.acc.config.TargetServer)1