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 legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2008 Sun Microsystems, Inc. 025 */ 026package org.opends.server.admin; 027 028 029 030import java.util.Collection; 031import java.util.Collections; 032 033import org.opends.server.admin.client.ClientConstraintHandler; 034import org.opends.server.admin.server.ServerConstraintHandler; 035 036 037 038/** 039 * An interface for enforcing constraints and dependencies between 040 * managed objects and their properties. Constraints express 041 * relationships between managed objects and their properties, for 042 * example: 043 * <ul> 044 * <li>referential integrity: where one managed object references 045 * another a constraint can enforce referential integrity. The 046 * constraint can prevent creation of references to non-existent 047 * managed objects, and also prevent deletion of referenced managed 048 * objects 049 * <li>property dependencies: for example, when a boolean property is 050 * <code>true</code>, one or more additional properties must be 051 * specified. This is useful for features like SSL, which when 052 * enabled, requires that various SSL related configuration options 053 * are specified 054 * <li>property constraints: for example, when an upper limit 055 * property must not have a value which is less than the lower limit 056 * property. 057 * </ul> 058 * On the client-side constraints are enforced immediately before a 059 * write operation is performed. That is to say, immediately before a 060 * new managed object is created, changes to a managed object are 061 * applied, or an existing managed object is deleted. 062 */ 063public abstract class Constraint { 064 065 /** 066 * Creates a new constraint. 067 */ 068 protected Constraint() { 069 // No implementation required. 070 } 071 072 073 074 /** 075 * Gets the client-side constraint handlers which will be used to 076 * enforce this constraint in client applications. The default 077 * implementation is to return an empty set of client constraint 078 * handlers. 079 * 080 * @return Returns the client-side constraint handlers which will be 081 * used to enforce this constraint in client applications. 082 * The returned collection must not be <code>null</code> 083 * but maybe empty (indicating that the constraint can only 084 * be enforced on the server-side). 085 */ 086 public Collection<ClientConstraintHandler> getClientConstraintHandlers() { 087 return Collections.emptySet(); 088 } 089 090 091 092 /** 093 * Gets the server-side constraint handlers which will be used to 094 * enforce this constraint within the server. The default 095 * implementation is to return an empty set of server constraint 096 * handlers. 097 * 098 * @return Returns the server-side constraint handlers which will be 099 * used to enforce this constraint within the server. The 100 * returned collection must not be <code>null</code> and 101 * must not be empty, since constraints must always be 102 * enforced on the server. 103 */ 104 public Collection<ServerConstraintHandler> getServerConstraintHandlers() { 105 return Collections.emptySet(); 106 } 107 108 109 110 /** 111 * Initializes this constraint. The default implementation is to do 112 * nothing. 113 * 114 * @throws Exception 115 * If this constraint could not be initialized. 116 */ 117 protected void initialize() throws Exception { 118 // Default implementation is to do nothing. 119 } 120 121}