inject

CDI Replacement for @ManagedProperty

微笑、不失礼 提交于 2019-12-06 02:03:49
问题 I'm very new to both CDI and JSF, and I'm trying to convert some code from Richfaces 4 showcase to use CDI instead of JSF annotations. I understand that I can use @Named to replace @MangedBean and @Inject to replace @ManagedProperty. But I'm having some trouble. I'm trying to convert the Richfaces Tree example specifically. I have made the following changes and I know this is not correct so please don't use this: //@ManagedBean //@ViewScoped @Named @SessionScoped public class TreeBean

Guice : Inject an ArrayList of Strings

狂风中的少年 提交于 2019-12-06 01:49:01
I'm trying to inject an ArrayList of String s with the help of Guice. I want to show a panel with many RadioButtons (for example) where an user can select some services to activate. Once selected, I would like to get all the names of the selected services and add them into a list, and inject this list to the manager responsible to create the services. Here is an example: public class UIProviderModule extends ProviderServiceModule { private ArrayList<String> requestedServices; public UIProviderModule(ArrayList<String> requestedServices) { this.requestedServices = requestedServices; } @Override

Can you inject code/an exe into a process with python?

青春壹個敷衍的年華 提交于 2019-12-05 12:35:12
I've seen a few sites talking about injecting DLL's (such as http://www.codeproject.com/KB/DLL/DLL_Injection_tutorial.aspx ), but I'm struggling with how to get an EXE to work. any help/tips would be appreciated. The best way I know how to explain it is "RunPE" where you execute an exe in the memory. Does that help at all? If you're asking how to inject code into a running Python process, what you want is https://fedorahosted.org/pyrasite/ . You can use the Reflective DLL Injector as described here. Metasploit project uses it to load its meterpreter plug-ins. AFAIK this is the only way to

How to pass parameter to injected class from another class in CDI?

∥☆過路亽.° 提交于 2019-12-05 10:35:11
I am new to CDI, tried to find solution for this question, but, couln't found any. Question is Suppose I have one class which is being injected(A) from, where some value(toPass) is getting injected, now I want to pass this same value(toPass) to class B, which is getting injected from class A. public class A { String toPass = "abcd"; // This value is not hardcoded @Inject private B b; } public class B { private String toPass; public B(String toPass) { toPass = toPass; } } Can anybody please help me in this? Note: we cannot initialize the toPass variable of B in the same way as we have

Martini 极好的 Go WEB 框架

a 夏天 提交于 2019-12-05 03:30:18
已知的其他框架看到的是传统OOP的影子, 到处充蚀 Class 风格的 OOP 方法. 而我们知道GoLang中是没有Class的. 笔者也曾努力用Go 的风格做WEB开发, 总感到力不从心. 写出的代码不能完全称之为框架, 到更像一个拷贝源码使用的应用. 要达到灵活需要修改源码. 直到看到了 Martini . 纯 GoLang 风格的框架出现了. 核心Injector Injector 是 Martini 的核心. 其代码非常简洁. 功能仅仅是通过反射包, 对函数进行参数类型自动匹配进行调用. 笔者曾经为完成类似的功能写了 typeless , 这是一个繁琐的高成本的实验品. Injector 把事情简单化了, Injector 假设函数的参数都具有不同的类型. 在WEB开发中的 HandlerFunc 通常都具有这样的形式. 因此通过反射包可以对参数进行自动的匹配并调用HandlerFunc, 当然事先要把所有可能使用到的参数 Map/MapTo 给 Injector 对象, 这很容易而且是可以预见的. 简洁的路由设计 Martini的路由 router.go 写的非常简洁实用, 可见作者使用正则的功力非常深厚. 举例: "/wap/:category/pow/**/:id" 匹配: "/wap/Golang/pow/Path1/ToPathN/Foo" 灵活的中间件

How to test implementations of Guice AbstractModule?

蹲街弑〆低调 提交于 2019-12-05 03:25:54
How to test implementations of Guice AbstractModule in a big project without creating fake implementations? Is it possible to test bind() and inject() methods? Typically the best way to test Guice modules is to just create an injector in your test and ensure you can get instances of keys you care about out of it. To do this without causing production stuff to happen you may need to replace some modules with other modules. You can use Modules.override to selectively override individual bindings, but you're usually better off just not installing "production" type modules and using faked bindings

what is the purpose of @Nonbinding annotation in a Qualifier supposed to be in Java EE7?

不羁岁月 提交于 2019-12-05 02:34:44
I am reading through the CDI injections in JavaEE 7 particularly using @Qualifier and @Produces to inject a custom Data type into a bean. I have the following code taken from JBoss documentation towards ends of the page. @Qualifier @Retention(RUNTIME) @Target({TYPE, METHOD, FIELD, PARAMETER}) public @interface HttpParam { @Nonbinding public String value(); } import javax.enterprise.inject.Produces; import javax.enterprise.inject.spi.InjectionPoint; class HttpParams { @Produces @HttpParam("") String getParamValue(InjectionPoint ip) { ServletRequest request = (ServletRequest) FacesContext

Understanding the behaviour of inject used with a lambda in Ruby

白昼怎懂夜的黑 提交于 2019-12-05 00:46:29
问题 I often plug pre-configured lambdas into enumerable methods like 'map', 'select' etc. but the behavior of 'inject' seems to be different. e.g. with mult4 = lambda {|item| item * 4 } then (5..10).map &mult4 gives me [20, 24, 28, 32, 36, 40] However, if I make a 2-parameter lambda for use with an inject like so, multL = lambda {|product, n| product * n } I want to be able to say (5..10).inject(2) &multL since 'inject' has an optional single parameter for the initial value, but that gives me ...

Converting spring xml to java configuration with implicit setter autowiring and ComponentScan

淺唱寂寞╮ 提交于 2019-12-04 21:13:08
I have two classes: vehicle.Tire and vehicle.Car. package vehicle; @Named public class Tire { private String age; } package vehicle; @Named public class Car { private Tire tire; // Spring calls this setter because default-autowire="byName" of xml configuration public void setTire(Tire newTire) { this.tire = newTire; } public Tire getTire() { return this.tire; } } The following spring xml works fine. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=

Inject $scope into filter (AngularJS)

可紊 提交于 2019-12-04 17:49:22
What I'm trying to do: Im using a ng-repeat directive on an associative array, which I want to filter. The build in angular filter isn't working on associative arrays/hashes. Because of that, I'm trying to write my own filter (inspired by http://angularjs.de/artikel/angularjs-ng-repeat ; it's in german, but the important code is below the headline "Beispiel 2: Filtern von Hashes mittels eigenem Filter" which means "Example 2: Filter Hashes with your own filter"). The ng-repeat: tr ng-repeat="(key, machine) in machines | customFilter | orderObjectBy:'name':false" note: orderObjectBy is also a