Example usage for org.springframework.context ApplicationContext getDisplayName

List of usage examples for org.springframework.context ApplicationContext getDisplayName

Introduction

In this page you can find the example usage for org.springframework.context ApplicationContext getDisplayName.

Prototype

String getDisplayName();

Source Link

Document

Return a friendly name for this context.

Usage

From source file:org.tradex.spring.ApplicationContextService.java

/**
 * Determines the unique ID assigned to the passed application context
 * @param appCtx application context to assign an ID for
 * @return the ID for the passed application context
 *///from ww w.  j a  va  2  s.com
protected static String getId(ApplicationContext appCtx) {
    String dn = appCtx.getDisplayName().trim();
    if (dn.isEmpty()) {
        return "#" + serial.incrementAndGet();
    }
    return dn;
}

From source file:org.jasig.springframework.context.BeanThatBroadcasts.java

public void setApplicationContext(ApplicationContext applicationContext) {
    this.applicationContext = applicationContext;
    if (applicationContext.getDisplayName().indexOf("listener") != -1) {
        applicationContext.getBean("listener");
    }//from  ww  w . j a v  a2s .c  o  m
}

From source file:org.sakaiproject.entitybroker.util.spring.EntityProviderAutoRegistrar.java

public void setApplicationContext(ApplicationContext context) throws BeansException {
    log.debug("setAC: " + context.getDisplayName());
    String[] autobeans = context.getBeanNamesForType(AutoRegisterEntityProvider.class, false, false);
    StringBuilder registeredPrefixes = new StringBuilder();
    for (String autobean : autobeans) {
        AutoRegisterEntityProvider register = (AutoRegisterEntityProvider) context.getBean(autobean);
        if (register.getEntityPrefix() == null || register.getEntityPrefix().equals("")) {
            // should this die here or is this error log enough? -AZ
            log.error(/*from   www  . j  av  a 2  s  .co m*/
                    "Could not autoregister EntityProvider because the enity prefix is null or empty string for class: "
                            + register.getClass().getName());
        } else {
            registeredPrefixes.append(" : " + register.getEntityPrefix());
            entityProviderManager.registerEntityProvider(register);
        }
    }
    log.info("AutoRegistered EntityProvider prefixes " + registeredPrefixes);
    // TODO - deal with de-registration in the case we ever support dynamic contexts.
}

From source file:org.echocat.jomon.spring.ContextLoadThreadGroup.java

@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    if (_name == null) {
        _name = applicationContext.getDisplayName();
    }/*from w w  w. j  ava 2  s  .  co  m*/
}

From source file:com.liferay.portal.spring.extender.internal.context.ModuleApplicationContextRegistrator.java

private void _refreshBeanFactory(ApplicationContext applicationContext) {
    try {//from ww  w .  j a v a 2s. co m
        BeanReferenceRefreshUtil.refresh(applicationContext.getAutowireCapableBeanFactory());
    } catch (Exception e) {
        _log.error(StringBundler.concat("Unable to refresh ", applicationContext.getDisplayName(),
                ". This may result in memory leaks on multiple ", "redeployments."));
    }
}

From source file:com.benfante.minimark.controllers.AdminController.java

@RequestMapping
public String spring(HttpServletRequest req, HttpServletResponse res, Model model) {
    ApplicationContext ctx = this.ctx;
    List<String> beans = new LinkedList<String>();
    while (ctx != null) {
        String[] beanNames = ctx.getBeanDefinitionNames();
        for (String beanName : beanNames) {
            Object bean = null;/*from  w  ww  . ja  v a 2 s  . c  o m*/
            try {
                bean = ctx.getBean(beanName);
                beans.add(beanName + " (" + bean.getClass() + ") [" + ctx.getDisplayName() + "]");
            } catch (BeansException beansException) {
                beans.add(beanName + " (only definition) [" + ctx.getDisplayName() + "]");
            }
        }
        ctx = ctx.getParent();
    }
    Collections.sort(beans);
    model.addAttribute("beans", beans);
    return "admin/spring";
}

From source file:com.griddynamics.banshun.web.ScanChildrenHandlerMapping.java

