Search in sources :

Example 1 with AgentArguments

use of org.glassfish.appclient.client.acc.AgentArguments 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 {
    int minor = JDK.getMinor();
    int major = JDK.getMajor();
    if (major < 9) {
        if (minor < 6) {
            throw new UserError(localStrings.getLocalString(stringsAnchor, "main.badVersion", "Current Java version {0} is too low; {1} or later required", new Object[] { System.getProperty("java.version"), "1.6" }));
        }
    }
    /*
         * 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) UserError(org.glassfish.appclient.client.acc.UserError) 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)

Aggregations

ACCClassLoader (org.glassfish.appclient.client.acc.ACCClassLoader)1 AgentArguments (org.glassfish.appclient.client.acc.AgentArguments)1 AppClientContainer (org.glassfish.appclient.client.acc.AppClientContainer)1 Builder (org.glassfish.appclient.client.acc.AppClientContainer.Builder)1 UserError (org.glassfish.appclient.client.acc.UserError)1 ClientContainer (org.glassfish.appclient.client.acc.config.ClientContainer)1 TargetServer (org.glassfish.appclient.client.acc.config.TargetServer)1