001/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*- 002 * 003 * Copyright © 2023–2025 microBean™. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 006 * the License. You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 011 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 012 * specific language governing permissions and limitations under the License. 013 */ 014package org.microbean.bean; 015 016/** 017 * An interface whose implementations complete initialization of contextual instances. 018 * 019 * <p>{@link PostInitializer}s are typically applied to {@linkplain Initializer#initialize(Object, Request) initialized 020 * instances}, i.e. contextual instances that have been fully injected.</p> 021 * 022 * <p>{@link PostInitializer}s are typically used in implementations of the {@link Factory#create(Request)} method, 023 * together with {@link InterceptionsApplicator}s, {@link Initializer}s and {@link Producer}s.</p> 024 * 025 * @param <I> the type of contextual instance 026 * 027 * @author <a href="https://about.me/lairdnelson" target="_top">Laird Nelson</a> 028 * 029 * @see #postInitialize(Object, Request) 030 * 031 * @see Initializer 032 * 033 * @see InterceptionsApplicator 034 * 035 * @see Producer 036 */ 037// Subordinate to Factory<I> (really to InterceptionsApplicator<I>). Normally applied to Initializer<I> output. 038// Calls postConstruct() methods. 039// Note that this deliberately does NOT extend Aggregate, since initialization must have already occurred. 040public interface PostInitializer<I> { 041 042 /** 043 * Completes the initialization of a contextual instance and returns the result. 044 * 045 * @param i an {@linkplain Initializer#initialize(Object, Request) initialized} contextual instance; must not be 046 * {@code null} 047 * 048 * @param r a {@link Request}; must not be {@code null} 049 * 050 * @return a contextual instance that has been completely initialized; never {@code null} 051 * 052 * @exception NullPointerException if either argument is {@code null} 053 */ 054 public I postInitialize(final I i, final Request<I> r); 055 056}