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