org.beanlet.springframework
Annotation Type SpringContext


@Retention(value=RUNTIME)
@Target(value={PACKAGE,TYPE,CONSTRUCTOR,METHOD,FIELD,PARAMETER})
public @interface SpringContext

Used to enabled Spring dependency injection.

A member can be injected with a Spring bean if a SpringContext is available for the specified member. Such a SpringContext can be defined at package-, class- or at member-level. There are two more requirements for members to support Spring beanlet injection:

Members marked with this annotation MUST also be annoted with Inject, otherwise the beanlet definition fails.

XML Representation

The following xml-fragments show how to express this annotation in xml. The 'spring-context' tags don't specify any element attribute, which means that this tag is applied to the beanlet's class.

 <beanlets xmlns="http://beanlet.org/schema/beanlet"
           xmlns:sf="http://beanlet.org/schema/springframework"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://beanlet.org/schema/beanlet http://beanlet.org/schema/beanlet/beanlet_1_0.xsd
                            http://beanlet.org/schema/springframework http://beanlet.org/schema/springframework/beanlet_springframework_1_0.xsd">
   <beanlet name="foo" type="com.acme.Foo">
     <sf:spring-contex path="spring.xml" type="CLASSPATH" format="XML" application-context="false"/>
   </beanlet>
 </beanlets>

Or:


 <beanlets xmlns="http://beanlet.org/schema/beanlet"
           xmlns:sf="http://beanlet.org/schema/springframework"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://beanlet.org/schema/beanlet http://beanlet.org/schema/beanlet/beanlet_1_0.xsd
                            http://beanlet.org/schema/springframework http://beanlet.org/schema/springframework/beanlet_springframework_1_0.xsd">
   <beanlet name="foo" type="com.acme.Foo">
     <sf:spring-contex application-context="false">
       <resource path="spring.xml" type="CLASSPATH" format="XML"/>
       <resource path="http://demo.beanlet.org/spring.xml" type="URL" format="XML"/>
     </sf:spring-context>
   </beanlet>
 </beanlets>

Or alternatively:


 <beanlets xmlns="http://beanlet.org/schema/beanlet"
           xmlns:sf="http://beanlet.org/schema/springframework"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://beanlet.org/schema/beanlet http://beanlet.org/schema/beanlet/beanlet_1_0.xsd
                            http://beanlet.org/schema/springframework http://beanlet.org/schema/springframework/beanlet_springframework_1_0.xsd">
   <beanlet name="foo" type="com.acme.Foo">
     <sf:spring-contex type="CLASSPATH" format="XML" application-context="false">
       <resource path="spring.xml"/>
       <resource path="http://demo.beanlet.org/spring.xml" type="URL"/>
     </sf:spring-context>
   </beanlet>
 </beanlets>

See Also:
Inject, Wiring

Required Element Summary
 SpringResource[] value
          Spring configuration resources.
 
Optional Element Summary
 boolean applicationContext
          Set to true for creating defining a Spring ApplicationContext, set to false to define a BeanFactory.
 

Element Detail

value

public abstract SpringResource[] value
Spring configuration resources.

applicationContext

public abstract boolean applicationContext
Set to true for creating defining a Spring ApplicationContext, set to false to define a BeanFactory.

Default:
false


Copyright © 2006-2012. All Rights Reserved.