當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。