/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.axis.client ;
import org.apache.axis.AxisFault;
import org.apache.axis.EngineConfiguration;
import org.apache.axis.components.logger.LogFactory;
import org.apache.axis.deployment.wsdd.WSDDConstants;
import org.apache.axis.message.SOAPBodyElement;
import org.apache.axis.utils.Messages;
import org.apache.axis.utils.Options;
import org.apache.axis.utils.StringUtils;
import org.apache.commons.logging.Log;
import javax.xml.rpc.ServiceException;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import java.util.Vector;
/**
* An admin client object that can be used both from the command line
* and programmatically.
*
* @author Rob Jellinghaus (robj@unrealities.com)
* @author Doug Davis (dug@us.ibm.com)
* @author Simeon Simeonov (simeons@macromedia.com)
*/
public class AdminClient
{
protected static Log log =
LogFactory.getLog(AdminClient.class.getName());
private static ThreadLocal defaultConfiguration = new ThreadLocal();
/**
* If the user calls this with an EngineConfiguration object, all
* AdminClients on this thread will use that EngineConfiguration
* rather than the default one. This is primarily to enable the
* deployment of custom transports and handlers.
*
* @param config the EngineConfiguration which should be used
*/
public static void setDefaultConfiguration(EngineConfiguration config)
{
defaultConfiguration.set(config);
}
private static String getUsageInfo()
{
String lSep = System.getProperty("line.separator");
StringBuffer msg = new StringBuffer();
// 26 is the # of lines in resources.properties
msg.append(Messages.getMessage("acUsage00")).append(lSep);
msg.append(Messages.getMessage("acUsage01")).append(lSep);
msg.append(Messages.getMessage("acUsage02")).append(lSep);
msg.append(Messages.getMessage("acUsage03")).append(lSep);
msg.append(Messages.getMessage("acUsage04")).append(lSep);
msg.append(Messages.getMessage("acUsage05")).append(lSep);
msg.append(Messages.getMessage("acUsage06")).append(lSep);
msg.append(Messages.getMessage("acUsage07")).append(lSep);
msg.append(Messages.getMessage("acUsage08")).append(lSep);
msg.append(Messages.getMessage("acUsage09")).append(lSep);
msg.append(Messages.getMessage("acUsage10")).append(lSep);
msg.append(Messages.getMessage("acUsage11")).append(lSep);
msg.append(Messages.getMessage("acUsage12")).append(lSep);
msg.append(Messages.getMessage("acUsage13")).append(lSep);
msg.append(Messages.getMessage("acUsage14")).append(lSep);
msg.append(Messages.getMessage("acUsage15")).append(lSep);
msg.append(Messages.getMessage("acUsage16")).append(lSep);
msg.append(Messages.getMessage("acUsage17")).append(lSep);
msg.append(Messages.getMessage("acUsage18")).append(lSep);
msg.append(Messages.getMessage("acUsage19")).append(lSep);
msg.append(Messages.getMessage("acUsage20")).append(lSep);
msg.append(Messages.getMessage("acUsage21")).append(lSep);
msg.append(Messages.getMessage("acUsage22")).append(lSep);
msg.append(Messages.getMessage("acUsage23")).append(lSep);
msg.append(Messages.getMessage("acUsage24")).append(lSep);
msg.append(Messages.getMessage("acUsage25")).append(lSep);
msg.append(Messages.getMessage("acUsage26")).append(lSep);
return msg.toString();
}
/**
* the object that represents our call
*/
protected Call call;
/**
* Construct an admin client w/o a logger.
* If the client cannot create a call object, then it does not throw an exception.
* Instead it prints a message to {@link System.err}.
* This is for 'historical reasons'
*/
public AdminClient()
{
try {
initAdminClient();
} catch (ServiceException e) {
System.err.println(Messages.getMessage("couldntCall00") + ": " + e);
call = null;
}
}
/**
* this is a somwhat contrived variant constructor, one that throws an exception
* if things go wrong.
* @param ignored
*/
public AdminClient(boolean ignored) throws ServiceException {
initAdminClient();
}
/**
* core initialisation routine
*
* @throws ServiceException
*/
private void initAdminClient() throws ServiceException {
// Initialize our Service - allow the user to override the
// default configuration with a thread-local version (see
// setDefaultConfiguration() above)
EngineConfiguration config =
(EngineConfiguration) defaultConfiguration.get();
Service service;
if (config != null) {
service = new Service(config);
} else {
service = new Service();
}
call = (Call) service.createCall();
}
/**
* External access to our Call
Call object this instance uses
*/
public Call getCall()
{
return call;
}
/**
* process the options then run a list call
* @param opts
* @return
* @throws Exception
*/
public String list(Options opts) throws Exception {
processOpts( opts );
return list();
}
/**
* send a list command
* @return the response from the call
* @throws Exception
*/
public String list() throws Exception {
log.debug( Messages.getMessage("doList00") );
String str = "
Processes a set of administration commands.
*The following commands are available:
*-lurl
sets the AxisServlet URL-hhostName
sets the AxisServlet host-pportNumber
sets the AxisServlet port-sservletPath
sets the path to the
* AxisServlet-ffileName
specifies that a simple file
* protocol should be used-uusername
sets the username-wpassword
sets the password-d
sets the debug flag (for instance, -ddd would
* set it to 3)-tname
sets the transport chain touselist
will list the currently deployed servicesquit
will quit (???)passwd value
changes the admin passwordxmlConfigFile
deploys or undeploys
* Axis components and web servicesIf -l
or -h -p -s
are not set, the
* AdminClient will invoke
* http://localhost:8080/axis/servlet/AxisServlet
.
AdminClient
and
* invokes process(args)
.
* Diagnostic output goes to log.info
.