cancel
Showing results for 
Search instead for 
Did you mean: 

Access SpringProcessEngineConfiguration in rest-webapp

b_schnarr
Champ in-the-making
Champ in-the-making
Hello at all,

I need to inject custom configuration parameters into the rest webapp. Therefore, I want to use the existing activiti-context.xml and the processEngineConfigurationBean. But I do not succeed in accessing the processEngineConfigurationBean.
In another post, there is written: "You can always access the Spring application context and get the configuration bean from that."
But as I am not a skilled java developer, this information is not enough.

Could someone give me a little code example how I can read in those config parameters within a rest-class? Lets say I extend the standard bean:


<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
      <property name="dataSource" ref="dataSource" />
      <property name="transactionManager" ref="transactionManager" />
      <property name="databaseSchemaUpdate" value="true" />
      <property name="mailServerHost" value="localhost" />
      <property name="mailServerPort" value="5025" />
      <property name="jobExecutorActivate" value="false" />
        <property name="customFormTypes">
          <list>
            <bean class="org.activiti.rest.form.UserFormType"/>
            <bean class="org.activiti.rest.form.ProcessDefinitionFormType"/>
            <bean class="org.activiti.rest.form.MonthFormType"/>  
          </list>
        </property>
   </bean>


with the two parameters ltpaKey and ltpaPassword:


<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
      <property name="dataSource" ref="dataSource" />
      <property name="transactionManager" ref="transactionManager" />
      <property name="databaseSchemaUpdate" value="true" />
      <property name="mailServerHost" value="localhost" />
      <property name="mailServerPort" value="5025" />
      <property name="jobExecutorActivate" value="false" />
               <property name="ltpaKey" value="****" />
               <property name="ltpaPassword" value="***" />
        <property name="customFormTypes">
          <list>
            <bean class="org.activiti.rest.form.UserFormType"/>
            <bean class="org.activiti.rest.form.ProcessDefinitionFormType"/>
            <bean class="org.activiti.rest.form.MonthFormType"/>  
          </list>
        </property>
   </bean>


How can I access those values in the rest-classes?

Thank you very much and best regards
Ben
13 REPLIES 13

b_schnarr
Champ in-the-making
Champ in-the-making
The values are both null, so the values does´n get injected when I do it this way….

b_schnarr
Champ in-the-making
Champ in-the-making
Ok, this does not lead to a solution. Another idea: I just use a .properties-file containing those 2 Strings.
But the question is where I must create this file so that I can access it from my CustomRestAuthenticator and later on, configure it after the deployment?

Thanks and best regards
Ben

jbarrez
Star Contributor
Star Contributor
If it's a regular properties file - which you read wiht the java.util.Properties package it's just a matter of putting it on the classpath (shared lib , WEB-INF/…/class, or whatever web container you're using), and loading it in your custom class.

b_schnarr
Champ in-the-making
Champ in-the-making
Thank you very much. This worked!