All contributions are welcome!

I would imagine that the most practical approach would be to add a new 
namespace handler called fluent, builder or similar. This could be provided as 
a new bundle in the blueprint project.

Adding some XML along the lines of the following to your blueprint:

<bean class="builderClass" fluent:begin-method="getConfigurable" 
fluent:end-method="create">

  <argument>2</argument>

  <fluent:configure method="setJDBCURL" value="someValue"/>
  <fluent:configure method="autoCommit">
      <value>true</value>
  <fluent:configure method="addListener" ref="someBeanId"/>
</bean>


could result in a configured bean using a fluent API like

builderClass.getConfigurable(2).setJDBCURL("someValue").autoCommit(true).addListener(blueprintBean).create();

Under the covers the namespace handler can turn the bean metadata into a 
"normal" blueprint metadata tree like the really verbose XML I gave as an 
example before.

What do you think?

Regards,

Tim Ward
-------------------
Apache Aries PMC member & Enterprise OSGi advocate
Enterprise OSGi in Action (http://www.manning.com/cummins)
-------------------


From: l...@code-house.org
Subject: Re: Aries and fluent builders
Date: Thu, 15 Dec 2011 09:42:40 +0100
To: user@aries.apache.org



Timothy,If you could give an advice where to start, I can experiment. Maybe we 
can add an attribute from additional namespace (aries-util?) which will mark an 
field as non standard java bean and let inject given value? But, it is possible 
to extend a <property> behavior somehow?
Regards,LukaszWe could look at adding some better fluent support in Aries 
blueprint (although it would be in a non-standard namespace). It might be a 
while before there was anything actually in trunk though.

Regards

Tim Ward
-------------------
Apache Aries PMC member & Enterprise OSGi advocate
Enterprise OSGi in Action (http://www.manning.com/cummins)
-------------------


From: l...@code-house.org
Subject: Re: Aries and fluent builders
Date: Thu, 15 Dec 2011 09:26:37 +0100
To: user@aries.apache.org

Hey Timothy,I know that solution proposed by you will work but it will mess a 
XML. Once I'll need to inject more values I will have 100 lines only to put 
true or false in some fields.
Regards,Lukasz
Hi,

It's not very concise, but this should work:

    <bean id="processEngineConfiguration1" 
class="org.activiti.engine.ProcessEngineConfiguration" 
factory-method="createStandaloneInMemProcessEngineConfiguration"/>

    <bean id="processEngineConfiguration2" 
factory-ref="processEngineConfiguration1" 
factory-method="setDatabaseSchemaUpdate">
      <argument value="false"/>
    </bean>

    <bean id="processEngineConfiguration3" 
factory-ref="processEngineConfiguration2" factory-method="setDataSource">
      <argument>
        <bean class="org.h2.jdbcx.JdbcDataSource">
          <property name="url" value="jdbc:h2:mem:activiti" />
        </bean>
      </argument>
    </bean>

    <bean id="processEngineConfiguration4" 
factory-ref="processEngineConfiguration3" 
factory-method="setJobExecutorActivate">
      <argument value="true"/>
    </bean>


    <bean id="processEngine" factory-ref="processEngineConfiguration4" 
factory-method="buildProcessEngine"/>
If you're interested in more information about advanced blueprint techniques 
then you may find Enterprise OSGi in Action to be a useful resource. You can 
get 37% off if you use the code eosgi37 at the Manning website - 
http://www.manning.com/cummins 

Regards,

Tim Ward
-------------------
Apache Aries PMC member & Enterprise OSGi advocate
Enterprise OSGi in Action (http://www.manning.com/cummins)
-------------------


From: l...@code-house.org
Subject: Aries and fluent builders
Date: Thu, 15 Dec 2011 08:58:47 +0100
To: user@aries.apache.org

Hello,I tried to use Aries instead of Spring to configure Activiti process 
engine. The problem I meet was related to fluent builders. Activiti can be 
configured with fluent builder, for example:
ProcessEngine processEngine = 
ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
  .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
  .setJdbcUrl("jdbc:h2:mem:my-own-db;DB_CLOSE_DELAY=1000")
  .setJobExecutorActivate(true)
  .buildProcessEngine();
I ported this fragment to an XML fragment:
    <bean id="processEngineConfiguration" 
class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration"> 
       <property name="jobExecutorActivate" value="true" />        <property 
name="databaseSchemaUpdate" value="false" />        <property 
name="dataSource">            <bean class="org.h2.jdbcx.JdbcDataSource">        
        <property name="url" value="jdbc:h2:mem:activiti" />            </bean> 
       </property>    </bean>    <bean id="processEngine" 
factory-ref="processEngineConfiguration" factory-method="buildProcessEngine">   
 </bean>
The error reported by blueprint 
is:org.osgi.service.blueprint.container.ComponentDefinitionException: No setter 
for jobExecutorActivate property
The jobExecutorActivate property returns an instance of 
ProcessEngineConfiguration so it is not a regular Java Bean property. Do you 
have any ideas how to manage both - Aries and Activiti to work together?
Best regards,Lukasz

                                          

Reply via email to