public void createHandlerMappingsAndRegisterHandlers(ApplicationContext child) {
    Map<String, HandlerMapping> matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(child,
            HandlerMapping.class, true, false);

    List<HandlerMapping> handlerMappings = new ArrayList<HandlerMapping>(matchingBeans.values());
    OrderComparator.sort(handlerMappings);
    handlerMappings.remove(this);
    if (handlerMappings.isEmpty()) {
        handlerMappings = createDefaultHandlerMappings(child);
        if (logger.isDebugEnabled()) {
            logger.debug("No HandlerMappings found in context '" + child.getDisplayName() + "': using default");
        }/*from  w w w. ja  va2 s. c  o  m*/
    }
    registerHandlers(handlerMappings);
}

From source file:org.atricore.idbus.kernel.main.mediation.camel.CamelIdentityMediationUnitContainer.java

public void init(IdentityMediationUnit u) throws IdentityMediationException {

    try {/*from w ww  . j  a  va  2 s. c o  m*/

        // We need a spring/camel IMU
        unit = (SpringMediationUnit) u;

        logger.info("Initializing Camel based Identity Mediation Engine with " + getMediators().size()
                + " mediators.");

        // ---------------------------------------------------------
        // Setup CXF, adding Camel transport programatically
        // ---------------------------------------------------------
        // TODO : THIST SHOULD BE DONE DECLARATIVE, USING SPRING DM!
        logger.debug("Configuring Camel Transport for CXF ... ");
        CamelTransportFactory camelTransportFactory = new CamelTransportFactory();
        camelTransportFactory.setTransportIds(new ArrayList<String>());
        camelTransportFactory.getTransportIds().add(CamelTransportFactory.TRANSPORT_ID);
        camelTransportFactory.setCamelContext(context);
        camelTransportFactory.setBus(bus);

        // registration the conduit initiator
        ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
        cim.registerConduitInitiator(CamelTransportFactory.TRANSPORT_ID, camelTransportFactory);

        /*
        org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory
                
        <value>http://schemas.xmlsoap.org/wsdl/http/</value>
        <value>http://schemas.xmlsoap.org/wsdl/soap/http</value>
        <value>http://www.w3.org/2003/05/soap/bindings/HTTP/</value>
        <value>http://cxf.apache.org/transports/http/configuration</value>
        <value>http://cxf.apache.org/bindings/xformat</value>
                
         */

        // registration the destination factory
        DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
        dfm.registerDestinationFactory(CamelTransportFactory.TRANSPORT_ID, camelTransportFactory);

        // set the bus as default
        // BusFactory.setDefaultBus(bus);

        ApplicationContext applicationContext = unit.getApplicationContext();
        logger.debug(
                "Binding Application Context [" + applicationContext.getDisplayName() + "] to JNDI Registry");

        ((JndiRegistry) context.getRegistry()).bind("applicationContext", applicationContext);
        template = context.createProducerTemplate();

        for (IdentityMediator mediator : getMediators()) {
            // pass on camel context
            mediator.init(this);
        }

    } catch (Exception e) {
        throw new IdentityMediationException(e);
    }
}

From source file:org.impalaframework.spring.module.graph.GraphDelegatingApplicationContext.java

private void maybeLogGetDependentBean(String name, ApplicationContext applicationContext) {
    if (logger.isDebugEnabled()) {
        logger.debug("Returning bean for bean name " + name + " from dependent application context "
                + applicationContext.getDisplayName());
    }//w  ww  .ja va  2 s  .c  o  m
}

From source file:org.springframework.context.RefreshedContextAttacherTest.java

@Test
public void testSingleOnContextInitializedCall() {
    final AtomicInteger counter = new AtomicInteger(0);
    RefreshedContextAttacher attacher = new RefreshedContextAttacher() {
        @Override/*from w  w w.j av a  2  s.  co m*/
        protected void onContextInitialized(ApplicationContext context) {
            super.onContextInitialized(context);
            logger.info("onContextInitialized(" + context.getDisplayName() + ") call count: "
                    + counter.incrementAndGet());
        }
    };
    ContextRefreshedEvent event = new ContextRefreshedEvent(applicationContext);
    for (int index = 1; index <= Byte.SIZE; index++) {
        attacher.onApplicationEvent(event);
        Assert.assertEquals("Mismatched number of calls at index=" + index, 1, counter.get());
    }
}