Simple example?

5 views
Skip to first unread message

nino martinez wael

unread,
Jul 6, 2010, 6:33:34 AM7/6/10
to ibaguice
Hi

Do you guys have a simple example using ibaguice?

regards Nino

Simone Tripodi

unread,
Jul 6, 2010, 6:49:53 AM7/6/10
to ibag...@googlegroups.com
Hi Nino,
in the development dir there is a samples dir, btw you can take a look
at a very very simple simple application I'm writing using iBaGuice:

http://code.google.com/p/ipinfo/source/browse/#svn/trunk

Have fun!
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/

nino martinez wael

unread,
Jul 6, 2010, 8:17:41 AM7/6/10
to ibag...@googlegroups.com
Yeah but wheres the configuration module?

Also I have run into a problem :

This yields:
        Injector injector = Guice.createInjector(new IbaguiceModule());
        Mapper mapper = injector
                .getInstance(Mapper.class);

com.google.inject.ConfigurationException: Guice configuration errors:

1) No implementation for com.company.Mapper was bound.
  while locating com.company.Mapper

1 error
    at com.google.inject.InjectorImpl.getProvider(InjectorImpl.java:784)
    at com.google.inject.InjectorImpl.getProvider(InjectorImpl.java:743)
    at com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:793)
    at com.company.WallBoardInformationCiscoProviderTest.guiceIntegrationTest(WallBoardInformationCiscoProviderTest.java:63)
    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:585)

But I do specify the Mapper in the session factory module:

        SqlSessionFactoryModule sqlSessionFactoryModule = new SqlSessionFactoryModule(
                DataSourceProvider.class, JdbcTransactionFactoryProvider.class);
        sqlSessionFactoryModule.setMapperClasses(Mapper.class);
        bindConstant().annotatedWith(
                com.google.inject.name.Names.named("mybatis.environment.id"))
                .to("production");

Also I am using the mybatis annotations for configuration of mapper classes is that a problem with ibaguice?



2010/7/6 Simone Tripodi <simone....@gmail.com>

Simone Tripodi

unread,
Jul 6, 2010, 8:33:32 AM7/6/10
to ibag...@googlegroups.com
Hola Nino,
the problem is that iBaGuice 1.0 doesn't support yet the Mapper
_injection_ (the method you're using is for _configuration_), since in
myBatis 3.0.1 each Mapper object lifecycle is valid only in the
SqlSession one.
That's a feature that will be available in iBaGuice 1.1, since in the
current ,yBatis 3.0.2-SNAPSHOT it will be possible retrieve Mapper
instances that rely on SqlSessionManager, a SqlSession thread safety
manager.

Ath the moment you've to use the dao template we provided to retrieve
the the current Mapper, take a read on
http://www.99soft.org/projects/ibaguice/1.0/dao.html

Feel free to ask questions if something doesn't look clear!!!

Hope this helps, hasta pronto!!!
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/

On Tue, Jul 6, 2010 at 2:17 PM, nino martinez wael

Simone Tripodi

unread,
Jul 6, 2010, 8:37:37 AM7/6/10
to ibag...@googlegroups.com
Hola Nino,
Sorry, just to reply to the first question, the configuration module is here:

http://code.google.com/p/ipinfo/source/browse/trunk/src/main/java/com/ipinfodb/rest/setup/IpLocationContextListener.java

Hope this helps, hasta pronto!!!!
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/

Reply all
Reply to author
Forward
0 new messages