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