Terracotta

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Terracotta 
License:
URL:http://terracotta.org/
Description:Terracotta Works like Network Attached Memory
Package NameComment
com.tc
com.tc.admin
com.tc.admin.common
com.tc.admin.dso
com.tc.admin.sessions
com.tc.asm Provides a small and fast bytecode manipulation framework.

The ASM framework is organized around the {@link org.objectweb.asm.ClassVisitor ClassVisitor}, {@link org.objectweb.asm.FieldVisitor FieldVisitor} and {@link org.objectweb.asm.MethodVisitor MethodVisitor} interfaces, which allow one to visit the fields and methods of a class, including the bytecode instructions of each method.

In addition to these main interfaces, ASM provides a {@link org.objectweb.asm.ClassReader ClassReader} class, that can parse an existing class and make a given visitor visit it. ASM also provides a {@link org.objectweb.asm.ClassWriter ClassWriter} class, which is a visitor that generates Java class files.

In order to generate a class from scratch, only the {@link org.objectweb.asm.ClassWriter ClassWriter} class is necessary. Indeed, in order to generate a class, one must just call its visitXXX methods with the appropriate arguments to generate the desired fields and methods. See the "helloworld" example in the ASM distribution for more details about class generation.

In order to modify existing classes, one must use a {@link org.objectweb.asm.ClassReader ClassReader} class to analyze the original class, a class modifier, and a {@link org.objectweb.asm.ClassWriter ClassWriter} to construct the modified class. The class modifier is just a {@link org.objectweb.asm.ClassVisitor ClassVisitor} that delegates most of the work to another {@link org.objectweb.asm.ClassVisitor ClassVisitor}, but that sometimes changes some parameter values, or call additional methods, in order to implement the desired modification process. In order to make it easier to implement such class modifiers, ASM provides the {@link org.objectweb.asm.ClassAdapter ClassAdapter} and {@link org.objectweb.asm.MethodAdapter MethodAdapter} classes, which implement the {@link org.objectweb.asm.ClassVisitor ClassVisitor} and {@link org.objectweb.asm.MethodVisitor MethodVisitor} interfaces by delegating all work to other visitors. See the "adapt" example in the ASM distribution for more details about class modification.

The size of the core ASM library, asm.jar, is only 42KB, which is much smaller than the size of the BCEL library (504KB), and than the size of the SERP library (150KB). ASM is also much faster than these tools. Indeed the overhead of a load time class transformation process is of the order of 60% with ASM, 700% or more with BCEL, and 1100% or more with SERP (see the test/perf directory in the ASM distribution)! @since ASM 1.3

com.tc.asm.commons Provides some useful class and method adapters. The preferred way of using these adapters is by chaining them together and to custom adapters (instead of inheriting from them). Indeed this approach provides more combination possibilities than inheritance. For instance, suppose you want to implement an adapter MyAdapter than needs sorted local variables and intermediate stack map frame values taking into account the local variables sort. By using inheritance, this would require MyAdapter to extend AnalyzerAdapter, itself extending LocalVariablesSorter. But AnalyzerAdapter is not a subclass of LocalVariablesSorter, so this is not possible. On the contrary, by using delegation, you can make LocalVariablesSorter delegate to AnalyzerAdapter, itself delegating to MyAdapter. In this case AnalyzerAdapter computes intermediate frames based on the output of LocalVariablesSorter, and MyAdapter can add new locals by calling the newLocal method on LocalVariablesSorter, and can get the stack map frame state before each instruction by reading the locals and stack fields in AnalyzerAdapter (this requires references from MyAdapter back to LocalVariablesSorter and AnalyzerAdapter).
com.tc.asm.signature Provides support for type signatures. @since ASM 2.0
com.tc.asm.tree

Provides an ASM visitor that constructs a tree representation of the classes it visits. This class adapter can be useful to implement "complex" class manipulation operations, i.e., operations that would be very hard to implement without using a tree representation (such as optimizing the number of local variables used by a method).

However, this class adapter has a cost: it makes ASM bigger and slower. Indeed it requires more than twenty new classes, and multiplies the time needed to transform a class by almost two (it is almost two times faster to read, "modify" and write a class with a ClassAdapter than with a ClassNode). This is why this package is bundled in an optional asm-tree.jar library that is separated from (but requires) the asm.jar library, which contains the core ASM framework. This is also why it is recommended not to use this class adapter when it is possible.

