Package com.github.jsr330.instance

Examples of com.github.jsr330.instance.DefaultClassInjector


    }
   
    @SuppressWarnings("unchecked")
    @Test
    public void conditionalInterfaceNonConfirming() {
        TypeConfig config = defaultBinder.instance(TestInterface.class).as(TestImplementation1.class).when((BindingCondition<TestInterface>) nonConfirming)
                .build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestInterface.class, null, null, null);
        assertNull(container);
    }
View Full Code Here


    }
   
    @SuppressWarnings("unchecked")
    @Test
    public void conditionalInterfaceConfirming() {
        TypeConfig config = defaultBinder.instance(TestInterface.class).as(TestImplementation1.class).when((BindingCondition<TestInterface>) confirming)
                .build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestInterface.class, null, null, null);
        assertNotNull(container);
        assertEquals(TestImplementation1.class, container.getType());
        assertFalse(container.isSingleton());
        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
    }
View Full Code Here

    }
   
    @SuppressWarnings("unchecked")
    @Test
    public void conditionalSingletonInterfaceNonConfirming() {
        TypeConfig config = defaultBinder.instance(TestInterface.class).asSingleton(TestImplementation1.class)
                .when((BindingCondition<TestInterface>) nonConfirming).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestInterface.class, null, null, null);
        assertNull(container);
    }
View Full Code Here

    }
   
    @SuppressWarnings("unchecked")
    @Test
    public void conditionalSingletonInterfaceConfirming() {
        TypeConfig config = defaultBinder.instance(TestInterface.class).asSingleton(TestImplementation1.class)
                .when((BindingCondition<TestInterface>) confirming).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestInterface.class, null, null, null);
        assertNotNull(container);
        assertEquals(TestImplementation1.class, container.getType());
        assertTrue(container.isSingleton());
        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
    }
View Full Code Here

    }
   
    @SuppressWarnings("unchecked")
    @Test
    public void conditionalSimpleTypeNonConfirming() {
        TypeConfig config = defaultBinder.instance(TestImplementation1.class).as(TestImplementation1.class)
                .when((BindingCondition<TestImplementation1>) nonConfirming).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestImplementation1.class, null, null, null);
        assertNull(container);
    }
View Full Code Here

    }
   
    @SuppressWarnings("unchecked")
    @Test
    public void conditionalSimpleTypeConfirming() {
        TypeConfig config = defaultBinder.instance(TestImplementation1.class).as(TestImplementation1.class)
                .when((BindingCondition<TestImplementation1>) confirming).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestImplementation1.class, null, null, null);
        assertNotNull(container);
        assertEquals(TestImplementation1.class, container.getType());
        assertFalse(container.isSingleton());
        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
    }
View Full Code Here

    }
   
    @SuppressWarnings("unchecked")
    @Test
    public void conditionalSingletonSimpleTypeNonConfirming() {
        TypeConfig config = defaultBinder.instance(TestImplementation1.class).asSingleton(TestImplementation1.class)
                .when((BindingCondition<TestImplementation1>) nonConfirming).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestImplementation1.class, null, null, null);
        assertNull(container);
    }
View Full Code Here

    }
   
    @SuppressWarnings("unchecked")
    @Test
    public void conditionalSingletonSimpleTypeConfirming() {
        TypeConfig config = defaultBinder.instance(TestImplementation1.class).asSingleton(TestImplementation1.class)
                .when((BindingCondition<TestImplementation1>) confirming).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestImplementation1.class, null, null, null);
        assertNotNull(container);
        assertEquals(TestImplementation1.class, container.getType());
        assertTrue(container.isSingleton());
        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
    }
View Full Code Here

   
    /**
     * Gets the {@link TypeConfig} by parsing the XML file. The correct sequence is ensured by the corresponding XSD file.
     */
    public TypeConfig getConfig(final ClassLoader loader) throws IOException, SAXException {
        final ConfigBuilder builder = new ConfigBuilder();
        XMLReader sax;
       
        if (source != null) {
            try {
                sax = XMLReaderFactory.createXMLReader();
                sax.setContentHandler(new ConfigHandler(loader, builder));
                sax.parse(new InputSource(source));
               
                return builder.build();
            } finally {
                try {
                    source.close();
                } catch (IOException exception) {
                    LOGGER.debug("error while closing reader.", exception);
View Full Code Here

     * Gets the type configs out of the json source.
     * A wrong sequence will lead to a {@link BinderException}.
     */
    public TypeConfig getConfig(ClassLoader loader) throws JsonProcessingException, IOException {
        JsonNode node;
        ConfigBuilder builder = new ConfigBuilder();
       
        if (source != null) {
            try {
                node = mapper.readTree(source);
                if (node.isArray()) {
                    for (int i = 0; i < node.size(); i++) {
                        parseConfig(loader, builder.get(), node.get(i));
                    }
                    return builder.build();
                }
            } finally {
                try {
                    source.close();
                } catch (IOException exception) {
View Full Code Here

TOP

Related Classes of com.github.jsr330.instance.DefaultClassInjector

Copyright © 2018 www.massapicom. 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.