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 management context factory which uses a pre-defined management
042 * context.
043 */
044 public final class InternalManagementContextFactory implements
045 ManagementContextFactory {
046
047 // The pre-defined management context.
048 private final ManagementContext context;
049
050
051
052 /**
053 * Creates a new internal management context factory using the
054 * provided management context.
055 *
056 * @param context
057 * The management context.
058 */
059 public InternalManagementContextFactory(ManagementContext context) {
060 this.context = context;
061 }
062
063 /**
064 * {@inheritDoc}
065 */
066 public void close()
067 {
068 // No implementation required.
069 // We let the user of this InternalManagementContextFactory close
070 // his/her context.
071 }
072
073 /**
074 * {@inheritDoc}
075 */
076 public ManagementContext getManagementContext(ConsoleApplication app)
077 throws ArgumentException, ClientException {
078 return context;
079 }
080
081
082
083 /**
084 * {@inheritDoc}
085 */
086 public void registerGlobalArguments(SubCommandArgumentParser parser)
087 throws ArgumentException {
088 // No implementation required.
089 }
090
091
092
093 /**
094 * {@inheritDoc}
095 */
096 public void validateGlobalArguments() throws ArgumentException {
097 // No implementation required.
098 }
099
100 /**
101 * {@inheritDoc}
102 */
103 public CommandBuilder getContextCommandBuilder() {
104 // No implementation required.
105 return new CommandBuilder(null, null);
106 }
107
108 }