Example usage for org.springframework.context.support AbstractApplicationContext getBeanDefinitionNames

List of usage examples for org.springframework.context.support AbstractApplicationContext getBeanDefinitionNames

Introduction

In this page you can find the example usage for org.springframework.context.support AbstractApplicationContext getBeanDefinitionNames.

Prototype

@Override
    public String[] getBeanDefinitionNames() 

Source Link

Usage

From source file:rooms.Application.java

public static void main(String[] args) throws ValueException, ThingException, InterruptedException {

    AbstractApplicationContext context = new AnnotationConfigApplicationContext(RoomConfig.class);
    //AbstractApplicationContext context = new AnnotationConfigApplicationContext(RoomConfigMongo.class);

    //        MongoOperations mo = (MongoOperations) context.getBean("mongoTemplate");
    final ThingControl tc = (ThingControl) context.getBean("thingControl");

    for (String s : context.getBeanDefinitionNames()) {
        System.out.println(s);//  w w w.  jav  a  2 s  .  c om
    }

    System.out.println("THINGSSSS");
    for (Thing t : tc.findAllThings()) {
        System.out.println("THING: " + t);
    }

    //        mo.dropCollection(Thing.class);
    //        mo.dropCollection(Bridge.class);
    //        mo.dropCollection(Light.class);

    List<Thing> t = tc.findThingsForType("bridge");

    Bridge b = new Bridge("10.0.0.40");
    Thing tb = tc.createThing("bridge", b);

    Light l = new Light(Group.GROUP_1, "white");
    Thing tl = tc.createThing("bedroom_ceiling", l);

    Light l2 = new Light(Group.GROUP_2, "white");
    Thing tl2 = tc.createThing("bedroom_bed", l2);

    Light l3 = new Light(Group.GROUP_3, "white");
    Thing tl3 = tc.createThing("bedroom_desk", l3);

    tc.addChildThing(tb, tl);
    tc.addChildThing(tb, tl2);
    tc.addChildThing(tb, tl3);

    List<Thing<Bridge>> bridges = tc.findThingsForType(Bridge.class);

    Map<String, LightWhiteV2> lights = Maps.newHashMap();

    for (Thing<Bridge> bridgeThing : bridges) {

        Bridge bridge = tc.getValue(bridgeThing);
        LimitlessLEDControllerV2 c = new LimitlessLEDControllerV2(b.getHost(), b.getPort());

        List<Thing<Light>> lightThings = tc.getChildrenForType(Observable.just(bridgeThing), Light.class, true);
        for (Thing<Light> tempLight : lightThings) {
            Light ll = tc.getValue(tempLight);
            LightWhiteV2 white = new LightWhiteV2(tempLight.getKey(), c, ll.getLightGroup());
            lights.put(white.getName(), white);
            System.out.println("LIGHT: " + white.getName());
        }
    }

    //        lights.get("bedroom_ceiling").setOn(true);
    lights.get("bedroom_bed").setOn(true);
    Thread.sleep(2000);
    //        lights.get("bedroom_ceiling").setOn(false);
    lights.get("bedroom_bed").setOn(false);
    Thread.sleep(2000);

}

From source file:de.javadesign.cdi.extension.spring.SpringBeanIntegrationExtension.java

/**
 * Register found beans from the application context.
 * /*from   w  w  w.java 2s.  com*/
 * @param applicationContext
 *            the spring application context
 * @param event
 *            the AfterBeanDiscoveryEvent
 */
private void registerBeans(final AbstractApplicationContext applicationContext, final AfterBeanDiscovery event,
        final BeanManager beanManager) {
    final String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
    final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
    Bean<?> springBean = null;
    for (final String beanName : beanDefinitionNames) {
        final BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName);
        springBean = createBean(beanName, beanDefinition, beanFactory, beanManager);

        if (springBean != null) {
            LOGGER.debug("Register Bean: {}.", springBean);
            event.addBean(springBean);
        }
    }

}