Re: Using Guice in Java SE application (with networking and database capabilities)

2012-06-26 Thread Christian Edward Gruber
On Jun 26, 2012, at 7:49 AM, Paulo Pires wrote: > Hi all, > > This is a guidance request from someone who's interested in learning Guice. > > I'm developing a Java SE application with some windows (SWT) that interacts > with the network (Netty.IO) and when some conditions are true writes to a

Re: Adding a module to an existing injector

2012-06-20 Thread Christian Edward Gruber
On Jun 20, 2012, at 10:20 AM, je...@swank.ca wrote: > I'm going to be investigating this. I'm working on an Android project that > uses Guice extensively and we're suffering some performance problems. I'll > keep this list posted with my progress. I expect to have something within a > few weeks.

Re: Adding a module to an existing injector

2012-06-20 Thread Christian Edward Gruber
On Jun 20, 2012, at 9:42 AM, glenviewjeff wrote: > I haven't been keeping detailed records, but from what I have been seeing, I > think much of my performance hits and optimization improvements has come from Awesome initial list. Thanks. > uglifying my code by removing annotations from inject

Re: Adding a module to an existing injector

2012-06-20 Thread Christian Edward Gruber
On Jun 20, 2012, at 9:11 AM, glenviewjeff wrote: > Christian, 95% of the startup code is Guice binding code; and there's zero > I/O, database/network operations, etc. If you're an Android developer, (or > even if you're not but are willing to install the Android tools so you can > use Tracevi

Re: Adding a module to an existing injector

2012-06-20 Thread Christian Edward Gruber
At this point there is no such beast. createInjector() is a builder, and creates an intact Injector. Having said that, you could do something like this with child injectors, but I worry that you would be swapping in a child injector for its parent in a running system, and there are a hell of

Tycho seems to not pull guice-multibinders properly… possibly because it's a fragment? (Was: Re: Guice and multibinders OSGI versioning and metadata)

2012-06-04 Thread Christian Edward Gruber
this reply, this is more of a tycho issue than a guice packaging issue. On Jun 4, 2012, at 1:47 PM, Stuart McCulloch wrote: > On 4 Jun 2012, at 17:56, Christian Edward Gruber wrote: >> I have a maven project Foo which depends on guice and guice-multibinders. >> I'm having no p

Guice and multibinders OSGI versioning and metadata

2012-06-04 Thread Christian Edward Gruber
Hey all, So, I'm using guice and guice-multibinders in an open-source osgi project, using felix and tycho to build with maven. I'm having a problem, and I see one resolution, but thought I'd ask on this list because I want to make sure my solution, which would change the way OSGI metadata i

Re: Can DI be used for Instantiating Value Objects

2012-05-16 Thread Christian Edward Gruber
I should throw this on a wiki or something. Christian. On May 16, 2012, at 6:10 AM, jordi wrote: > Bubba, I think that Christian responded to your questions in a very > "bookmarkable" way ;) > > On Sun, May 13, 2012 at 4:51 PM, Christian Edward Gruber > wrote: >

Re: Can DI be used for Instantiating Value Objects

2012-05-13 Thread Christian Edward Gruber
at 12:29 PM, Bubba 42 wrote: > Many thanks guys for the input. > > Is there an example (Hello World level of complexity) which > illustrates the collaborators, configuration, and consumables > stereotypes? > > I'd be happy to put one together if it'd benefit folks --

Re: Can DI be used for Instantiating Value Objects

2012-05-11 Thread Christian Edward Gruber
Please don't inject value classes, generally speaking. I tend to think of dependencies in three kinds - collaborators, configuration, and consumables. Consumables are value classes that are consumed by and transformed by your collaborators, in the context of your configuration. Generally con

Re: post-injection and destruction made easy :)

2012-04-26 Thread Christian Edward Gruber
Nice, I'll take a peek at it next week. Christian. On Apr 26, 2012, at 9:52 AM, Simone Tripodi wrote: > Hi all guys, > > I needed a simple way to invoke post-injections callbacks and > destructor methods in an easy way using Guice - I know GuiceyFruit > does all the work, but since yesterday I

Re: Inject a class from a passed in string of fully qualified classname.

2012-04-13 Thread Christian Edward Gruber
You should be able to do this, so long as you're not playing crazy games with classloaders. Class.forName() is not advisable, as you don't always get the right classloader. But in principle this can work. Christian. On Apr 13, 2012, at 4:48 AM, Marko Lavikainen wrote: > Can't you use Class.f

Re: Get bound TypeListeners

2012-03-27 Thread Christian Edward Gruber
Do we have an existing issue for getElements() outstanding? Christian. On Mar 26, 2012, at 10:44 PM, Sam Berlin wrote: > I don't believe there's currently a way. Injector is missing (and in need > of) a getElements() method similar to Elements.getElements(Module). > > sam > > On Mon, Mar 26

Re: Child injector causes Guice configuration errors

2012-03-13 Thread Christian Edward Gruber
Can you replicate this with extremely minimalist ExternalDataSourceModule() and PushServletModule()s? The devil's in the details here. What is being bound may have an impact. One thing worth noting is that, as I recall, when you createChildInjector() you force bindings sooner than they would

Re: Call an init method after injection is done

2012-03-06 Thread Christian Edward Gruber
A common way to do this is to use a multibinder to bind services, and have a service manager which starts up services post-injection. You can't easily follow the dependency graph without digging into the SPI, but you could use a MapBinder to declare services and what services they need to be st

Re: Build Guice and extensions with Maven

