Skip to end of metadata
Go to start of metadata

What is Yan?

Yan container stands for Yet Another Non-intrusive container for object dependency injection.

The core of Yan is a compact Java API with no dependency to any other lib.

Around the tiny core, are services such as component monitoring, life cycle management, xml configuration etc.

For xml configuration support, see Nuts.

How is Yan similar to other IoC containers like PicoContainer and Spring?

  • They all support type 1, type 2 and type3 dependency injection.
  • They all provide a Java API that enables the container to be used programatically.
  • Both manual wiring and some sort of auto wiring are provided.
  • The API is typically non-intrusive in the sense that the components managed by the container can have no dependency onto the container so that can be used outside of the container.
  • Containers can be managed in a hierarchy. See Yan container hierarchy

How does Yan differ from other IoC containers?

  • "What type of injection is supported?" is no more a question.
    Yan supports literally any type of injection you can imagine. Constructor injection, setter injection, factory injection, factory then setter injection, factory then factory then setter then field then method injection, blah blah blah. Anything doable in Java code can be achieved declaratively with no need to procedurally implement a big fat interface like ComponentAdapter.
    See Dependency Injection Types.
  • Maintainable components. Components such as sub-components, parameters, properties can be nested or scoped locally without registered into container, thus avoids messing up the global namespace of components.
  • Extensible xml configuration ability. Custom tags can be built to implement sophisticated components. Spring can be integrated to take advantage of Spring's various services such as Spring AOP. See Nuts for more info.
  • Lifecycle can be defined and managed for both singleton and prototype components in exactly the same way.
    Any method or logic can be used in lifecycle. Parameters can also be passed to lifecycle.
    See Lifecycle for further discussion.
  • Yan utilizes combinatorory logic that's proved powerful in the community of functional programming.
    Arbitrarily complex components can be constructed by declaratively combining simpler components, which may be combinations of yet simpler components. See Everything is Component
  • Nuts facilities like extensible auto-wiring mode, customizable tags, extensible auto-registration, concise collection literal together make xml configuration much easier and maintainable.

Why do I need Yan?

  • Object dependencies may become unwieldy to manage for a big application using ioc design.
  • Yan demands no configuration file, which makes it ideal to be embedded programmatically into other applications.
  • Yan does offer an XML configuration support though. When you do want an xml configuration, see Nuts the xml dialect of Yan. Find out how much more concise it is than your current xml based container.

Still in doubt? See What's all the fuss about IoC Container?.

PicoContainer has more to say about "Why IoC Container".

What are "Component", "Component Instance", "Container"?

Component instances are business objects in the application domain. They are objects of your classes such as Vehicle, Fruit, BankAccount, Person, blah blah blah. These classes may each require a different way to create objects. For example, constructor, static factory, factory method, prototype, or any other possible way in Java.
Yan has no requirement for these classes to implement any interface, to extend any class, to expose any constructor or factory method or java bean setters.

Component, in Yan's terminology, is an object encapsulating the object creation logic. Yan programmer uses Component to describe the ways to create component instances. If you know PicoContainer, it is similar concept as ComponentAdapter.

Container, is an object that manages Component. It is also responsible for instantiating component instances using the Component objects stored in it.

What is Dependency Injection?

Dependency Injection is a design pattern where you simply declare the dependencies of your object and assume they will eventually be injected into the object.

Some discussions about Dependency Injection can be found here.

License

Yan is licensed under BSD style license. So it's free to both commercial and open source use.

News

Blog Posts

Contacts

Ben Yu

  • No labels