You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@aries.apache.org by Frizz <fr...@googlemail.com> on 2016/02/17 20:16:14 UTC

Accessing Blueprint beans in Java code

I have a complex object that I define in a Blueprint XML file (with , ref=,
...). It’s composed of various other objects that are also defined in
Blueprint, like this:

<bean id=”complexObject”>
        <property name=”subObject1” ref=”subObject1ref” />
        <property name=”subObject2” ref=”subObject2ref” />   ...
</bean>
<bean id=”subObject1ref”>
   ...</bean>

Now I want to make a FactoryClass that creates those complex objects. I
don’t want to move all my Blueprint XML code to Java (using new object,
object.setBlaBla(), etc.).

Is it possible that I keep the object setup and wiring in Blueprint, and
access the object from my Java code?

public class FactoryClass {
        MyComplexObject createMyComplexObject() {
                instance = Get a new instance of my “complexObject”
bean from my the Blueprint XML
                return instance;
        }}

RE: Accessing Blueprint beans in Java code

Posted by CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>.
Hello,

What do you mean “access the object from my Java code”?

Basic is you may create beans from Blueprint and inject them in Java via constructors or setters. Bean creation might be from regular “constructor call”, or via static or instance factories. The injections will remain the same regardless of how you instantiated your beans.

JP


De : Frizz [mailto:frizzthecat@googlemail.com]
Envoyé : mercredi 17 février 2016 20:16
À : user@aries.apache.org
Objet : Accessing Blueprint beans in Java code


I have a complex object that I define in a Blueprint XML file (with , ref=, ...). It’s composed of various other objects that are also defined in Blueprint, like this:

<bean id=”complexObject”>

        <property name=”subObject1” ref=”subObject1ref” />

        <property name=”subObject2” ref=”subObject2ref” />

   ...
</bean>



<bean id=”subObject1ref”>

   ...

</bean>

Now I want to make a FactoryClass that creates those complex objects. I don’t want to move all my Blueprint XML code to Java (using new object, object.setBlaBla(), etc.).

Is it possible that I keep the object setup and wiring in Blueprint, and access the object from my Java code?

public class FactoryClass {

        MyComplexObject createMyComplexObject() {

                instance = Get a new instance of my “complexObject” bean from my the Blueprint XML

                return instance;

        }

}