2010-10-13 Thread Christian Edward Gruber
Guava is certainly released into the central repo, so it would be quite easy for Guice to depend on guava on the maven side, and import whenever important on the ant side. Christian. On Oct 13, 2010, at 4:11 AM, Willi Schönborn wrote: > On 13/10/10 06:27, Dhanji R. Prasanna wrote: >> >> OK, I

Re: Guice 3.0 ?

2010-09-21 Thread Christian Edward Gruber
I'm in. ping me off-line and I'll get things going on our end. Happy to collaborate too, if people have preliminary POM work that we want to bring in. Christian. On Sep 21, 2010, at 11:24 AM, Dhanji R. Prasanna wrote: > We'd love to do so, but as we are time-constrained we'd love for volunt

Re: Guice and the command pattern

2010-05-25 Thread Christian Edward Gruber
You might want to look into Map Binders. Christian. On May 25, 2010, at 2:54 PM, KreeK wrote: I'm new to Guice and wanted to get some advice on how to use it with our application that uses the command pattern. The app has a CommandMap which maps Events to Commands. commandMap.map(FooEvent.EVE

Re: Problems while diving into guice code

2010-05-23 Thread Christian Edward Gruber
It is, but I and a couple of others have worked up build-worthy poms (I accidentally ditched mine, so I'll have to re-create), but I did get it working with a pom for the guice trunk at one point. Christian. On May 23, 2010, at 2:43 PM, Dhanji R. Prasanna wrote: I think our pom is designed

Re: Suggested way of injecting static dependencies

2010-04-27 Thread Christian Edward Gruber
Please don't do this - you're using a single static logger behind an instance variable, and using Logger quite differently than it's intended. And what happens if someone doens't force the constructor... log is not initialized. Or what if there are multiple injectors in the VM - now you h

Re: Suggested way of injecting static dependencies

2010-04-27 Thread Christian Edward Gruber
Yes, I would make your methods non-static, make the class instantiatable - if you MUST, make a singleton static factory method, but in your Guice-ified code, don't use the factory method - just inject it where you need it, and in its constructor, ask for the logger. If you use it outside of

Re: Mixing scopes with Providers: RequestScoped & Singleton

2010-04-19 Thread Christian Edward Gruber
Can I beg you not to do this, despite what others may suggest about how this is possible. It's such a very bad practice that seems to be prevalent in guice (depend something of wide scope on something of narrow scope by depending on its provider). I would recommend, instead, that you not p

Re: Merge Maven pom.xml files into trunk?

2010-04-16 Thread Christian Edward Gruber
I'll take a look at it, but I have to get the guava libraries dealt with and some other things more directly related to my day-job. But I'm interested in what you've pulled together and will take a peek. cheers, Christian. On Apr 16, 2010, at 10:02 AM, Jelle Herold wrote: On 6 apr 2010,

Re: Guice release schedule?

2010-04-16 Thread Christian Edward Gruber
See my other comment. On Apr 16, 2010, at 10:11 AM, Jelle Herold wrote: On 26 mrt 2010, at 12:37, James Strachan wrote: On 24 March 2010 17:33, Bob Lee wrote: The only change I can think of is JSR-330 support. Which would be great to release! We'll probably have a release in a couple

Re: Conditional Scoping

2010-04-06 Thread Christian Edward Gruber
I would tend to create a wrapper service which I depend on, and let it choose the internals based on what's available at runtime. One layer of indirection can save you a lot of hell. :) Christian. On Apr 6, 2010, at 6:08 PM, Willi Schönborn wrote: Hi folks, i'm stuck at the following sit

Re: Merge Maven pom.xml files into trunk?

2010-04-04 Thread Christian Edward Gruber
On Apr 4, 2010, at 9:31 AM, Max Bowsher wrote: Christian Edward Gruber wrote: I wouldn't try to fill it in to use maven-eclipse-plugin - you need far less to make m2eclipse work I've not used m2eclipse, but I don't understand how the above can be true: all you need for th

Re: Merge Maven pom.xml files into trunk?

2010-04-03 Thread Christian Edward Gruber
I wouldn't try to fill it in to use maven-eclipse-plugin - you need far less to make m2eclipse work (I had a pom working last year, I can maybe dig it out). But yeah, I wouldn't try to use ant-run... better to make a maven build work, then use ant's maven tags to use m2 to resolve dependen

Re: books on guice 2.0

2009-12-21 Thread Christian Edward Gruber
Or you can get it from the horse's mouth. :) Good book, BTW, Dhanji. Christian. On Dec 21, 2009, at 4:36 PM, Dhanji R. Prasanna wrote: > Dependency Injection is updated for Guice 2.0 (the servlet API, > etc.), yes. > > Dhanji. > > On Tue, Dec 22, 2009 at 7:58 AM, mariuss > wrote: > As far

Re: books on guice 2.0

2009-12-21 Thread Christian Edward Gruber
I think Dhanji's book is, but I was finding Robbie's book a little stale given where/how Guice has gone. It does refer to most of the new stuff, just won't have sophisticated usages, examples, concerns to watch out for. Christian. On Dec 21, 2009, at 3:58 PM, mariuss wrote: > As far as I

Re: Binding without interfaces

2009-11-07 Thread Christian Edward Gruber
I've added the example to the documentation at: http://code.google.com/p/google-guice/wiki/LinkedBindings Christian. On Nov 7, 2009, at 6:09 PM, Jon Vaughan wrote: > > Aha, nice one. That wasn't mentioned (well, there was no example > like that) on http://code.google.com/p/google-guice/wiki/

Re: Injecting domain services in domain objects

2009-10-28 Thread Christian Edward Gruber
+1, generally speaking. I think people sometimes get into this because D-I systems are a bit like meta-factories, and with assisted injection and providers, you can do factory-like things. But it creates really tempting paths that lead to scoping problems. In general, I like to keep val