The following code and corresponding tc-config.xml seems to work for me
with the 3.3.0 release. I run foo.Foo with dso-java (ie. custom mode) and
I get the injected instance and the root is a terracotta root.

package foo;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.terracotta.annotations.Root;

import com.tc.cluster.DsoCluster;
import com.tc.injection.annotations.InjectedDsoInstance;
import com.tcclient.cluster.DsoNode;

public class Foo {

        @InjectedDsoInstance
        private DsoCluster cluster;

        @Root
        private final Map<String, String> root = new
ConcurrentHashMap<String, String>();

        public static void main(String[] args) {
                new Foo().foo();

        }

        private void foo() {
                root.put(root.size() + "", "");
                System.err.println(root.size());

                DsoNode currentNode = cluster.getCurrentNode();
                System.err.println(currentNode);
        }

}

<?xml version="1.0" encoding="UTF-8"?>

<tc:tc-config xmlns:tc="http://www.terracotta.org/config";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-6.xsd";>

  <clients>
    <modules>
      <module name="terracotta-toolkit-1.0"
group-id="org.terracotta.toolkit"/>
    </modules>
  </clients>

</tc:tc-config>





> -----Original Message-----
> From: tc-dev-boun...@lists.terracotta.org [mailto:tc-dev-
> boun...@lists.terracotta.org] On Behalf Of Tim Eck
> Sent: Wednesday, July 21, 2010 2:03 PM
> To: tc-dev@lists.terracotta.org
> Subject: Re: [tc-dev] Problems with InjectedDsoInstance annotation
> 
> Actually using the annotations is a little trickier in express mode (as
> opposed to custom mode).
> 
> I'll run a test here to verify if it does indeed work, but the only
> thing
> that should differ here (between 3.2.x and 3.3.0) is what <module> you
> list in your tc-config.xml. In 3.2.x you needed to activate
> tim-annotations, where as now you need terracotta-toolkit-1.0 (note
> that
> you need to specify the groupId too which is "org.terracota.toolkit").
> 
> Not sure if this forum post is relevant to your situation, but it was
> close in topic:
>   http://forums.terracotta.org/forums/posts/list/3978.page
> 
> 
> 
> > -----Original Message-----
> > From: tc-dev-boun...@lists.terracotta.org [mailto:tc-dev-
> > boun...@lists.terracotta.org] On Behalf Of Sergio Bossa
> > Sent: Tuesday, July 20, 2010 8:14 PM
> > To: tc-dev@lists.terracotta.org
> > Subject: Re: [tc-dev] Problems with InjectedDsoInstance annotation
> >
> > Any updates on this, guys?
> >
> > I could turn the question in ... how to use the annotations bundled
> > with the toolkit jar *without* going express mode (that is, with
> > bytecode instrumentation)?
> >
> > On Tue, Jul 20, 2010 at 10:42 PM, Sergio Bossa
> <sergio.bo...@gmail.com>
> > wrote:
> > > Thanks Tim.
> > >
> > > I think I've got the problem: the InjectedDsoInstance is applied to
> > an
> > > instrumented class marked with Terracotta annotations; for the
> > > annotations I dropped the old tim-annotations because I saw they've
> > > been moved into the toolkit, but now I'm wondering: how does
> > > Terracotta notice the use of annotations if I don't configure them
> > > through the tim?
> > > To recap: I use Terracotta instrumentation but I use the toolkit
> for
> > > the annotations (such as Root and InstrumentedClass), how does
> > > Terracotta recognize which classes to instrument without the old
> > > tim-annotations?
> > >
> > > On Tue, Jul 20, 2010 at 7:23 PM, Tim Eck <t...@terracottatech.com>
> > wrote:
> > >> The InjectedDsoInstance is part of the tim-api library now, but I
> > don't
> > >> know why it would be functioning any differently between 3.2 and
> > 3.3.
> > >>
> > >> Are you trying to use it in an express usage context?
> > >>
> > >>> -----Original Message-----
> > >>> From: tc-dev-boun...@lists.terracotta.org [mailto:tc-dev-
> > >>> boun...@lists.terracotta.org] On Behalf Of Sergio Bossa
> > >>> Sent: Tuesday, July 20, 2010 9:18 AM
> > >>> To: tc-dev
> > >>> Subject: [tc-dev] Problems with InjectedDsoInstance annotation
> > >>>
> > >>> Hi guys,
> > >>>
> > >>> The InjectedDsoInstance annotation doesn't seem to work on 3.3: I
> > get
> > >>> a null DsoCluster.
> > >>> In order to use it with terracotta 3.3, I had to switch to tim-
> api
> > >>> 1.3.0 ... is that right? Am I missing something?
> > >>>
> > >>> --
> > >>> Sergio Bossa
> > >>> http://www.linkedin.com/in/sergiob
> > >>> _______________________________________________
> > >>> tc-dev mailing list
> > >>> tc-dev@lists.terracotta.org
> > >>> http://lists.terracotta.org/mailman/listinfo/tc-dev
> > >> _______________________________________________
> > >> tc-dev mailing list
> > >> tc-dev@lists.terracotta.org
> > >> http://lists.terracotta.org/mailman/listinfo/tc-dev
> > >>
> > >
> > >
> > >
> > > --
> > > Sergio Bossa
> > > http://www.linkedin.com/in/sergiob
> > >
> >
> >
> >
> > --
> > Sergio Bossa
> > http://www.linkedin.com/in/sergiob
> > _______________________________________________
> > tc-dev mailing list
> > tc-dev@lists.terracotta.org
> > http://lists.terracotta.org/mailman/listinfo/tc-dev
> _______________________________________________
> tc-dev mailing list
> tc-dev@lists.terracotta.org
> http://lists.terracotta.org/mailman/listinfo/tc-dev
_______________________________________________
tc-dev mailing list
tc-dev@lists.terracotta.org
http://lists.terracotta.org/mailman/listinfo/tc-dev

Reply via email to