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; }
/** * 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); } }
private static Object handleFactoryMethodResult(String name, Component component, Object result, ScopeType scope) { // see if a value was outjected by the factory method Object value = Contexts.lookupInStatefulContexts(name); if (value == null) { // usually a factory method returning a value ScopeType outScope = getOutScope(scope, component); if (outScope != STATELESS) { // the null check is for page scope, which doesn't handle setting a null value if (result != null) { outScope.getContext().set(name, result); } // shouldn't need to call remove since there wasn't previously a value } return result; } else { // usually a factory method with a void return type if (scope != UNSPECIFIED) { throw new IllegalArgumentException("factory method with defined scope outjected a value: " + name); } return value; } }
/** * Calls the spring destroy callback when seam destroys the component * * @see org.jboss.seam.Component#callDestroyMethod(Object) */ @Override public void destroy(Object instance) { super.destroy(instance); // Cannot call the callback on a STATELESS bean because we have no way of storing it. if (getScope() != ScopeType.STATELESS) { Runnable callback = (Runnable) getScope().getContext().get(DESTRUCTION_CALLBACK_NAME_PREFIX + getName()); if (callback != null) { callback.run(); } } }
public void out() { getScope().getContext().set( getName(), getValue().getValue() ); }
public void in() { Object object = getScope()==null ? Component.getInstance( getName() ) : getScope().getContext().get( getName() ); getValue().setValue( object ); }
private void remove() { getComponent().getScope().getContext().remove( getComponent().getName() ); if ( log.isDebugEnabled() ) { log.debug( "Stateful component was removed: " + getComponent().getName() ); } }
outScope.getContext().remove(name); outScope.getContext().set(name, value);
private static Object createInstanceFromFactory(String name, ScopeType scope, Init.FactoryMethod factoryMethod, Object factory) { // check whether there has been created an instance by another thread // while waiting for this function's lock if (scope != STATELESS) { Object value = (scope == null) ? Contexts.lookupInStatefulContexts(name) : scope.getContext().get(name); if (value != null) { return value; } } if (factory == null) { return null; } else { Object result = factoryMethod.getComponent().callComponentMethod(factory, factoryMethod.getMethod()); return handleFactoryMethodResult(name, factoryMethod.getComponent(), result, factoryMethod.getScope()); } }
getScope().getContext().set(name, instance); getScope().getContext().remove(name);
if (component != null) bean = scope.getContext().get(component.getName()); if (bean != null) // in a portal environment, this is possible scope.getContext().remove(component.getName());
/** * Startup a component and all its dependencies */ static void startup(Component component) { if ( component.isStartup() ) { for ( String dependency: component.getDependencies() ) { Component dependentComponent = Component.forName(dependency); if (dependentComponent!=null) { startup(dependentComponent); } } } if ( !component.getScope().getContext().isSet( component.getName() ) ) { log.debug( "starting up: " + component.getName() ); component.newInstance(); } }
ScopeType scope = wrapper.getVariableScope(dataModelAnn); Object dataModel = getOutScope(scope, this).getContext().get(name); if ( dataModel!=null )
Annotation dataModelAnn = dataModelGetter.getAnnotation(); ScopeType scope = wrapper.getVariableScope(dataModelAnn); Context context = getOutScope(scope, this).getContext(); Object existingDataModel = context.get(name);
result = in.scope().getContext().get(name);
if ( scope!=ScopeType.STATELESS && scope.isContextActive() ) scope.getContext().remove(name);
if ( observer.getComponent().hasUnwrapMethod() ) listener = observer.getComponent().getScope().getContext().get(name);