Skip to content

Instantly share code, notes, and snippets.

class ViewConversationExpirationEvaluator
implements ConversationExpirationEvaluator
{
private static final long serialVersionUID = -1298186767354202960L;
private String viewId;
private boolean expired;
ViewConversationExpirationEvaluator()
{
if(FacesContext.getCurrentInstance().getViewRoot() != null)
import org.os890.codi.addon.conversation.api.ViewConversationScoped;
import javax.annotation.PostConstruct;
import javax.inject.Named;
import java.io.Serializable;
import java.util.Date;
@Named
@ViewConversationScoped
public class ViewConversationBean implements Serializable
@ApplicationScoped
public class SimulatedViewScopeObserver
{
protected void observeNavigation(
@Observes PreViewConfigNavigateEvent preViewConfigNavigateEvent,
EditableWindowContext editableWindowContext)
{
if (!preViewConfigNavigateEvent.getFromView()
.equals(preViewConfigNavigateEvent.getToView()))
{
@ConversationScoped
public class ConversationAwareNoSqlTransactionProxy implements Transaction, Serializable
{
private NoSqlDb noSqlDb; //handle serialization (if needed/supported)
private Transaction transaction; //handle serialization (if needed/supported)
//required by proxy libs
protected ConversationAwareNoSqlTransactionProxy()
{
}
//for a partial integration in GlassFish3 in case of:
//java.lang.NullPointerException at com.sun.jersey.server.impl.cdi.CDIExtension.processAnnotatedField
public class JerseyAwareLoaderService extends DefaultLoaderService
{
@Override
public <T> List<T> load(Class<T> serviceType, ClassLoader classLoader)
{
List<T> result = super.load(serviceType, classLoader);
//nesting leads to the path of a page (-> view-id) and inheritance to meta-data-inheritance
//currently there would be no ide support to show where the meta-data comes from in case of meta-data-inheritance via nesting
//(it's easy to see in small applications but difficult in large applications)
//represents a folder
@Page(navigation = REDIRECT)
public interface Pages
{
//represents a folder
//can be referenced via @ConversationGroup, @View, @Matches,...
@os890
os890 / WeldBeanFilter.java
Last active December 16, 2015 11:29
veto beans for weld
public class WeldFilter implements Extension
{
public void vetoForWeld(@Observes ProcessAnnotatedType processAnnotatedType, BeanManager beanManager)
{
if (!beanManager.getClass().getName().contains("org.apache."))
{
processAnnotatedType.veto();
}
}
}
@os890
os890 / BeanManagerProvider.java
Created April 20, 2013 23:29
ds with multiple cdi implementations
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
public class MyActor extends UntypedActor
{
@Inject
private MyService myService;
@Override
public void onReceive(Object o) throws Exception
{
myService.process(/*...*/);
}
//starts the container once and one session + request per test-method
@RunWith(CdiTestRunner.class)
public class ContainerAndInjectionControl
{
@Inject
private ApplicationScopedBean applicationScopedBean;
@Inject
private SessionScopedBean sessionScopedBean;