I am using Dependency Injection in my code (with Ninject) and thought I was doing quite well until I came across a performance problem that was caused by a misunderstanding of where DI containers fit into your code. There seems to be a lot of information on how to use DI frameworks but not too much on where not to use them or how best t...
Is it possible to inject ejb's into pojo's using the @EJB annotation?
If it is, do I have to set up anything special on a JBoss server to make it work?
Please let us not discuss the rationale behind doing this - I am just trying to hack some old code to make it work :-)
...
To start I'm using Ninject 1.5. I have two projects: Web project and a Class library. My DI configuration is within the Web project. Within my class library I have the following defined:
public interface ICacheService<T>
{
string Identifier { get; }
T Get();
void Set( T objectToCache, TimeSpan...
Like threading issues? Bottlenecks? Memory problems?
...
Hi,
I have a custom HTTP Module. I would like to inject the logger using my IoC framework, so I can log errors in the module. However, of course I don't get a constructor, so can't inject it into that. What's the best way to go about this?
If you need the specific IoC container - I'm currently using Windsor, but may soon move to Aut...
I'm registering few modules in my Prism application using UnityBootstrapper
protected override IModuleCatalog GetModuleCatalog()
{
var catalog = new ModuleCatalog();
catalog
.AddModule(typeof(LoginModule))
.AddModule(typeof(AppModule))
.AddModule(typeof(DataTransformationModule), InitializationMode.OnDemand)...
Is there a recommended pattern for shutting down / closing objects created with Guice?
The lifecycle I'm aiming for is:
Prepare a Guice Module
Create an injector
Use the injector through your code to obtain objects (injector.getInstance(Foo.class))
...
Close any resources held by said objects (file handles, TCP connections, etc...). I...
Let's say that I've got a BarService under grails-app/services and regular Groovy class 'Foo' like this under src/groovy.
class Foo {
def barService
}
Are there any way to turn this into a Spring bean programmatically at runtime? Just to clarify, I want to get a reference to BarService injected into the barService field.
def fooIns...
Hi.
I have a Main.fla (controlled by Main.as) that has a child named Slide (a Movieclip controlled by another class, Slide.as).
Sometimes, my Slide object have to call the method "nextSlide" on his father, Main object. To do this I tried "this.parent.nextSlide()", but I got this error:
1061: Call to a possibly undefined method nextSli...
Should you design your code to make testing easier? And if so how to design c++ code so that it is easy to test.
How do you apply dependency-injection in c++?
Should I implement the classes using a pure interface class as the base in order to simplify the creation of fake test objects?
That would force me into making a lot of virtual...
I'm relatively unskilled in Dependency Injection, and I'd like to learn some best practices and anti-patterns to use and avoid respectively when using DI.
...
I've used a fair amount of dependency injection, but I'd like to get input on how to handle information from the user at runtime.
I have a class that connects to a com port. I allow the user to select the com port number. Right now, I have that com port parameter as a constructor argument. The reasoning being that the class cannot funct...
I'm not sure if there is merit to this question or not, but are there any best practices and anti-patterns specific to Google Guice?
Please direct any generic DI patterns to this question.
...
I'm going round in circles at the moment trying to get the pattern right for using Dependency Injection with a number of IEnumerables.
I have three types of object that I want to return from my database: Projects, Batches and Tasks. I want to create a Repository that has the following form:
public interface IRepository<T>
{
IEnume...
This is what I want from DI container:
public class Class
{
public Class(IDependency dependency, string data) { }
}
var obj = di.Resolve<Class>(() => new Class(null, "test"));
Points of interest:
Can resolve both dependency and data in constructor.
Can use type-safe syntax to pass constructor parameters (exact syntax may vary)....
I'm trying to implement my custom authorize attribute like:
public class MyCustomAuth : AuthorizeAttribute
{
private readonly IUserService _userService;
public MyCustomAuth(IUserService userService)
{
_userService= userService;
}
... continued
}
I am using Castle Windsor for automatically resolve the depende...
I have a piece of logic I want to test and it uses dependency injected interface with one (or more) void methods, example:
interface IMyService
{
void MethodA (MyComplexObject arg1, int arg2);
}
What I would want is to create a stub for this IMyService that would just record the method invocations of MethodA and I would later be a...
Hi there,
I am trying to use unity to automatically inject a datacontext on my repository using a new instance each time.., my idea is the ensure that each time a new datacontext is injected
Currently its failing on creating the repository, i think it can't resolve MyDataContext
Before creating a constructor on "the repository" (see b...
Hi there,
Previously i managed to setup my unity to provide a new DataContext each time to my Repository project. It works great.
But for example, I am in a WCF method which opens up 2 services which in turn opens up 2 repositories (repository pattern).. i was hoping to be able to reuse the same datacontext within the same wcf method....
I'm working on improving the security of my company's website and wanted to create a token to prevent forgery attempts that could be easily maintained this is what I came up with.
public class AntiForgeryToken
{
private readonly string _referenceToken;
public AntiForgeryToken()
{
_referenceToken = Guid.NewGuid().ToS...