The root class is the ClassNode, that can be created from existing bytecode. For example:

  ClassReader cr = new ClassReader(source);
  ClassNode cn = new ClassNode();
  cr.accept(cn, true);

Now content of ClassNode can be modified and then serialized back into bytecode:

  ClassWriter cw = new ClassWriter(true);
  cn.accept(cw);

Using simple ClassAdapter it is possible to create MethodNode instances per-method. In this example MethodNode is acting as a buffer that is flushed out at visitEnd() call:

  ClassReader cr = new ClassReader(source);
  ClassWriter cw = new ClassWriter();
  ClassAdapter ca = new ClassAdapter(cw) {
      public MethodVisitor visitMethod(int access, String name, 
          String desc, String signature, String[] exceptions) {
        final MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
        MethodNode mn = new MethodNode(access, name, desc, signature, exceptions) {
            public void visitEnd() {
              // transform or analyze method code using tree API
              accept(mv);
            }
          };
      }
    };
  cr.accept(ca, true);

Several strategies can be used to construct method code from scratch. The first option is to create a MethodNode, and then create XXXInsnNode instances and add them to the instructions list:

MethodNode m = new MethodNode(...);
m.instructions.add(new VarInsnNode(ALOAD, 0));
...

Alternatively, you can use the fact that MethodNode is a MethodVisitor, and use that to create the XXXInsnNode and add them to the instructions list through the standard MethodVisitor interface:

MethodNode m = new MethodNode(...);
m.visitVarInsn(ALOAD, 0);
...

If you cannot generate all the instructions in sequential order, i.e. if you need to save some pointer in the instruction list and then insert instructions at that place after other instructions have been generated, you can use InsnList methods insert() and insertBefore() to insert instructions at saved pointer.

MethodNode m = new MethodNode(...);
m.visitVarInsn(ALOAD, 0);
AbstractInsnNode ptr = m.instructions.getLast();
m.visitVarInsn(ALOAD, 1);
// inserts an instruction between ALOAD 0 and ALOAD 1
m.instructions.insert(ptr, new VarInsnNode(ALOAD, 0));
...

If you need to insert instructions while iterating over an existing instruction list, you can also use several strategies. The first one is to use a ListIterator over the instruction list:

ListIterator it = m.instructions.iterator();
while (it.hasNext()) {
    AbstractInsnNode n = (AbstractInsnNode) it.next();
    if (...) {
        it.add(new VarInsnNode(ALOAD, 0));
    }
}

It is also possible to convert instruction list into the array and iterate trough array elements:

AbstractInsnNode[] insns = m.instructions.toArray();
for(int i = 0; i<insns.length; i++) {
    AbstractInsnNode n = insns[i];
    if (...) {
        m.instructions.insert(n, new VarInsnNode(ALOAD, 0));
    }
}

If you want to insert these instructions through the MethodVisitor interface, you can use another instance of MethodNode as a MethodVisitor and then insert instructions collected by that instance into the instruction list. For example:

AbstractInsnNode[] insns = m.instructions.toArray();
for(int i = 0; i<insns.length; i++) {
    AbstractInsnNode n = insns[i];
    if (...) {
        MethodNode mn = new MethodNode();
        mn.visitVarInsn(ALOAD, 0);
        mn.visitVarInsn(ALOAD, 1);
        m.instructions.insert(n, mn.instructions);
    }
}

@since ASM 1.3.3

com.tc.asm.tree.analysis

Provides a framework for static code analysis based on the asm.tree package.

Basic usage:

ClassReader cr = new ClassReader(bytecode);
ClassNode cn = new ClassNode();
cr.accept(cn, ClassReader.SKIP_DEBUG);

List methods = cn.methods;
for (int i = 0; i < methods.size(); ++i) {
    MethodNode method = (MethodNode) methods.get(i);
    if (method.instructions.size() > 0) {
        Analyzer a = new Analyzer(new BasicInterpreter());
        a.analyze(cn.name, method);
        Frame[] frames = a.getFrames();
        // Elements of the frames arrray now contains info for each instruction 
        // from the analyzed method. BasicInterpreter creates BasicValue, that
        // is using simplified type system that distinguishes the UNINITIALZED, 
        // INT, FLOAT, LONG, DOUBLE, REFERENCE and RETURNADDRESS types.
        ...
    }
}   

