Options module

2011-04-20 Thread Dhanji R. Prasanna
[cross-posted to guice/sitebricks]

Hi All,

A basic version of the options module is now in place. Options enable you to
specify application-specific parameters at runtime, say via command line, to
configure your app in a natural, type safe fashion:

@Options
public interface MyConfig {
  String domain();
  int port();
}

and on the command line:

java MyApp --domain=google.com --port=80


The MyConfig interface can then be injected *anywhere* in your App so long
as you install the OptionsModule. Here's an example:
https://github.com/dhanji/sitebricks/blob/master/sitebricks-options/src/test/java/com/google/sitebricks/options/OptionsTest.java

Note that this does not require sitebricks to work (it works in any vanilla
Guice app), and will ship as part of Sitebricks 0.8.6. It even supports
namespaces to disambiguate different @Options interfaces. We also support
(multiple) resource bundles and properties files as means of configuring
(not just the command line).

Maven dep (if you build locally):

  com.google.sitebricks
  sitebricks-options
  0.8.5-SNAPSHOT


Or give us a week until 0.8.6!

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



GuiceCon details

2011-03-17 Thread Dhanji R. Prasanna
When you arrive at the Googleplex on Saturday, please gather at the entrance
to Building 40 by 11am. If you are late please find me on googletalk (
dha...@gmail.com) instant messaging or send me an email, I will receive it
immediately, and come out to meet you.

If anyone asks you (like security) say you are attending an event and that
you're waiting for me (Dhanji R. Prasanna) or Jesse Wilson. We will be in
Room KIEV. Do NOT enter the building without someone from Google. This is a
security restriction we have to follow.

Thanks and look forward to seeing you there!
Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



GuiceCon final update

2011-03-16 Thread Dhanji R. Prasanna
Hi All,

First ever GuiceCon is on for this Saturday =)

Building 40, Kiev @ Googleplex (gather outside the building entrance at
11am)
http://code.google.com/p/google-guice/wiki/GuiceCon2011

If you haven't signed up yet, *email me directly* (do NOT RSVP on the form
until you hear from me) there are still spots open. There will be lunch
served. We'd also love if you'd like to present something, so do email me if
you are interested.

Hope to see you there!
Dhanji. =)

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



GuiceCon update

2011-03-10 Thread Dhanji R. Prasanna
Hi All,

GuiceCon 2011 is finalized. Details here:
https://docs.sonatype.org/display/GUICECON/GuiceCon2011

It will be held at the Googleplex in Building 40 at 11am, Saturday March 19.
Please wait at the entrace and someone from Google will sign you in.

Bring your presentations and questions! There's still time to RSVP. Hope to
see you there.
Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



GuiceCon updates

2011-03-05 Thread Dhanji R. Prasanna
Hi all,

If you haven't registered yet, there's still time (info here:
http://code.google.com/p/google-guice/wiki/GuiceCon2011 ). GuiceCon will
tentatively be held at the Googleplex in Mountain View. Details forthcoming.

In the meantime if you'd like to present or lead a session please add
yourself to this wiki:
https://docs.sonatype.org/display/GUICECON/GuiceCon2011

Feel free to email any questions to this list.

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: GuiceCon showcase

2011-02-19 Thread Dhanji R. Prasanna
More info about GuiceCon:
http://code.google.com/p/google-guice/wiki/GuiceCon2011

On Sun, Feb 20, 2011 at 3:20 PM, Dhanji R. Prasanna wrote:

> For the upcoming GuiceCon in the bay area, we'd like to show case some apps
> that are built on Guice. If you have a public, user-facing app that you'd
> like to share please let us know by replying to this thread with:
>
> Name of app
> Names of developers
> URL if applicable
> Short description of what it is
> Description of how Guice is used and any remarks
>
> We will show a selection of these apps at the informal GuiceCon intro. (the
> more entries the better!)
> Thanks!
>
> Dhanji.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



GuiceCon showcase

2011-02-19 Thread Dhanji R. Prasanna
For the upcoming GuiceCon in the bay area, we'd like to show case some apps
that are built on Guice. If you have a public, user-facing app that you'd
like to share please let us know by replying to this thread with:

Name of app
Names of developers
URL if applicable
Short description of what it is
Description of how Guice is used and any remarks

We will show a selection of these apps at the informal GuiceCon intro. (the
more entries the better!)
Thanks!

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Guice Conference

2011-02-15 Thread Dhanji R. Prasanna
First ever GuiceCon!What?

An informal gathering of Guice users and contributors.
Why?

Meet like minded folk, make your case for features, extensions AND show off
your products, libraries, patterns and skills.
When?

Saturday, March 19th, 2011
Where?

San Francisco Bay Area

*Details TBD (check back here). But likely will be held at Google offices in
San Francisco or the Googleplex in Mountain View.*

*RSVP:* http://goo.gl/rU3iJ

*Questions/Comments:* Send email to this thread!

Special thanks to Jason van Zyl.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Guice extension for statistics and server monitoring

2010-12-13 Thread Dhanji R. Prasanna
[cross-post from sitebricks list]

As of r176, I've added a StatModule which allows you to monitor and track
various custom stats in real time from running servers. This is really
useful for checking on the health of running services or keeping track of
various runtime stats efficiently.

Here's how it works:

Any singleton can export any variable (which has a valid toString() method)
simply by annotating that field. Let's say you have a service that is used
to download some file:

public class DownloadService {

*  @Stat("download-count")*
  private final AtomicInteger downloads = new AtomicInteger();

  @Get void performDownload() {
downloads.incrementAndGet();

// send file...
  }
}

And make sure to install the StatModule with a location at which to serve
the stats:
install(new StatModule("/stats"));

This requires Guice Servlet to be working properly. Each time you request
the /stats page you will see the aggregation of all stats in the system
snapshotted at the time at which you requested the page.

This is neat because you can build offsite monitoring services that
periodically snapshot stats in a running system and store them in a
timeseries database (for example), for later visualization. All with a
simple annotation.

It will be in Maven Central at the next push of Sitebricks (although
sitebricks is NOT needed to use this extension).

Enjoy!

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Status of Guice and persistence support

2010-10-17 Thread Dhanji R. Prasanna
On Mon, Oct 18, 2010 at 10:31 AM, jon stevens  wrote:

> Hi all,
>
> I'm new to guice and guice-persist. I just got guice-persist
> integrated into a war based project sitting on top of Tomcat 6. Seems
> to work brilliantly. On my laptop, Tomcat starts up in 2 seconds which
> includes starting hibernate and connecting to the database.
>

Thanks for the kind words! Glad it's working nicely for you.


>
> A couple notes so far:
>
> http://code.google.com/p/google-guice/wiki/JPA
> JpaModule should be JpaPersistModule
>

Fixed, thanks!


>
> I'd really like to be able to instantiate my own EntityManager
> implementation (I add a few handy methods to mine). Haven't figured
> how to do that quite yet. What I do right now is @Singleton a bean
> that wraps a @Inject EntityManager. Works well enough, but it would be
> nice to be able to do this more cleanly.
>

Hmm, we deliberately don't proxy (or allow proxying) EntityManager coz it
may create problems with spec compatibility. But you could presumably create
your own version of JpaPersistModule where you bind a proxy instead.


> I really wish there was more lifecycle support in guice (specifically
> @PostConstruct/@PreDestroy) for my beans. I know James S did some work
> with guiceyfruit, but it seems like it is a dead project. I'm looking
> next into seeing how hard it will be to just put weld into the mix.
>

Yea, one issue here is the Guice team has not been able to agree on the
ideal solution for lifecycle (this debate has been ongoing since 2007). So
as an alternative, Bob created the TypeListener system that enables things
like guiceyfruit without directly implementing them.

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Guice Persist @Transactional doesn't work with @Inject injected EntityManager (Hibernate)

2010-10-17 Thread Dhanji R. Prasanna
Probably because your class is a Singleton and EntityManager is not. You
need to inject a Provider instead.

Dhanji.

On Mon, Oct 18, 2010 at 12:14 PM, Alistair wrote:

> Hi
>
> I've been experimenting with the snapshot of Guice 3 and the persist
> API. I have followed the instructions and set up a ServletModule with
> a filter:
>
> filter( "/*" ).through( PersistFilter.class );
>
> I've annotated a method with @Transactional, and in that class I
> inject the EntityManager:
>
> @Inject
> private final EntityManager _em = null;
>
> Then in the transactional method I create a new JPA entity:
>
> @Transactional
> public void test()
> {
>TestObject testObject = new testObject();
>testObject.setDescription( "Hello, world" );
>_em.persist( productComponent );
> }
>
> However, Hibernate never updates the database. You can see in the log
> that it calls out to the sequence to generate the primary key, but
> never executes the INSERT. If I check the value of
> _em.getTransaction().isActive() in this method it returns false.
>
> As a last resort I changed the code to match the code from the Guice
> Persist unit tests and programmatically construct an EntityManager:
>
> @Inject
> private final Injector injector = null;
>
> @Transactional
> public void test()
> {
>EntityManager em = injector.getInstance( EntityManager.class );
>TestObject testObject = new testObject();
>testObject.setDescription( "Hello, world" );
>em.persist( productComponent );
> }
>
> This now works correctly. Can anyone shed any light on why the first
> approach with an injected EntityManager didn't work?
>
> When I debugged the JpaLocalTxnInterceptor in Guice Persist, it did
> report the transaction was active - this seemed to imply that there
> were two EntityManagers but I don't understand why the @Inject syntax
> causes a different instance of the EntityManager to be injected (e.g.
> not the one that the @Transaction annotation relates to).
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: "Parameter based singleton scope" in AssistedInject factory?

2010-10-14 Thread Dhanji R. Prasanna
Interesting problem. I've heard this referred to as the "Multiton" pattern.

Dhanji.

On Fri, Oct 15, 2010 at 3:27 AM, Fred Faber  wrote:

> Basically you have a factory that should return a singleton instance for
> each unique string value passed into it?
>
> FactoryProvider won't do this for you out of the box, as it will create a
> new instance per invocation (as you've illustrated).
>
> What I would do in this case is to decorate your factory with an
> implementation that controls singletonness:
>
> interface CacheFactory {
>   // This can be named anything you want, not just "create"
>   NamedCache create(String name);
> }
>
> class CachingCacheFactory implements CacheFactory {
>
>  private final CacheFactory underlyingFactory;
>
>  //
> http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/collect/MapMaker.html
>  private final Map caches = new MapMaker()
>   .makeComputingMap(new Function(){
>@Override public NamedCache apply(String name) {
> return underlyingFactory.create(name);
>   }
>   });
>
>   @Inject
>   CachingCacheFactory {
>   @AlwaysCreatesNewInstances CacheFactory cacheFactory) {
>  this.underlyingFactory = cacheFactory;
>}
>
>   @Override
>   NamedCache create(String name) {
>   return caches.get(name);
>   }
> }
>
>
> * * *
>
> public class YourModule extends AbstractModule {
>
>@Override protected void configure() {
>// as an alternative to binding this as a singleton, you could
> inject the map of caches
>// as a singleton instance.  6 or 1/2 dozen, unless you want to
> unittest your
>// implementation, in which case you'll want to inject the singleton
> map
>bind(CacheFactory.class)
>.to(CachingCacheFactory.class)
>.in(Singleton.class);
>
>//
> http://google-guice.googlecode.com/svn/trunk/javadoc/com/google/inject/assistedinject/FactoryModuleBuilder.html
>// this binds a "CacheFactory" instance, annotated with
> @AlwaysCreatesNewInstances, to
>// a default factory implementation which will return instances of
> NamedCacheLocal when
>// its create() method is invoked
>install(new FactoryModuleBuilder()
>.implement(NamedCache, NamedCacheLocal)
>.build(Key.get(NamedCache.class,
> AlwaysCreatesNewInstances.class));
> }
> }
>
> That should do the trick.
>
> -Fred
>
>
> On Thu, Oct 14, 2010 at 4:25 AM, Sondre Bjornebekk <
> sondre.bjorneb...@gmail.com> wrote:
>
>> Hi,
>>
>> Trying to use assisted inject and find it pretty neat, the minor
>> detail is that it does not quite work for me yet :-)
>>
>> I have created a Map wrapper to ease switching of caches (typically to
>> something like Coherence) for my application. I want the Map to be
>> returned "in a Singleton scope, based on the value of the (assisted)
>> parameter". I am doing:
>>
>> bind(CacheFactory.class).toProvider(
>> FactoryProvider.newFactory(CacheFactory.class,
>> NamedCacheLocal.class) );
>>
>> And I have:
>> /**
>>  * A factory for named caches, that later might hide its
>> implementation using a cluster wide storage.
>>  */
>>
>> public interface CacheFactory {
>>//had to be named create to work with guice assisted inject, so
>> renamed from getNamedCache
>>public NamedCache create(String name);
>> }
>>
>> public interface NamedCache extends Map {
>>public int getHitPercent();
>>public String getHitPercentString();
>>...
>> }
>>
>> /**
>>  * A named cache with a local map as implementation for storage.
>>  */
>>
>> public class NamedCacheLocal implements NamedCache {
>> ...
>>
>>/**
>> * Constructs a NamedCacheLocal with its dependencies.
>> */
>>@Inject
>>public NamedCacheLocal(@Assisted String cacheName) {
>> ...
>> }
>>
>> I have this (failing) unit test that checks that the same cache is
>> used for the same name:
>>
>>System.out.println("doing put / get test");
>>NamedCache namedCache =
>> namedCacheFactory.create("myCache");
>>namedCache.put("fisk","fesk");
>>for(int i=0;i<10; i++){
>>Object o = namedCache.get("non-hit");
>>namedCache.put("test"+i,"testval"+i);
>>}
>>Object hit = namedCache.get("fisk");
>>System.out.println("cache " + namedCache + " delivered value "
>> + hit + " to a hit percent of " + namedCache.getHitPercentString());
>>assertTrue(namedCache.getHitPercent() > 8 &&
>> namedCache.getHitPercent() < 10);
>>NamedCache namedCacheWithSameName =
>> namedCacheFactory.create("myCache");
>>for(int i=0;i<10; i++){
>>String val = namedCacheWithSameName.get("test"+i);
>>System.out.println("got val from cache: " + val);
>>}
>>//should have used the same reference, thus hit pct now higher
>>System.out.println("done with cache " +
>> namedCacheWithSameName);
>>assertTrue(namedCache.getHitPercent() > 10);
>> 

Re: Custom just-in-time bindings?

2010-10-13 Thread Dhanji R. Prasanna
You should be able to implement something like this with TypeListeners.

Dhanji.

2010/10/14 Willi Schönborn 

>  +1 for that feature
>
> I came across the situation that i wanted to inject
> some proxy like so:
>
> @Inject
> public Service(@Proxy Listener listener) {
>...
> }
>
> Proxies in my context can be retrieved using some kind of registry,
> so everything i need to know is the binding annotation and the type.
> Your request would also solve my problem.
>
>
> On 13/10/2010 20:15, PhilBeaudoin wrote:
>
>> I've build a number of utility classes that makes it easy to use guice
>> within a JUnit 4 test. The idea is similar in spirit to Guiceberry but
>> my goal was to make it easy to use dependency injection for Unit tests
>> and for all levels of integration tests. [1]
>>
>> A killer feature for this framework would be the ability to
>> automatically create mocks when Guice does not have a binding for a
>> specific interface. I've been digging at the source code quite a bit
>> and can't find a way to do this. With the current architecture, I
>> think I would need to place a custom injector at the top of the
>> injector hierarchy. However, this is impossible right now because:
>> 1) InjectorImpl is final and
>> 2) It expects an InjectorImpl as a parent
>>
>> A better approach would probably be to allow me to hook onto the
>> InjectorImpl mechanism for creation of just-in-time bindings. For
>> example, if the injector fails to create a just-in-time binding it
>> could try to use a user-provided BindingCreator for that key.
>>
>> If you're interested in such a feature, I would happily work on a
>> patch for it.
>>
>> Cheers,
>>
>> Philippe
>>
>>
>> [1] If you're curious, you can look at:
>>
>> http://code.google.com/p/gwt-platform/source/browse/test/com/gwtplatform/mvp/client/PresenterWidgetTest.java
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Status of Guice and persistence support

2010-10-13 Thread Dhanji R. Prasanna
On Wed, Oct 13, 2010 at 8:27 PM, Josh Kamau  wrote:

> Danji;
>
> Does it mean the support for Hibernate api has been dropped? I didnt want
> to use the EntityManager api but native hibernate.
>

Yes, that is correct. The hibernate team themselves are also moving in this
direction, so I felt it was the logical choice.

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Status of Guice and persistence support

2010-10-13 Thread Dhanji R. Prasanna
On Wed, Oct 13, 2010 at 7:34 PM, Josh Kamau  wrote:

> Hi team;
>
> 1 .Does Guice-persist have support  for hibernate? it used to be there in
> warp-persist.
>

Yes, it is supported via JPA.


> 2. How can i get guice-persist with maven? do i have to compile it from the
> code? Can i use guice-persist with Guice 2.0?
>

There are no poms yet, but Stuart might be able to point you in the right
direction--the maven guys maintain a version of Guice called sisu-guice
which has maven poms I believe.

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Build Guice and extensions with Maven

2010-10-12 Thread Dhanji R. Prasanna
OK, I had a chat with Jesse--let's go ahead and change the dir layout in the
maven style, given the following caveats:
- We need to make sure the ant build still works
- Maven should produce the same artifact as Ant (with jarjar'ed internals).
I don't think it serves us to have divergent binaries.
- We should not need to make any source code changes in Guice.

Dhanji.

On Wed, Oct 13, 2010 at 3:24 PM, Jason van Zyl wrote:

>
> On Oct 12, 2010, at 10:46 PM, Dhanji R. Prasanna wrote:
>
> Haha, that's very kind.
>
> I am not arguing against this change per se. In fact, I do want to support
> maven for everyone who uses it. However, changing the dir layout is a bit
> more drastic than my original suggestion, so I would have to get consensus
> from the entire Guice team (Bob, Jesse, Fred, et al, even though Sam and
> Stuart are on board), and our priorities may be slightly different--we want
> to make it easy for both Google-internal and external contributors, we do
> not have any resources other than Java files, etc., so we have to balance
> these pressures =)
>
>
> And I have zero interest in making anyone use Maven if they don't want to.
> But if you don't want to take the POMs as we submitted them, then don't use
> them. Stuart and I can do a better job at supporting Maven users from our
> side because the build we have we know will work in IDEs and anything else
> Maven related because we use the build output everyday.
>
> We'll make sure there is a build of the release in Maven Central with
> proper javadocs and sources with POMs that work. We'll also make sure users
> can clone Guice out of git and just build. We'll keep the repo up-to-date
> with a automatic sync. You don't need to do any work. It's no burden for us
> because we've been doing it for quite some time, and it's in all of our
> products so there shouldn't be any fear about us dropping off the face of
> the planet.
>
> That having been said I'm definitely interested in keeping our maven users
> happy, so will aim for something works well for everyone involved.
>
> Dhanji.
>
> On Wed, Oct 13, 2010 at 9:21 AM, Andrei Pozolotin <
> andrei.pozolo...@gmail.com> wrote:
>
>> Dhanji, hello;
>>
>> just a note from a very intrested bystander:
>>
>> you are a world-renown book author and genius of depenency injection;
>>
>> can you please just accept Jason view on build system setup?
>>
>> "there is no right or wrong but thinking makes it so", right?
>>
>> delay of joy (and guice) is needless! :-)
>>
>> thank you;
>>
>> Andrei
>>
>>
>> On Oct 12, 4:56 pm, Jason van Zyl  wrote:
>> > On Oct 9, 2010, at 8:34 PM, Dhanji R. Prasanna wrote:
>> > > On Sun, Oct 10, 2010 at 3:31 AM, Mingfai 
>> wrote:
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "google-guice" group.
>> To post to this group, send email to google-gu...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-guice+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-guice?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>
> Thanks,
>
> Jason
>
> --
> Jason van Zyl
> Founder,  Apache Maven
> http://twitter.com/jvanzyl
> -
>
> In short, man creates for himself a new religion of a rational
> and technical order to justify his work and to be justified in it.
>
>   -- Jacques Ellul, The Technological Society
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Build Guice and extensions with Maven

