Questions tagged [context-injection]

Design pattern almost synonym to dependency injection, except that injected objects can be different for each class instance.

The difference between context and dependency injection lies in the temporal nature of the injected object.

  • A database connection relates to dependency injection, since all instances of a class will use the same connection.

  • A user session relates more to context injection, since every instance of a class will have different and temporal user session objects.

References:

http://www.oracle.com/technetwork/articles/java/cdi-javaee-bien-225152.html

9 questions
3
votes
1 answer

Jersey ContainerRequestFilter - modifying a query param does not modify the context request in the controller

I have the following filter in jersey 2.23 running in tomcat 7.0.69: @PreMatching @Priority(Priorities.HEADER_DECORATOR) public class TestFilter implements ContainerRequestFilter { @Context HttpServletRequest req; @Override public…
user1390217
  • 41
  • 1
  • 5
2
votes
0 answers

Context Injection in Specflow failing in c# when parallel test are executed in xunit, but works in sequential run

I created a xunit project and added specflow with Gherkin and selenium web drivers to the project. I've following StepDefinition file, [Binding] public class MyPageStepDefinition { private readonly UserContext _userContext; private readonly…
2
votes
1 answer

C# Specflow - Need Feature and Scenario Title without using FeatureContext and ScenarioContext

I have a hooks.cs Binding file which have BeforeTestRun, BeforeFeature and BeforeScenario. I need Title of current Feature and scenario for log and report purposes. Since I am running the test in parallel, ScenarioContext throws exception as: The…
Sathish
  • 350
  • 3
  • 24
2
votes
2 answers

SpecFlow - Context Injection vs Scenario Context

Anyone using SpecFlow will likely have come across Context Injection and Scenario Context for storing data across different binding classes. (For more detail see: https://specflow.org/documentation/Sharing-Data-between-Bindings/) As a Developer, the…
Charlie S
  • 4,366
  • 6
  • 59
  • 97
1
vote
1 answer

How do I get the requests HttpHeaders in a CDI bean in Quarkus?

I would like to get the AcceptableLanguage header of the originating request to select the correct translation language. I thought that this would work: import javax.ws.rs.core.HttpHeaders; @ApplicationScoped public class TranslationService{ …
Herr Derb
  • 4,977
  • 5
  • 34
  • 62
1
vote
1 answer

Two step construction. Useful or just a code smell?

Normally I expect that once an object is constructed, it should be ready for use, period. No two step construction. If you need calling two constructors for using an object something is very wrong... right? class Contact attr_accessor…
SystematicFrank
  • 16,555
  • 7
  • 56
  • 102
0
votes
1 answer

Is SpecFlow Context Injection Thread Safe?

I am using SpecFlow to power an API integration test harness that will provide living documentation and test coverage of a new UI API. I have a few feature files written and have finally gotten to the point that I'm trying to run around 60 tests in…
Thomas Parikka
  • 472
  • 5
  • 17
0
votes
1 answer

In spec flow is scenario context Injection thread safe?

http://www.specflow.org/documentation/Context-Injection/ [Binding] public class MyStepDefs { private readonly PersonData personData; public MyStepDefs(PersonData personData) // use it as ctor parameter { this.personData = personData; …
0
votes
1 answer

Are e4 rcp context injections slow

I am writing an RCP application in eclipse. When I load my application my application models are loaded from a file in the disk and injected with context. Using a profiler I noticed that the inject method slows me down... Is this a known…
whomaniac
  • 1,258
  • 4
  • 15
  • 22