public Component(Class<?> clazz, String componentName, ScopeType componentScope, boolean startup, String[] dependencies, String jndiName) { this(clazz, componentName, componentScope, startup, dependencies, jndiName, Contexts.getApplicationContext()); }
protected Context getApplicationContext() { return Contexts.getApplicationContext(); }
@Override public void sendMessage(Message message, Address[] recipients) throws MessagingException { Contexts.getApplicationContext().set(VAR_NAME, message); }
/** * Get the most recently rendered message sent using the MockTransport. */ public static void clearMailMessage() { Contexts.getApplicationContext().remove(VAR_NAME); }
/** * Get the most recently rendered message sent using the MockTransport. */ public static MimeMessage getMailMessage() { return (MimeMessage) Contexts.getApplicationContext().get(VAR_NAME); }
@Factory(value="org.jboss.seam.core.applicationContext", autoCreate=true) public Context getApplicationContext() { return org.jboss.seam.contexts.Contexts.getApplicationContext(); }
@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); }
public String[] getApplication() { String[] names = org.jboss.seam.contexts.Contexts.getApplicationContext().getNames(); Arrays.sort(names); return names; }
public void confirmOrder(long orderId) { Order order = (Order) em.createQuery( "select o from Order o where o.orderId = :orderId") .setParameter("orderId", orderId).getSingleResult(); order.setStatus(Order.Status.PROCESSING); Contexts.getApplicationContext().remove("deliveryDateTimer" + orderId); Contexts.getApplicationContext().remove("adminTimer" + orderId); }
protected static List<String> listAllComponentsNames() { List<String> names = new ArrayList<>(); if (Contexts.isApplicationContextActive()) { for (String name : Contexts.getApplicationContext().getNames()) { if (name.endsWith(".component")) { names.add(name.replace(".component", "")); } } } return names; }
protected void flushContextCache() { // A4J and Event cache don't play well ... Contexts.getApplicationContext().remove("registredConnectInstance"); Contexts.getApplicationContext().remove("connectUpdateStatusInfo"); appsViews.flushCache(); }
protected void flushContextCache() { // A4J and Event cache don't play well ... Contexts.getApplicationContext().remove("registredConnectInstance"); Contexts.getApplicationContext().remove("connectUpdateStatusInfo"); appsViews.flushCache(); }
public static CaptchaImage instance() { if ( !Contexts.isApplicationContextActive() ) { throw new IllegalStateException("No application context active"); } return (CaptchaImage) Contexts.getApplicationContext().get(CaptchaImage.class); }
public static Component forName(String name) { if ( !Contexts.isApplicationContextActive() ) { throw new IllegalStateException("No application context active"); } return (Component) Contexts.getApplicationContext().get( name + ".component" ); }
public static Init instance() { if ( !Contexts.isApplicationContextActive() ) { throw new IllegalStateException("No active application scope"); } Init init = (Init) Contexts.getApplicationContext().get(Init.class); //commented out because of some test cases: /*if (init==null) { throw new IllegalStateException("No Init exists"); }*/ return init; }
/** * Convenience method that retrieves the servlet context from application * scope. * * @return the current servlet context */ public static ServletContext getCurrentServletContext() { if (!Contexts.isApplicationContextActive()) { return servletContext; } return (ServletContext) Contexts.getApplicationContext().get(SERVLET_CONTEXT_KEY); }
protected Collection<Component> findSeamComponents() { // Iterate through all variables in the application context that end with ".component" log.debug("discovering all Seam components"); Collection<Component> seamComponents = new HashSet(); String[] applicationContextNames = Contexts.getApplicationContext().getNames(); for (String applicationContextName : applicationContextNames) { if (applicationContextName.endsWith(".component")) { Component seamComponent = (Component) Component.getInstance(applicationContextName, ScopeType.APPLICATION); seamComponents.add(seamComponent); } } return seamComponents; }
@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; }
protected void installMockTransport() { Contexts.getApplicationContext().set(Seam.getComponentName(MailSession.class), new MailSession("mock").create()); }