2010-10-12 Thread Dhanji R. Prasanna
Haha, that's very kind.

I am not arguing against this change per se. In fact, I do want to support
maven for everyone who uses it. However, changing the dir layout is a bit
more drastic than my original suggestion, so I would have to get consensus
from the entire Guice team (Bob, Jesse, Fred, et al, even though Sam and
Stuart are on board), and our priorities may be slightly different--we want
to make it easy for both Google-internal and external contributors, we do
not have any resources other than Java files, etc., so we have to balance
these pressures =)

That having been said I'm definitely interested in keeping our maven users
happy, so will aim for something works well for everyone involved.

Dhanji.

On Wed, Oct 13, 2010 at 9:21 AM, Andrei Pozolotin <
andrei.pozolo...@gmail.com> wrote:

> Dhanji, hello;
>
> just a note from a very intrested bystander:
>
> you are a world-renown book author and genius of depenency injection;
>
> can you please just accept Jason view on build system setup?
>
> "there is no right or wrong but thinking makes it so", right?
>
> delay of joy (and guice) is needless! :-)
>
> thank you;
>
> Andrei
>
>
> On Oct 12, 4:56 pm, Jason van Zyl  wrote:
> > On Oct 9, 2010, at 8:34 PM, Dhanji R. Prasanna wrote:
> > > On Sun, Oct 10, 2010 at 3:31 AM, Mingfai  wrote:
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Status of Guice and persistence support

2010-10-11 Thread Dhanji R. Prasanna
Hi,

Guice persist at trunk is more or less stable. Warp persist has been
superceded by it. You can use a snapshot build, it should be fine for the
foreseeable future.

We support @Transactional, injecting the EntityManager and many other
features:
http://code.google.com/p/google-guice/wiki/GuicePersist

We support JPA 1 and 2 but nothing special for 2.

Dhanji.

On Mon, Oct 11, 2010 at 12:30 PM, Michael Ballantyne <
michael.ballant...@gmail.com> wrote:

> Hello All,
>
> I am considering porting part of a project to Guice and will be
> needing to use JPA or hibernate. Currently we are using EJBs with
> injected EntityManager and transactions, but we want to move away from
> EJBs so we can move from an EAR on jboss to a tomcat WAR. Along the
> way, we want to make fuller use of dependency injection and make
> development nicer.
>
> What can guice provide? I noticed that the development version
> includes guice-persist, and also that warp-persist exists for some
> current version (1 or 2?), but appears unmaintained. I am not sure
> what I should select that will be usable now and maintained in the
> future. Also, at current we are currently using some features of
> Hibernate included only in JPA 1, not 2. Is JPA 2 supported by any of
> the options?
>
> Any suggestions / hints?
>
> Thanks,
> Michael Ballantyne
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Accessing bindings in ServletContextListener

2010-10-09 Thread Dhanji R. Prasanna
One possibility is to inject your required classes after contextCreated:

public class MyGuiceConfig extends GuiceServletContextListener {
  @Inject MyShutdownService service;

  @Override protected Injector getInjector() {
Injector injector = Guice.createInjector(..);
injector.injectMembers(this);
return injector;
  }

  @Override public void contextDestroyed() ...
}

You can also access the injector from the servlet context
by GuiceServletContextListener.INJECTOR_NAME but I don't recommend this
approach.

Dhanji.

On Sun, Oct 10, 2010 at 8:43 AM, Jerzy Czopek wrote:

> I have an web app with set up very nice with guice. The thing is I'd
> like to access some binded classes in my extension of
> GuiceServletContext, especially in contextDestroyed() method so I can
> perform some clean shutdown. How can I do this?
>
> Regards,
> Jerzy
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Build Guice and extensions with Maven

2010-10-09 Thread Dhanji R. Prasanna
On Sun, Oct 10, 2010 at 3:31 AM, Mingfai  wrote:
>
> for sure Maven in theory "should" be able to handle different structure and
> Guice's developers could have their own preference, the maven's structure
> does have some advantages. Let's compare:
>src/...
>test/...
>
> with:
>
>core/src/main/java/...
>core/src/test/java/...
>

Not to start a flame war here, but this comparison seems rather starkly to
point out the simplicity and elegance of our current layout. =)

Also, I'm supporting mavenizing as an alternative for our users who are
familiar with maven, but it would be more difficult for me to make the
argument to replace Ant as the primary build system (that is another
discussion for another thread), which I am not proposing right now.

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Build Guice and extensions with Maven

2010-10-08 Thread Dhanji R. Prasanna
On Thu, Oct 7, 2010 at 8:46 PM, Stuart McCulloch  wrote:

> On 6 October 2010 11:38, Dhanji R. Prasanna  wrote:
>
>> Spoke to Jason offline. If you are able, you should check these poms in.
>
>
> I'd also like to move the core code into it's own directory and align the
> source and test directories
> to match what maven expects (src/main/java and src/test/java) - ant doesn't
> care about the layout
> so it's much easier to use this convention (and amend the ant scripts to
> use it) than force maven
> to use the ant layout - especially once you get IDEs involved
>

I would much rather not move these dirs if that is possible--I thought maven
could handle any layouts? I think our current layout is nice and clean.

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Building Guice

2010-10-08 Thread Dhanji R. Prasanna
We don't use maven to build Guice (yet). You can use ant distjars to build
Guice.

sisu guice is a fork of Guice that sonatype maintains with some patches
specific to their needs. IIUC, they are looking to move away from this and
back to Guice trunk as all those patches move upstream.

Dhanji.

On Fri, Oct 8, 2010 at 12:30 AM, Murali  wrote:

> svn checkout http://google-guice.googlecode.com/svn/trunk/ google-
> guice
> cd google-guice
> mvn clean install
>
> doesn't work. Just empty jar files under target dir.
> That is, no Java code got compiled, I see this in maven build output:
> [INFO] [compiler:compile {execution: default-compile}]
> [INFO] No sources to compile
>
> where as
>
> git clone http://github.com/sonatype/sisu-guice.git
> cd sisu-guice
> mvn clean install
>
> works.
>
> Is former not the right way to build Guice? What is sisu guice? Why
> have both svn and git?
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Weird JpaPersistService Issue

2010-10-08 Thread Dhanji R. Prasanna
What is your JPA provider?

Btw how are you checking the object id? If you're looking at its hashcode
that wont tell you anything as hashcodes can repeat. Im not familiar with
eclipse's debugger. We have tests asserting that entitymanagers should not
cross, so I wonder if it is some flushing issue with your JPA provider?

Dhanji.

On Wed, Oct 6, 2010 at 5:13 AM, mgbowman wrote:

> This is a shot in the dark but let me explain what's going on...
>
> I'm using guice + guice-servlet + guice-persist (20100927) in my
> current development efforts. Every method in my business logic which
> access the EntityManager is annotated with @Transactional. Using the
> Eclipse debugger, I can confirm that at the end of every Transaction
> the call to JpaPersistService.end() is called which removes the
> ThreadLocal EntityManager instance.
>
> It seems that on subsequent requests which are handled by a thread
> which had already serviced a previous request, the ThreadLocal returns
> a previously created EntityManager (confirmed by the object id in the
> Eclipse debugger) which is returning a 'stale' state of the database.
>
> I'm completely at a loss of words on this and I'm going to debug it
> more tomorrow. If there's any chance that anybody could give any sort
> of insight, it will be greatly appreciated.
>
> I will update with any new info as I uncover it.
>
> Thanks in advanced,
> --mgbowman
>
> Note: I'm running on Java 1.6 + Tomcat 6.0.29 under OS X 10.6.4
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: @Configurable in Guice

2010-10-07 Thread Dhanji R. Prasanna
I see =)

Well, Guice's AOP (and Spring's originally) does not use load-time weaving,
both using run-time weaving.

Dhanji.

On Thu, Oct 7, 2010 at 2:34 AM, Brian Pontarelli wrote:

> That's what I meant by AOP. ;)
>
> -bp
>
>
> On Oct 6, 2010, at 6:46 AM, Dhanji R. Prasanna wrote:
>
> Neither, it is load-time weaving.
>
> Dhanji.
>
> On Wed, Oct 6, 2010 at 3:47 AM, Brian Pontarelli wrote:
>
>> Sounds like magic hand-waving to me. You should avoid the use of 'new'
>> when possible and just ask the Injector for a new instance. Then Guice takes
>> care of everything else for you. On a side note, I wonder if this is AOP or
>> compile-time code injection?
>>
>> -bp
>>
>>
>> On Oct 4, 2010, at 5:48 PM, yarco wrote:
>>
>> > I really like this feature in spring. Will there be support for it (i
>> > know about injectMembers in Guice)? Its kind of cool to just new A()
>> > and have all members injected automatically.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "google-guice" group.
>> > To post to this group, send email to google-gu...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> google-guice+unsubscr...@googlegroups.com
>> .
>> > For more options, visit this group at
>> http://groups.google.com/group/google-guice?hl=en.
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "google-guice" group.
>> To post to this group, send email to google-gu...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-guice+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-guice?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Build Guice and extensions with Maven

2010-10-06 Thread Dhanji R. Prasanna
Spoke to Jason offline. If you are able, you should check these poms in.

Dhanji.

On Wed, Oct 6, 2010 at 9:00 PM, Stuart McCulloch  wrote:

> On 5 October 2010 05:22, Dhanji R. Prasanna  wrote:
>
>> Nice! Will these poms work with Guice core?
>
>
> yes, they already build core (both AOP and no-AOP flavours) and the
> extensions - next step is to add the doclava doclet
>
>
>> Dhanji.
>>
>> On Tue, Oct 5, 2010 at 3:14 AM, Jason van Zyl wrote:
>>
>>> FYI,
>>>
>>> I just finished building Guice along with all the extensions using the
>>> build that Stuart put together:
>>>
>>> http://gist.github.com/609958
>>>
>>> Should be possible doing the following:
>>>
>>> git clone http://github.com/sonatype/sisu-guice.git
>>> cd sisu-guice
>>> mvn clean install
>>>
>>> Thanks,
>>>
>>> Jason
>>>
>>> --
>>> Jason van Zyl
>>> Founder,  Apache Maven
>>> http://twitter.com/jvanzyl
>>> -
>>>
>>> We know what we are, but know not what we may be.
>>>
>>>   -- Shakespeare
>>>
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "google-guice" group.
>>> To post to this group, send email to google-gu...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> google-guice+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-guice?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "google-guice" group.
>> To post to this group, send email to google-gu...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-guice+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-guice?hl=en.
>>
>
>
>
> --
> Cheers, Stuart
>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: @Configurable in Guice

2010-10-05 Thread Dhanji R. Prasanna
Though, Im sure there are ant tasks that do this at build time too.

Dhanji.

On Wed, Oct 6, 2010 at 8:46 AM, Dhanji R. Prasanna  wrote:

> Neither, it is load-time weaving.
>
> Dhanji.
>
>
> On Wed, Oct 6, 2010 at 3:47 AM, Brian Pontarelli wrote:
>
>> Sounds like magic hand-waving to me. You should avoid the use of 'new'
>> when possible and just ask the Injector for a new instance. Then Guice takes
>> care of everything else for you. On a side note, I wonder if this is AOP or
>> compile-time code injection?
>>
>> -bp
>>
>>
>> On Oct 4, 2010, at 5:48 PM, yarco wrote:
>>
>> > I really like this feature in spring. Will there be support for it (i
>> > know about injectMembers in Guice)? Its kind of cool to just new A()
>> > and have all members injected automatically.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "google-guice" group.
>> > To post to this group, send email to google-gu...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> google-guice+unsubscr...@googlegroups.com
>> .
>> > For more options, visit this group at
>> http://groups.google.com/group/google-guice?hl=en.
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "google-guice" group.
>> To post to this group, send email to google-gu...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-guice+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-guice?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: @Configurable in Guice

2010-10-05 Thread Dhanji R. Prasanna
Neither, it is load-time weaving.

Dhanji.

On Wed, Oct 6, 2010 at 3:47 AM, Brian Pontarelli wrote:

> Sounds like magic hand-waving to me. You should avoid the use of 'new' when
> possible and just ask the Injector for a new instance. Then Guice takes care
> of everything else for you. On a side note, I wonder if this is AOP or
> compile-time code injection?
>
> -bp
>
>
> On Oct 4, 2010, at 5:48 PM, yarco wrote:
>
> > I really like this feature in spring. Will there be support for it (i
> > know about injectMembers in Guice)? Its kind of cool to just new A()
> > and have all members injected automatically.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> > To post to this group, send email to google-gu...@googlegroups.com.
> > To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> > For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Build Guice and extensions with Maven

2010-10-04 Thread Dhanji R. Prasanna
Nice! Will these poms work with Guice core?

Dhanji.

On Tue, Oct 5, 2010 at 3:14 AM, Jason van Zyl wrote:

> FYI,
>
> I just finished building Guice along with all the extensions using the
> build that Stuart put together:
>
> http://gist.github.com/609958
>
> Should be possible doing the following:
>
> git clone http://github.com/sonatype/sisu-guice.git
> cd sisu-guice
> mvn clean install
>
> Thanks,
>
> Jason
>
> --
> Jason van Zyl
> Founder,  Apache Maven
> http://twitter.com/jvanzyl
> -
>
> We know what we are, but know not what we may be.
>
>   -- Shakespeare
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Neo4j and persistence

2010-09-26 Thread Dhanji R. Prasanna
You have to build Guice Persist from source for the jar. It is part of the
Guice 3.0 broad release. However, it should be reasonably stable now to try.

We do not support neo4j, but it should be pretty easy to extend Guice
Persist to do so. Have a look at extending PersistModule to provide this
functionality.

Dhanji.

On Sun, Sep 26, 2010 at 8:54 PM, yby  wrote:

> Hi,
>
> I'm using Guice 2.0, and wondering how to integrate it with Neo4J
> (neo4j.org). Particularly, I'd like to annotate a method with
> @Transactional, and have Guice handle the details of starting and
> commiting a Neo4j transaction.
> Has anyone been able to do this with Guice 2.0?
> Also, I'm not able to locate the guice-persist.jar that is discussed
> here:
> http://code.google.com/docreader/#p=google-guice&s=google-guice&t=GuicePersist
> It's not in the list of jars and isn't being built from the sources of
> Guice 2.0 (at least not for me).
> So what am I missing? Do I need Guice 3 ?
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: java.lang.InstantiationException

2010-09-23 Thread Dhanji R. Prasanna
It will instantiate this once when the first request arrives (lazy
singleton). If it can't be instantiated, it will try again the next request
because there is no instance, and again...

What is the exception saying?

Dhanji.

On Fri, Sep 24, 2010 at 3:28 AM, Sandeep  wrote:

