|
Glassfish example source code file (AppClientCommand.java)
The Glassfish AppClientCommand.java source code/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development * and Distribution License("CDDL") (collectively, the "License"). You * may not use this file except in compliance with the License. You can * obtain a copy of the License at * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html * or packager/legal/LICENSE.txt. See the License for the specific * language governing permissions and limitations under the License. * * When distributing the software, include this License Header Notice in each * file and include the License file at packager/legal/LICENSE.txt. * * GPL Classpath Exception: * Oracle designates this particular file as subject to the "Classpath" * exception as provided by Oracle in the GPL Version 2 section of the License * file that accompanied this code. * * Modifications: * If applicable, add the following below the License Header, with the fields * enclosed by brackets [] replaced by your own identifying information: * "Portions Copyright [year] [name of copyright owner]" * * Contributor(s): * If you wish your version of this file to be governed by only the CDDL or * only the GPL Version 2, indicate your decision by adding "[Contributor] * elects to include this software in this distribution under the [CDDL or GPL * Version 2] license." If you don't indicate a single choice of license, a * recipient has the option to distribute your version of this file under * either the CDDL, the GPL Version 2 or to extend the choice of license to * its licensees as provided above. However, if you add GPL Version 2 code * and therefore, elected the GPL Version 2 license, then the option applies * only if the new code is made subject to such option by the copyright * holder. */ package org.glassfish.appclient.client.acc; import com.sun.enterprise.glassfish.bootstrap.ProxyModule; import com.sun.enterprise.module.Module; import com.sun.enterprise.module.ModuleDefinition; import com.sun.enterprise.module.ModuleMetadata; import com.sun.enterprise.module.ModulesRegistry; import com.sun.enterprise.module.ResolveError; import com.sun.enterprise.module.bootstrap.BootException; import com.sun.enterprise.module.bootstrap.Main; import com.sun.enterprise.module.bootstrap.StartupContext; import com.sun.enterprise.module.impl.HK2Factory; import com.sun.enterprise.module.impl.ModulesRegistryImpl; import com.sun.enterprise.util.LocalStringManager; import com.sun.enterprise.util.LocalStringManagerImpl; import com.sun.hk2.component.ExistingSingletonInhabitant; import com.sun.hk2.component.Holder; import com.sun.hk2.component.InhabitantsParser; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Properties; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; import java.util.logging.Logger; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import org.glassfish.appclient.client.acc.config.ClientContainer; import org.glassfish.appclient.client.acc.config.Property; import org.glassfish.appclient.client.acc.config.Security; import org.glassfish.appclient.client.acc.config.TargetServer; import org.glassfish.enterprise.iiop.api.IIOPConstants; import org.jvnet.hk2.component.Habitat; /** * Implements the appclient command. * * @author tjquinn */ public class AppClientCommand { /** * Command-line option definitions */ private static final String CLIENT = "-client"; private static final String NAME = "-name"; private static final String MAIN_CLASS = "-mainclass"; private static final String TEXT_AUTH = "-textauth"; private static final String XML_PATH = "-xml"; private static final String ACC_CONFIG_XML = "-configxml"; private static final String DEFAULT_CLIENT_CONTAINER_XML = "sun-acc.xml"; // duplicated in com.sun.enterprise.jauth.ConfigXMLParser private static final String SUNACC_XML_URL = "sun-acc.xml.url"; private static final String NO_APP_INVOKE = "-noappinvoke"; //Added for allow user to pass user name and password through command line. private static final String USER = "-user"; private static final String PASSWORD = "-password"; private static final String PASSWORD_FILE = "-passwordfile"; private static final String DASH = "-"; private static final String TARGETSERVER = "-targetserver"; private static final String lineSep = System.getProperty("line.separator"); // XXX Replace with reference to v3 equiv of S1ASCtxFactory.IIOP_ENDPOINTS_PROPERTY private static final String IIOP_ENDPOINTS_PROPERTY = "com.sun.appserv.iiop.endpoints"; private static LocalStringManager localStrings = new LocalStringManagerImpl(AppClientCommand.class);; private static final Logger _logger = Logger.getLogger(AppClientCommand.class.getName()); protected final String[] args; protected String clientJarOrDirOrClassFile = null; protected String displayName = null; protected String mainClass = null; protected String xmlPath = null; protected String accConfigXml = DEFAULT_CLIENT_CONTAINER_XML; protected String jwsACCConfigXml = null; protected String[] appArgs; protected String classFileFromCommandLine = null; protected boolean useTextAuth = false; protected boolean runClient = true; protected String username = null; protected char[] password = null; protected String servers = null; private ClientContainer clientContainerFromConfigFile = null; /** loaded Class if user specified a .class file as the -client value */ private Class clientClass = null; /** * Main method for the command. * * @param args the command line arguments */ public static void main(String[] args) { try { new AppClientCommand(args).run(); } catch (UserError ue) { ue.displayAndExit(); } catch (Throwable t) { t.printStackTrace(); System.exit(1); } } private AppClientCommand(String[] args) throws BootException, URISyntaxException { this.args = args; } private void run() throws UserError, FileNotFoundException, JAXBException { /* *Handle any command line arguments intended for the ACC (as opposed to *the client itself) and save the returned args intended for the client. */ // String[] appArgs = processCommandLine(args); clientContainerFromConfigFile = processConfigFile(); /* * Choose the target servers to use in preparing the config. */ final TargetServer[] targetServers = TargetServerHelper.targetServers( clientContainerFromConfigFile, servers); /* * Use the appropriate constructor based on how the user has indicated * the client to be run. */ /* * See if the user specified a .class file as the -client. */ AppClientContainer.Builder builder; if (isClientValueClassFile()) { // builder = configureForClassFile(targetServers, clientJarOrDirOrClassFile); } else { // builder = configureFor } } private boolean isClientValueClassFile() { return clientJarOrDirOrClassFile.endsWith(".class"); } // private AppClientContainer.Builder configureForClassFile( // final TargetServer[] targetServers, // final String classFileName) throws UserError { // /* // * Try to load the class. // */ // final String className = clientJarOrDirOrClassFile.substring( // 0, clientJarOrDirOrClassFile.lastIndexOf(".class") + 1); // Class clientClass; // try { // clientClass = getClass().forName(className); // } catch (ClassNotFoundException ex) { // File classFile = new File(clientJarOrDirOrClassFile); // throw new UserError(localStrings.getLocalString( // getClass(), // "appclient.cannotFindClassFile", // "Because -client did not appear, tried to use {0} as a class name but could not find {1}", // new Object[] {className, classFile.getAbsolutePath()})); // } // AppClientContainer.Builder config = AppClientContainer.newBuilder( // targetServers); // // return config; // } /** *Processes any command-line arguments, setting up static variables for use *later in the processing. *<p> *As side-effects, these variables may be assigned values: *<ul> *<le>clientJarOrDirOrClassFile *<le>displayName *<le>mainClass *<le>xmlPath *<le>accConfigXml *<le>guiAuth *<le>runClient *<le>classFileFromCommandLine *<le>servers *</ul> *@param args the command-line arguments passed to the ACC *@return arguments to be passed to the actual client (with ACC arguments removed) */ private String[] processCommandLine(String[] args) throws UserError { List<String> clientArgs = new ArrayList Other Glassfish examples (source code examples)Here is a short list of links related to this Glassfish AppClientCommand.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.