Package org.springframework.context

Examples of org.springframework.context.ApplicationContext.containsBean()


        final ApplicationContext ctx = ((ConfigurableApplicationContext) schedulerContext.get("applicationContext"));

        // Try to re-create job bean from underlying task (useful for managing
        // failover scenarios)
        if (!ctx.containsBean(bundle.getJobDetail().getKey().getName())) {
            Long taskId = JobInstanceLoader.getTaskIdFromJobName(bundle.getJobDetail().getKey().getName());
            if (taskId != null) {
                TaskDAO taskDAO = ctx.getBean(TaskDAO.class);
                SchedTask task = taskDAO.find(taskId);
View Full Code Here


     * @see ClassUtils#getShortNameAsProperty(Class)
     */
    protected Object getServiceForClassType(Class serviceType) {
        String lookupName = ClassUtils.getShortNameAsProperty(serviceType);
        ApplicationContext ctx = getApplicationContext();
        if (ctx.containsBean(lookupName)) {
            Object bean = ctx.getBean(lookupName);
            if (serviceType.isAssignableFrom(bean.getClass())) {
                if(logger.isDebugEnabled()) {
                    logger.debug("Using bean '" + lookupName + "' (" + bean.getClass().getName() + ") for service " + serviceType.getName());
                }
View Full Code Here

        directoryProvider = (DirectoryProvider) appContext.getBean("directoryProvider", DirectoryProvider.class);
        alertProvider = (AlertProvider) appContext.getBean("alertProvider", AlertProvider.class);
        dataSourceProvider = (DataSourceProvider) appContext.getBean("dataSourceProvider", DataSourceProvider.class);
        propertiesProvider = (PropertiesProvider) appContext.getBean("propertiesProvider", PropertiesProvider.class);
       
        if (appContext.containsBean("scheduledReportCallbacks"))
        {
          callbacks = (List<ScheduledReportCallback>) appContext.getBean("scheduledReportCallbacks", List.class);
        }
       
        return appContext;
View Full Code Here

     */
    static class ContextHolder
    {
        public static IFolderLabelPolicy getLabelPolicy() {
            final ApplicationContext applicationContext = PortalApplicationContextLocator.getApplicationContext();
            if (applicationContext.containsBean(FOLDER_LABEL_POLICY)) {
                final IFolderLabelPolicy folderLabelPolicy = (IFolderLabelPolicy)applicationContext.getBean(FOLDER_LABEL_POLICY, IFolderLabelPolicy.class);
                return folderLabelPolicy;
            }

            return null;
View Full Code Here

        }

        Class pageClass = page.getClass();
        String beanName = toBeanName(pageClass);

        if (applicationContext.containsBean(beanName)
            || applicationContext.containsBean(pageClass.getName())) {

            // Beans are injected through Spring
        } else {
View Full Code Here

        Class pageClass = page.getClass();
        String beanName = toBeanName(pageClass);

        if (applicationContext.containsBean(beanName)
            || applicationContext.containsBean(pageClass.getName())) {

            // Beans are injected through Spring
        } else {

            // Inject any Spring beans into the page instance
View Full Code Here

    public final void testMockContext() {
        MockApplicationContextFactory factory = new MockApplicationContextFactory();
        ApplicationContext mockContext = factory.mockContext();

        assertNull(mockContext.getBean("mybean"));
        assertFalse(mockContext.containsBean("mybean"));
       
        Object object = new Object();
        factory.putBean("mybean", object);
        assertSame(object, mockContext.getBean("mybean"));
View Full Code Here

       
        Object object = new Object();
        factory.putBean("mybean", object);
        assertSame(object, mockContext.getBean("mybean"));

        assertTrue(mockContext.containsBean("mybean"));
        assertEquals(Object.class, mockContext.getType("mybean"));
    }
   
    public final void testStrictContext() {
        MockApplicationContextFactory factory = new MockApplicationContextFactory(true);
View Full Code Here

        }
        catch (NoSuchBeanDefinitionException e) {
            assertEquals("No bean named 'mybean' is defined", e.getMessage());
        }
       
        assertFalse(mockContext.containsBean("mybean"));
       
        Object object = new Object();
        factory.putBean("mybean", object);
        assertSame(object, mockContext.getBean("mybean"));
View Full Code Here

       
        Object object = new Object();
        factory.putBean("mybean", object);
        assertSame(object, mockContext.getBean("mybean"));

        assertTrue(mockContext.containsBean("mybean"));

        assertEquals(Object.class, mockContext.getType("mybean"));
    }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.