/** * Ignore PersistenceContextAttributes if scope is stateless */ @Override public List<BijectedAttribute> getPersistenceContextAttributes() { if(getScope().equals(ScopeType.STATELESS)) { return Collections.emptyList(); } return super.getPersistenceContextAttributes(); } }
public static Object getInstance(String name, ScopeType scope, boolean create, boolean allowAutocreation) { Object result = scope==STATELESS ? null : scope.getContext().get(name); result = getInstance(name, create, allowAutocreation, result, scope); return result; }
private String getPrefix(String id) { return ScopeType.CONVERSATION.getPrefix() + '#' + id + '$'; }
public static StatusMessages instance() { Component component = Component.forName(StatusMessages.COMPONENT_NAME); if(component != null && !component.getScope().isContextActive()) { throw new IllegalStateException("No active "+component.getScope().name()+" context"); } //Attempting to get the instance anyway for backwards compatibility with some potential hack situations. return (StatusMessages) Component.getInstance(COMPONENT_NAME); }
throws BeansException for (ScopeType scope : ScopeType.values()) beanFactory.registerScope(prefix + scope.name(), new SeamScope(scope)); beanFactory.registerScope(prefix + scope.name().toLowerCase(), new SeamScope(scope)); scope = ScopeType.valueOf(definition.getScope().replaceFirst(prefix, "").toUpperCase());
component.getScope(); if ( enforceRequired || outScope.isContextActive() ) outScope.getContext().remove(name); outScope.getContext().set(name, value);
ScopeType scope = wrapper.getVariableScope(dataModelAnn); Object dataModel = getOutScope(scope, this).getContext().get(name); if ( dataModel!=null ) if ( PAGE.equals(scope) )
private void installFactoryFromXmlElement(Element factory) { String scopeName = factory.attributeValue("scope"); String name = factory.attributeValue("name"); if (name == null) { throw new IllegalArgumentException("must specify name in <factory/> declaration"); } String method = factory.attributeValue("method"); String value = factory.attributeValue("value"); if (method == null && value == null) { throw new IllegalArgumentException( "must specify either method or value in <factory/> declaration for variable: " + name); } ScopeType scope = scopeName == null ? ScopeType.UNSPECIFIED : ScopeType.valueOf(scopeName .toUpperCase()); boolean autoCreate = Boolean.parseBoolean(factory.attributeValue("auto-create")); factoryDescriptors.add(new FactoryDescriptor(name, scope, method, value, autoCreate)); }
@Override public void afterCompletion(int status) { //Close the seam call we started if it is still active. if(ScopeType.APPLICATION.isContextActive()) { log.debug("Ending Transactional Seam Call"); Lifecycle.endCall(); } else { log.warn("Spring started a transactional Seam call but somebody else closed before it before the transaction committed."); } } }
private ScopeType() { prefix = "org.jboss.seam." + toString(); }
public static FacesMessages instance() { Component component = Component.forName(StatusMessages.COMPONENT_NAME); if(component != null && !component.getScope().isContextActive()) { throw new IllegalStateException("No active "+component.getScope().name()+" context"); } //Attempting to get the instance anyway for backwards compatibility with some potential hack situations. return (FacesMessages) Component.getInstance(StatusMessages.COMPONENT_NAME); } }
if ( enforceRequired || in.scope().isContextActive() ) result = in.scope().getContext().get(name);
ScopeType scope = ScopeType.valueOf(node.getAttributes().getNamedItem("scope") .getNodeValue()); if (scope != ScopeType.STATELESS
protected static void runTasks() { Component component = Component.forName(StatusMessages.COMPONENT_NAME); if( component != null && !component.getScope().isContextActive() ) { return; } //Attempting to get the instance anyway for backwards compatibility with some potential hack situations. StatusMessages statusMessages = instance(); if ( statusMessages != null ) { statusMessages.doRunTasks(); } }
protected static synchronized List<SeamComponentInfo> listNuxeoComponents() { if (components == null) { components = new ArrayList<>(); for (String cName : listAllComponentsNames()) { SeamComponentInfoImpl desc = new SeamComponentInfoImpl(); Component comp = Component.forName(cName); String className = comp.getBeanClass().getName(); // if (className.startsWith("org.nuxeo")) { if (!className.startsWith("org.jboss")) { desc.setName(cName); desc.setScope(comp.getScope().toString()); desc.setClassName(className); @SuppressWarnings("rawtypes") Set<Class> ifaces = comp.getBusinessInterfaces(); if (ifaces != null && ifaces.size() > 0) { for (Class<?> iface : ifaces) { desc.addInterfaceName(iface.getName()); } } desc.addInterfaceName(comp.getBeanClass().getName()); components.add(desc); } } Collections.sort(components); } return components; } }
/** * Registers a destruction callback with this bean. * * @param name bean name * @param destroy the destroy to set */ public void registerDestroyCallback(String name, Runnable destroy) { // Not sure yet how to register a stateless bean's Destruction callback. if (getScope() != ScopeType.STATELESS) { getScope().getContext().set(DESTRUCTION_CALLBACK_NAME_PREFIX + name, destroy); } }
else if ( component.getScope().isContextActive() ) log.warn("Cannot create Seam component, scope is not active: " + name + "(" + component.getScope().name() + ")");
if ( scope!=ScopeType.STATELESS && scope.isContextActive() ) scope.getContext().remove(name);
output.setScope( ScopeType.valueOf( scopeName.toUpperCase() ) );
/** * Starts a Seam Call if one is not available and if executing within a Spring * Transaction. */ public static void beginTransactionalSeamCall() { if (ScopeType.APPLICATION.isContextActive()) { log.debug("Application available. Won't start a new call"); return; } if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationManager .registerSynchronization(new SeamLifecycleSynchronization()); log.debug("Beginning Transactional Seam Call"); Lifecycle.beginCall(); return; } throw new IllegalStateException( "Seam application context not available and cannot be started. " + "Seam Managed Persistence Context not available. " + "Try placing the spring bean call inside of a spring transaction or try making the spring bean " + "a Seam Component using <seam:component/>."); }