dependency-injection

Injecting arrays with Unity

回眸只為那壹抹淺笑 提交于 2019-12-18 04:48:06
问题 My goal is to constructor inject an array of objects implementing an interface. The following is the way I currently have it. Container .RegisterInstance<Company>(ParseCompany(args[1]) .RegisterInstance<eTargets>(ParseTargets(args[2])) .RegisterInstance<ILoader[]>(new ILoader[] { Container.Resolve<CustomerLoader>(), Container.Resolve<PaymentLoader(), Container.Resolve<InvoiceLoader() }); Is it typical to call Resolve in container configuration this way or is there a more standard way to

ClassCastException: org.springframework.orm.jpa.EntityManagerHolder cannot be cast to org.springframework.orm.hibernate5.SessionHolder

ぐ巨炮叔叔 提交于 2019-12-18 04:25:07
问题 I try to create simple user login and registration page. But I cannot create user using services method. I have a service for creating new user. @Service public class LocalUserDetailsService implements UserService { //... @Transactional @Override public User registerNewUserAccount(UserDto userDto) throws EmailExistsException { System.out.println("registerNewUserAccount called"); if (emailExist(userDto.getEmail())) { throw new EmailExistsException( "There is an account with that email adress:

Struts 2 - Sending mail with embedded URL

ぐ巨炮叔叔 提交于 2019-12-18 04:21:22
问题 For a project for my company, I have to send emails containing embedded URLs, which the user will be prompted to follow. For example, a person registers on the website, and then the Struts2 application sends an email to that person in which there is a URL to confirm the subscription. So far, the form submission, and sending the email (from inside the action), work just fine. The problem on which I'm stuck is that I can't find a way to generate the URL I'd like to embed in the mail body. I

Struts 2 - Sending mail with embedded URL

送分小仙女□ 提交于 2019-12-18 04:21:00
问题 For a project for my company, I have to send emails containing embedded URLs, which the user will be prompted to follow. For example, a person registers on the website, and then the Struts2 application sends an email to that person in which there is a URL to confirm the subscription. So far, the form submission, and sending the email (from inside the action), work just fine. The problem on which I'm stuck is that I can't find a way to generate the URL I'd like to embed in the mail body. I

Conditional injection of bean

左心房为你撑大大i 提交于 2019-12-18 04:13:00
问题 I want to have inject a bean based on a String parameter passed from client. public interface Report { generateFile(); } public class ExcelReport extends Report { //implementation for generateFile } public class CSVReport extends Report { //implementation for generateFile } class MyController{ Report report; public HttpResponse getReport() { } } I want report instance to be injected based on the parameter passed. Any help would be greatly appretiated. Thanks in advance 回答1: Use Factory method

What are the benefits of AngularJS dependancy injection?

☆樱花仙子☆ 提交于 2019-12-18 04:12:38
问题 I have been working with angular for some times now, and I fail to see how it is an improvement from my previous way of coding. First, I can't see what's wrong with having a central object to hold your project, after all, the injector is a singleton that looks up your dependancies into a central place, so angular does have a central object, it's just hidden. Namspacing doesn't necesally means coupling, if it's done properly. En even when it's done, you don't need every single object of your

Injecting Beans in JSF 2.0

南笙酒味 提交于 2019-12-18 03:45:58
问题 I have a Session scoped bean import javax.faces.bean.SessionScoped; import javax.inject.Named; @Named @SessionScoped public class SessionBean implements Serializable{ I inyect the object in one Filter... public class FiltroSeguridad implements Filter{ @Inject private SessionBean sessionBean; @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request;

.net-core Dependency Injection

。_饼干妹妹 提交于 2019-12-18 03:44:10
问题 I have a Generic repository which I want to register for DI, it implements an interface IRepository. Normally I would create an instance of it like this: IRepository repo = new Repository<Order>(); However I am trying to get up to speed in .net 5 ahead of release and want to get this working with DI, I have resorted to the following : services.AddTransient<DAL.IRepository<Models.Order>, DAL.Repository<Models.Order>>(); But this feels wrong, I don't want 50+ lines in there one for each of the

Which .NET dependency injection framework do you use? [closed]

耗尽温柔 提交于 2019-12-18 03:43:18
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Currently there are quite a few DI/IoC-frameworks for .NET out there (http://www.hanselman.com/blog

How exactly does dependency injection reduce coupling?

左心房为你撑大大i 提交于 2019-12-18 03:31:08
问题 I've done plenty of reading on Dependency Injection, but I have no idea, how does it actually reduce coupling? The analogy I have of DI is that all components are registered with a container, so theyre are like in a treasure chest. To get a component, you obviously register it first, but then you would have to interrogate the treasure chest (which is like a layer of indirection). Is this the right analogy? It doesn't make obvious how the "injection" happens, though (how would that fit in with