001/* 002 * jDTAUS Core API 003 * Copyright (C) 2005 Christian Schulte 004 * <cs@schulte.it> 005 * 006 * This library is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2.1 of the License, or any later version. 010 * 011 * This library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 019 * 020 */ 021package org.jdtaus.core.container; 022 023import java.util.Locale; 024 025/** 026 * Gets thrown for property overwrite constraint violations. 027 * <p>A {@code Dependency} is allowed to provide values for any properties 028 * declared for its specification only if the specification applies to scope 029 * {@code SCOPE_MULTITON}. An implementation must provide values for all 030 * properties declared for its implemented specifications. This exception gets 031 * thrown for any violations to these restrictions.</p> 032 * 033 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 034 * @version $JDTAUS: PropertyOverwriteConstraintException.java 8641 2012-09-27 06:45:17Z schulte $ 035 * 036 * @see Implementation#getProperties() 037 * @see Dependency#getProperties() 038 */ 039public class PropertyOverwriteConstraintException extends IllegalStateException 040{ 041 //--Constants--------------------------------------------------------------- 042 043 /** Serial version UID for backwards compatibility with 1.2.x classes. */ 044 private static final long serialVersionUID = -6382737345293763298L; 045 046 //---------------------------------------------------------------Constants-- 047 //--Constructors------------------------------------------------------------ 048 049 /** 050 * Creates a new {@code PropertyOverwriteConstraintException} instance 051 * taking the identifier of an implementation defining a dependency 052 * providing property values although the specification does not apply to 053 * the multiton scope. 054 * 055 * @param implementationIdentifier identifier of the implementation defining 056 * a dependency violating the constraint. 057 * @param dependencyName name of the dependency defined for the 058 * implementation identified by {@code implementationIdentifier} violating 059 * the constraint. 060 */ 061 public PropertyOverwriteConstraintException( 062 final String implementationIdentifier, final String dependencyName ) 063 { 064 super( PropertyOverwriteConstraintExceptionBundle.getInstance(). 065 getPropertyOverwriteConstraintMessage( Locale.getDefault(), 066 implementationIdentifier, 067 dependencyName ) ); 068 069 this.implementationIdentifier = implementationIdentifier; 070 this.specificationIdentifier = null; 071 this.dependencyName = dependencyName; 072 this.propertyName = null; 073 } 074 075 /** 076 * Creates a new {@code PropertyOverwriteConstraintException} instance 077 * taking the identifier of an implementation not implementing a 078 * specification property together with information regarding the 079 * unimplemented property. 080 * 081 * @param implementationIdentifier identifier of the implementation not 082 * implementing a specification property. 083 * @param specificationIdentifier identifier of the specification an 084 * implementation does not implement a property of. 085 * @param propertyName name of the unimplemented property. 086 */ 087 public PropertyOverwriteConstraintException( 088 final String implementationIdentifier, 089 final String specificationIdentifier, final String propertyName ) 090 { 091 super( PropertyOverwriteConstraintExceptionBundle.getInstance(). 092 getPropertyNotImplementedMessage( Locale.getDefault(), 093 implementationIdentifier, 094 specificationIdentifier, 095 propertyName ) ); 096 097 this.implementationIdentifier = implementationIdentifier; 098 this.specificationIdentifier = specificationIdentifier; 099 this.propertyName = propertyName; 100 this.dependencyName = null; 101 } 102 103 //------------------------------------------------------------Constructors-- 104 //--PropertyOverwriteConstraintException------------------------------------ 105 106 /** 107 * Identifier of the implementation defining a dependency violating the 108 * constraint. 109 * @serial 110 */ 111 private final String implementationIdentifier; 112 113 /** 114 * Identifier of the specification defining a property not implemented by 115 * the implementation. 116 * @serial 117 */ 118 private final String specificationIdentifier; 119 120 /** 121 * Name of the dependency defined for the implementation identified by 122 * property {@code implementationIdentifier} violating the constraint. 123 * @serial 124 */ 125 private final String dependencyName; 126 127 /** 128 * Name of the property not implemented by the implementation. 129 * @serial 130 */ 131 private final String propertyName; 132 133 /** 134 * Gets the identifier of the implementation defining a dependency 135 * violating the constraint. 136 * 137 * @return identifier of the implementation defining a dependency 138 * violating the constraint. 139 */ 140 public String getImplementationIdentifier() 141 { 142 return this.implementationIdentifier; 143 } 144 145 /** 146 * Gets the identifier of the specification defining a property not 147 * implemented by the implementation. 148 * 149 * @return identifier of the specification defining a property not 150 * implemented by the implementation or {@code null}. 151 */ 152 public String getSpecificationIdentifier() 153 { 154 return this.specificationIdentifier; 155 } 156 157 /** 158 * Gets the name of the dependency defined for the implementation identified 159 * by the value of property {@code implementationIdentifier} violating the 160 * constraint. 161 * 162 * @return name of the dependency defined for the implementation identified 163 * by the value of property {@code implementationIdentifier} violating the 164 * constraint or {@code null}. 165 */ 166 public String getDependencyName() 167 { 168 return this.dependencyName; 169 } 170 171 /** 172 * Gets the name of the property not implemented by the implementation. 173 * 174 * @return name of the property not implemented by the implementation or 175 * {@code null}. 176 */ 177 public String getPropertyName() 178 { 179 return this.propertyName; 180 } 181 182 //------------------------------------PropertyOverwriteConstraintException-- 183}