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 2014 ForgeRock AS. 015 */ 016 017package org.forgerock.openig.decoration; 018 019import org.forgerock.json.JsonValue; 020import org.forgerock.openig.decoration.helper.LazyReference; 021import org.forgerock.openig.heap.Heap; 022import org.forgerock.openig.heap.Name; 023 024/** 025 * A decoration {@code Context} is a way to provide the decorator(s) all of the available 026 * information about the instance to decorate. 027 */ 028public interface Context { 029 /** 030 * Returns the name of the heap object being decorated. 031 * 032 * @return the name of the heap object being decorated. 033 */ 034 Name getName(); 035 036 /** 037 * Returns the heap object being decorated configuration. Should be considered as a read-only view of the 038 * configuration (does not trigger any reconfiguration). 039 * 040 * @return the heap object being decorated configuration. 041 */ 042 JsonValue getConfig(); 043 044 /** 045 * Returns the heap that spawned the decorated heap object. This permits decorators to borrow references just like 046 * any component. Notice that this reference has to be used with caution because any attempt to resolve a reference 047 * in a decorator that is globally declared for a heap will produce an infinite recursion leading to a 048 * java.lang.StackOverflowError. In order to prevent that, decorator's implementer are encouraged to use a 049 * {@link LazyReference} that will load the reference lazily (ideally just before it is really needed, but not 050 * during the loading of the heap). 051 * 052 * @return the heap that spawned the decorated heap object. 053 * @see LazyReference 054 */ 055 Heap getHeap(); 056}