001 /*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License"). You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 * Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 * Copyright 2007-2008 Sun Microsystems, Inc.
026 */
027 package org.opends.server.tools.dsconfig;
028
029
030
031 import org.opends.server.admin.client.ManagementContext;
032 import org.opends.server.tools.ClientException;
033 import org.opends.server.util.args.ArgumentException;
034 import org.opends.server.util.args.SubCommandArgumentParser;
035 import org.opends.server.util.cli.CommandBuilder;
036 import org.opends.server.util.cli.ConsoleApplication;
037
038
039
040 /**
041 * A factory for retrieving the management context which should be
042 * used by the dsconfig application.
043 * <p>
044 * Factory implementations are responsible for registering their
045 * required global options during initialization.
046 */
047 public interface ManagementContextFactory {
048
049 /**
050 * Gets the management context which sub-commands should use in
051 * order to manage the directory server. Implementations can use the
052 * application instance for retrieving passwords interactively.
053 *
054 * @param app
055 * The application instance.
056 * @return Returns the management context which sub-commands should
057 * use in order to manage the directory server.
058 * @throws ArgumentException
059 * If a management context related argument could not be
060 * parsed successfully.
061 * @throws ClientException
062 * If the management context could not be created.
063 */
064 ManagementContext getManagementContext(ConsoleApplication app)
065 throws ArgumentException, ClientException;
066
067
068 /**
069 * Closes this management context.
070 */
071 void close();
072
073
074 /**
075 * Initializes this management context factory using the provided
076 * parser. The management context factory can register global
077 * options with the parser if required.
078 *
079 * @param parser
080 * The application sub-command argument parser.
081 * @throws ArgumentException
082 * If the factory failed to register its required global
083 * options.
084 */
085 void registerGlobalArguments(SubCommandArgumentParser parser)
086 throws ArgumentException;
087
088
089
090 /**
091 * Validates any global arguments passed to the application.
092 * Implementations of this method should check that the values
093 * passed to their global arguments are valid and are not
094 * incompatible with each other.
095 *
096 * @throws ArgumentException
097 * If the global arguments are invalid for some reason.
098 */
099 void validateGlobalArguments() throws ArgumentException;
100
101 /**
102 * Returns the command builder that provides the equivalent arguments in
103 * interactive mode to get the management context.
104 * @return the command builder that provides the equivalent arguments in
105 * interactive mode to get the management context.
106 */
107 CommandBuilder getContextCommandBuilder();
108 }