Git Product home page Git Product logo

jsr-330's Introduction

JSR-330

Implementation of Java JSR-330 (actually partially implemented)

Exemple :

 public static void main(String[] args) throws InstantiationException, IllegalAccessException, IllegalArgumentException, NoImplementationException, DoesNotImplementException, NotAnInterfaceException, IsNotScopeException, AmbiguousImplementationsException {

        ContainerConfig config = new ContainerConfig() {
            @Override
            public void configure() throws NotAnInterfaceException, DoesNotImplementException, NoImplementationException, IsNotScopeException, InstantiationException, IllegalAccessException, AmbiguousImplementationsException {
                bind(Name2Service.class).to(Name2ServiceImpl.class);
                bind(Name2Service.class).annotatedWith(Touch.class).to(NameTouchServiceImpl.class);
                bind(Name2Service.class).annotatedWith(Touch1.class, Touch2.class).to(NameMultiTouchServiceImpl.class);
                bind(Name2Service.class).annotatedWith(LeJoliSingleton.class).to(SingleServiceImpl.class).withScope(Singleton.class);
                bind(Name2Service.class).named("CocoLasticot").to(NamedServiceImpl.class);
            }
        };

        DIContainer container = DIContainer.createWith(config);

        ModuleTest1 mt1 = container.getInstance(ModuleTest1.class);
        mt1.shootM2();
        mt1.shootMTouch();
        mt1.shootMultiTouch();
        mt1.shootSingleton1();
        mt1.shootSingleton2();
        mt1.shootCocoLasticot();
    }

    public ModuleTest1() {
    }
    
    @Inject
    private Name2Service name2service;

    public void shootM2() {
        System.out.println(name2service.give2Name());
    }
    
    @Inject
    @Touch
    private Name2Service nameTouchService;

    public void shootMTouch() {
        System.out.println(nameTouchService.give2Name());
    }
    
    @Inject
    @Touch1 @Touch2
    private Name2Service nameMultiTouchService;

    public void shootMultiTouch() {
        System.out.println(nameMultiTouchService.give2Name());
    }
    
    @Inject
    @LeJoliSingleton
    private Name2Service singletonService1;

    public void shootSingleton1() {
        System.out.println(singletonService1.give2Name());
    }
    
    @Inject
    @LeJoliSingleton
    private Name2Service singletonService2;

    public void shootSingleton2() {
        System.out.println(singletonService2.give2Name());
    }
    
    @Inject
    @Named("CocoLasticot")
    private Name2Service namedService2;

    public void shootCocoLasticot() {
        System.out.println(namedService2.give2Name());
    }
}

jsr-330's People

Contributors

julienderay avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.