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; 028 029 030 031 import java.util.Collection; 032 import java.util.Collections; 033 034 import org.opends.server.admin.client.ClientConstraintHandler; 035 import org.opends.server.admin.server.ServerConstraintHandler; 036 037 038 039 /** 040 * An interface for enforcing constraints and dependencies between 041 * managed objects and their properties. Constraints express 042 * relationships between managed objects and their properties, for 043 * example: 044 * <ul> 045 * <li>referential integrity: where one managed object references 046 * another a constraint can enforce referential integrity. The 047 * constraint can prevent creation of references to non-existent 048 * managed objects, and also prevent deletion of referenced managed 049 * objects 050 * <li>property dependencies: for example, when a boolean property is 051 * <code>true</code>, one or more additional properties must be 052 * specified. This is useful for features like SSL, which when 053 * enabled, requires that various SSL related configuration options 054 * are specified 055 * <li>property constraints: for example, when an upper limit 056 * property must not have a value which is less than the lower limit 057 * property. 058 * </ul> 059 * On the client-side constraints are enforced immediately before a 060 * write operation is performed. That is to say, immediately before a 061 * new managed object is created, changes to a managed object are 062 * applied, or an existing managed object is deleted. 063 */ 064 public abstract class Constraint { 065 066 /** 067 * Creates a new constraint. 068 */ 069 protected Constraint() { 070 // No implementation required. 071 } 072 073 074 075 /** 076 * Gets the client-side constraint handlers which will be used to 077 * enforce this constraint in client applications. The default 078 * implementation is to return an empty set of client constraint 079 * handlers. 080 * 081 * @return Returns the client-side constraint handlers which will be 082 * used to enforce this constraint in client applications. 083 * The returned collection must not be <code>null</code> 084 * but maybe empty (indicating that the constraint can only 085 * be enforced on the server-side). 086 */ 087 public Collection<ClientConstraintHandler> getClientConstraintHandlers() { 088 return Collections.emptySet(); 089 } 090 091 092 093 /** 094 * Gets the server-side constraint handlers which will be used to 095 * enforce this constraint within the server. The default 096 * implementation is to return an empty set of server constraint 097 * handlers. 098 * 099 * @return Returns the server-side constraint handlers which will be 100 * used to enforce this constraint within the server. The 101 * returned collection must not be <code>null</code> and 102 * must not be empty, since constraints must always be 103 * enforced on the server. 104 */ 105 public Collection<ServerConstraintHandler> getServerConstraintHandlers() { 106 return Collections.emptySet(); 107 } 108 109 110 111 /** 112 * Initializes this constraint. The default implementation is to do 113 * nothing. 114 * 115 * @throws Exception 116 * If this constraint could not be initialized. 117 */ 118 protected void initialize() throws Exception { 119 // Default implementation is to do nothing. 120 } 121 122 }