@since ASM 1.4.3

com.tc.asm.util Provides ASM visitors that can be useful for programming and debugging purposes. These class visitors are normally not used by applications at runtime. This is why they are bundled in an optional asm-util.jar library that is separated from (but requires) the asm.jar library, which contains the core ASM framework. @since ASM 1.3.2
com.tc.aspectwerkz
com.tc.aspectwerkz.annotation
com.tc.aspectwerkz.aspect
com.tc.aspectwerkz.aspect.container
com.tc.aspectwerkz.aspect.management
com.tc.aspectwerkz.cflow
com.tc.aspectwerkz.compiler
com.tc.aspectwerkz.connectivity
com.tc.aspectwerkz.definition
com.tc.aspectwerkz.definition.aspectj5
com.tc.aspectwerkz.definition.deployer
com.tc.aspectwerkz.env
com.tc.aspectwerkz.exception
com.tc.aspectwerkz.expression
com.tc.aspectwerkz.expression.ast
com.tc.aspectwerkz.expression.regexp
com.tc.aspectwerkz.hook
com.tc.aspectwerkz.hook.impl
com.tc.aspectwerkz.intercept
com.tc.aspectwerkz.joinpoint
com.tc.aspectwerkz.joinpoint.impl
com.tc.aspectwerkz.joinpoint.management
com.tc.aspectwerkz.perx
com.tc.aspectwerkz.proxy
com.tc.aspectwerkz.reflect
com.tc.aspectwerkz.reflect.impl.asm
com.tc.aspectwerkz.reflect.impl.java
com.tc.aspectwerkz.transform
com.tc.aspectwerkz.transform.inlining
com.tc.aspectwerkz.transform.inlining.compiler
com.tc.aspectwerkz.transform.inlining.deployer
com.tc.aspectwerkz.transform.inlining.model
com.tc.aspectwerkz.transform.inlining.spi
com.tc.aspectwerkz.transform.inlining.weaver
com.tc.aspectwerkz.util
com.tc.async.api
com.tc.async.impl
com.tc.backport175
com.tc.backport175.bytecode
com.tc.backport175.bytecode.spi
com.tc.backport175.proxy
com.tc.bootjar
com.tc.bootjar.java.util
com.tc.bundles
com.tc.bundles.exception
com.tc.bytes
com.tc.capabilities
com.tc.cluster
com.tc.common.proxy
com.tc.common.proxy.subpkg
com.tc.config
com.tc.config.lock
com.tc.config.schema
com.tc.config.schema.beanfactory
com.tc.config.schema.builder
com.tc.config.schema.context
com.tc.config.schema.defaults
com.tc.config.schema.dynamic
com.tc.config.schema.listen
com.tc.config.schema.messaging.http
com.tc.config.schema.migrate
com.tc.config.schema.repository
com.tc.config.schema.setup
com.tc.config.schema.setup.sources
com.tc.config.schema.test
com.tc.config.schema.utils
com.tc.config.schema.validate
com.tc.exception
com.tc.gcrunner
com.tc.geronimo
com.tc.geronimo.transform
com.tc.hibernate
com.tc.ibatis
com.tc.installer.action
com.tc.installer.panel
com.tc.installer.util
com.tc.io
com.tc.io.serializer
com.tc.io.serializer.api
com.tc.io.serializer.impl
com.tc.jboss
com.tc.jboss.transform
com.tc.jetty
com.tc.jrexx.automaton
com.tc.jrexx.regex
com.tc.jrexx.set
com.tc.l2.api
com.tc.l2.context
com.tc.l2.ha
com.tc.l2.handler
com.tc.l2.msg
com.tc.l2.objectserver
com.tc.l2.state
com.tc.lang
com.tc.logging
com.tc.management
com.tc.management.beans
com.tc.management.beans.logging
com.tc.management.beans.object
com.tc.management.beans.sessions
com.tc.management.beans.tx
com.tc.management.exposed
com.tc.management.opentypes.adapters
com.tc.management.remote.connect
com.tc.management.remote.protocol
com.tc.management.remote.protocol.terracotta
com.tc.management.stats
com.tc.memorydatastore.client
com.tc.memorydatastore.message
com.tc.memorydatastore.server
com.tc.memorydatastore.server.handler
com.tc.net
com.tc.net.core
com.tc.net.core.event
com.tc.net.groups
com.tc.net.protocol
com.tc.net.protocol.delivery
com.tc.net.protocol.tcm
com.tc.net.protocol.tcm.msgs
com.tc.net.protocol.transport
com.tc.net.proxy
com.tc.net.util
com.tc.object
com.tc.object.appevent
com.tc.object.applicator
com.tc.object.bytecode
com.tc.object.bytecode.aspectwerkz
com.tc.object.bytecode.hook
com.tc.object.bytecode.hook.impl
com.tc.object.cache
com.tc.object.change
com.tc.object.change.event
com.tc.object.config
com.tc.object.config.schema
com.tc.object.config.spec
com.tc.object.context
com.tc.object.dmi
com.tc.object.dna.api
com.tc.object.dna.impl
com.tc.object.event
com.tc.object.field
com.tc.object.glassfish.transform
com.tc.object.gtx
com.tc.object.handler
com.tc.object.handshakemanager
com.tc.object.ibm
com.tc.object.idprovider.api
com.tc.object.idprovider.impl
com.tc.object.loaders
com.tc.object.lockmanager.api
com.tc.object.lockmanager.impl
com.tc.object.logging
com.tc.object.msg
com.tc.object.net
com.tc.object.session
com.tc.object.tools
com.tc.object.tx
com.tc.object.tx.optimistic
com.tc.object.util
com.tc.object.walker
com.tc.objectserver
com.tc.objectserver.api
com.tc.objectserver.context
com.tc.objectserver.control
com.tc.objectserver.core.api
com.tc.objectserver.core.impl
com.tc.objectserver.gtx
com.tc.objectserver.handler
com.tc.objectserver.handshakemanager
com.tc.objectserver.impl
com.tc.objectserver.l1.api
com.tc.objectserver.l1.impl
com.tc.objectserver.lockmanager.api
com.tc.objectserver.lockmanager.impl
com.tc.objectserver.managedobject
com.tc.objectserver.managedobject.bytecode
com.tc.objectserver.mgmt
com.tc.objectserver.persistence.api
com.tc.objectserver.persistence.impl
com.tc.objectserver.persistence.sleepycat
com.tc.objectserver.tx
com.tc.objectserver.uuid
com.tc.pattern
com.tc.plugins
com.tc.process
com.tc.properties
com.tc.reporter
com.tc.runtime
com.tc.server
com.tc.servers
com.tc.session
com.tc.simulator.app
com.tc.simulator.container
com.tc.simulator.control
com.tc.simulator.crasher
com.tc.simulator.distrunner
com.tc.simulator.listener
com.tc.stats
com.tc.stats.counter
com.tc.stats.counter.sampled
com.tc.stats.statistics
com.tc.sysinfo
com.tc.test
com.tc.test.activepassive
com.tc.test.collections
com.tc.test.proxyconnect
com.tc.test.restart
com.tc.test.server
com.tc.test.server.appserver
com.tc.test.server.appserver.cargo
com.tc.test.server.appserver.deployment
com.tc.test.server.appserver.glassfishv1
com.tc.test.server.appserver.jboss3x
com.tc.test.server.appserver.jboss4x
com.tc.test.server.appserver.jetty6x
com.tc.test.server.appserver.load
com.tc.test.server.appserver.tomcat5x
com.tc.test.server.appserver.was6x
com.tc.test.server.appserver.wasce1x
com.tc.test.server.appserver.weblogic8x
com.tc.test.server.appserver.weblogic9x
com.tc.test.server.util
com.tc.test.transactions
com.tc.text
com.tc.tomcat
com.tc.tomcat.session
com.tc.tomcat.transform
com.tc.tomcat50
com.tc.tomcat50.session
com.tc.tomcat55
com.tc.tomcat55.session
com.tc.util
com.tc.util.concurrent
com.tc.util.concurrent.locks
com.tc.util.diff
com.tc.util.event
com.tc.util.exception
com.tc.util.factory
com.tc.util.io
com.tc.util.runtime
com.tc.util.sequence
com.tc.util.startuplock
com.tc.util.stringification
com.tc.verify
com.tc.weblogic
com.tc.weblogic.transform
com.tc.websphere
com.tc.welcome
com.tcclient.cache
com.tcclient.ehcache
com.tcclient.object
com.tcclient.util
com.tcclient.util.concurrent.locks
com.tcsimulator
com.tcsimulator.container
com.tcsimulator.distrunner
com.tcsimulator.listener
com.tcspring
com.tcspring.beans
com.tcspring.beans.orm.data
com.tcspring.beans.orm.domain
com.tcspring.beans.orm.hibernate
com.tcspring.events
com.tctest
com.tctest.domain
com.tctest.dso
com.tctest.longrunning
com.tctest.management
com.tctest.modules.lucene_2_0_0
com.tctest.perf.collections
com.tctest.restart
com.tctest.restart.system
com.tctest.restart.unit
com.tctest.rife.elements
com.tctest.rife.tests
com.tctest.runner
com.tctest.server.appserver.load
com.tctest.server.appserver.unit
com.tctest.service
com.tctest.spring
com.tctest.spring.aj
com.tctest.spring.aop
com.tctest.spring.bean
com.tctest.spring.bean.domain
com.tctest.spring.bean.orm.hibernate
com.tctest.spring.integrationtests
com.tctest.spring.integrationtests.load
com.tctest.spring.integrationtests.tests
com.tctest.spring.integrationtests.tests.sellitem
com.tctest.stringbuffer
com.tctest.transparency
com.tctest.util
com.tctest.webapp.listeners
com.tctest.webapp.servletfilters
com.tctest.webapp.servlets
com.tctest.wicket
com.tcverify
com.terracotta.session
com.terracotta.session.util
com.zerog.ia.customcode.util.fileutils
demo.cart
demo.chatter
demo.continuations
demo.coordination
demo.events
demo.events.web
demo.inventory
demo.jmx
demo.jmx.web
demo.jtable
demo.sharededitor
demo.sharededitor.controls
demo.sharededitor.events
demo.sharededitor.models
demo.sharededitor.ui
demo.sharedqueue
demo.tasklist.action
demo.tasklist.common
demo.tasklist.form
demo.tasklist.service
demo.townsend.action
demo.townsend.common
demo.townsend.form
demo.townsend.service
demo.webflow
dso
dso.concurrency
java.util
java.util.concurrent
java.util.concurrent.locks
javax.servlet.http
jmx
net.sf.ehcache
net.sf.ehcache.store
org.apache.catalina.connector
org.springframework.web.context.request
org.terracotta.dso
org.terracotta.dso.actions
org.terracotta.dso.correction
org.terracotta.dso.decorator
org.terracotta.dso.dialogs
org.terracotta.dso.editors
org.terracotta.dso.editors.chooser
org.terracotta.dso.editors.xml
org.terracotta.dso.editors.xmlbeans
org.terracotta.dso.launch
org.terracotta.dso.properties
org.terracotta.dso.refactoring
org.terracotta.dso.util
org.terracotta.dso.views
org.terracotta.dso.wizards
org.terracotta.modules
org.terracotta.modules.cglib_2_1_3
org.terracotta.modules.cglib_2_1_3.object.applicator
org.terracotta.modules.cglib_2_1_3.object.config
org.terracotta.modules.cglib_2_1_3.object.dna.impl
org.terracotta.modules.cglib_2_1_3.util
org.terracotta.modules.configuration
org.terracotta.modules.ehcache.commons_1_0
org.terracotta.modules.ehcache.commons_1_0.util
org.terracotta.modules.ehcache_1_2_4
org.terracotta.modules.ehcache_1_3
org.terracotta.modules.hibernate_3_1_2
org.terracotta.modules.hibernate_3_1_2.object.applicator
org.terracotta.modules.hibernate_3_1_2.object.config
org.terracotta.modules.hibernate_3_1_2.util
org.terracotta.modules.iBatis_2_2_0
org.terracotta.modules.iBatis_2_2_0.object.applicator
org.terracotta.modules.iBatis_2_2_0.object.config
org.terracotta.modules.jetty_6_1
org.terracotta.modules.jetty_6_1.adapters
org.terracotta.modules.lucene_2_0_0
org.terracotta.modules.struts_1_1
org.terracotta.modules.surefire_2_3
org.terracotta.modules.test
org.terracotta.modules.websphere_6_1
org.terracotta.modules.wicket_1_3_0
org.terracotta.tcbuild.configuration
org.terracotta.ui.util
weblogic.j2ee.descriptor
weblogic.management.descriptors.webapp
weblogic.servlet.internal
weblogic.servlet.internal.session
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.