@Override public void sendMessage(Message message, Address[] recipients) throws MessagingException { Contexts.getApplicationContext().set(VAR_NAME, message); }
public void setSearchFilter(String searchFilter) { Context pageContext = Contexts.getPageContext(); if (pageContext != null) { pageContext.set("searchFilter", searchFilter); } this.searchFilter = searchFilter; }
@Override public void setChangeableDocument(DocumentModel changeableDocument) { if (log.isDebugEnabled()) { log.debug("Setting changeable document to: " + changeableDocument); } this.changeableDocument = changeableDocument; Contexts.getEventContext().set("changeableDocument", changeableDocument); }
public void setupCurrentUser() { Principal currentUser = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal(); sessionContext.set("currentUser", currentUser); }
public void setHtml5DndEnabled(boolean enabled) { Contexts.getSessionContext().set("useHtml5DragAndDrop", enabled); }
protected void setupCurrentUser() { sessionContext.set("currentUser", getUser()); }
protected void setupCurrentUser() { sessionContext.set("currentUser", getUser()); }
@OperationMethod public DocumentModel push(DocumentModel value) { if ("session".equalsIgnoreCase(scope)) { Contexts.getSessionContext().set(name, value); } else if ("conversation".equalsIgnoreCase(scope)) { Contexts.getConversationContext().set(name, value); } else if ("page".equalsIgnoreCase(scope)) { Contexts.getPageContext().set(name, value); } else if ("event".equalsIgnoreCase(scope)) { Contexts.getEventContext().set(name, value); } return value; }
/** * Restores the state of the event context. If the value is stored away, it is restored * It it was not in the map, it was not in the context in the first place so clean * up what we have placed there during this run. * * @param names The list of context keys to restore * @param context The context to target */ private void restoreOriginalValues(String[] names, Context context) { for (String name : names) { if (originalValues.containsKey(name)) { context.set(name, originalValues.get(name)); } else { context.remove(name); } } }
public Object createResource(HttpRequest request, HttpResponse response, InjectorFactory factory) { // Push this onto event context so we have it available in ResteasyContextInjectionInterceptor Contexts.getEventContext().set(ResteasyContextInjectionInterceptor.RE_HTTP_REQUEST_VAR, request); Contexts.getEventContext().set(ResteasyContextInjectionInterceptor.RE_HTTP_RESPONSE_VAR, response); log.debug("creating RESTEasy resource instance by looking up Seam component: " + seamComponent.getName()); return Component.getInstance(seamComponent.getName()); }
private void saveWrapper(Object bean, Component component, Field field, Object dataModel, Object value) throws Exception { Contexts.getConversationContext().set( getFieldId(component, field), value ); if (dataModel==null) { Reflections.set(field, bean, null); } else { // JBSEAM-1814, JBPAPP-1616 Clearing the wrapped data is simply unnecessary. Either we leave it alone, or we set the field to null. //setWrappedData(dataModel, null); } }
/** * 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); } }
@SuppressWarnings("unchecked") private static Map<String, String> getSpringComponentNameMap() { if (Contexts.getApplicationContext().get(SPRING_COMPONENT_NAME_MAP) == null) { Contexts.getApplicationContext().set(SPRING_COMPONENT_NAME_MAP, new HashMap<String, String>()); } return (Map<String, String>) Contexts.getApplicationContext().get(SPRING_COMPONENT_NAME_MAP); }
/** * @return a cache that stores fields annotated with the @Inject annotation for the Guice component classes */ @SuppressWarnings("unchecked") private Map<Class,Collection<Field>> getGuiceComponentFieldsMap() { if (Contexts.getApplicationContext().get(GUICE_COMPONENT_FIELDS_MAP) == null) { Contexts.getApplicationContext().set(GUICE_COMPONENT_FIELDS_MAP, new HashMap<Class, Collection<Field>>()); } return (Map<Class, Collection<Field>>) Contexts.getApplicationContext().get(GUICE_COMPONENT_FIELDS_MAP); }
protected void installMockTransport() { Contexts.getApplicationContext().set(Seam.getComponentName(MailSession.class), new MailSession("mock").create()); }
@SuppressWarnings("deprecation") public static Model forClass(Class clazz) { if ( !Contexts.isApplicationContextActive() ) { throw new IllegalStateException("No application context active"); } String name = getModelName(clazz); Model model = (Model) Contexts.getApplicationContext().get(name); if ( model==null ) { model = clazz.isAnnotationPresent(javax.persistence.Entity.class) ? new Entity(clazz) : new Model(clazz); Contexts.getApplicationContext().set(name, model); } return model; }
public void out() { getScope().getContext().set( getName(), getValue().getValue() ); }
@Observer(Identity.EVENT_POST_AUTHENTICATE) public void setUserAccountForSession() { if (Contexts.isEventContextActive() && Contexts.isSessionContextActive()) { Contexts.getSessionContext().set(AUTHENTICATED_USER, Contexts.getEventContext().get(AUTHENTICATED_USER)); } }
private ResolverChain createDefaultResolverChain() { ResolverChain chain = (ResolverChain) Contexts.getSessionContext().get(DEFAULT_RESOLVER_CHAIN); if (chain == null) { chain = new ResolverChain(); for (String resolverName : Init.instance().getPermissionResolvers()) { chain.getResolvers().add((PermissionResolver) Component.getInstance(resolverName, true)); } Contexts.getSessionContext().set(DEFAULT_RESOLVER_CHAIN, chain); if (Events.exists()) Events.instance().raiseEvent(DEFAULT_RESOLVER_CHAIN_CREATED, chain); } return chain; }
/** * Will attempt to authenticate quietly if the user's credentials are set and they haven't * authenticated already. A quiet authentication doesn't throw any exceptions if authentication * fails. * * @return true if the user is logged in, false otherwise */ public boolean tryLogin() { if (!authenticating && getPrincipal() == null && credentials.isSet() && Contexts.isEventContextActive() && !Contexts.getEventContext().isSet(LOGIN_TRIED)) { Contexts.getEventContext().set(LOGIN_TRIED, true); quietLogin(); } return isLoggedIn(); }