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 2008 Sun Microsystems, Inc.
026     */
027    package org.opends.server.admin.std.meta;
028    
029    
030    
031    import org.opends.server.admin.BooleanPropertyDefinition;
032    import org.opends.server.admin.ClassPropertyDefinition;
033    import org.opends.server.admin.client.AuthorizationException;
034    import org.opends.server.admin.client.CommunicationException;
035    import org.opends.server.admin.client.ConcurrentModificationException;
036    import org.opends.server.admin.client.ManagedObject;
037    import org.opends.server.admin.client.MissingMandatoryPropertiesException;
038    import org.opends.server.admin.client.OperationRejectedException;
039    import org.opends.server.admin.ManagedObjectAlreadyExistsException;
040    import org.opends.server.admin.ManagedObjectDefinition;
041    import org.opends.server.admin.PropertyProvider;
042    import org.opends.server.admin.server.ConfigurationChangeListener;
043    import org.opends.server.admin.server.ServerManagedObject;
044    import org.opends.server.admin.std.client.ApproximateMatchingRuleCfgClient;
045    import org.opends.server.admin.std.server.ApproximateMatchingRuleCfg;
046    import org.opends.server.admin.std.server.MatchingRuleCfg;
047    import org.opends.server.admin.Tag;
048    import org.opends.server.types.DN;
049    
050    
051    
052    /**
053     * An interface for querying the Approximate Matching Rule managed
054     * object definition meta information.
055     * <p>
056     * Approximate Matching Rules define a set of rules for performing
057     * approximate matching operations against assertion values. In many
058     * cases, approximate matching is based on a "sounds like" operation.
059     */
060    public final class ApproximateMatchingRuleCfgDefn extends ManagedObjectDefinition<ApproximateMatchingRuleCfgClient, ApproximateMatchingRuleCfg> {
061    
062      // The singleton configuration definition instance.
063      private static final ApproximateMatchingRuleCfgDefn INSTANCE = new ApproximateMatchingRuleCfgDefn();
064    
065    
066    
067      // Register the tags associated with this managed object definition.
068      static {
069        INSTANCE.registerTag(Tag.valueOf("core-server"));
070      }
071    
072    
073    
074      /**
075       * Get the Approximate Matching Rule configuration definition
076       * singleton.
077       *
078       * @return Returns the Approximate Matching Rule configuration
079       *         definition singleton.
080       */
081      public static ApproximateMatchingRuleCfgDefn getInstance() {
082        return INSTANCE;
083      }
084    
085    
086    
087      /**
088       * Private constructor.
089       */
090      private ApproximateMatchingRuleCfgDefn() {
091        super("approximate-matching-rule", MatchingRuleCfgDefn.getInstance());
092      }
093    
094    
095    
096      /**
097       * {@inheritDoc}
098       */
099      public ApproximateMatchingRuleCfgClient createClientConfiguration(
100          ManagedObject<? extends ApproximateMatchingRuleCfgClient> impl) {
101        return new ApproximateMatchingRuleCfgClientImpl(impl);
102      }
103    
104    
105    
106      /**
107       * {@inheritDoc}
108       */
109      public ApproximateMatchingRuleCfg createServerConfiguration(
110          ServerManagedObject<? extends ApproximateMatchingRuleCfg> impl) {
111        return new ApproximateMatchingRuleCfgServerImpl(impl);
112      }
113    
114    
115    
116      /**
117       * {@inheritDoc}
118       */
119      public Class<ApproximateMatchingRuleCfg> getServerConfigurationClass() {
120        return ApproximateMatchingRuleCfg.class;
121      }
122    
123    
124    
125      /**
126       * Get the "enabled" property definition.
127       * <p>
128       * Indicates whether the Approximate Matching Rule is enabled for
129       * use.
130       *
131       * @return Returns the "enabled" property definition.
132       */
133      public BooleanPropertyDefinition getEnabledPropertyDefinition() {
134        return MatchingRuleCfgDefn.getInstance().getEnabledPropertyDefinition();
135      }
136    
137    
138    
139      /**
140       * Get the "java-class" property definition.
141       * <p>
142       * Specifies the fully-qualified name of the Java class that
143       * provides the Approximate Matching Rule implementation.
144       *
145       * @return Returns the "java-class" property definition.
146       */
147      public ClassPropertyDefinition getJavaClassPropertyDefinition() {
148        return MatchingRuleCfgDefn.getInstance().getJavaClassPropertyDefinition();
149      }
150    
151    
152    
153      /**
154       * Managed object client implementation.
155       */
156      private static class ApproximateMatchingRuleCfgClientImpl implements
157        ApproximateMatchingRuleCfgClient {
158    
159        // Private implementation.
160        private ManagedObject<? extends ApproximateMatchingRuleCfgClient> impl;
161    
162    
163    
164        // Private constructor.
165        private ApproximateMatchingRuleCfgClientImpl(
166            ManagedObject<? extends ApproximateMatchingRuleCfgClient> impl) {
167          this.impl = impl;
168        }
169    
170    
171    
172        /**
173         * {@inheritDoc}
174         */
175        public Boolean isEnabled() {
176          return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
177        }
178    
179    
180    
181        /**
182         * {@inheritDoc}
183         */
184        public void setEnabled(boolean value) {
185          impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
186        }
187    
188    
189    
190        /**
191         * {@inheritDoc}
192         */
193        public String getJavaClass() {
194          return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
195        }
196    
197    
198    
199        /**
200         * {@inheritDoc}
201         */
202        public void setJavaClass(String value) {
203          impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
204        }
205    
206    
207    
208        /**
209         * {@inheritDoc}
210         */
211        public ManagedObjectDefinition<? extends ApproximateMatchingRuleCfgClient, ? extends ApproximateMatchingRuleCfg> definition() {
212          return INSTANCE;
213        }
214    
215    
216    
217        /**
218         * {@inheritDoc}
219         */
220        public PropertyProvider properties() {
221          return impl;
222        }
223    
224    
225    
226        /**
227         * {@inheritDoc}
228         */
229        public void commit() throws ManagedObjectAlreadyExistsException,
230            MissingMandatoryPropertiesException, ConcurrentModificationException,
231            OperationRejectedException, AuthorizationException,
232            CommunicationException {
233          impl.commit();
234        }
235    
236      }
237    
238    
239    
240      /**
241       * Managed object server implementation.
242       */
243      private static class ApproximateMatchingRuleCfgServerImpl implements
244        ApproximateMatchingRuleCfg {
245    
246        // Private implementation.
247        private ServerManagedObject<? extends ApproximateMatchingRuleCfg> impl;
248    
249        // The value of the "enabled" property.
250        private final boolean pEnabled;
251    
252        // The value of the "java-class" property.
253        private final String pJavaClass;
254    
255    
256    
257        // Private constructor.
258        private ApproximateMatchingRuleCfgServerImpl(ServerManagedObject<? extends ApproximateMatchingRuleCfg> impl) {
259          this.impl = impl;
260          this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
261          this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
262        }
263    
264    
265    
266        /**
267         * {@inheritDoc}
268         */
269        public void addApproximateChangeListener(
270            ConfigurationChangeListener<ApproximateMatchingRuleCfg> listener) {
271          impl.registerChangeListener(listener);
272        }
273    
274    
275    
276        /**
277         * {@inheritDoc}
278         */
279        public void removeApproximateChangeListener(
280            ConfigurationChangeListener<ApproximateMatchingRuleCfg> listener) {
281          impl.deregisterChangeListener(listener);
282        }
283        /**
284         * {@inheritDoc}
285         */
286        public void addChangeListener(
287            ConfigurationChangeListener<MatchingRuleCfg> listener) {
288          impl.registerChangeListener(listener);
289        }
290    
291    
292    
293        /**
294         * {@inheritDoc}
295         */
296        public void removeChangeListener(
297            ConfigurationChangeListener<MatchingRuleCfg> listener) {
298          impl.deregisterChangeListener(listener);
299        }
300    
301    
302    
303        /**
304         * {@inheritDoc}
305         */
306        public boolean isEnabled() {
307          return pEnabled;
308        }
309    
310    
311    
312        /**
313         * {@inheritDoc}
314         */
315        public String getJavaClass() {
316          return pJavaClass;
317        }
318    
319    
320    
321        /**
322         * {@inheritDoc}
323         */
324        public Class<? extends ApproximateMatchingRuleCfg> configurationClass() {
325          return ApproximateMatchingRuleCfg.class;
326        }
327    
328    
329    
330        /**
331         * {@inheritDoc}
332         */
333        public DN dn() {
334          return impl.getDN();
335        }
336    
337      }
338    }