# Option to Inject ActivityStubs to WorkflowImpl

**URL:** <https://community.temporal.io/t/option-to-inject-activitystubs-to-workflowimpl/8972>\
**Category:** Community Support\
**Tags:** java-sdk, general-impl, activity\
**Created:** [July 27, 2023, 4:04am UTC](https://community.temporal.io/t/option-to-inject-activitystubs-to-workflowimpl/8972 "2023-07-27T04:04:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![workflow](https://avatars.discourse-cdn.com/v4/letter/w/58956e/32.png) [@workflow](https://community.temporal.io/u/workflow)\
**Post date:** [July 27, 2023, 4:04am UTC](https://community.temporal.io/t/option-to-inject-activitystubs-to-workflowimpl/8972/1 "2023-07-27T04:04:30Z")

</div>

I currently inject ActivityOptions into workflow using `WorkflowImplementationOptions` & create ActivityStubs within the workflow.

Looks like there no option to inject ActivityStubs into the workflow (to further reduce boilerplate code). Is it because ActivityStubs need to recreated for each WorkflowExecution, like WorkflowStubs?

---

<div class="post-metadata">

**Author:** ![antonio.perez](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/antonio.perez/32/2417_2.png) [@antonio.perez](https://community.temporal.io/u/antonio.perez)\
**Post date:** [July 27, 2023, 10:35pm UTC](https://community.temporal.io/t/option-to-inject-activitystubs-to-workflowimpl/8972/2 "2023-07-27T22:35:49Z")

</div>

@workflow

The main reason not to support dependency injection in the workflow is because it can break determinism.

> Looks like there no option to inject ActivityStubs into the workflow (to further reduce boilerplate code).

Can you elaborate on this? You could have a factory or utility method to create activityOptions. On the other hand, it is a good practice to have different activity options for different types of activities, e.g not all activities require the same startToCloseTimeout

Antonio
