dependency-injection

EJB: Dependency injection without Interface

烂漫一生 提交于 2019-12-23 20:45:29
问题 I had this code @Local interface IRepo { //... } @Stateless class Repo implements IRepo { // .. } class WebS { @EJB private IRepo repo; // ... } And all worked normally. But now I remove interface IRepo and make @Stateless class Repo { // .. } class WebS { @EJB private Repo repo; // ... } and JNDI look up fails. could not resolve global JNDI name for @EJB for container WebS ... Can I make Dependency injection without Interface? 回答1: You should use @Stateless @LocalBean // <-- annotation here

Visualizing dependency tree depth in autofac

本秂侑毒 提交于 2019-12-23 19:28:12
问题 I may have been searching for the wrong stuff, looking in the wrong boxes. But I can't seem to find a good way to visualize how deep my dependecy tree is in C#. I've initially tried just hooking up on the preparing-event & the activating-event from Autofac. But I can't figure out if this is good enough. The results looks kinda funky. It seems that the preparing-event is initiated too often. And it seems that the activating event is only activated when a new object is actually created. Our

AngularJS: Factory is always undefined when injected in controller

早过忘川 提交于 2019-12-23 19:17:23
问题 I am trying a simple example of an AddressBook Angular application. I have a factory that returns an array of records and it it gets displayed in a list view using a List controller angular.module('abModule', ['ngRoute']) .factory('AddressBook', function() { var address_book = [ { "id": 1, "first_name": "John", "last_name": "Doe", "age": 29 }, { "id": 2, "first_name": "Anna", "last_name": " Smith", "age": 24 }, { "id": 3, "first_name": "Peter", "last_name": " Jones", "age": 39 } ]; alert(

Grails Packaging and Naming Conventions

六月ゝ 毕业季﹏ 提交于 2019-12-23 18:43:49
问题 Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered is in naming services Example SomthingGatewayService.groovy can't be initialized in both these ways - SomthingGatewayService somtinggatewayService - def somtinggatewayService I understand that the problem is in the 2 Capital Letters 'S'omthing and 'G'ateway before the conventional 'S'ervice, so its

How can I make the cache name in Spring cache configurable?

≯℡__Kan透↙ 提交于 2019-12-23 18:42:56
问题 We use Spring cache framework for caching, and we'd like to able to support multiple namespaces for caches, such as "book", or "isbn", with the cache namespaces being configurable, rather than hardcoded in the class, like, instead of having @Cacheable({ "book","isbn"}) public Book findBook(ISBN isbn) {...} we want to be able somehow inject the cache name from a properties file, so that the cache name can be dynamically set, like: @Cacheable({ #cachename1, #cachename2}) public Book findBook

Get an injected dependency in a non-Angular class

时光怂恿深爱的人放手 提交于 2019-12-23 18:36:28
问题 I have the current (& simplified) class : export class NavigationItem { constructor( private router: Router ) {} navigateTo() { this.router.navigate([this.id]); } } I would like not to have to inject myself the router everytime I declare a new instance of this class. Is there a way of doing so ? I thought about something along the lines of export class NavigationItem { @Inject(forwardRef(() => Router)) private _router: Router; constructor() {} navigateTo() { this.router.navigate([this.id]); }

How can I register all my services with castle windsor wcf facility

谁都会走 提交于 2019-12-23 18:18:49
问题 Basicly I can register one service like this. Container.Register(Component.For<IMyService>() .AsWcfClient(new DefaultClientModel() { Endpoint = WcfEndpoint .BoundTo(new NetNamedPipeBinding()) .At("net.pipe://localhost/MyService") }) .LifeStyle.PerWebRequest); But I could not figure out how to register all my services with similar configuration. the thing I was hoping to run is this... Container.Register( AllTypes.FromAssemblyNamed("My.Server.MyContracts") .Pick().If(x => x.Name.EndsWith(

Custom AuthorizeAttribute Ninject Property Injection doesn't work (injected property have sub dependant services which need to be injected)

陌路散爱 提交于 2019-12-23 18:05:38
问题 I think the specifics of my question are very much different than the other similar questions which I have red. I know that when I have custom AuthorizeAttribute I can't inject dependencies with the constructor. This is because the constructor will take the parameters - in my case the permission strings. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)] public class UserAllCSPermissionBasedAuthFilter : AuthorizeAttribute { I am

In Java, given an object, is it possible to override one of the methods?

别来无恙 提交于 2019-12-23 18:00:05
问题 I have an object of class A. I want to override one of the methods of that class. Can this be done? More specifically, I have an object that is being injected into a field. I need to override one of the methods, before I can use it. I am trying to see if Reflection could help solve the problem. Note that the method that I am trying override does not dependent on private variables of that class. 回答1: Look into Dynamic Proxy classes. 回答2: Yes. Overriding means writing a new class, compiling it,

Autofac Module Scanning for Various Applications

大城市里の小女人 提交于 2019-12-23 17:47:35
问题 Let's say you're working on an ASP.NET MVC project and it is layers split up into different projects in a single solution. Each project has autofac modules created to wire up the dependencies. Now, I would like to scan the assemblies and register all of the modules into the container. I adapted an extension method similar to what was shared here http://goo.gl/VJEct public static void RegisterAssemblyModules(this ContainerBuilder builder, Assembly assembly) { var scanningBuilder = new