> We inherited a codebase that has Guice on the server side supporting
> GWT code on the client side. While we have the basic 'handler'
> mappings, the rest of the server side still heavily relies on
> singletons and factories. I am in the initial steps of converting
> things over.
>
> I have a file uploading servlet that needs to maintain a map of
> uploaded files per user session. It also needs to read some properties
> from a .properties file.
>
> I am injecting a 'propertyreader' instance into the servlet
> @Inject
>public FileUploadServlet(PropertyReader propertyReader) {
> 
>
> The servlet is bound in a servlet module.
>  bind(FileUploadServlet.class).in(Singleton.class);
>serveRegex("/.gupld").with( FileUploadServlet.class );
>
> I am getting instantiation exceptions on GET requests. Technically, it
> should be a singleton and new requests shouldn't attempt to create new
> instances of this object, right?
>
> What am I doing wrong?
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: guice aop: calling base class (non proxy) method?

2010-09-22 Thread Dhanji R. Prasanna
You could do it by binding two different instances and using an instance
matcher.

Dhanji.

On Thu, Sep 23, 2010 at 12:08 PM, Sam Berlin  wrote:

> This is actually a deficiency in the Binder API right now -- interceptors
> match based on Class (and Method), not Key.   I looked into this a while ago
> when someone asked a similar question internally, and there didn't seem to
> be any reason within the implementation that it was limited to Class (as
> opposed to Key), but changing it to Key would be a clunky API change (it
> would require an additional method name... it can't be an overloaded method
> because the limitation on Class is in the generics, and the generic types
> would clash).
>
> sam
>
> On Wed, Sep 22, 2010 at 9:45 PM, Dhanji R. Prasanna wrote:
>
>> The simple way to do it would be to bind the class to two different keys:
>> one which gets intercepted and one that doesn't.
>>
>> Dhanji.
>>
>>
>> On Wed, Sep 22, 2010 at 7:37 AM, Andrei Pozolotin <
>> andrei.pozolo...@gmail.com> wrote:
>>
>>> Hello;
>>>
>>> SITUATOIN:
>>>
>>> when I use guice aop interceptor for a class:
>>>
>>> class Base { void call() {} }
>>>
>>> the guice aop will use cglib to produce a proxy derived class, such
>>> as:
>>>
>>> class Base&&EnhancerByGuice$$12345678 extends Base { void call() {} }
>>>
>>> PROBLEM:
>>>
>>> how can I call original Base.call() method and NOT EnhancerByGuice?
>>>
>>> in the spirit of invokeSuper():
>>>
>>> http://cglib.sourceforge.net/apidocs/net/sf/cglib/MethodProxy.html#invokeSuper%28java.lang.Object,%20java.lang.Object[]%29
>>>
>>> Thank you;
>>>
>>> Andrei
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "google-guice" group.
>>> To post to this group, send email to google-gu...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> google-guice+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-guice?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "google-guice" group.
>> To post to this group, send email to google-gu...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-guice+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-guice?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: guice aop: calling base class (non proxy) method?

2010-09-22 Thread Dhanji R. Prasanna
The simple way to do it would be to bind the class to two different keys:
one which gets intercepted and one that doesn't.

Dhanji.

On Wed, Sep 22, 2010 at 7:37 AM, Andrei Pozolotin <
andrei.pozolo...@gmail.com> wrote:

> Hello;
>
> SITUATOIN:
>
> when I use guice aop interceptor for a class:
>
> class Base { void call() {} }
>
> the guice aop will use cglib to produce a proxy derived class, such
> as:
>
> class Base&&EnhancerByGuice$$12345678 extends Base { void call() {} }
>
> PROBLEM:
>
> how can I call original Base.call() method and NOT EnhancerByGuice?
>
> in the spirit of invokeSuper():
>
> http://cglib.sourceforge.net/apidocs/net/sf/cglib/MethodProxy.html#invokeSuper%28java.lang.Object,%20java.lang.Object[]%29
>
> Thank you;
>
> Andrei
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Guice 3.0 from svn not working?

2010-09-22 Thread Dhanji R. Prasanna
did you try ant distjars?

This error trace means that jarjar did not run and repackage Guice's
internal deps.

Dhanji.

On Thu, Sep 23, 2010 at 6:44 AM, Daniel Manzke  wrote:

> Hi Guys,
>
> I checked out Guice 3.0 from the trunk and I can't get it up and
> running. I run the ant-Tasks with "dist" to get a Snapshot, due the
> fact that no one is provided through Maven.
> I've created a simple java application and added javax.inject.jar and
> the aopalliance.jar, but when starting the application, I get
> following error:
>
> Exception in thread "main"
> com.google.inject.internal.util.ComputationException:
> java.lang.NoClassDefFoundError: com/google/inject/internal/cglib/proxy/
> CallbackFilter
>at com.google.inject.internal.util.MapMaker
> $StrategyImpl.compute(MapMaker.java:553)
>at com.google.inject.internal.util.MapMaker
> $StrategyImpl.compute(MapMaker.java:419)
>at com.google.inject.internal.util.CustomConcurrentHashMap
> $ComputingImpl.get(CustomConcurrentHashMap.java:2042)
>at com.google.inject.internal.FailableCache.get(FailableCache.java:
> 48)
>at
>
> com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:
> 49)
>at
>
> com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:
> 125)
>at
>
> com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:
> 491)
>at
>
> com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:
> 808)
>at
>
> com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:
> 740)
>at
>
> com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:
> 233)
>at
>
> com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:
> 183)
>at
>
> com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:
> 814)
>at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:
> 46)
>at
>
> com.google.inject.internal.BindingProcessor.runCreationListeners(BindingProcessor.java:
> 240)
>at
>
> com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:
> 145)
>at
>
> com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:
> 118)
>at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:100)
>at com.google.inject.Guice.createInjector(Guice.java:95)
>at com.google.inject.Guice.createInjector(Guice.java:72)
>at com.google.inject.Guice.createInjector(Guice.java:61)
>at ExampleApp.run(ExampleApp.java:41)
>at ExampleApp.main(ExampleApp.java:47)
> Caused by: java.lang.NoClassDefFoundError: com/google/inject/internal/
> cglib/proxy/CallbackFilter
>at
>
> com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:
> 81)
>at com.google.inject.internal.ConstructorInjectorStore.access
> $000(ConstructorInjectorStore.java:28)
>at com.google.inject.internal.ConstructorInjectorStore
> $1.create(ConstructorInjectorStore.java:36)
>at com.google.inject.internal.ConstructorInjectorStore
> $1.create(ConstructorInjectorStore.java:32)
>at com.google.inject.internal.FailableCache
> $1.apply(FailableCache.java:37)
>at com.google.inject.internal.util.MapMaker
> $StrategyImpl.compute(MapMaker.java:549)
>... 21 more
> Caused by: java.lang.ClassNotFoundException:
> com.google.inject.internal.cglib.proxy.CallbackFilter
>at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>at java.security.AccessController.doPrivileged(Native Method)
>at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>... 27 more
>
>
> I did a little bit more research, but the 3.0 is not having any
> dependencies to it, but the code tries to load it. Some ideas?
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Guice 3.0 ?

2010-09-21 Thread Dhanji R. Prasanna
We'd love to do so, but as we are time-constrained we'd love for volunteers
to help with this process. Particularly in writing the build poms and so
forth...

Dhanji.

On Tue, Sep 21, 2010 at 2:07 AM, Antoine DESSAIGNE <
antoine.dessai...@gmail.com> wrote:

> Thanks a lot for updating the wiki :)
>
> Do you plan on publishing Guice 3.0 snapshots on a maven repository?
>
> Antoine.
>
> 2010/9/21 Sam Berlin 
>
> There's a preliminary list of new features & changes now @
>> http://code.google.com/p/google-guice/wiki/Guice30 .  Lots of details are
>> missing, but the major concepts are there.
>>   sam
>>
>> On Wed, Sep 15, 2010 at 3:22 AM, Antoine DESSAIGNE <
>> antoine.dessai...@gmail.com> wrote:
>>
>>> Thanks a lot for the info. I can't wait to see this changelist :)
>>>
>>> 2010/9/14 Sam Berlin 
>>>
 I'll regenerate a new changelist for 3.0, to help review of it &
 hopefully spur use.  We'll probably start with a snapshot/beta release, for
 folks who don't like building from head -- but SVN head has been very 
 stable
 for a long time now and in use at multiple projects (including in Google 
 and
 now also as the DI container in Maven).  It's kind of amazing how many
 things have changed since the 2.0 release, yet with very few actual API
 changes.

 sam

 On Tue, Sep 14, 2010 at 3:43 AM, Antoine 
 wrote:

> Hi everyone,
>
> I'm following the SVN feed and I'm excited by some of the features of
> what might become Guice 3.0 like persistency or mini-guice.
>
> I was wondering whether or not you have a list of the features you
> want to include in Guice 3.0 and whether or not you have a rough idea
> of the expected release date (within 3 month from now? 6 month? a
> year? more?)
>
> Thanks a lot for your answers.
>
> Antoine.
>
> --
> You received this message because you are subscribed to the Google
> Groups "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>
  --
 You received this message because you are subscribed to the Google
 Groups "google-guice" group.
 To post to this group, send email to google-gu...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-guice+unsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/google-guice?hl=en.

>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "google-guice" group.
>>> To post to this group, send email to google-gu...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> google-guice+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-guice?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "google-guice" group.
>> To post to this group, send email to google-gu...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-guice+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-guice?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Overriding Bindings

2010-09-20 Thread Dhanji R. Prasanna
You can't do this at the binding level, but you can at the Module level, so
if you refactor correctly should be able to get what you want.

Check out Modules.override()

Dhanji.

On Mon, Sep 20, 2010 at 10:13 AM, Lucas Cavalcanti
wrote:

> Hi,
>
> I have a class intended for subclassing where I configure a module,
> and the subclass can configure its own module.
>
> The injector is created by:
>
> Injector injector = Guice.createInjector(new SuperClassModule(),
> subclassModule());
>
> Is there any way to override a SuperClassModule binding on the
> subclassModule() ?
>
> Thanks,
> Lucas
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Q: Http Sessions managment in guice

2010-09-20 Thread Dhanji R. Prasanna
It's possible, we'd have to create one per listener type though, so it is
not as elegant as the filter and servlet model.

On Mon, Sep 20, 2010 at 1:09 AM, Moandji Ezana  wrote:

> On Sun, Sep 19, 2010 at 9:24 PM, Dhanji R. Prasanna wrote:
>
>> you should use the servlet container's HttpSessionListener directly
>
>
> I was thinking about this a couple of days ago, but haven't had the chance
> to try it out. Is it possible to have Guice instantiate and configure
> listeners in the same way it does servlets?
>
> Moandji
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Q: Http Sessions managment in guice

2010-09-19 Thread Dhanji R. Prasanna
Guice doesn't provide any direct support for this--you should use the
servlet container's HttpSessionListener directly.

As a matter of principle, we typically shy away from too much direct use of
sessions as they scale very poorly.

Dhanji.

On Sun, Sep 19, 2010 at 4:19 AM, amiserio  wrote:

> Hi,
> I need a session manager, who will keep a list of current sessions and
> keep it up to date.
> How to use HttpSessionListener with guice?
> Is it possible to track the creation and destruction of the sessions?
> if so, how?
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Guice + Jetty, works in Eclipse, not standalone

2010-09-18 Thread Dhanji R. Prasanna
Check out some of the acceptance tests in Sitebricks, they all use Guice
Servlet + Jetty.

http://code.google.com/p/google-sitebricks/source/checkout

On Fri, Sep 17, 2010 at 7:57 AM, batkins  wrote:

