This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * {@inheritDoc} | |
| * @see java.lang.instrument.ClassFileTransformer#transform(java.lang.ClassLoader, java.lang.String, java.lang.Class, java.security.ProtectionDomain, byte[]) | |
| */ | |
| @Override | |
| public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { | |
| byte[] bytecode = classfileBuffer; | |
| if(classBeingRedefined==null) { | |
| if(loader instanceof GroovyClassLoader && isGeneratedClosure(bytecode)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.codehaus.groovy.control.* | |
| import org.codehaus.groovy.ast.ClassHelper; | |
| import org.helios.gmx.classloading.*; | |
| // Acquire the instrumentation instance | |
| def instrumentation = ByteCodeRepository.getInstance().agentInstrumentation.getInstrumentation(); | |
| // Define a closre | |
| foo = {message -> println message}; | |
| // Define a simple class file transformer | |
| class ByteCodeNet implements java.lang.instrument.ClassFileTransformer { | |
| def clazzName; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.helios.gmx.classloading.*; | |
| import org.codehaus.groovy.control.* | |
| def instrumentation = ByteCodeRepository.getInstance().agentInstrumentation.getInstrumentation(); | |
| class ByteCodeNet implements java.lang.instrument.ClassFileTransformer { | |
| public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, java.security.ProtectionDomain protectionDomain, byte[] classfileBuffer) { | |
| if(ByteCodeRepository.getInstance().isGeneratedClosure(classfileBuffer)) { | |
| println "Generated Closure: $className"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.helios.jmx; | |
| import java.io.ObjectInputStream; | |
| import java.lang.management.ManagementFactory; | |
| import java.util.Set; | |
| import javax.management.Attribute; | |
| import javax.management.AttributeList; | |
| import javax.management.AttributeNotFoundException; | |
| import javax.management.InstanceAlreadyExistsException; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Executor bossPool = Executors.newCachedThreadPool(); | |
| Executor workerPool = Executors.newCachedThreadPool(); | |
| ChannelFactory channelFactory = new NioClientSocketChannelFactory(boosPool, workerPool); | |
| ChannelPipelineFactory pipelineFactory = new ChannelPipelineFactory() { | |
| public ChannelPipeline getPipeline() throws Exception { | |
| return Channels.pipeline( | |
| new ObjectEncoder() | |
| } | |
| }; | |
| Bootstrap boostrap = new ClientBootstrap(channelFactory); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <table border='1'><tr><th>Direction</th><th>Sharable</th><th>Exclusive</th></tr><tr><td>Upstream</td><td valign='top'> | |
| <ul> | |
| <li>org.jboss.netty.handler.timeout.ReadTimeoutHandler</li> | |
| <li>org.jboss.netty.handler.codec.base64.Base64Decoder</li> | |
| <li>org.jboss.netty.handler.timeout.IdleStateHandler</li> | |
| <li>org.jboss.netty.handler.codec.protobuf.ProtobufDecoder</li> | |
| <li>org.jboss.netty.handler.codec.string.StringDecoder</li> | |
| </ul></td><td valign='top'> | |
| <ul> | |
| <li>org.jboss.netty.handler.timeout.IdleStateAwareChannelUpstreamHandler</li> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MyStringServerFactory implements ChannelPipelineFactory { | |
| public ChannelPipeline getPipeline() throws Exception { | |
| ChannelPipeline p = Channels.pipeline(); | |
| // Decoders | |
| p.addLast("frameDecoder", new DelimiterBasedFrameDecoder(Delimiters.lineDelimiter())); | |
| p.ddLast("stringDecoder", new StringDecoder(CharsetUtil.UTF_8)); | |
| // Encoder | |
| p.addLast("stringEncoder", new StringEncoder(CharsetUtil.UTF_8)); | |
| return p; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MyPipelineFactory implements ChannelPipelineFactory { | |
| public ChannelPipeline getPipeline() throws Exception { | |
| // Create and configure a new pipeline for a new channel. | |
| ChannelPipeline p = Channels.pipeline(); | |
| p.addLast("encoder", new EncodingHandler()); | |
| p.addLast("decoder", new DecodingHandler()); | |
| p.addLast("logic", new LogicHandler()); | |
| return p; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Generalized websocket service invoker | |
| * @param command A (mandatory) JSON subscription request | |
| * @param options:<ul> | |
| * <li><b>timeout</b>: The timeout in ms. on the request invocation confirm. (i.e. not a subscriber timeout) Default is 2000 ms.</li> | |
| * <li><b>onresponse</b>: A callback invoked when the immediate response of the command invocation is received.</li> | |
| * <li><b>ontimeout</b>: A callback invoked when the request times out</li> | |
| * <li><b>onevent</b>: A callback invoked when an asynchronous event is received associated to the original invocation.</li> | |
| * <li><b>oncancel</b>: A callback invoked the asynchronous event subscription associated to the original invocation is cancelled</li> | |
| * </ul> |