Search in sources :

Example 1 with Builder

use of org.glassfish.appclient.client.acc.AppClientContainer.Builder 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 2 with Builder

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

the class AppClientFacade method createBuilder.

private static Builder createBuilder(final TargetServer[] targetServers, final ClientContainer clientContainer, final AppclientCommandArguments appClientCommandArgs) throws IOException {
    Builder builder = AppClientContainer.newBuilder(targetServers);
    /*
         * Augment the builder with settings from the app client options that
         * can affect the builder itself.  (This is distinct from options
         * that affect what client to launch which are handled in creating
         * the ACC itself.
         */
    updateClientCredentials(builder, appClientCommandArgs);
    final List<MessageSecurityConfig> msc = clientContainer.getMessageSecurityConfig();
    if (msc != null) {
        builder.getMessageSecurityConfig().addAll(clientContainer.getMessageSecurityConfig());
    }
    builder.logger(new ACCLogger(clientContainer.getLogService()));
    final AuthRealm ar = clientContainer.getAuthRealm();
    if (ar != null) {
        builder.authRealm(ar.getClassname());
    }
    final List<Property> p = clientContainer.getProperty();
    if (p != null) {
        builder.containerProperties(p);
    }
    return builder;
}
Also used : AuthRealm(org.glassfish.appclient.client.acc.config.AuthRealm) Builder(org.glassfish.appclient.client.acc.AppClientContainer.Builder) MessageSecurityConfig(org.glassfish.appclient.client.acc.config.MessageSecurityConfig) ACCLogger(org.glassfish.appclient.client.acc.ACCLogger) Property(org.glassfish.appclient.client.acc.config.Property)

Aggregations

Builder (org.glassfish.appclient.client.acc.AppClientContainer.Builder)2 ACCClassLoader (org.glassfish.appclient.client.acc.ACCClassLoader)1 ACCLogger (org.glassfish.appclient.client.acc.ACCLogger)1 AgentArguments (org.glassfish.appclient.client.acc.AgentArguments)1 AppClientContainer (org.glassfish.appclient.client.acc.AppClientContainer)1 AuthRealm (org.glassfish.appclient.client.acc.config.AuthRealm)1 ClientContainer (org.glassfish.appclient.client.acc.config.ClientContainer)1 MessageSecurityConfig (org.glassfish.appclient.client.acc.config.MessageSecurityConfig)1 Property (org.glassfish.appclient.client.acc.config.Property)1 TargetServer (org.glassfish.appclient.client.acc.config.TargetServer)1