> I have an app build into a war file, and would like to use embedded
> jetty to run it.  In eclipse dev mode, everything works as expected,
> but when I try to use it standalone with embedded jetty, I get 404s on
> each of the servlets.  When I go to the context root (/jost), I get
> the HTML welcome page, as expected.
>
> The gwt.xml file has rename-to="jost".  My ServletModule is:
>
>public void configureServlets() {
>serve("/jost/test").with(TestServlet.class);
>serve("/jost/register").with(RegServlet.class);
>}
>
> web.xml is:
>
>
>guiceFilter
>com.google.inject.servlet.GuiceFilter class>
>
>
>
>guiceFilter
>/*
>
>
>
> class>com.netapp.rre.jost.server.guice.JostServletContextListener
>
>
>
>
>Jost.html
>
>
> My jetty server is launched as follows:
>
>Server server = new Server(8080);
>
>WebAppContext webapp = new WebAppContext();
>webapp.setContextPath("/jost");
>webapp.setTempDirectory(new File("."));
>webapp.setWar("jost.war");
>
>server.setHandler(webapp);
>server.start()
>server.join();
>
> Here's output from my jetty launch:
>
> 2010-09-17 09:14:51.749:DBUG::STARTED
> selectchannelconnec...@0.0.0.0:8080
> org.eclipse.jetty.server.ser...@dc840f STOPPED
>  +-webappcont...@a56a7c@a56a7c/jost,file:/C:/p4/jost/server/
> webapp/,jost.war sta
> rted
>+-sessionhand...@107ebe1 started
>   +-constraintsecurityhand...@544ec1 started
>  +-servlethand...@10f11b8 started
> +-[/*]/[]==0=>guiceFilter{}
> +-[/]=>default{maxCacheSize=25600, dirAllowed=true,
> gzip=true,
> maxCachedFileSize=1000, redirectWelcome=false, cacheType=both,
> acceptRanges=
> true, welcomeServlets=false, aliases=false, useFileMappedBuffer=true,
> maxCachedF
> iles=1000}
> +-[*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX,
> *.XSP]=>jsp
> {logVerbosityLevel=DEBUG, fork=false, xpoweredBy=false, scratchdir=C:
> \p4\jost\se
> rver\jsp}
> +-[/jost/gwt-log]=>remoteLoggerServiceImpl{}
>  +=roles=[]
>  +=/={TRACE={RoleInfo,F,C[]}}
>
> When request  http://localhost:8080/jost/register, I get
>
> 2010-09-17 09:23:22.383:DBUG::call servlet default
> 2010-09-17 09:23:22.383:DBUG::RESOURCE /register=null
> 2010-09-17 09:23:22.383:DBUG::RESOURCE /register=null
> 2010-09-17 09:23:22.383:DBUG::resource=null
> 2010-09-17 09:23:22.399:DBUG::RESPONSE /jost/register  404
> 2010-09-17 09:23:22.446:DBUG::EXCEPTION
>
> This is probably something right in front of me, but I've been banging
> my head against this wall for awhile now, and could use other eyes on
> it.  Any help would be most appreciated.
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Guice 3.0 ?

2010-09-14 Thread Dhanji R. Prasanna
It will be very soon. The main feature targets are on the dev-list
somewhere. Guice-persist is more or less ready to go pending docs.

Dhanji.

On Tue, Sep 14, 2010 at 3:43 AM, Antoine wrote:

> Hi everyone,
>
> I'm following the SVN feed and I'm excited by some of the features of
> what might become Guice 3.0 like persistency or mini-guice.
>
> I was wondering whether or not you have a list of the features you
> want to include in Guice 3.0 and whether or not you have a rough idea
> of the expected release date (within 3 month from now? 6 month? a
> year? more?)
>
> Thanks a lot for your answers.
>
> Antoine.
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Google Guice (pronounced "Guice")

2010-09-08 Thread Dhanji R. Prasanna
On Mon, Sep 6, 2010 at 10:01 PM, Blessed Geek  wrote:

>
> Pneumonoultramicroscopicsilicovolcanoconiosis is not a fictitious
> word.
>

I know, if you look at my email it says "fActitious" not "fIctitious", hence
the comment about pronounceability.
http://en.wiktionary.org/wiki/factitious


> It is one of the longest word - in fact, the longest word if we
> discount words formed by chemical structural nomenclature. Even though
> this word is a medical word, it is not tainted by structural
> nomenclature.
>

Yes, this word was popular meme when I was 4th grade along
with Supercalifragilisticexpialidocious.

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: AppEngine's UserService class affects Guice session scoped objects in Appengine runtime

2010-09-04 Thread Dhanji R. Prasanna
Yes that's possible, but I believe it requires you explicitly set the object
on the session every time it is mutated. This more or less defeats the
purpose of @SessionScoped.

There are also additional restrictions around Serialization etc.

Dhanji.

On Sun, Sep 5, 2010 at 12:01 AM, Andrew Wiley  wrote:

>
>
> On Sat, Sep 4, 2010 at 3:13 AM, Dhanji R. Prasanna wrote:
>
>>
>> This is definitely an appengine problem. Appengine is a cluster service,
>> it does not guarantee that two requests from the same user will be serviced
>> by the same physical process. So anything stored in the session in the first
>> request may not be available in the second.
>>
>> Instead of using sessions this way you must use Memcache (for data that
>> can be recomputed) or the appengine datastore (for "oracular" data, i.e.
>> data that cannot be recomputed). And retrieve it each time inside the
>> request from either location.
>>
>> Dhanji.
>>
>>
>>
> I'd have to recheck the docs to be sure, but I'm pretty sure AppEngine does
> guarantee that the session will carry over because it's storing the session
> in the datastore under the hood. At least, that's what I remember reading.
>
> Andrew Wiley
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: AppEngine's UserService class affects Guice session scoped objects in Appengine runtime

2010-09-04 Thread Dhanji R. Prasanna
On Wed, Sep 1, 2010 at 5:47 PM, DmitriS  wrote:

>
> Hi!
>
> I have created some sample GWT application, which uses Guice 2.0.1,,
> gwt-dispatch 1.1.0 and AppEngine 1.3.6. For user authorization I use
>
> com.google.appengine.api.users.UserService class. For every kind of
> RPC request I use specific action handler, which implements
> ActionHandler, coming from gwt-dispatch library.
> First action handler checks, if user has just logged in, generates
> login or logout URLs and tries to fill with additional user data my
> custom, session
>
> scoped class UserInfo:
>
> package sesstest.server;
>
> import java.io.Serializable;
>
> public class UserInfo implements Serializable {
>
>private static final long serialVersionUID = 5L;
>private String testValue;
>
>public UserInfo() {
>}
>
>public UserInfo(final String testValue) {
>this.testValue = testValue;
>}
>
>public String getTestValue() {
>return testValue;
>}
>
>public void setTestValue(String testValue) {
>this.testValue = testValue;
>}
> }
>
>
>
> FirstActionHandler:
>
>
>@Inject
>public FirstActionHandler(final Provider userInfoProvider)
> {
>this.userInfoProvider = userInfoProvider;
>}
>
>
>@Override
>public MyActionsResult execute(FirstAction action, ExecutionContext
> arg1)
>throws DispatchException {
>logger.debug("first action handler, execute method has been
> started");
>UserInfo userInfo = userInfoProvider.get();
>
>String link;
>String linkText;
>UserService userService =
> UserServiceFactory.getUserService();
>User currentUser = userService.getCurrentUser();
>if (currentUser == null){
>link =
> userService.createLoginURL(action.getRedirectUrl());
>linkText = "User is not logged in. Please login!";
>} else {
>link =
> userService.createLogoutURL(action.getRedirectUrl());
>linkText = currentUser.getEmail();
>}
>
>userInfo.setTestValue("text from first action handler");
>
>MyActionsResult result = new MyActionsResult(linkText,
> link);
>logger.debug("finish");
>return result;
>}
>
>
> In second action handler, where I get UserInfo instance in the same
> way, I expect it to contain previously specified testValue, but IT'S
> NULL :(
>
>
> I have only one Guice binding:
>
>bind(UserInfo.class).in(SessionScoped.class);
>
> According to gwt-dispatch, all action handlers are singletons.
> My appengine-web.xml contains this line:
> true
>
> The most interesting thing is that all this happens ONLY in web mode
> on appengine, in GWT hosted mode everything works fine.
>
> This definitely happens because of UserService. If I remove it from
> first action handler, and only define some value for
> userInfo.testValue, it will be available inside
>
> second action handler in both hosted and web (deployed on appengine)
> modes.
>
> Could anybody explain me how should I use this UserService together
> with session scoped objects? Any additional Guice bindings for that?
> Or maybe this is more appengine related problem...
>
>
This is definitely an appengine problem. Appengine is a cluster service, it
does not guarantee that two requests from the same user will be serviced by
the same physical process. So anything stored in the session in the first
request may not be available in the second.

Instead of using sessions this way you must use Memcache (for data that can
be recomputed) or the appengine datastore (for "oracular" data, i.e. data
that cannot be recomputed). And retrieve it each time inside the request
from either location.

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Error injecting constructor when using bindInterceptor and constructor injection

2010-09-03 Thread Dhanji R. Prasanna
Do you have a security manager installed different from the default? Or are
you running in an Appserver or something?
Dhanji.

On Wed, Sep 1, 2010 at 10:26 AM, cody lim  wrote:

> My apps encounter error like
> 1) Error injecting constructor,
> java.lang.IllegalAccessError:...
> when i used bindInterceptor and constructor injection. (The apps run
> fine when i use field injection)
> Is there any way to solve the conflict?
>
>
>
> i)LoggingModule
> public class LoggingModule  extends AbstractModule {
>
>@Override
>protected void configure() {
>LoggingInterceptor loggingInterceptor = new
> LoggingInterceptor();
>requestInjection(loggingInterceptor);
>bindInterceptor(Matchers.any() ,Matchers.any(),
> loggingInterceptor);
>
>}
> }
>
> ii)
> constructor
> @Inject
>LogonServlet(Provider sessionProvider, LDAPDao ldapDao,
>final BasicDetailDao basicDetailDao, final CommonDao
> commonDao,
> final UserDao userDao) {
>this.sessionProvider = sessionProvider;
>this.userDao = userDao;
>}
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Constructor Injection resulting in InvocationTargetException

2010-09-03 Thread Dhanji R. Prasanna
Your code appears to be incomplete. Can you post the module as is? It looks
like there is no binding to the String serverAddress that is causing the
problem. Look into the use of bindConstant() in the Guice docs.

Dhanji.

On Wed, Sep 1, 2010 at 12:52 AM, Al Tice  wrote:

> I am new to Guice. I am currently trying to inject a service
> dependency and continue to get the following error. Any help would be
> appreciated. Thanks.
>
> com.google.inject.internal.ComputationExcep
> tion: com.google.inject.internal.ComputationException:
> com.google.inject.interna
> l.cglib.core.CodeGenerationException:
> java.lang.reflect.InvocationTargetExceptio
> n-->null
>
> I basically have a server class.
> @Inject
>public PostServiceImpl( String serverAddress) {
>this.serverAddress;
>}
>
> I am not sure
>
>@Inject
>public Inquiry(ContactDAO contactDAO, PostService postService) {
>
>this.contactDAO = contactDAO;
>this.postService = postService;
>
>}
>
> And in the contextlistener file.
>
> bind(PostService.class).to(PostServiceImpl.class);
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Extending Guice in order to make @Inject optional

2010-09-03 Thread Dhanji R. Prasanna
You can use the bind().toConstructor() API to achieve this.

On Tue, Aug 31, 2010 at 3:38 AM, Paulo Silveira wrote:

> Hello
>
> I would like to make @Inject optional if there is a single
> constructor. In this case, the single constructor should be used. Is
> there an easy way to implement this feature?
>
> Is there any way to extend these injection points?
> http://code.google.com/p/google-guice/wiki/InjectionPoints
>
> Or a way to programmatically configure which constructor of each class
> should be used for injection.
>
> thanks!
>
> --
> Paulo Silveira
> www.caelum.com.br
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: simplest servlet example possible getting 404

2010-09-01 Thread Dhanji R. Prasanna
On Thu, Sep 2, 2010 at 12:11 AM, Dan Billings  wrote:

> I got it working!
>
> Eclipse/m2Eclipse was running another server that was actually
> handling my requests, so it turns out I had it configured properly
> after all!!
>
> For the record, using serve("/file") actually requires //
> file, so Dhanji, your recommendation of using serve("test/file")
> actually results in a url of /test/test/file.  So I am
> going to keep that in mind.
>

Woops, yea, I think it's the regex version that takes the whole URI into
account.

Glad it's working!

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: ServletScopes.APPLICATION and @ApplicationScoped?

2010-09-01 Thread Dhanji R. Prasanna
Sure. Thanks for the kind words, Jesse deserves a lot of the credit for the
good docs in Custom Scopes, and our good docs in general.

Dhanji.

On Wed, Sep 1, 2010 at 7:52 PM, Brian R. Jackson

> wrote:

> On Sep 1, 1:04 am, "Dhanji R. Prasanna"  wrote:
> > On Wed, Sep 1, 2010 at 1:11 AM, Brian R. Jackson
> > <
> brian%2bgoo...@jaxzin.com >
> >
> > > wrote:
> > > I have a guice app running in a JavaEE container and realize I have
> > > the need to annotate my classes/providers with a (non-existant)
> > > @ApplicationScoped.  Specifically I'm registering ehcache MBeans and
> > > need to dispose of them when the application is unloaded from the
> > > container, and wanted to use guiceyfruit support of JSR-250 to do
> > > that.
> >
> > > My question, is there a good reason this scope doesn't already exist?
> > > Am I missing something silly, like the feature exists in a different
> > > form?
> >
> > Well, it sounds a lot like @Singleton. If you mean is there some broader
> > Java EE specific application scope, then no, we do not have an out-of-box
> > solution for that =)
> >
> > Dhanji.
>
>
> Thanks Dhanji,
> After posting this yesterday I came to the realization that @Singleton
> is exactly equivalent to what I'm asking about.  I forgot that each
> application has their own Injector and that @Singletons aren't shared
> at the JVM level, only at the Injector level.
>
> By the way, it was incredibly simple to write the custom scope, which
> I had done until I realized it effectively duplicated @Singleton and
> Scopes.SINGLETON.  Great job with the excellent documentation of
> custom scopes.  I threw out my implementation when I realized it
> didn't add any value over Scopes.SINGLETON, which stored objects in
> ServletContext.setAttribute() instead of the private volatile field in
> the anonymous Provider that Scopes.SINGLETON uses.
>
> Thanks again,
> Brian
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: ServletScopes.APPLICATION and @ApplicationScoped?

2010-08-31 Thread Dhanji R. Prasanna
On Wed, Sep 1, 2010 at 1:11 AM, Brian R. Jackson

> wrote:

> I have a guice app running in a JavaEE container and realize I have
> the need to annotate my classes/providers with a (non-existant)
> @ApplicationScoped.  Specifically I'm registering ehcache MBeans and
> need to dispose of them when the application is unloaded from the
> container, and wanted to use guiceyfruit support of JSR-250 to do
> that.
>
> My question, is there a good reason this scope doesn't already exist?
> Am I missing something silly, like the feature exists in a different
> form?


Well, it sounds a lot like @Singleton. If you mean is there some broader
Java EE specific application scope, then no, we do not have an out-of-box
solution for that =)

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: simplest servlet example possible getting 404

2010-08-31 Thread Dhanji R. Prasanna
Also, try changing it to:

serve("/test/file")

Guice reads the entire request URI for dispatch.

Dhanji.

On Wed, Sep 1, 2010 at 2:53 PM, Dhanji R. Prasanna  wrote:

> Can you paste the code in:
>
> billco.test.guice.GuiceListener please?
>
>
> On Wed, Sep 1, 2010 at 9:34 AM, Dan Billings  wrote:
>
>> BTW I'm using Jetty
>>
>> On Aug 31, 6:27 pm, Dan Billings  wrote:
>> > GuiceModule:
>> > serve("/file").with(FileServlet.class);
>> >
>> > Navigating to /test/file gives me a 404
>> >
>> > I know for a fact my listener is being called.
>> >
>> > As a control, I have one explicitly mapped Servlet which works fine at
>> > /test/simple
>> >
>> > My web.xml:
>> >
>> > 
>> > guiceFilter
>> > com.google.inject.servlet.GuiceFilter
>> >   
>> >
>> >   
>> > guiceFilter
>> > /*
>> >   
>> >   
>> > billco.test.guice.GuiceListener
>> >   
>> >
>> >   
>> >   SimpleServlet
>> >   billco.test.SimpleServlet
>> >   
>> >   
>> >   SimpleServlet
>> >   /simple
>> >   
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "google-guice" group.
>> To post to this group, send email to google-gu...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-guice+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-guice?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: simplest servlet example possible getting 404

2010-08-31 Thread Dhanji R. Prasanna
Can you paste the code in:

billco.test.guice.GuiceListener please?

On Wed, Sep 1, 2010 at 9:34 AM, Dan Billings  wrote:

> BTW I'm using Jetty
>
> On Aug 31, 6:27 pm, Dan Billings  wrote:
> > GuiceModule:
> > serve("/file").with(FileServlet.class);
> >
> > Navigating to /test/file gives me a 404
> >
> > I know for a fact my listener is being called.
> >
> > As a control, I have one explicitly mapped Servlet which works fine at
> > /test/simple
> >
> > My web.xml:
> >
> > 
> > guiceFilter
> > com.google.inject.servlet.GuiceFilter
> >   
> >
> >   
> > guiceFilter
> > /*
> >   
> >   
> > billco.test.guice.GuiceListener
> >   
> >
> >   
> >   SimpleServlet
> >   billco.test.SimpleServlet
> >   
> >   
> >   SimpleServlet
> >   /simple
> >   
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Guice 3.0 SNAPSHOT

2010-08-29 Thread Dhanji R. Prasanna
Hi,
guice-persist is not set up for maven yet, give it a couple of weeks and it
should be ready. In the meantime if you would like to contribute a patch to
make it maven-happy, we're welcome that!

Dhanji.

On Sun, Aug 29, 2010 at 10:35 PM, Deepak  wrote:

> Tried mvn:install on google-persist. But it just exports jar without
> any class files. Any pointers will be appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Apache Maven trunk now uses Guice

2010-08-24 Thread Dhanji R. Prasanna
Hooray!

Congratulations.

Dhanji.

On Wed, Aug 25, 2010 at 7:27 AM, Stuart McCulloch  wrote:

> Hi folks,
>
> FYI... Maven 3 trunk is now using Guice in place of Plexus:
>
>http://svn.apache.org/viewvc?view=revision&revision=988484
>
> So watch out for the next Maven 3 beta release! (3.0-beta-3)
>
> --
> Cheers, Stuart
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Inject the same Instance in two different Beans with Guice

2010-08-20 Thread Dhanji R. Prasanna
For complex graphs like this I would just write a builder that assembled the
structure correctly. There are some things that Guice shouldn't be
shoe-horned into doing. =)

Dhanji.

On Fri, Aug 20, 2010 at 7:23 PM, Stuart McCulloch  wrote:

> On 20 August 2010 16:16, dg  wrote:
>
>>
>> I don't know a direct way in Guice to do this.  However, depending on
>> the structure of your objects, you might be able to get away with
>> something like this
>>
>> class MyModule implements Module {
>>  [snip]
>>  @Provides
>>  provide MasterBean( ContextBean ctx, OtherDep dep ) {
>> return new MasterBean( new SubBean1( ctx ), new SubBean2( ctx ),
>> otherDep );
>>  }
>> }
>>
>> It's not ideal, but...
>>
>
> you could also use the AssistedInject extension to pass on the
> context to the sub beans while still using Guice to inject them
>
> for complex graphs another solution is to use child injectors:
>
>
> http://stackoverflow.com/questions/3014140/dependency-injection-scoping-by-region-guice-spring-whatever
>
> HTH
>
> -d
>>
>> On Aug 18, 7:43 am, Olli  wrote:
>> > Hi,
>> >
>> > I'm struggling with injecting one instance into two different beans.
>> >
>> > Here is my bean structure:
>> >
>> > - MasterBean
>> > - SubBean1
>> > - SubBean2
>> >
>> > MasterBean get both SubBean's injected, the SubBean's does not know
>> > each other.
>> > Both SubBeans get's one ContextBean instance injected.
>> >
>> > The scope of the ContextBean should be attached to the MasterBean, so
>> > when I create a new MasterBean, two new SubBean's should be created
>> > and one ContextBean which is being injected into the two SubBeans.
>> >
>> > Using a singleton is not really a solution because it limits the
>> > MasterBean to one instance. Another solution would be an additional
>> > Guice-Scope, but this a little bit overkill I think... :-(
>> >
>> > Any ideas how to solve this?
>> >
>> > Regards,
>> > Oliver
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "google-guice" group.
>> To post to this group, send email to google-gu...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-guice+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-guice?hl=en.
>>
>>
>
>
> --
> Cheers, Stuart
>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Best practice to inject and clean up resources per request

2010-08-20 Thread Dhanji R. Prasanna
Check out warp-persist which provides all of this functionality for you.
http://www.wideplay.com/guicewebextensions2

Dhanji.

On Thu, Aug 19, 2010 at 9:21 PM, Johannes wrote:

> Hi,
>
> i need a kick start how do this "the guice way".
>
> I have an api to an legacy system which has support for transactions.
> Now I want to write transactional servlets where fresh transactions
> automaticly get injected for each request and automaticly removed when
> the request is done.
>
> My idea is to write a filter which adds a transaction to each new
> request and clean ups after the request is done. Is this the prefered
> way? Or are they better options?
>
> J.
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Google Guice (pronounced "Guice")

2010-08-20 Thread Dhanji R. Prasanna
On Fri, Aug 20, 2010 at 5:11 PM, Blessed Geek  wrote:

> On page 3 of google-guice.googlecode.com/files/
> JavaOnGuice20070426.pdf, it says ...
>
> Google Guice (pronounced "Guice") ...
>

It's supposed to be a joke. I guess it doesn't translate well...


>
> Doesn't help very much, does it?
>
> "Pneumonoultramicroscopicsilicovolcanoconiosis" is pronounced
> "Pneumonoultramicroscopicsilicovolcanoconiosis".
>
>
The irony with your example of course, is that factitious words are easy to
pronounce by inference...

Dhanji ;)

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Mixing Guice and Swing

2010-08-07 Thread Dhanji R. Prasanna
Just to clarify there are no "Guice threads" as such (unless you count the
finalizer thread from FinalizableReferenceQueue, which is not strictly a
Guice artifact).

And getInstance() being thread-safe means that multiple threads can invoke
that method without corrupting Guice's internals or creating multiple
singleton copies by accident of concurrency.

Dhanji.

On Sun, Aug 8, 2010 at 5:34 AM, Tim Peierls  wrote:

> Guice guarantees that a *happens-before* edge exists between injection
> actions that arise as the result of a call to Injector.getInstance and
> actions in the thread following that call in program order, so if you only
> call getInstance in the EDT when injecting Swing components it doesn't
> matter whether Guice performs the injection in its own thread(s) or in the
> EDT. (But in fact the latter is the case.)
>
> The important thing is not to access Swing components in your own
> background threads -- with a few documented exceptions, they are not
> thread-safe. (And because of that, Swing components must not be Singletons,
> unless the injector creation is also in the EDT.)
>
> It wouldn't hurt to add this reassurance to the javadocs, or at least the
> wiki.
>
> --tim
>
>
> On Sat, Aug 7, 2010 at 12:05 PM, cowwoc  wrote:
>
>> Hi,
>>
>> I remember reading that Guice.getInstance() is thread-safe. I also
>> remember reading that one should only interact with Swing components
>> through the event-dispatch thread, even when constructing them.
>>
>> What happens if I invoke Guice.getInstance() inside the EDT? Does it
>> instantiate the dependencies on the current thread (EDT)? Or does it
>> use its own Guice-specific thread?
>>
>> On a side-note, you might want to specify this in the Javadoc.
>>
>> Thank you,
>> Gili
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "google-guice" group.
>> To post to this group, send email to google-gu...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-guice+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-guice?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Guice injection into WebWork 2 actions

2010-08-06 Thread Dhanji R. Prasanna
Hi,

Yea this was an attempt I made some time ago to get struts2 working with
GS2. Unfortunately the way that struts2 works makes it difficult to
integrate with us, so I didn't get far beyond an initial experiment (then
all my time to work on it evaporated).

If you have a solution to this, I'd be happy to take a closer look at it.

Dhanji.

On Sat, Aug 7, 2010 at 7:47 AM, ghirschhorn  wrote:

> Looking into the source code, I found an updated version of the code
> from the above post (http://groups.google.com/group/google-guice/
> browse_thread/thread/b1290d846f883207/1a3c7718511c0650?
> lnk=gst&q=webwork#1a3c7718511c0650).
>
> This updated version still didn't work for me, but got me farther. I
> was getting some error because after plugged-in injector was finished,
> there were some Interceptors that were causing errors because they had
> not been injected and therefore not constructed.  Not sure why this is
> not a problem in Struts2 -- perhaps the loading order is different.
> Anyway, I was able to make the code work for me simply by ignoring
> injection in these cases and falling back to the normal construction
> method.  So some (or all?) Interceptors won't be inject-able here, but
> my WebWork Actions were injected fine.
>
> In case anyone is having the same problem here is the code:
>
>
> /**
>  * Copyright (C) 2009 Google Inc.
>  *
>  * Licensed under the Apache License, Version 2.0 (the "License");
>  * you may not use this file except in compliance with the License.
>  * You may obtain a copy of the License at
>  *
>  * http://www.apache.org/licenses/LICENSE-2.0
>  *
>  * Unless required by applicable law or agreed to in writing, software
>  * distributed under the License is distributed on an "AS IS" BASIS,
>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
>  * See the License for the specific language governing permissions and
>  * limitations under the License.
>  */
>
> package com.google.inject.servlet;
>
> import com.google.inject.AbstractModule;
> import com.google.inject.Binder;
> import com.google.inject.Injector;
> import com.google.inject.Module;
> import com.google.inject.internal.Annotations;
> //import com.opensymphony.xwork2.ActionInvocation;
> //import com.opensymphony.xwork2.ObjectFactory;
> //import com.opensymphony.xwork2.config.ConfigurationException;
> //import com.opensymphony.xwork2.config.entities.InterceptorConfig;
> //import com.opensymphony.xwork2.inject.Inject;
> //import com.opensymphony.xwork2.interceptor.Interceptor;
> import com.opensymphony.xwork.ActionInvocation;
> import com.opensymphony.xwork.ObjectFactory;
> import com.opensymphony.xwork.config.ConfigurationException;
> import com.opensymphony.xwork.config.entities.InterceptorConfig;
> import com.opensymphony.xwork.interceptor.Interceptor;
> import java.lang.annotation.Annotation;
> import java.util.ArrayList;
> import java.util.HashSet;
> import java.util.List;
> import java.util.Map;
> import java.util.Set;
> import java.util.logging.Logger;
>
> /**
>  * Cleanup up version from Bob's GuiceObjectFactory. Now works
> properly with
>  * GS2 and fixes several bugs.
>  *
>  * @author dha...@gmail.com
>  *
>  * Modified com.google.inject.servlet.Struts2Factory to work with
> WebWork. Only
>  * major change was to change handling of Interceptors.  Some (maybe
> all?) Interceptors
>  * are not injected by this code because the original mechanism
> resulted in
>  * errors possibly due to WebWork/Struts2 differences in loading
> order.
>  * @author ghirschh...@fetch.com
>  */
> public class WebWorkFactory extends ObjectFactory {
>
>  static final Logger logger =
>  Logger.getLogger(WebWorkFactory.class.getName());
>
>  volatile Injector webWorkInjector;
>  boolean developmentMode = false;
>  List interceptors
>  = new ArrayList();
>  private static final String ERROR_NO_INJECTOR =
>  "Cannot find a Guice injector in the servlet context. Are you"
>  + " sure you registered GuiceServletContextListener in your
> application's web.xml?";
>
>  @Override
>  public boolean isNoArgConstructorRequired() {
>return false;
>  }
>
> //  @Inject(value = "webWork.devMode", required = false)
>  void setDevelopmentMode(String developmentMode) {
>this.developmentMode = "true".equals(developmentMode.trim());
>  }
>
>  Set> boundClasses = new HashSet>();
>
>  public Class getClassInstance(String name) throws
> ClassNotFoundException {
>Class clazz = super.getClassInstance(name);
>
>synchronized (this) {
>  if (webWorkInjector == null) {
>// We can only bind each class once.
>if (!boundClasses.contains(clazz)) {
>  try {
>// Calling these methods now helps us detect
> ClassNotFoundErrors
>// early.
>clazz.getDeclaredFields();
>clazz.getDeclaredMethods();
>
>boundClasses.add(clazz);
>  } catch (Throwable t) {
>// WebWork should still work even though some classes
> a

Re: Slow start up with ~500 bindings.

2010-08-01 Thread Dhanji R. Prasanna
On Mon, Aug 2, 2010 at 2:46 AM, je...@swank.ca  wrote:

> Miroslav,
>
> When heavyweight work is done during @Inject methods, @Provides
> methods and static initializers, that will be slow if these injections
> are performed during injector creation. Injector creation is naturally
> single-threaded, so I prefer to do file I/O, RPCs and cache preloading
> after the injector has been started - then I can run these tasks in
> parallel. A profiler like YourKit will help you here.
>
> Dhanji, does sitebricks do much work at injector-creation time?
>

It depends, if you use the scan() system it can get very expensive as it
will try to load all classes in a package tree. If you use modular config (
http://code.google.com/p/google-sitebricks/wiki/ModularConfig) this problem
goes away. Otherwise all of sitebricks' work is done in the init() method of
the servlet pipeline, which should not impact injector creation time.

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: AssertionError using guice servlet

2010-07-27 Thread Dhanji R. Prasanna
Guice Servlet itself works fine in appengine, so Im a little puzzled as to
how you're seeing this error =(

Are you building from trunk? Or using a binary from somewhere?

Dhanji.

On Tue, Jul 27, 2010 at 6:32 PM, Stuart McCulloch  wrote:

> On 23 July 2010 21:53, Dennis  wrote:
>
>> I followed the instructions for using guice servlet on App Engine
>> ( http://code.google.com/p/google-guice/wiki/GoogleAppEngine ,
>> http://code.google.com/p/google-guice/wiki/Servlets ).
>> Basically I copied the whole stuff and did not change anything except
>> package names (and of course the Servlets to serve).
>>
>> Whenever I run the project this is what happens:
>>
>> 23.07.2010 13:46:34 com.google.apphosting.utils.jetty.JettyLogger warn
>> WARNING: failed
>> com.google.apphosting.utils.jetty.devappenginewebappcont...@1d36dfe{/,D:
>> \Data\eclipse\workspace\project\war}: java.lang.AssertionError:
>> java.lang.IllegalAccessException: Class
>> com.google.inject.DefaultConstructionProxyFactory$1 can not access a
>> member of class com.google.inject.servlet.ManagedServletPipeline with
>> modifiers "public"
>> 23.07.2010 13:46:34 com.google.apphosting.utils.jetty.JettyLogger warn
>> WARNING: failed jettycontainerservice$apiproxyhand...@14d5bc9:
>> java.lang.AssertionError: java.lang.IllegalAccessException: Class
>> com.google.inject.DefaultConstructionProxyFactory$1 can not access a
>> member of class com.google.inject.servlet.ManagedServletPipeline with
>> modifiers "public"
>> 23.07.2010 13:46:34 com.google.apphosting.utils.jetty.JettyLogger warn
>> WARNING: Error starting handlers
>> java.lang.AssertionError: java.lang.IllegalAccessException: Class
>> com.google.inject.DefaultConstructionProxyFactory$1 can not access a
>> member of class com.google.inject.servlet.ManagedServletPipeline with
>> modifiers "public"
>>at com.google.inject.DefaultConstructionProxyFactory
>> $1.newInstance(DefaultConstructionProxyFactory.java:85)
>>at
>> com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:
>> 85)
>>at com.google.inject.ConstructorBindingImpl
>> $Factory.get(ConstructorBindingImpl.java:111)
>>at com.google.inject.ProviderToInternalFactoryAdapter
>> $1.call(ProviderToInternalFactoryAdapter.java:45)
>>at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:
>> 811)
>>at
>>
>> com.google.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:
>> 42)
>>at com.google.inject.Scopes$1$1.get(Scopes.java:54)
>>at
>>
>> com.google.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:
>> 48)
>>at
>>
>> com.google.inject.SingleParameterInjector.inject(SingleParameterInjector.java:
>> 42)
>>at
>>
>> com.google.inject.SingleParameterInjector.getAll(SingleParameterInjector.java:
>> 66)
>>at
>> com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:
>> 84)
>>at com.google.inject.ConstructorBindingImpl
>> $Factory.get(ConstructorBindingImpl.java:111)
>>at com.google.inject.ProviderToInternalFactoryAdapter
>> $1.call(ProviderToInternalFactoryAdapter.java:45)
>>at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:
>> 811)
>>at
>>
>> com.google.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:
>> 42)
>>at com.google.inject.Scopes$1$1.get(Scopes.java:54)
>>at
>>
>> com.google.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:
>> 48)
>>at com.google.inject.FactoryProxy.get(FactoryProxy.java:56)
>>at com.google.inject.ProviderToInternalFactoryAdapter
>> $1.call(ProviderToInternalFactoryAdapter.java:45)
>>at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:
>> 811)
>>at
>>
>> com.google.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:
>> 42)
>>at com.google.inject.Scopes$1$1.get(Scopes.java:54)
>>at
>>
>> com.google.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:
>> 48)
>>at
>>
>> com.google.inject.SingleParameterInjector.inject(SingleParameterInjector.java:
>> 42)
>>at
>>
>> com.google.inject.SingleParameterInjector.getAll(SingleParameterInjector.java:
>> 66)
>>at
>> com.google.inject.SingleMethodInjector.inject(SingleMethodInjector.java:
>> 84)
>>at com.google.inject.InjectionRequestProcessor$StaticInjection
>> $1.call(InjectionRequestProcessor.java:109)
>>at com.google.inject.InjectionRequestProcessor$StaticInjection
>> $1.call(InjectionRequestProcessor.java:106)
>>at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:
>> 804)
>>at com.google.inject.InjectionRequestProcessor
>> $StaticInjection.injectMembers(InjectionRequestProcessor.java:106)
>>at
>>
>> com.google.inject.InjectionRequestProcessor.injectMembers(InjectionRequestProc

Re: Documented examples for Providers seem unnecessary - what am I missing?

2010-07-27 Thread Dhanji R. Prasanna
In your example, the log entry would get overwritten each time. With a
provider you'd get a new entry each time.

Dhanji.

On Fri, Jul 23, 2010 at 5:10 AM, Himsit  wrote:

> At
> http://code.google.com/docreader/#p=google-guice&s=google-guice&t=InjectingProviders
> they say:
>
> "With normal dependency injection, each type gets exactly *one
> instance* of each of its dependent types. The RealBillingService gets
> one CreditCardProcessor and one TransactionLog. When this flexibility
> is necessary, Guice binds a provider."
>
> But CreditCardProcessor and TransactionLog *are* two different types
> (and therefore only need one instance each). Why is this "flexibility"
> not "normal"?
>
> Furthermore, down the page under "Providers for Multiple Instances",
> they give this code:
>
> public class LogFileTransactionLog implements TransactionLog {
>
>  private final Provider logFileProvider;
>
>  @Inject
>  public LogFileTransactionLog(Provider logFileProvider)
> {
>this.logFileProvider = logFileProvider;
>  }
>
>  public void logChargeResult(ChargeResult result) {
>LogFileEntry summaryEntry = logFileProvider.get();
>summaryEntry.setText("Charge " + (result.wasSuccessful() ?
> "success" : "failure"));
>summaryEntry.save();
>
>if (!result.wasSuccessful()) {
>  LogFileEntry detailEntry = logFileProvider.get();
>  detailEntry.setText("Failure result: " + result);
>  detailEntry.save();
>}
>  }
>
>
> Why does LogFileEntry need a provider? Wouldn't this work just fine
> without one:
>
> public class LogFileTransactionLog implements TransactionLog {
>
>  private final LogFileEntry logFileEntry;
>
>  @Inject
>  public LogFileTransactionLog(LogFileEntry logFileEntry) {
>this.logFileEntry = logFileEntry;
>  }
>
>  public void logChargeResult(ChargeResult result) {
>logFileEntry.setText("Charge " + (result.wasSuccessful() ?
> "success" : "failure"));
>logFileEntry.save();
>
>if (!result.wasSuccessful()) {
>  logFileEntry.setText("Failure result: " + result);
>  logFileEntry.save();
>}
>  }
>
> What am I missing? Does each call to Provider.get() create a new
> instance of LogFileEntry? If so, how would you gather them up later?
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Using Assistedinject on Android

2010-07-25 Thread Dhanji R. Prasanna
The stacktrace is complaining that the constructor needs to take
android.app.Activity but instead is taking android.content.Context.

Dhanji.

On Mon, Jul 26, 2010 at 12:41 AM, Laxs  wrote:

> sorry, could you explain it to me please.
>
> the constructor for NotifyMeDatabase is following:
>
> @AssistedInject
>public NotifyMeDatabase(@Assisted Context context){
>super(
>context,
>DATABASE_NAME,
>null,
>DATBASE_VERSION);
>}
>
> NotifyMeDatabase inherit from SQLiteOpenHelper  and Implements a
> interface
>
> thanks
>
> Larry
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Warp persist transactions

2010-07-21 Thread Dhanji R. Prasanna
Are you marking methods @Transactional and can you verify that the
transaction interceptor is running?

Dhanji.

On Wed, Jul 21, 2010 at 6:17 PM, Josh Kamau  wrote:

> Hello;
>
> I am using guice and warp persist for transactions with JPA hibernate
> implementation. I noticed that the transactions are not committing . If i
> call the entitymanager.getTransaction().begin() and .commit(), it works.
> What am i doing wrong with warp-persist? Below my warp persist code samples
>
> 1. web.xml configuration
>
> 
>  warpFilter
>
> com.wideplay.warp.persist.PersistenceFilter
>  
>
>  
>  warpFilter
>  /*
>  
>
> 2. guice binding
> bindConstant().annotatedWith(JpaUnit.class).to("myPU");
>
> 3. Module creation
> Module warpModule =
> PersistenceService.usingJpa().across(UnitOfWork.REQUEST).buildModule();
>
> 4. Persistence.xml
>
>  xmlns="http://java.sun.com/xml/ns/persistence";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd";>
>
>
>
>  com.josh.myapp.model.Project
>
>   
>   value="org.postgresql.Driver"/>
>  
>   value="postgres"/>
>   value="jdbc:postgresql://localhost:5432/myapp"/>
>   value="org.hibernate.dialect.PostgreSQLDialect"/>
>  
>  
>   
>
>
> 
>
> I am using guice 2.0 and warp-persist 2.0
>
> regards.
>
> Josh.
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: What does google guice not support google initiated standards (javax.inject) ?

2010-07-18 Thread Dhanji R. Prasanna
Google Guice is the reference implementation for javax.inject.

Is your gripe that we don't have a link to a nightly Jar file? Checking out
and building Guice takes all of a minute or less. It's rather hyperbolic to
suggest that we do not support javax.inject because we don't have a prebuilt
jar for downloading off head. =)

Having said that, it might be useful to users such as yourself for us to
host a nightly or weekly snapshot somewhere (perhaps off a bamboo account?)

Dhanji.

On Sun, Jul 18, 2010 at 8:51 PM, mortench  wrote:

> Last year "javax.inject" was announced on the google blog ("http://
> googlecode.blogspot.com/2009/05/javaxinjectinject.html") - supposedly
> to backed be backed by "Google Guice" and SpringSource etc. That was a
> big step forward. Cool.
>
> But why is google guice now the ONLY framework that does not support
> javax.inject in the releases that can be downloaded. Spring 3.0
> supports it and Weld/JSR-299/CDI supports it but not google guice. So
> now the very people at google that started this javax.inject thing
> does not officially support it ?
>
> P.S. Yes I heard that there is some code in subversion that is
> supposed to support some of javax.inject but there is no official
> downloadable release that has 100% support as far as I now.
>
> /Morten
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Using Assistedinject on Android

2010-07-16 Thread Dhanji R. Prasanna
Unfortunately Dalvik does not permit class runtime generation (hence noaop)
so you may not be able to use the assistedinject until it does =(

Dhanji.

On Wed, Jul 14, 2010 at 8:53 PM, Laxs  wrote:

> Hi all,
>
> I want to use the Assistedinject Extension on my Android Project.
>
> I actually add assistedinject.jar as a Referenced libary,
> When I use @Assistedinject to pass a Context-object to my
> Implementation I got following Exception:
>
> Uncaught handler: thread main exiting due to uncaught exception
> com.google.inject.CreationException: Guice creation errors:
> ...
> Caused by: java.lang.IllegalArgumentException:
> 
>
> When I use @Inject everything works fine.
> I added the guice-2.0-no_aop.jar also as a Referenced libary.
>
> But I have to use @Assistedinject for having a parameterized
> Constructor Injection to pass the context-object to my Implementation
>
> Hope you can help me with my problem
>
> Thanks in advance
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Custom Filter not being invoked by GuiceFilter

2010-07-16 Thread Dhanji R. Prasanna
Can you post your web.xml? Are you sure it is getting picked up at all?

Dhanji.

On Sat, Jul 17, 2010 at 2:47 AM, Jas  wrote:

> By the way, the filter configuration s really
> filter("/*").through(RequestAuthenticationServletFilter.class);
>
> thx.
>
> On Jul 16, 4:20 pm, Jas  wrote:
> > So I am trying to inject a few dependencies into a so-called
> > AuthFilter and I control the invokation of this AuthFilter from within
> > the configureServlets() override. Something like: (along with custom
> > binding module)
> >
> > public class GuiceServletConfig extends GuiceServletContextListener {
> > @Override
> > protected Injector getInjector() {
> > return Guice.createInjector(new ServletModule() {
> > @Override
> > public void configureServlets() {
> > filter("/*").through(AuthenticationFilter.class);
> > }
> > },
> > new GuiceConfigModule()
> > );
> > }
> >
> > I do have the web.xml configured as instructed with the GuiceFilter
> > mapping. I should also mention that the web.xml also contains a
> > servlet mapping for Jersey with some init-params (not mentioned
> > below):
> >
> > 
> > Jersey Web Application
> >  > class>com.sun.jersey.spi.container.servlet.ServletContainer > class>
> > 
> >
> > The entire application is deployed on Glassfish.
> >
> > The problem is: I don't see my AuthFilter getting invoked in the
> > chain. Am i missing something in the chain?
> >
> > Here's the signature for the AuthFilter class:
> >
> > @Singleton
> > public class RequestAuthenticationServletFilter implements Filter {
> > private AuthTokenValidator authTokenValidator;
> > private UrlAccountIdExtractor urlAccountIdExtractor;
> >
> > @Inject
> > public RequestAuthenticationServletFilter(AuthTokenValidator
> > authTokenValidator, UrlAccountIdExtractor urlAccountIdExtractor) {
> > this.authTokenValidator = authTokenValidator;
> > this.urlAccountIdExtractor = urlAccountIdExtractor;
> > }
> >
> > ..
> >
> > }
> >
> > Any help would be most appreciated. I am new to Java for I apologize
> > if I am missing something very glaring! THANKS.
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Clean up a RequestScoped Object

2010-07-01 Thread Dhanji R. Prasanna
You could write a simple filter("/*")... that injects and calls close() on
the PersistenceManager in a try/finally block.

FYI guice-persist will provide some kind of automation for this particular
use case.

Dhanji.

On Fri, Jul 2, 2010 at 1:06 PM, Andrew Wiley  wrote:

> If I have an object that is RequestScoped, and I use a Provider to get
> instances of it while processing requests, is there any way to call a method
> on the object when request processing is complete? Specifically, on the
> Google App Engine, my understanding is that PersistenceManagers should be
> RequestScoped because they aren't thread safe, but I need to call the
> close() methodwhen I finish handling the Request. The danger is that if I
> get the same PersistenceManager in multiple methods, it becomes hard to know
> when to close it and when not to.
> I guess I could just create one whenever I needed it instead of tying it to
> the Request, but each PersistenceManager embodies a database connection in
> JDO. I'll have to look up how that works when it's tied to the BigTable
> backend and see whether having possibly hundreds or thousands of
> PersistenceManagers is okay in that case, but I know it's not normally okay.
> Could anyone advise me here?
>
> Andrew Wiley
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Artificially triggering scopes

2010-07-01 Thread Dhanji R. Prasanna
You could also check out the several EasyMock tests in GuiceServlet's own
test suite on our codesite.

Dhanji.

On Fri, Jul 2, 2010 at 7:21 AM, charles gay  wrote:

> Hi Kazimierz,
> can you post an example of unit testing an httpservlet or
> servletFilter, called by the GuiceFilter, like implied in your prevous
> post?
>
> best regards,
>
> Charles.
>
> On 19 juin, 22:51, Kazimierz Pogoda  wrote:
> > On Thu, Jun 17, 2010 at 1:21 PM, yaniv kessler  wrote:
> > > I wanted to know if anyone tried to artificially induce scopes like
> Request
> > > or Session in unit tests and what is the best way to go about it.
> >
> > I tried with success, though my solution is specific to GWT RCP
> > testing. I have built abstraction around GuiceFilter which is
> > initialized on @BeforeClass together with Injector instance, and
> > destroyed on @AfterClass. The idea is to simply call doFilter on
> > GuiceFilter instance in every test, and pass FilterChain instance
> > which will call servlet's doGet or doPost method. I mock
> > ServletContext, HttpSession, HttpServletRequest, HttpServletResponse
> > with the help of spring-test library. In case of GWT RPC instead of
> > calling servlet's doPost method I just wrap service instance with
> > dynamic proxy which ensures that any method invocation is performed
> > inside GuiceFilter.doFilter method. This way I can test RPC service
> > and avoid any processing in the HTTP stack.
> >
> > > This question is being asked within the context of wicket pages
> testing.
> >
> > In case of wicket you would have to call WicketFilter instance in the
> > FilterChain in addition to GuiceFilter and construct appropriate
> > HttpServletRequest mock pointing to specific wicket page.
> >
> > --
> > "Meaning is differential not referential"
> >
> > kazik 'morisil' pogodahttp://www.xemantic.com/http://blog.xemantic.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Controllers

2010-07-01 Thread Dhanji R. Prasanna
Try google-sitebricks - Project Hosting on Google
Code,
though it is still in alpha.

Dhanji.

On Fri, Jul 2, 2010 at 6:37 AM, Marcel Overdijk wrote:

> I've read the documentation about Guice Servlet integration but I'm
> wondering if Guice provides something similar like Spring MVC.
>
> Like having 1 servlet and creating Controllers which are mapped to
> urls.
> And perhaps some annotation to autoconvert request params to method
> arguments.
>
>
> Cheers,
> Marcel
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Guice persist, first release?

2010-06-27 Thread Dhanji R. Prasanna
Not too far :)

On Monday, June 28, 2010, nino martinez wael
 wrote:
> Hi
>
> How far are guice persist from the first release?
>
> regards Nino
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-guice+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Hotswap or redeploy

2010-06-26 Thread Dhanji R. Prasanna
Yea, we handle this for OSGi I believe. Stuart can tell you more. You can
also build the NoAOP extension that will not create any proxy classes. This
question is best answered on the Guice list.

Dhanji.

On Sat, Jun 26, 2010 at 10:57 PM, John Patterson wrote:

> Hi, I was wondering how others handle the loss of hotswapping when
> using Guice?
>
> Do you re-start the servlet container on every change?  Use
> JavaRebel?  Or is there some way to stop Guice using its own enhanced
> classes and class loader?

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Guice framework not able to intercept private methods

2010-06-19 Thread Dhanji R. Prasanna
That's correct. This is because Java does not provide virtual dispatch for
private methods, it is not possible to intercept them. If you declare them
at any other scope (package local, public or protected) it will work fine.

Dhanji.

On Sun, Jun 20, 2010 at 2:57 PM, sandy  wrote:

> I am using Guice with AOP alliance
> There is a private method in my class and I have created an method
> interceptor for it
> but the control doesnt reaches to my interceptor.But when I changed
> the accessifier from private to public it works
>
> Same is the case with accessing a class's private variable.I have to
> define a getter for all the private fields of a class
>
> Just curios to know, Is this a limitation of Guice framework or there
> is a work around for it
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Artificially triggering scopes

2010-06-19 Thread Dhanji R. Prasanna
That sounds reasonable. Another important point is to call
GuiceFilter.destroy() on tearDown()

Dhanji.

On Sun, Jun 20, 2010 at 6:51 AM, Kazimierz Pogoda  wrote:

> On Thu, Jun 17, 2010 at 1:21 PM, yaniv kessler  wrote:
> > I wanted to know if anyone tried to artificially induce scopes like
> Request
> > or Session in unit tests and what is the best way to go about it.
>
> I tried with success, though my solution is specific to GWT RCP
> testing. I have built abstraction around GuiceFilter which is
> initialized on @BeforeClass together with Injector instance, and
> destroyed on @AfterClass. The idea is to simply call doFilter on
> GuiceFilter instance in every test, and pass FilterChain instance
> which will call servlet's doGet or doPost method. I mock
> ServletContext, HttpSession, HttpServletRequest, HttpServletResponse
> with the help of spring-test library. In case of GWT RPC instead of
> calling servlet's doPost method I just wrap service instance with
> dynamic proxy which ensures that any method invocation is performed
> inside GuiceFilter.doFilter method. This way I can test RPC service
> and avoid any processing in the HTTP stack.
>
> > This question is being asked within the context of wicket pages testing.
>
> In case of wicket you would have to call WicketFilter instance in the
> FilterChain in addition to GuiceFilter and construct appropriate
> HttpServletRequest mock pointing to specific wicket page.
>
> --
> "Meaning is differential not referential"
>
> kazik 'morisil' pogoda
> http://www.xemantic.com/ http://blog.xemantic.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: How does GuiceFilter work?

2010-06-13 Thread Dhanji R. Prasanna
It is done in the ManagedFilterPipeline class. Every servlet you register in
a module is collected there and instantiated on init(). The logic is similar
to multibinder.

Dhanji.

On Sat, Jun 12, 2010 at 6:10 PM, shane  wrote:

> When you have GuiceFilter up and running (has been configued in
> web.xml), Guice Servlet is set up. And I install an instance of
> ServletModule like following:
>
> public class MyGuiceServletConfig extends GuiceServletContextListener
> {
>
>@Override
>protected Injector getInjector() {
>return Guice.createInjector(new ServletModule() {
>
>@Override
>protected void configureServlets() {
>serve("*.html").with(MyServlet.class);
>}
>});
>}
> }
>
> I know that GuiceFilter has controled the creating of MyServlet.class
> object and inject object as you like. I want to find how, so I read
> the source code of GuiceFilter but can't figure out. This is the core
> code of GuiceFilter, I can't find any clue about guice's creation
> controlling.
>
>  public void doFilter(ServletRequest servletRequest,
>  ServletResponse servletResponse, FilterChain filterChain)
>  throws IOException, ServletException {
>
>Context previous = localContext.get();
>FilterPipeline filterPipeline = pipeline;
>
>try {
>  localContext.set(new Context((HttpServletRequest)
> servletRequest,
>  (HttpServletResponse) servletResponse));
>
>  //dispatch across the servlet pipeline, ensuring web.xml's
> filterchain is honored
>  filterPipeline.dispatch(servletRequest, servletResponse,
> filterChain);
>
>} finally {
>  localContext.set(previous);
>}
>  }
>
> Does anybody know how GuiceFilter control the creating process of all
> the configured servelts and inject as you want? Thank you for your
> answer.
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Startup time on GAE

2010-06-07 Thread Dhanji R. Prasanna
Is this inside a GAE application or something completely local (i.e. running
in Jetty)?

Dhanji.

On Mon, Jun 7, 2010 at 12:48 AM, Miroslav Genov wrote:

>  Hello,
> I'm encountering similar issue with Guice. Currently the initialization
> time of my application is for about 12 seconds. (From my log: Injector
> Initialization Time:12023 ms). On my local development machine it's
> initialized for Time:4982 ms.
>
> Here is some logging snippets from my local environment that are showing
> execution time of the initialization operations:
>
> Jun 7, 2010 7:26:44 AM com.google.inject.internal.Stopwatch resetAndLog
> FINE: Module execution: 1849ms
>
> Jun 7, 2010 7:26:45 AM com.google.inject.internal.Stopwatch resetAndLog
> FINE: Binding initialization: 517ms
>
> Jun 7, 2010 7:26:47 AM com.google.inject.internal.BytecodeGen newFastClass
> FINE: Loading class
> com.google.sitebricks.rendering.control.DefaultWidgetRegistry FastClass with
> com.google.appengine.tools.development.isolatedappclassloa...@1326484
> Jun 7, 2010 7:26:47 AM com.google.inject.internal.BytecodeGen newFastClass
> FINE: Loading class com.google.sitebricks.compiler.StandardCompilers
> FastClass with
> com.google.appengine.tools.development.isolatedappclassloa...@1326484
> Jun 7, 2010 7:26:47 AM com.google.inject.internal.BytecodeGen newFastClass
> FINE: Loading class com.google.sitebricks.DebugModePageBook FastClass with
> com.google.appengine.tools.development.isolatedappclassloa...@1326484
> Jun 7, 2010 7:26:47 AM com.google.inject.internal.BytecodeGen newFastClass
> FINE: Loading class com.google.sitebricks.DebugModeRoutingDispatcher
> FastClass with
> com.google.appengine.tools.development.isolatedappclassloa...@1326484
> Jun 7, 2010 7:26:47 AM com.google.inject.internal.Stopwatch resetAndLog
> FINE: Binding validation: 2308ms
>
> Any idea how I can optimize my application ?
>
> I was thinking for using of child injectors and late bindings, but
> currently I couldn't find out clean way to do it.
>
> Regards,
>   Miroslav
>
>
> On 02/10/2010 01:11 AM, Dhanji R. Prasanna wrote:
>
> Do you have a lot of AOP running? That could be making GAE run additional
> classes through the security loader.
>
>  Dhanji.
>
> On Wed, Feb 10, 2010 at 9:35 AM, John Patterson wrote:
>
>> Yes but pre-compilation does not affect Guice startup time.
>>
>>   On 10 Feb 2010, at 05:20, Dhanji R. Prasanna wrote:
>>
>>   Have you tried using offline precompilation?
>>
>>  Dhanji.
>>
>> On Wed, Feb 10, 2010 at 7:05 AM, Bob Lee  wrote:
>>
>>> John,
>>>
>>>  Enable FINE-level logging for Guice's Stopwatch:
>>>
>>>Logger stopwatchLogger =
>>> Logger.getLogger(com.google.inject.internal.Stopwatch.class.getName());
>>>stopwatchLogger.setLevel(Level.FINE);
>>>
>>>  This will log perf #s and tell you at a high level where the time is
>>> spent during injector creation.
>>>
>>>  Beyond that, I'd use a profiler like YourKit.
>>>
>>>  Unless you have a ginormous configuration, my guess is something
>>> expensive is happening in one of your modules. 4 seconds sounds excessive. I
>>> use Guice on Android, even going so far as to create a separate injector for
>>> each screen, and startup time hasn't been an issue.
>>>
>>>  Bob
>>>
>>> On Sun, Feb 7, 2010 at 2:17 PM, jd  wrote:
>>>
>>>> Hi, I am using Guice with a Google App Engine project but have found
>>>> that the startup time of Guice is killing my app.  "Loading requests"
>>>> are very frequent in GAE and need to be fast or your user sits and
>>>> waits. Currently the apps startup time is about 6 seconds and of that
>>>> the Injector takes 4 seconds to build.  This is with Stage set to
>>>> Development which did knock about two seconds off the time.
>>>>
>>>> My question is, are there any other tricks to reduce Guice startup
>>>> time.  Could some configuration be saved or serialized rather than
>>>> recalculated every time my app spins up a new instance?
>>>>
>>>> Thanks,
>>>>
>>>> John.
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "google-guice" group.
>>>> To post to this group, send email to google-gu...@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> google-guice+unsubscr...@googlegroups.com
>>>> .
>>>

Re: Singletons are not singletons with respect to polymorphism?

2010-06-07 Thread Dhanji R. Prasanna
Actually once you grok that everything in Guice is key-based and not class
based, a world of clarity opens up =)

In that regard I believe we have one of the best balanced APIs between
flexibility and correctness. I certainly understand, however that this may
not be your first reaction upon uncovering this Guice property.

Dhanji.

On Sun, Jun 6, 2010 at 11:48 PM, Tim Boudreau  wrote:

> > Just add:
> > bind(AImpl.class).in(Scopes.SINGLETON);
> > Before the other two bindings. That will solve your problem.
> >
> > Explanation:
> > All bindings in Guice are transitive and resolved by key, so a A ->
>
> Wow, that is stunningly non-intuitive - but it does work, so thank you
> very much.
>
> I wonder if something like this should not be supported by the API in
> a more obvious way.  It makes sense that polymorphism isn't supported
> by default - you don't want people to be able to use
> @Inject java.lang.Object foo;
> and have that work, so I understand the reason it is the way it is.
>
> But it would be nice to just have an API call which looks like:
> bindPolymorphic (BaseClass.class, ImplClass.class);  //okay, horrible
> method name
> to bind BaseClass -> Subclass1 -> Subclass2 -> ImplClass
> can all be injected without explicit bind calls for each type.
>
> You can *almost* do this in a Module (see terrifying code below), but
> with a very non-obvious caveat - you need to request a
> Provider before you bind your own Provider that maps all
> supertypes.  So the one thing that cannot be injected is ImplClass
> itself (otherwise the provider would itself in an endless loop) - you
> need an instance of ImplClass, and the ability to reference a
> Provider at bind-time, and the custom Provider must ask
> Guice to create it.
>
> I'd imagine this could be supported inside Guice *with* the ability to
> inject the actual implementation type too - AFAICT that is not
> possible to do inside a Module.
>
> The only thing this does is eliminate the need to have bind() calls
> for a list of supertypes, but it would be considerably more intuitive
> (*if* it did not have the requirement that the exact type you are
> binding cannot be injected):
>
>abstract class BaseModule extends AbstractModule {
>protected  void bindPolymorphic(Class t,
> Class mostSpecificSubtype) {
>Provider p = new SubtypeProvider(t,
> mostSpecificSubtype);
>Class x =
> mostSpecificSubtype.getSuperclass();  //CANNOT BIND S ITSELF!
>do {
>bind((Class) x).toProvider(p);
>x = x.getSuperclass();
>} while (isType(t, x));
>if (t.isInterface()) {
>bind(t).toProvider(p);
>}
>}
>
>private class SubtypeProvider implements
> Provider {
>private final Provider internalProvider;
>private S s;
>SubtypeProvider(Class type, Class
> mostSpecificSubtype) {
>internalProvider = getProvider(mostSpecificSubtype);
>}
>@Override
>public synchronized T get() {
>return s == null ? (s = internalProvider.get()) : s;
> }
>}
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Singletons are not singletons with respect to polymorphism?

2010-06-06 Thread Dhanji R. Prasanna
On Sun, Jun 6, 2010 at 12:20 AM, Tim Boudreau  wrote:

> I have a codebase with several layers of SPI in separate projects -
> we'll call this these projects SPI (minimal interfaces), SPISupport
> (convenience implementations of some common logic - in practice there
> is yet another layer that ties you to some specific data storage
> choices but simplifies things further).  A frequent pattern is:
>  - SPI contains "interface A" and "class Something { @Inject A a; ..."
>  - SPISupport contains "abstract class AbstractA implements A" and
> "final class HelperClass { @Inject AbstractA a; ..."
>  - TestHarness contains "ReferenceImplementation extends AbstractA {"
>
> A test implementation then extends AbstractA over a HashMap - a thing
> that really *has* to be a singleton with respect to the module that
> creates it (but using a static would make it possible for unit tests
> to cause side effects for each other).
> bind (A.class).to(AImpl.class).in(Scopes.SINGLETON);
> bind (AbstractA.class).to(AImpl.class).in(Scopes.SINGLETON);
>
> Rather surprisingly, *two* instances of AImpl are created - so far I
> have found no clean way to avoid this.  Since SPI cannot know about
> classes in SPISupport, this is rather a impasse.
>

Just add:

bind(AImpl.class).in(Scopes.SINGLETON);

Before the other two bindings. That will solve your problem.

Explanation:
All bindings in Guice are transitive and resolved by key, so a A ->
singleton bound to non-singleton AImpl, Similarly AbstractA -> singleton
bound to (different instance of) non-singleton AImpl. If you bind AImpl as a
singleton, then both A and AbstractA simply point to the binding of AImpl,
which is the same singleton.

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Extending

2010-06-06 Thread Dhanji R. Prasanna
But you can add new modules to the injector cant you? That is all I am
suggesting you do. Guice supports multiple ServletModules.

Dhanji.

On Sun, Jun 6, 2010 at 8:35 AM, Vega  wrote:

> Thanks
> THe proble is - I don't have control over GuiceServletConfig class, so
> I need somehow to add new "serves" bindings without change to it...
>
> On Jun 5, 6:41 pm, "Dhanji R. Prasanna"  wrote:
> > Don't do this, instead just install another top level module. Or if you
> want
> > to encapsulate your new bindings completely, then install it from your
> > GuiceServletConfig module. If you override configureServlets() you will
> be
> > forcing yourself and your users to be aware of the super class and to
> always
> > call super.configureServlets() and so forth, which is a maintenance mess.
> >
> > If you decompose into separate modules, then things become very simple.
> >
> > Dhanji.
> >
> > On Sat, Jun 5, 2010 at 7:04 AM, Vega  wrote:
> > > I have a trouble with subclassing class that extends ... . The problem
> > > is - I don't know how to add more "serve" bindings in the subclass.
> > > For example
> >
> > > public class GuiceServletConfig extends GuiceServletContextListener {
> > >  private static final Logger LOG =
> > > Logger.getLogger(GuiceServletConfig.class.getName());
> >
> > >  @Override
> > >  protected Injector getInjector() {
> > >ServletModule servletModule = new ServletModule() {
> > >  @Override
> > >  protected void configureServlets() {
> > >serveRegex("\\/_wave/.*").with(ForumBotty.class);
> > >serve("/admin/jsonrpc").with(JsonRpcProcessor.class);
> >
> > >serve("/send_email_updates").with(SendEmailUpdates.class);
> > >serve("/send_wave_updates").with(SendWaveUpdates.class);
> > >serve("/
> > > add_participants_task").with(AddParticipantsTask.class);
> >
> > >serve("/feeds/
> > > get_tag_counts").with(GetTagCounts.class);
> > >serve("/feeds/get_post_counts").with(GetPostCounts.class);
> > >serve("/feeds/get_forum_posts").with(GetForumPosts.class);
> > >serve("/feeds/get_latest_digest").with(GetLatestDigest.class);
> > >serve("/feeds/json").with(JsonGenerator.class);
> > >serve("/feeds/atom").with(AtomGenerator.class);
> >
> > >serve("/info").with(InfoServlet.class);  //TODO remove
> >
> > >//serve("/migrateTags").with(MigrateTags.class);
> > >//serve("/migrateTagsTask").with(MigrateTagsTask.class);
> > >  }
> > >};
> > >   // more stuff
> > >  return Guice.createInjector(servletModule, businessModule);
> > > }
> >
> > > Now, I have a class
> > > public class AggfiGuiceServiceConfig extends GuiceServletConfig{
> > > //
> > > }
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "google-guice" group.
> > > To post to this group, send email to google-gu...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > google-guice+unsubscr...@googlegroups.com
> 
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-guice?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Extending

2010-06-05 Thread Dhanji R. Prasanna
Don't do this, instead just install another top level module. Or if you want
to encapsulate your new bindings completely, then install it from your
GuiceServletConfig module. If you override configureServlets() you will be
forcing yourself and your users to be aware of the super class and to always
call super.configureServlets() and so forth, which is a maintenance mess.

If you decompose into separate modules, then things become very simple.

Dhanji.

On Sat, Jun 5, 2010 at 7:04 AM, Vega  wrote:

> I have a trouble with subclassing class that extends ... . The problem
> is - I don't know how to add more "serve" bindings in the subclass.
> For example
>
> public class GuiceServletConfig extends GuiceServletContextListener {
>  private static final Logger LOG =
> Logger.getLogger(GuiceServletConfig.class.getName());
>
>  @Override
>  protected Injector getInjector() {
>ServletModule servletModule = new ServletModule() {
>  @Override
>  protected void configureServlets() {
>serveRegex("\\/_wave/.*").with(ForumBotty.class);
>serve("/admin/jsonrpc").with(JsonRpcProcessor.class);
>
>serve("/send_email_updates").with(SendEmailUpdates.class);
>serve("/send_wave_updates").with(SendWaveUpdates.class);
>serve("/
> add_participants_task").with(AddParticipantsTask.class);
>
>serve("/feeds/
> get_tag_counts").with(GetTagCounts.class);
>serve("/feeds/get_post_counts").with(GetPostCounts.class);
>serve("/feeds/get_forum_posts").with(GetForumPosts.class);
>serve("/feeds/get_latest_digest").with(GetLatestDigest.class);
>serve("/feeds/json").with(JsonGenerator.class);
>serve("/feeds/atom").with(AtomGenerator.class);
>
>serve("/info").with(InfoServlet.class);  //TODO remove
>
>//serve("/migrateTags").with(MigrateTags.class);
>//serve("/migrateTagsTask").with(MigrateTagsTask.class);
>  }
>};
>   // more stuff
>  return Guice.createInjector(servletModule, businessModule);
> }
>
> Now, I have a class
> public class AggfiGuiceServiceConfig extends GuiceServletConfig{
> //
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Wicket Guice

2010-05-29 Thread Dhanji R. Prasanna
[+guice-users]

Hi, looks great, you should promote it in the Wicket list too.

Dhanji.

On Sat, May 29, 2010 at 4:03 AM, yaniv kessler  wrote:

> Hello Dhanji,
>
> I got your email from the Warp Mailing list and I hope it is Ok that I use
> it to contact you directly. I would like to submit a post I wrote about an
> alternative way to integrate Wicket and Guice to the Guice 3rd party wiki
> page. The motivation and difference from the more common methods is
> explained in the post itself.
>
> Other than that I would love to get some input on the Guicey side of
> things, since I'm new to Guice (only 3-4 months since discovery) and only
> used it in one production / commercial project so far.
>
> Post is here:
> http://headtoscreencollision.blogspot.com/2010/05/wicket-and-guice-alternate-route.html
>
> I also like to take this opportunity to thank you for creating so many
> wonderful libs and projects for the benefit of us all, keep it up ;-)
>
> Regards,
>
> Yaniv Kessler
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: ServletModule does not work with Server Side Includes

2010-05-26 Thread Dhanji R. Prasanna
Can you explain what you mean by "gets included"? Do you mean
RequestDispatcher.include? If so it should work. If you have servlets
registered in web.xml that may not work. You should prefer registering all
your servlets in ServletModule if possible...

Dhanji.

On Wed, May 26, 2010 at 2:53 AM, senny  wrote:

> Hey
>
> Our Web-application, which uses Guice and the ServletModule do not
> work properly when the application gets included. The problem is that
> the GuiceFilter does not delegate the request to the specified
> Servlets. I guess the reason for this behaviour is, that the
> patternMatcher only matches against the servletPath. I thought that
> the servlet path is not the actual requested URL when including an
> application. Am I doing something wrong or is there another way to get
> Guice working with includes?
>
> Cheers,
> -- Yves
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: How to demonstrate all dependencies are satisfied

2010-05-25 Thread Dhanji R. Prasanna
If you create the injector in Stage.TOOL and requireExplicitBindings() that
should be enough to assert everything is bound properly.

Dhanji.

On Wed, May 19, 2010 at 1:02 PM, AB  wrote:

> I am looking for some way to demonstrate, perhaps at test time or app
> startup, that all dependencies are satisfied with bindings. Once could
> of course do this will a complete set of functional tests that
> exersize every part of the system but I am looking for something that
> runs faster and doesnt require writing Selenium (or whatever) for a
> large webapp. I was thinking that one could load every class on the
> classpath (perhaps limited to specific packages of code that we
> wrote), inspect every field and setter for @Inject tag and verify
> there is a binding. Or perhaps just attempt to inject every class. For
> my purposes, we can ignore dynamically loaded classes not known at
> compile time.
>
> I want to believe someone out there has solved this.  Does anyone have
> any ideas?
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Problems while diving into guice code

2010-05-23 Thread Dhanji R. Prasanna
Happy for you or anyone else maven savvy to submit a buildable pom too!

Dhanji =)

On Sun, May 23, 2010 at 11:45 AM, Christian Edward Gruber <
cgru...@google.com> wrote:

> 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 for hosting, not as a build pom, that's why it
> probably doesn't work.
>
> Greg can tell you more. But yes go ahead and add any deps you need to make
> it build (should just be those two for guice itself).
>
> Dhanji.
>
> On Sun, May 23, 2010 at 11:36 AM, Pablo Fernandez <
> fernandezpabl...@gmail.com> wrote:
>
>> Hi guys,
>>
>> I recently downloaded guice source code to see if I can help with some
>> of the open issues. This is what I did:
>>
>> 1) checked out the source code with svn.
>>
>> 2) did mvn eclipse:eclipse to generate the project file
>>
>> 3) added both src and test to build path
>>
>> Now the problem is that it does not compile. By default the pom.xml is
>> missing some dependencies (aopalliance and javax.inject), so my
>> question is: Am I doing something wrong? Should I add these to the pom
>> and let maven take care of it?
>>
>> Thanks.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "google-guice" group.
>> To post to this group, send email to google-gu...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-guice+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-guice?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Problems while diving into guice code

2010-05-23 Thread Dhanji R. Prasanna
I think our pom is designed for hosting, not as a build pom, that's why it
probably doesn't work.

Greg can tell you more. But yes go ahead and add any deps you need to make
it build (should just be those two for guice itself).

Dhanji.

On Sun, May 23, 2010 at 11:36 AM, Pablo Fernandez <
fernandezpabl...@gmail.com> wrote:

> Hi guys,
>
> I recently downloaded guice source code to see if I can help with some
> of the open issues. This is what I did:
>
> 1) checked out the source code with svn.
>
> 2) did mvn eclipse:eclipse to generate the project file
>
> 3) added both src and test to build path
>
> Now the problem is that it does not compile. By default the pom.xml is
> missing some dependencies (aopalliance and javax.inject), so my
> question is: Am I doing something wrong? Should I add these to the pom
> and let maven take care of it?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Guice strategy with multiple war files

2010-05-21 Thread Dhanji R. Prasanna
On Friday, May 21, 2010, Willi Schönborn  wrote:
> On 21/05/10 01:44, bklough wrote:
>
> http://www.objectsource.com/j2eechapters/Ch21-ClassLoaders_and_J2EE.htm
>
> This might help as a start along the path of ClassLoader
> enlightenment, which someone will need in order to keep the Singleton
> beast from snarfing heads.  Singletons across WARs within an EAR are
> bad, from every perspective, but good luck.
>
>
> I have another use cases for multiple servlet modules with independent
> guice filters:
> I am about to embed jetty (or grizzly) with multiple contexts. Want i
> want is to share instances of my framework but no servlets/filters
> between the contexts. But this seems to be impossible as long as the guice
> filter uses static state.

This is now possible if you use guice to create the guicefilters (with
the caveat that your app doesn't rely on servlet context via the
injector).

Dhanji.

>
> On May 19, 7:07 am, senny  wrote:
>
>
> Hey
>
> We have an EAR project, which contains multiple war projects. Our
> current Guice setup is one Injector per war so that we can use a
> ServletModule for both of them. The problem we are facing now, is that
> we need to share singleton instances between the war files. Since we
> have different injectors, we don't have the same singleton scope. Is
> there a solution to that problem? Or how would you work around it?
>
> Cheers,
> -- Yves
>
> --
> You received this message because you are subscribed to the Google Groups 
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-guice+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/google-guice?hl=en.
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-guice+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Guice strategy with multiple war files

2010-05-19 Thread Dhanji R. Prasanna
On Wed, May 19, 2010 at 11:02 AM, senny  wrote:

> Is it possible to use two ServletModules in combination with child
> Injectors?


No it is not, unfortunately. With the new patch in trunk you can create
multiple Guice filters, however the servlet context is still shared so you
end up with a corrupt state if you use it at all (we had another internal
need for multiple Guice filters). If you can live with that problem (i.e.
NEVER inject ServletContext in your app) then that may be a quick solution.

It is definitely my plan to fully support multiple servlet modules however.


> And where should I create the "Root Injector"? I am
> currently creating the Injectors in a ServletContextListener.
>

Instead, I would share it via a different system like JNDI (which we support
via an extension). You can't even rely on a static variable since
classloader isolation would play spoil sport.

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Guice integration into Apache BeanValidation

2010-05-13 Thread Dhanji R. Prasanna
Cool! I worked on the JSR-303 specification, so that is nice to see.

Dhanji.

On Thu, May 13, 2010 at 2:17 AM, Simone Tripodi wrote:

> Hi all,
> I want just to let the Guice community know that in the Apache Bean
> Validation (JSR-303 implementation) we've been integrating
> google-guice for multiple purposes:
>
> * bootstrap bval using google-guice;
> * obtain ConstraintValidator instances using the google-guice
> injector, so to easily support the DI;
> * easily inject the Validator reference into components that require it;
> * easily intercept @Validate annotated methods and validate method
> arguments.
>
> If someone is interested in participating, you can find more info on
> http://incubator.apache.org/projects/beanvalidation.html
> Suggestions, feedbacks, wishes, nice to have, etc. are more than welcome!!!
>
> Best regards,
> Simo
>
> http://people.apache.org/~simonetripodi/
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: warp persist, guice & wicket: use warp persist not in http request

2010-05-11 Thread Dhanji R. Prasanna
Detaching is a good idea, a second level cache is even better ( see
hibernate docs ) also you can use a custom unit of work after the
session has closed. There's no reason this will be expensive if you
use a second level cache.

Dhanji

On Tuesday, May 11, 2010, Edward Zarecor  wrote:
> If the data you are loading isn't changing, you could load it on start up and 
> detach your hibernate objects or cache the data in any number of other ways 
> so that it is still available after the loading session has closed.  
> WorkManager would be the appropriate way to load data outside of 
> Request/Response cycle in a web application.
>
> http://www.wideplay.com/transactionsemantics, see the section on "Custom 
> Units of Work."
>
> You could also rely on the various caching mechanisms hibernate provides, 
> rather than doing this yourself.
>
> Ed.
>
>
> On Tue, May 11, 2010 at 11:56 AM, Christoph Grün  wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Thanks! In this class, some data is saved into hibernate objects
> and then the session is closed. However, in my case I would like to load some 
> instances
> from Hibernate, Jena, etc. as well as images from different sources and hold
> them in memory so that I save time as soon as an HTTP request needs them.
>
>
>
> I think that WorkManager.beginWork is not appropriate as I
> cannot access this data from an HTTP session.
>
>
>
> Christoph
>
>
>
>
>
> Von:
> google-guice@googlegroups.com [mailto:google-gu...@googlegroups.com] Im
> Auftrag von Edward Zarecor
> Gesendet: Dienstag, 11. Mai 2010 17:50
> An: google-guice@googlegroups.com
> Betreff: Re: warp persist, guice & wicket: use warp persist not in
> http request
>
>
>
>
>
> Sorry, I had meant to paste this URL into the original email
> -- multi-tasking!
>
>
>
>
>
>
>
>
>
> http://jweekend.co.uk/dev/LegUp
>
>
>
>
>
> Use the form to generate a maven command and run it locally.
>  The code will be under src/java as per usual.
>
>
>
>
>
>
>
>
>
>
>
> Ed.
>
>
>
>
>
>
>
>
>
> On Tue, May 11, 2010 at 11:36 AM, Christoph Grün 
> wrote:
>
>
>
>
>
> Ed, thanks a lot for your
> answer. Where can I find the DataInitializer.java class?
>
>
>
> Thanks, Christoph
>
>
>
>
>
> Von: google-guice@googlegroups.com
> [mailto:google-gu...@googlegroups.com]
> Im Auftrag von Edward Zarecor
> Gesendet: Dienstag, 11. Mai 2010 16:50
>
>
>
>
>
>
> An: google-guice@googlegroups.com
> Betreff: Re: warp persist, guice & wicket: use warp persist not in
> http request
>
>
>
>
>
>
>
>
>
>
>
>
>
> Take
> a look at one of the Guice, Warp and Wicket Archetypes available here,
> especially useful as you are using Wicket.
>
>
>
>
>
>
>
>
>
> Isn't
> what you are trying to accomplish analogous to what happens in
> DataInitializer.java?
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Spring hell I'm in

2010-05-07 Thread Dhanji R. Prasanna
Last time I checked that's how springs javaconfig worked. It's a bit
like a module with only provides methods.

Dhanji.

On Saturday, May 8, 2010, Brian Pontarelli  wrote:
> I have a client that is using the full Spring stack and I'm trying to figure 
> out good ways to use their setup. I figured there might be other Guice users 
> that have been in the same situation and could help.
>
> I wanted to use JSR 330, which I've recently realized is severely lacking. 
> That API doesn't have any configuration interfaces or @ImplementedBy and 
> that's where this process appears to get annoying. Spring provides the 
> ability to declare a class as @Configuration, but then it appears to force me 
> to define all my injections using factory methods and constructors. This 
> essentially forces me to construct all the implementations of any interface 
> by hand. If I have to write factories and constructors for everything I might 
> as well use XML since they are essentially the same thing.
>
> Is this accurate or am I missing something vital that makes Spring actually a 
> DI container and not a factory facade?
>
> Any suggestions would be much appreciated.
>
> -bp
>
> --
> You received this message because you are subscribed to the Google Groups 
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-guice+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Problem with guice+warp persist+inheritance

2010-05-05 Thread Dhanji R. Prasanna
You can specify your own matcher in warp persist using the forAll()
clause when you create a PersistenceModule.

@Inherited is really not what you want as it does not get inherited on
methods annotations.

Dhanji.

On Wednesday, May 5, 2010, Eduardo Nunes  wrote:
> Another key thing regarding this problem: it only happens if you compile the 
> application using ant (I believe it happens if you compile using JDK) instead 
> of eclipse. If you compile it using eclipse, no problem happens.
>
> Do you have an idea?
>
> On Tue, May 4, 2010 at 3:24 PM, Eduardo Nunes  wrote:
>
> Unfortunately it didn't work. I read the warp persistent source code and 
> everything looks fine there, I think the problem is in the Matcher used. I'm 
> not sure how it works but looks like the matcher isn't applied to the methods 
> of the super classes, just to the current one.
>
> This is the 
> interceptor: http://warp-persist.googlecode.com/svn/trunk/warp-persist/src/com/wideplay/warp/persist/hibernate/HibernateLocalTxnInterceptor.java it
>  doesn't get called on the methods declared in the super class.
>
>
> This is the factory that creates the 
> matchers: http://warp-persist.googlecode.com/svn/trunk/warp-persist/src/com/wideplay/warp/persist/PersistenceMatchers.java
>
>
> Maybe some committer of google-guice can help me to clarify those things.
> Best regards,Eduardo S. Nunes
>
> On Tue, May 4, 2010 at 2:24 PM, Jonathan Abourbih  wrote:
> I saw something in an earlier thread about this:
> w.schoenb...@googlemail.com says:
>
>
> Annotations in java need the
> http://java.sun.com/javase/6/docs/api/java/lang/annotation/Inherited.html
> annotation when inheritence is required.
>
>
>
> I'm not sure if WarpPersist has defined @Transactional with that annotation, 
> but might be a start for you.
> Jonathan
>
>
>
>
>
>
>
>
>
> On 4 May 2010, at 18:14, Eduardo Nunes wrote:
>
> Hi all,
> I have a problem with warp persist. It's a inheritance problem. If a have a 
> class A with a method name "save" with annotation @Transactional and I have a 
> class B that extends A. If I call b.save it seems to ignore the 
> @Transactional annotation, if I do a simple method @Transactional void save() 
> { super.save() }; it works.
>
>
> Do you have any idea about it?
> Best regards,
> --
> Eduardo S. Nunes
> http://enunes.org
>
>
>  --
>  You received this message because you are subscribed to the Google Groups 
> "google-guice" group.
>  To post to this group, send email to google-gu...@googlegroups.com.
>  To unsubscribe from this group, send email to 
> google-guice+unsubscr...@googlegroups.com.
>  For more options, visit this group at 
> http://groups.google.com/group/google-guice?hl=en.
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-guice+unsubscr...@googlegro
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-guice+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/google-guice?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Mapping Stripes Filter with Guice ServletModule

2010-04-24 Thread Dhanji R. Prasanna
On Sat, Apr 24, 2010 at 10:04 PM, senny  wrote:

> Hey Dhanji
>
> I tried that but ended in a endless dispatcher loop somehow. Do I need
> to set the additional  tags for the Guice Filter to make
> it work for server side includes?


Hmm, try the same tags you have for stripes filter on GuiceFilter.
Unfortunately we don't officially support some of the lesser used arcane
features of the servlet spec, so it may take a couple of roundtrips on this
list to get it right =(

Also if need be, and justifiable we can apply a patch to support it.

Another Question I got is, How can I
> apply a filter to a given servlet with ServletModule like the  name> tag does in the wex.xml? Is this possible or do I need to
> specify the same patterns for both?
>

You need to specify a filter. We deliberately chose not to use the name
binding route for type safety and clarity. Otoh, we support regex matching
so that should be fairly easy.

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Mapping Stripes Filter with Guice ServletModule

2010-04-23 Thread Dhanji R. Prasanna
Yes you can do that. You will need to setup Guice Filter in web.xml as shown
here:
http://code.google.com/p/google-guice/wiki/Servlets

Then you can bind Stripes' filters and servlets as shown in the "Configuring
Guice Servlet" section.

Dhanji.

On Sat, Apr 24, 2010 at 12:38 AM, senny  wrote:

> Hey there
>
> I am very new to Guice and would like to use it with our Stripes
> Application. I would like to add the StripesFilter and the
> DispatcherServilet inside the ServletModule. Can anyone tell me how to
> do that? Or do i still need to define the StripesFilter and the
> Dispatcher in the web xml? It is important that the StripesFilter also
> gets used for ServerSide includes and forwards.My currend web.xml
> Mappings look like:
>
>  
>DispatcherServlet
> class>net.sourceforge.stripes.controller.DispatcherServlet class>
>2
>  
>
>  
>DispatcherServlet
>*.do
>  
>
>  
>StripesFilter
>net.sourceforge.stripes.controller.StripesFilter filter-class>
>  
>
>  
>StripesFilter
>DispatcherServlet
>REQUEST
>FORWARD
>INCLUDE
>  
>
> Cheers,
> -- Yves
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Obscure SecurityException during injection on Appengine

2010-04-16 Thread Dhanji R. Prasanna
On Fri, Apr 16, 2010 at 10:00 PM, dha...@gmail.com  wrote:

> Looks like you're missing aopalliance.jar
>
>
Sorry, not aopalliance, but some other Jar one of your libraries depends on.
Appengine will report this obscurely by failing in its
SecurityManager, unfortunately =(

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: guice and jax-ws

2010-04-09 Thread Dhanji R. Prasanna
Hi,

I think the question might be better for the JAX-WS mailing list. Not sure
there are many here with that experience.

Dhanji.

On Sat, Apr 10, 2010 at 5:16 AM, ale  wrote:

> jax-ws-commons.dev.java.net/guice

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: bind from a class name

2010-03-24 Thread Dhanji R. Prasanna
Can't you use Class.forName in between?

On Thu, Mar 25, 2010 at 1:04 PM, Bill de hOra  wrote:

> Is there a way to bind from a class name (ie the class' string name)
> instead of a .class?
>
> Bill
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Creating more boilerplate with Guice

2010-03-17 Thread Dhanji R. Prasanna
On a slightly unrelated note, I take issue with the insinuation that
Functional languages do not do the strategy pattern well. I'd say higher
order programming achieves the same goal, and somewhat more elegantly than
the strategy pattern.

Dhanji.

On Thu, Mar 18, 2010 at 2:57 PM, Jason Felice wrote:

> I just posted this blog article:
>
> http://eraserhead.net/2010/03/creating-boilerplate-with-google-guice/
>
> A note:  While it seems to be a peculiar problem, I'm not slamming Guice,
> Guice is still a big net win for us!
>
> I post here for thoughts on this problem, and suggestions for solutions to
> it.
>
> Excerpt:
>
> There’s plenty of boilerplate that Guice removes, mostly in the “bean
> wiring” category, and this is good. Interestingly, there are areas in which
> I’ve found myself writing *more* boilerplate with Guice, and an instance
> of this is what I’d like to discuss today.
>
> I work with some people who have become thoroughly disgusted with OOP and
> advocate for functional style with immutable data types. I appreciate
> functional style with immutable data types, but I must say that the Strategy
> pattern  is something OOP
> does well and not something that FP does nearly as well. I tend to use
> strategy pattern quite a bit in our XPay (and in our C++ product, DAS). One
> reason to prefer Strategy pattern to switch 
> statementsis to have a single 
> point of control over
> *which* strategy implementation to use. This use case usually conjures
> itself into being in a Factory method 
> patternwhich has the 
> single switch statement which provides an instance of the
> concrete type based on input parameters.
>
> In Guice, you can inject a Provider and Guice will automatically
> create a type that produces instances of Foo. This is useful for
> dependencies. So our factory ends up looking something like this:
>
> class FooFactory {
>
>
> private final Provider typeAFooProvider;
>
> private final Provider typeBFooProvider;
>
> private final Provider typeCAFooProvider;
>
> private final Provider typeCBFooProvider;
>
> private final Provider typeDFooProvider;
>
> private final Provider typeEFooProvider;
>
>
> @Inject
> public FooFactory(
> final Provider typeAFooProvider,
>
> final Provider typeBFooProvider,
> final Provider typeCAFooProvider,
>
> final Provider typeCBFooProvider,
> final Provider typeDFooProvider,
>
> final Provider typeEFooProvider
> )
>
> {
> this.typeAFooProvider = typeAFooProvider;
>
> this.typeBFooProvider = typeBFooProvider;
>
> this.typeCAFooProvider = typeCAFooProvider;
>
> this.typeCBFooProvider = typeCBFooProvider;
>
> this.typeDFooProvider = typeDFooProvider;
>
> this.typeEFooProvider = typeEFooProvider;
>
> }
>
> public Foo get(char type, boolean inverted) {
>
> switch (type) {
> case 'A':
>
> return typeAFooProvider.get();
>
> case 'B':
> return typeBFooProvider.get();
>
> case 'C':
> if (inverted)
>
> return typeCAFooProvider.get();
>
> else
> return typeCBFooProvider.get();
>
> case 'D':
> return typeBFooProvider.get();
>
> case 'E':
> return typeBFooProvider.get();
>
> default:
> throw new FooFactoryException("Can't determine type.");
>
> }
> }
> };
>
> Ugh!
>
> This is “better” boilerplate than the bean wiring before in that it hints
> that we might be able to concoct a general solution; however, I haven’t yet
> found it. One solution which I’ve rejected is the “injecting an injector”
> solution:
>
> class FooFactory {
>
>
> private final Injector injector;
>
> @Inject
>
> public FooFactory(final Injector injector) {
>
>  this.injector = injector;
>
> }
> public Foo get(char type, boolean inverted) {
>
> switch (type) {
> case 'A':
>
> return injector.createInstance(TypeAFoo.class);
>
> case 'B':
> return injector.createInstance(TypeBFoo.class);
>
> case 'C':
> if (inverted)
>
> return injector.createInstance(TypeCAFoo.class);
>
> else
> return injector.createInstance(TypeCBFoo.class);
>
> case 'D':
> return injector.createInstance(TypeDFoo.class);
>
> case 'E':
> return injector.createInstance(TypeEFoo.class);
>
> default:
> throw new FooFactoryException("Can't determine type.");
>
> }
> }
> };
>
> The reason I’ve rejected this approach is that it prevents Guice from
> checking the entire dependency graph at boot – Guice doesn’t know which
> types you are

Re: Guice Billing Service example code

2010-03-15 Thread Dhanji R. Prasanna
Hello,

I don't think that is a working example. It is just a code snippet. But you
could try to browse under the source tree for our examples:
http://code.google.com/p/google-guice/source/browse/#svn/trunk/examples

This has an example of how to use xml to configure Guice (though this is not
a recommended approach). You could also try the video at
http://code.google.com/p/google-guice/

Dhanji.

On Tue, Mar 16, 2010 at 2:23 PM, Dhiren Bhatia <
dhiren_bha...@mba.berkeley.edu> wrote:

> Hi Dhanji,
>
> Hope you don't mind me reaching out to you directly. I was wondering if the
> source code for the Billing Service example in the Guice documentation is
> posted anywhere or if you could share it. It would be super helpful to go
> through the tutorial with the code available. I couldn't find it on the site
> or get an answer on the guice google group.
>
> Thanks!
> Dhiren

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: ClassCastException for GuiceFilter with Guice 2.0 and JBoss 4.2.2

2010-03-11 Thread Dhanji R. Prasanna
On Fri, Mar 12, 2010 at 7:10 AM, Brandon Atkinson <
brandon.n.atkin...@gmail.com> wrote:

> I have had this problem before.
>
> Are you using maven by any chance?
>
> If so, make sure that you've made servlet-api a provided dependency.
>
> For some reason, guice-servlet's pom declares that it has a compile time
> dependency on servlet-api.  This causes the servlet-api classes to be loaded
> into your war.  Since there are two defined copies of the servlet api
> classes (in two different class loaders) a CCE occurs.
>

messy =(

what do you suggest we do to our pom to fix this?

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Jersey + Guice

2010-03-10 Thread Dhanji R. Prasanna
Interesting.

BTW you can simplify this vastly by using Sitebricks which comes with built
in Jackson and restful web services support and is built on top of Guice.

Dhanji.

On Wed, Mar 10, 2010 at 6:39 AM, Iqbal Yusuf Dipu
wrote:

> http://wp.me/PnkVx-2Z
> A mini tutorial on
> "JAX-RS Jersey + Guice + Objectify + Simple XML + Jackson on Google
> App Engine Java"
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Guice servlet problem with Jetty (using Google Eclipse Plugin for GWT)

2010-03-06 Thread Dhanji R. Prasanna
Also, sounds like a problem that the GWT team may be able to answer better.

Dhanji.

On Sat, Mar 6, 2010 at 9:02 PM, Alen Vrečko  wrote:

> Make sure you are not using the HttpServletRequest out of scope. e.g.
>
> @Singleton
> public class Foo{
>
> @Inject HttpServletRequest request;
>
> }
>
> is a very bad idea. I'd recommend you use a provider
>
> @Singleton
> public class Foo{
>
> @Inject Provider session;
>
> }
>
> Or go with @RequestScoped
>
> Cheers
> Alen
>
> On Mar 4, 5:07 pm, Marc Guillemot  wrote:
> > Hi,
> >
> > I have some problems using HttpSession or HttpServletRequest injection
> > under Jetty in GWT dev mode (using Google Eclipse plugin).
> >
> > With HttpSession, a new session gets created which is not the
> > "standard" session for my client therefore I can't find the attribute
> > placed there by a servlet.
> >
> > If I use HttpServletRequest injection and call myself getSection() on
> > it, I get following exception:
> >
> > Caused by: java.lang.IllegalStateException: No SessionHandler or
> > SessionManager
> > at org.mortbay.jetty.Request.getSession(Request.java:1115)
> > at org.mortbay.jetty.Request.getSession(Request.java:1105)
> > at myproj.server.MyService.myMethod(MyService.java:48)
> > at myproj.server.RPCServiceImpl.doAction(RPCServiceImpl.java:186)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> > 39)
> > at
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
> > 25)
> > at java.lang.reflect.Method.invoke(Method.java:597)
> > at
> > com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
> > 562)
> >
> > Is it a know problem with Jetty + GWT + Google Eclipse Plugin?
> >
> > Cheers,
> > Marc.
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to google-gu...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-guice+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



Re: Help understanding @Inject (doesn't inject unless I use injector.getInstance())

2010-03-03 Thread Dhanji R. Prasanna
On Wed, Mar 3, 2010 at 8:29 PM, infinity2heaven wrote:

> Thanks Eelco, I figured the anonymous inner class accessing an object
> reference, and while fixing it, your suggestion of using
> requestStaticInjection solves my problem.
>
> Dhanji:
> I still don't understand how autowire is "by default" in Guice. In the
> example I mentioned, I have to create n modules for each Class
> referencing template variable. Agreed, the following code
>
> new AbstractModule() {
>@Override
>public void configure() {
> requestStaticInjection (this);
> }});
>
> would inject the reference in the static instance, but that means I
> have to write the same boilerplate code for every test, ie, every
> class that has @Inject Template template.
>

It will work for non-static members, with just @Inject. Static injection is
not really intended to be used except in very rare cases like serialization.

The thing you need a module for is to couple interfaces to implementations
so Guice can tell which implementation to use when you refer to Template
(assuming it is an interface), for example XmlTemplate or HtmlTemplate. And
if you use @ImplementedBy on the interface, you don't need modules at all.

Dhanji.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.



  1   2   3   4   >