All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.weld.tck.ContextualsImpl Maven / Gradle / Ivy

There is a newer version: 6.0.0.CR1
Show newest version
package org.jboss.weld.tck;

import jakarta.enterprise.context.spi.Context;
import jakarta.enterprise.context.spi.CreationalContext;

import org.jboss.cdi.tck.spi.Contextuals;

public class ContextualsImpl implements Contextuals {
    @Override
    public  Inspectable create(T instance, Context context) {
        return new InspectableContextual<>(instance);
    }

    static class InspectableContextual implements Inspectable {
        private final T instanceToReturn;

        private CreationalContext createCC;
        private T destroyInstance;
        private CreationalContext destroyCC;

        InspectableContextual(T instanceToReturn) {
            this.instanceToReturn = instanceToReturn;
        }

        @Override
        public T create(CreationalContext creationalContext) {
            createCC = creationalContext;
            return instanceToReturn;
        }

        @Override
        public void destroy(T instance, CreationalContext creationalContext) {
            destroyInstance = instance;
            destroyCC = creationalContext;
        }

        @Override
        public CreationalContext getCreationalContextPassedToCreate() {
            return createCC;
        }

        @Override
        public T getInstancePassedToDestroy() {
            return destroyInstance;
        }

        @Override
        public CreationalContext getCreationalContextPassedToDestroy() {
            return destroyCC;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy