当前位置: 首页>>代码示例>>Java>>正文


Java CreationalContext.release方法代码示例

本文整理汇总了Java中javax.enterprise.context.spi.CreationalContext.release方法的典型用法代码示例。如果您正苦于以下问题:Java CreationalContext.release方法的具体用法?Java CreationalContext.release怎么用?Java CreationalContext.release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.enterprise.context.spi.CreationalContext的用法示例。


在下文中一共展示了CreationalContext.release方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testInjectionTarget

import javax.enterprise.context.spi.CreationalContext; //导入方法依赖的package包/类
@Test
public void testInjectionTarget() {
	BeanManager beanManager = current().getBeanManager();
	// CDI uses an AnnotatedType object to read the annotations of a class
	AnnotatedType<String> type = beanManager.createAnnotatedType(String.class);
	// The extension uses an InjectionTarget to delegate instantiation,
	// dependency injection
	// and lifecycle callbacks to the CDI container
	InjectionTarget<String> it = beanManager.createInjectionTarget(type);
	// each instance needs its own CDI CreationalContext
	CreationalContext<String> ctx = beanManager.createCreationalContext(null);
	// instantiate the framework component and inject its dependencies
	String instance = it.produce(ctx); // call the constructor
	it.inject(instance, ctx); // call initializer methods and perform field
								// injection
	it.postConstruct(instance); // call the @PostConstruct method
	// destroy the framework component instance and clean up dependent
	// objects
	assertNotNull("the String instance is injected now", instance);
	assertTrue("the String instance is injected now but it's empty", instance.isEmpty());
	it.preDestroy(instance); // call the @PreDestroy method
	it.dispose(instance); // it is now safe to discard the instance
	ctx.release(); // clean up dependent objects
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:25,代码来源:InjectSPITestCase.java

示例2: destroy

import javax.enterprise.context.spi.CreationalContext; //导入方法依赖的package包/类
/**
 * Destroy the instance.
 *
 * @param contextual the contextual.
 */
public void destroy(Contextual contextual) {
    String scopeId = (String) request.getAttribute(SCOPE_ID);
    if (null != scopeId) {
        HttpSession session = request.getSession();
        if (contextual instanceof PassivationCapable == false) {
            throw new RuntimeException("Unexpected type for contextual");
        }
        PassivationCapable pc = (PassivationCapable) contextual;
        final String sessionKey = SCOPE_ID + "-" + scopeId;
        Map<String, Object> scopeMap = (Map<String, Object>) session.getAttribute(sessionKey);
        if (null != scopeMap) {
            Object instance = scopeMap.get(INSTANCE + pc.getId());
            CreationalContext<?> creational = (CreationalContext<?>) scopeMap.get(CREATIONAL + pc.getId());
            if (null != instance && null != creational) {
                contextual.destroy(instance, creational);
                creational.release();
            }
        }
    }
}
 
开发者ID:mvc-spec,项目名称:ozark,代码行数:26,代码来源:RedirectScopeManager.java

示例3: execute

import javax.enterprise.context.spi.CreationalContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <R> R execute(DefaultAssetTask task, Class<R> resultType) {
	String taskId = UUID.randomUUID().toString();
	TaskContext context = new DefaultTaskContext(taskId, task);
	Bean<Task> bean = getBean(task.getTaskName());
	CreationalContext<Task> creationalContext = (CreationalContext<Task>) beanManager.createCreationalContext(bean);
	try {
		CurrentTaskContext.set(context);
		Task instance = (Task) beanManager.getReference(bean, Task.class, creationalContext);
		R result = (R) instance.execute();
		beanManager.fireEvent(new TaskExecuted(context));
		return result;
	} finally {
		CurrentTaskContext.clear();
		creationalContext.release();
	}
}
 
开发者ID:poquito,项目名称:assetmanager,代码行数:18,代码来源:DefaultAssetTaskHandler.java

示例4: execute

import javax.enterprise.context.spi.CreationalContext; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public <R> R execute(@Valid RodeoCommand<R> command) {
	CreationalContext<Object> context = beanManager.createCreationalContext(null);
	try {
		AnnotatedType type = (AnnotatedType) beanManager.createAnnotatedType(command.getClass());
		beanManager.createInjectionTarget(type).inject(command, context);
		return command.execute();
	} finally {
		context.release();
	}
}
 
开发者ID:arz-latte,项目名称:latte-rodeo,代码行数:12,代码来源:RodeoModel.java

示例5: destroy

import javax.enterprise.context.spi.CreationalContext; //导入方法依赖的package包/类
@Override
public void destroy(T instance, CreationalContext<T> creationalContext) {
    try {
        target.preDestroy(instance);
        target.dispose(instance);
    } catch (Exception cause) {
        throw new InjectionException("Error while destroying " + this, cause);
    } finally {
        creationalContext.release();
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:SyntheticBean.java

示例6: programmaticInjection

import javax.enterprise.context.spi.CreationalContext; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> void programmaticInjection(Class clazz, T injectionObject) throws NamingException {
	InitialContext initialContext = new InitialContext();
	Object lookup = initialContext.lookup("java:comp/BeanManager");
	BeanManager beanManager = (BeanManager) lookup;
	AnnotatedType annotatedType = beanManager.createAnnotatedType(clazz);
	InjectionTarget injectionTarget = beanManager.createInjectionTarget(annotatedType);
	CreationalContext creationalContext = beanManager.createCreationalContext(null);
	injectionTarget.inject(injectionObject, creationalContext);
	creationalContext.release();
}
 
开发者ID:culturagovbr,项目名称:GOG,代码行数:12,代码来源:CdiHelper.java

示例7: destroy

import javax.enterprise.context.spi.CreationalContext; //导入方法依赖的package包/类
@Override
public void destroy(Bean<T> bean, T instance, CreationalContext<T> creationalContext) {
    Assert.requireNonNull(bean, "bean");
    Assert.requireNonNull(creationalContext, "creationalContext");
    injectionTarget.preDestroy(instance);
    creationalContext.release();
}
 
开发者ID:canoo,项目名称:dolphin-platform,代码行数:8,代码来源:DolphinPlatformContextualLifecycle.java

示例8: unregisterTransformers

import javax.enterprise.context.spi.CreationalContext; //导入方法依赖的package包/类
/**
 * Unregister all transformers.
 */
public void unregisterTransformers() {
    for (Transformer<?, ?> transformer : _transformers) {
        _transformerRegistry.removeTransformer(transformer);
    }
    for (CreationalContext<?> context : _cdiCreationalContexts) {
        context.release();
    }
    _cdiCreationalContexts.clear();
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:13,代码来源:TransformerRegistryLoader.java

示例9: unregisterValidators

import javax.enterprise.context.spi.CreationalContext; //导入方法依赖的package包/类
/**
 * Unregister all validators.
 */
public void unregisterValidators() {
    for (Validator validator : _validators) {
        _validatorRegistry.removeValidator(validator);
    }
    for (CreationalContext<?> context : _cdiCreationalContexts) {
        context.release();
    }
    _cdiCreationalContexts.clear();
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:13,代码来源:ValidatorRegistryLoader.java

示例10: destroy

import javax.enterprise.context.spi.CreationalContext; //导入方法依赖的package包/类
@Override
public void destroy(T instance, CreationalContext<T> creationalContext) {
    creationalContext.release();
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:5,代码来源:CommonBean.java

示例11: destroy

import javax.enterprise.context.spi.CreationalContext; //导入方法依赖的package包/类
@Override
public void destroy(Bean<T> bean, T instance, CreationalContext<T> creationalContext) {
	creationalContext.release();
}
 
开发者ID:kamaladafrica,项目名称:axon-cdi,代码行数:5,代码来源:SimpleEventSchedulerContextualLifecycle.java

示例12: destroy

import javax.enterprise.context.spi.CreationalContext; //导入方法依赖的package包/类
@Override
public void destroy(final Bean<R> bean, final R instance, final CreationalContext<R> creationalContext) {
	creationalContext.release();
}
 
开发者ID:kamaladafrica,项目名称:axon-cdi,代码行数:5,代码来源:RepositoryContextualLifecycle.java

示例13: destroy

import javax.enterprise.context.spi.CreationalContext; //导入方法依赖的package包/类
public void destroy(T instance, CreationalContext<T> creationalContext) {
	creationalContext.release();
}
 
开发者ID:yanaga,项目名称:winter-data-jpa,代码行数:4,代码来源:SimpleRepositoryBean.java

示例14: destroy

import javax.enterprise.context.spi.CreationalContext; //导入方法依赖的package包/类
@Override
public void destroy(MetricsCollector instance, CreationalContext<MetricsCollector> creationalContext) {
    creationalContext.release();
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:5,代码来源:MetricCollectorBean.java


注:本文中的javax.enterprise.context.spi.CreationalContext.release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。