001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2008 Sun Microsystems, Inc.
015 */
016package org.forgerock.opendj.server.config.meta;
017
018
019
020import org.forgerock.opendj.config.AdministratorAction;
021import org.forgerock.opendj.config.BooleanPropertyDefinition;
022import org.forgerock.opendj.config.ClassPropertyDefinition;
023import org.forgerock.opendj.config.client.ConcurrentModificationException;
024import org.forgerock.opendj.config.client.ManagedObject;
025import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException;
026import org.forgerock.opendj.config.client.OperationRejectedException;
027import org.forgerock.opendj.config.DefaultBehaviorProvider;
028import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider;
029import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException;
030import org.forgerock.opendj.config.ManagedObjectDefinition;
031import org.forgerock.opendj.config.PropertyOption;
032import org.forgerock.opendj.config.PropertyProvider;
033import org.forgerock.opendj.config.server.ConfigurationChangeListener;
034import org.forgerock.opendj.config.server.ServerManagedObject;
035import org.forgerock.opendj.config.Tag;
036import org.forgerock.opendj.ldap.DN;
037import org.forgerock.opendj.ldap.LdapException;
038import org.forgerock.opendj.server.config.client.GetConnectionIdExtendedOperationHandlerCfgClient;
039import org.forgerock.opendj.server.config.server.ExtendedOperationHandlerCfg;
040import org.forgerock.opendj.server.config.server.GetConnectionIdExtendedOperationHandlerCfg;
041
042
043
044/**
045 * An interface for querying the Get Connection Id Extended Operation
046 * Handler managed object definition meta information.
047 * <p>
048 * The Get Connection Id Extended Operation Handler provides a
049 * mechanism for clients to obtain the internal connection ID that the
050 * server uses to reference their client connection.
051 */
052public final class GetConnectionIdExtendedOperationHandlerCfgDefn extends ManagedObjectDefinition<GetConnectionIdExtendedOperationHandlerCfgClient, GetConnectionIdExtendedOperationHandlerCfg> {
053
054  /** The singleton configuration definition instance. */
055  private static final GetConnectionIdExtendedOperationHandlerCfgDefn INSTANCE = new GetConnectionIdExtendedOperationHandlerCfgDefn();
056
057
058
059  /** The "java-class" property definition. */
060  private static final ClassPropertyDefinition PD_JAVA_CLASS;
061
062
063
064  /** Build the "java-class" property definition. */
065  static {
066      ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
067      builder.setOption(PropertyOption.MANDATORY);
068      builder.setOption(PropertyOption.ADVANCED);
069      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class"));
070      DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.GetConnectionIDExtendedOperation");
071      builder.setDefaultBehaviorProvider(provider);
072      builder.addInstanceOf("org.opends.server.api.ExtendedOperationHandler");
073      PD_JAVA_CLASS = builder.getInstance();
074      INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
075  }
076
077
078
079  // Register the tags associated with this managed object definition.
080  static {
081    INSTANCE.registerTag(Tag.valueOf("core-server"));
082  }
083
084
085
086  /**
087   * Get the Get Connection Id Extended Operation Handler
088   * configuration definition singleton.
089   *
090   * @return Returns the Get Connection Id Extended Operation Handler
091   *         configuration definition singleton.
092   */
093  public static GetConnectionIdExtendedOperationHandlerCfgDefn getInstance() {
094    return INSTANCE;
095  }
096
097
098
099  /**
100   * Private constructor.
101   */
102  private GetConnectionIdExtendedOperationHandlerCfgDefn() {
103    super("get-connection-id-extended-operation-handler", ExtendedOperationHandlerCfgDefn.getInstance());
104  }
105
106
107
108  /** {@inheritDoc} */
109  public GetConnectionIdExtendedOperationHandlerCfgClient createClientConfiguration(
110      ManagedObject<? extends GetConnectionIdExtendedOperationHandlerCfgClient> impl) {
111    return new GetConnectionIdExtendedOperationHandlerCfgClientImpl(impl);
112  }
113
114
115
116  /** {@inheritDoc} */
117  public GetConnectionIdExtendedOperationHandlerCfg createServerConfiguration(
118      ServerManagedObject<? extends GetConnectionIdExtendedOperationHandlerCfg> impl) {
119    return new GetConnectionIdExtendedOperationHandlerCfgServerImpl(impl);
120  }
121
122
123
124  /** {@inheritDoc} */
125  public Class<GetConnectionIdExtendedOperationHandlerCfg> getServerConfigurationClass() {
126    return GetConnectionIdExtendedOperationHandlerCfg.class;
127  }
128
129
130
131  /**
132   * Get the "enabled" property definition.
133   * <p>
134   * Indicates whether the Get Connection Id Extended Operation
135   * Handler is enabled (that is, whether the types of extended
136   * operations are allowed in the server).
137   *
138   * @return Returns the "enabled" property definition.
139   */
140  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
141    return ExtendedOperationHandlerCfgDefn.getInstance().getEnabledPropertyDefinition();
142  }
143
144
145
146  /**
147   * Get the "java-class" property definition.
148   * <p>
149   * Specifies the fully-qualified name of the Java class that
150   * provides the Get Connection Id Extended Operation Handler
151   * implementation.
152   *
153   * @return Returns the "java-class" property definition.
154   */
155  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
156    return PD_JAVA_CLASS;
157  }
158
159
160
161  /**
162   * Managed object client implementation.
163   */
164  private static class GetConnectionIdExtendedOperationHandlerCfgClientImpl implements
165    GetConnectionIdExtendedOperationHandlerCfgClient {
166
167    /** Private implementation. */
168    private ManagedObject<? extends GetConnectionIdExtendedOperationHandlerCfgClient> impl;
169
170
171
172    /** Private constructor. */
173    private GetConnectionIdExtendedOperationHandlerCfgClientImpl(
174        ManagedObject<? extends GetConnectionIdExtendedOperationHandlerCfgClient> impl) {
175      this.impl = impl;
176    }
177
178
179
180    /** {@inheritDoc} */
181    public Boolean isEnabled() {
182      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
183    }
184
185
186
187    /** {@inheritDoc} */
188    public void setEnabled(boolean value) {
189      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
190    }
191
192
193
194    /** {@inheritDoc} */
195    public String getJavaClass() {
196      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
197    }
198
199
200
201    /** {@inheritDoc} */
202    public void setJavaClass(String value) {
203      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
204    }
205
206
207
208    /** {@inheritDoc} */
209    public ManagedObjectDefinition<? extends GetConnectionIdExtendedOperationHandlerCfgClient, ? extends GetConnectionIdExtendedOperationHandlerCfg> definition() {
210      return INSTANCE;
211    }
212
213
214
215    /** {@inheritDoc} */
216    public PropertyProvider properties() {
217      return impl;
218    }
219
220
221
222    /** {@inheritDoc} */
223    public void commit() throws ManagedObjectAlreadyExistsException,
224        MissingMandatoryPropertiesException, ConcurrentModificationException,
225        OperationRejectedException, LdapException {
226      impl.commit();
227    }
228
229
230
231    /** {@inheritDoc} */
232    public String toString() {
233      return impl.toString();
234    }
235  }
236
237
238
239  /**
240   * Managed object server implementation.
241   */
242  private static class GetConnectionIdExtendedOperationHandlerCfgServerImpl implements
243    GetConnectionIdExtendedOperationHandlerCfg {
244
245    /** Private implementation. */
246    private ServerManagedObject<? extends GetConnectionIdExtendedOperationHandlerCfg> impl;
247
248    /** The value of the "enabled" property. */
249    private final boolean pEnabled;
250
251    /** The value of the "java-class" property. */
252    private final String pJavaClass;
253
254
255
256    /** Private constructor. */
257    private GetConnectionIdExtendedOperationHandlerCfgServerImpl(ServerManagedObject<? extends GetConnectionIdExtendedOperationHandlerCfg> impl) {
258      this.impl = impl;
259      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
260      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
261    }
262
263
264
265    /** {@inheritDoc} */
266    public void addGetConnectionIdChangeListener(
267        ConfigurationChangeListener<GetConnectionIdExtendedOperationHandlerCfg> listener) {
268      impl.registerChangeListener(listener);
269    }
270
271
272
273    /** {@inheritDoc} */
274    public void removeGetConnectionIdChangeListener(
275        ConfigurationChangeListener<GetConnectionIdExtendedOperationHandlerCfg> listener) {
276      impl.deregisterChangeListener(listener);
277    }
278    /** {@inheritDoc} */
279    public void addChangeListener(
280        ConfigurationChangeListener<ExtendedOperationHandlerCfg> listener) {
281      impl.registerChangeListener(listener);
282    }
283
284
285
286    /** {@inheritDoc} */
287    public void removeChangeListener(
288        ConfigurationChangeListener<ExtendedOperationHandlerCfg> listener) {
289      impl.deregisterChangeListener(listener);
290    }
291
292
293
294    /** {@inheritDoc} */
295    public boolean isEnabled() {
296      return pEnabled;
297    }
298
299
300
301    /** {@inheritDoc} */
302    public String getJavaClass() {
303      return pJavaClass;
304    }
305
306
307
308    /** {@inheritDoc} */
309    public Class<? extends GetConnectionIdExtendedOperationHandlerCfg> configurationClass() {
310      return GetConnectionIdExtendedOperationHandlerCfg.class;
311    }
312
313
314
315    /** {@inheritDoc} */
316    public DN dn() {
317      return impl.getDN();
318    }
319
320
321
322    /** {@inheritDoc} */
323    public String toString() {
324      return impl.toString();
325    }
326  }
327}