Access SpringProcessEngineConfiguration in rest-webapp

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2014 10:28 AM
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
- Labels:
-
Archive

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2014 03:13 AM
So you changed the SpringProcessEngineConfiguration class and added these additional properties (ltpaKey and ltpaPassword) ?
Because that would be needed for this solution.
You could create a separate Bean definition in activiti-context.xml and using ProcessEngines.getDefaultProcessEngine().getProcessEngineConfiguration() you can get access to the SpringProcessEngineConfiguration instance. From that class you can get the Spring ApplicationContext and get to your bean. Spring also offers ways to retrieve the application context in other ways.
Best regards,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2014 07:11 AM
thanks for your reply. I tried what you said: ProcessEngines.getDefaultProcessEngine().getProcessEngineConfiguration()
But getProcessEngineConfiguration() is not available, only getFormService(), getHistoryService(), getIdenticyService() etc….
Did I understand you right that I could define this bean here in the activiti-context.xml:
<code>
<bean id="ltpaParameters" class="org.activiti.rest.common.filter.RestAuthenticatorImpl">
<property name="ltpaKey" value="***" />
<property name="ltpaPassword" value="***" />
</bean>
</code>
But still the question how to access this? Would it be enough to create the getters / setters for injection or do I have do make more?
Thank you very much and best regards
Ben

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2014 04:35 PM
Which Activiti version are you using? I see the following methods in EngineServices:
<blockcode>
public interface EngineServices {
RepositoryService getRepositoryService();
RuntimeService getRuntimeService();
FormService getFormService();
TaskService getTaskService();
HistoryService getHistoryService();
IdentityService getIdentityService();
ManagementService getManagementService();
ProcessEngineConfiguration getProcessEngineConfiguration();
}
</blockcode>
And ProcessEngine extends EngineServices.
Best regards,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2014 04:39 AM
Thanks and best regards
Ben
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2014 04:51 AM
No idea why Eclipse wouldn't show it … it's right there on the interface:
public interface ProcessEngine extends EngineServices {

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2014 04:33 AM
<code>
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine;
/**
* Interface implemented by all classes that expose the Activiti services.
*
* @author Joram Barrez
*/
public interface EngineServices {
RepositoryService getRepositoryService();
RuntimeService getRuntimeService();
FormService getFormService();
TaskService getTaskService();
HistoryService getHistoryService();
IdentityService getIdentityService();
ManagementService getManagementService();
}
</code>
And I use 5.15.1
Has anyone an idea?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2014 06:00 AM
I created this bean in activiti-context.xml:
<code>
<bean id="ltpaParameters" class="org.activiti.rest.common.filter.RestAuthenticatorImpl">
<property name="ltpaKey" value="***" />
<property name="ltpaPassword" value="***" />
</bean>
</code>
After adding <code>ProcessEngineConfiguration getProcessEngineConfiguration()</code> to the interface, I can access this service. But now, what is the next step to get my both string values?
<code>ProcessEngines.getDefaultProcessEngine().getProcessEngineConfiguration()</code>
gives me only getDefaultCamelContext(), but no idea how to get the Spring ApplicationContext from that.
It would be great if someone could give me a minimal but complete code example on how I can retrieve those 2 values.
Thank you very much and best regards
Ben

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2014 06:49 AM
There, I have
<code>
protected String ltpaKey;
protected String ltpaPassword;
</code>
with the setters and getters, and in the activiti-ui-context.xml, I extended the explorerApp bean. Then, my values got injected.
I tried the same in my CustomRestAuthenticatorImpl:
I created the 2 variables, added the setters and getters and added my own bean like this:
<code>
<bean id="ltpaParameters" class="org.activiti.rest.common.filter.RestAuthenticatorImpl">
<property name="ltpaKey" value="***" />
<property name="ltpaPassword" value="***" />
</bean>
</code>
But the values won´t get injected.
Any posts are highly appreciated.
Thanks
Ben
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2014 07:37 AM
But ProcessEngine doesn't implement it in your code?
