dependency-injection

ejb reference in deployment descriptor (without annotations )

爷,独闯天下 提交于 2019-12-13 02:23:47
问题 I try to inject dependency in EJB 3.0 using only deployment descriptor. When I deploy my app to Glassfish (v3.1) I get this exception: java.lang.RuntimeException: Warning : Unable to determine local business vs. remote business designation for EJB 3.0 ref Local ejb-ref name=ejb/Test2,Local 3.x interface =pl.Test2Local,ejb-link=Test2,lookup=,mappedName=,jndi-name=,refType=Session I have no idea what I do wrong. Can anybody help me, please? The ejb-jar.xml descriptor is: <session> <ejb-name

Dependency Injection for DAL with multiple database strings using StructureMap

爷,独闯天下 提交于 2019-12-13 02:19:23
问题 I have an application that uses Structuremap for DI for both my business and DAL layer. Up to this point, I have had a single DAL per environment that I have been working on. So I would grab it from the config and use that value for all my connections. An example of this is. using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Database"].ToString())) { //Do a call to db here. } I am calling this method using structure map as follows. ObjectFactory.GetInstance

Business layer handling Linq-objects without knowing it?

岁酱吖の 提交于 2019-12-13 02:11:37
问题 I am refactoring my application to be less dependent on the data source (at the moment I am using Linq To Sql). But I like the nice way that Linq To Sql generates my classes out of my database and the way it tracks changes. If this was not Linq I would just wrap the class with an interface and then let my business layer depend on that interface. However, I cannot do this with linq. So lets say I have a repository IFooRepository where Foos is a table in the database and Linq has generated the

Ninject: No matching bindings are available, and the type is not self-bindable

那年仲夏 提交于 2019-12-13 02:09:06
问题 Edit: Problem solved This is my error message: Message=Error activating IValueCalculator No matching bindings are available, and the type is not self-bindable. Activation path: 1) Request for IValueCalculator Suggestions: 1) Ensure that you have defined a binding for IValueCalculator. 2) If the binding was defined in a module, ensure that the module has been loaded into the kernel. 3) Ensure you have not accidentally created more than one kernel. 4) If you are using constructor arguments,

how to implement dependency injection in mvc?

旧街凉风 提交于 2019-12-13 02:08:04
问题 I'm trying to implement dependency injection but i know how to implement the interface and repository of classes then i don't know what shall i do. This my sample: public class User { public int Id { get; set; } public string Name { get; set; } public string LastName { get; set; } } This is my interface: public interface IUser { IEnumerable<User> GetUsers(); void AddUser(User user); void EditUser(User user); void DeleteUser(int id); User UserGetById(int id); void Save(); } This is my

How to access UserProfile in _Layout View

别说谁变了你拦得住时间么 提交于 2019-12-13 01:58:08
问题 In my MVC application I have a shared _Layout.cshtml file that displays the menu for a User On that View I want to display information from the UserProfile entity - created using SimpleMembership and thus linked to the IPrincipal User that can be accessed directly in the _Layout page. So I wrote an extension method that makes a call on my UnitOfWork and looks like this: public static UserProfile GetUserProfile(this IPrincipal u) { IUnitOfWork uow = new UnitOfWork(); return uow.UserRepository

how to init guice if my running class is junit?

感情迁移 提交于 2019-12-13 01:25:26
问题 I'm writing an API module. while developing I use junit to run the code however eventually some other modules will use my API. I want to use dependency injection pattern a) Where should be my main entry where I init all the dependencies or global utils? b) I thought it be neater using guice injector, but where should I init it? 回答1: It depends on what you're trying to do. I find, with BoundFieldModule and the @Bind annotation in Guice 4.0, that it's generally easiest to just use Guice

Changing implementation of interface depending on environment

依然范特西╮ 提交于 2019-12-13 01:18:27
问题 I have an application which uses an interface IBackend for communicating with a backend. In the production environment I wish to use class ProdBackend : IBackend as the implementation of the interface. In the test environment I wish to use TestBackend : IBackend . The application is packaged into a zip file, which must be independent of whether it is deployed in the prod or test environment. How can I make the application use a different implementation of IBackend depending on the environment

looking for various way of implemention Dependency injection using unity

余生颓废 提交于 2019-12-13 01:18:01
问题 i am new in Dependency injection. i just got familiar how to implement dependency injection with Interface injection but we know that Dependency injection can be implemented with three way or may be more and those are :- Interface injection : The service provides an interface which consumers must implement. The interface exposes specific behaviors at run time. Setter injection : The dependent object exposes a “setter” method to inject the dependency. Constructor injection : Dependencies are

The right way to do property dependency injection using Unity

只谈情不闲聊 提交于 2019-12-13 01:16:43
问题 I have a class that needs a dependency injecting. As the class is already an implementation of another abstraction, and its 'sibling' implementations may not share the same dependencies, I am attempting to use property injection and not constructor injection. (All these classes/interface names are just for illustrative purposes) My IProvider abstraction: public interface IProvider { void ProviderMethod(); } My IProvider implementation (with the IData dependency I want to inject) : public