Rick Wagner

Recent Posts

Using .NET Core in a “Disconnected” Environment

Using .NET Core in a “Disconnected” Environment

Security is a very important consideration when running your custom middleware applications.  The internet can be an unfriendly place.

Sometimes middleware users have a requirement for their software to run in a “‘disconnected” environment, which is one where the network is not routed to addresses outside the one the local node is on—in other words, no internet.

Continue reading “Using .NET Core in a “Disconnected” Environment”

Share

Changing objects in flight, without a Debugger

How to change data in-flight, without a Debugger

Do you ever wish you could change the behavior of some object in the middle of a bunch of method calls?  I sometimes do.

Maybe you want to set some properties on an object to replicate a fault.  Maybe you’d like to force a specific return value from a method for some reason.  These are both very possible, without altering the source code for your application.

I like to do this through Byteman.  Byteman is a JBoss project that deals with bytecode injection.  This means that you can inject code you want to run, specifying where you want to run it.  It’s sort of like AOP, except I think it allows more freedom for the user.  It’s also pretty easy to use.

Here’s how:

1)  Make a helper class to do the work you want done
2)  Put the helper class in a .jar
3)  Write the Byteman rule that tells the helper class to do it’s thing

That’s it!  So here’s the example.

Part 1, the helper class
**********************************

public void addMarker(Message msg){
System.out.println(“Changing Message contents.”);
Body msgBody = msg.getBody();
msgBody.add(“Hey, I’ve got changed content”);
System.out.println(“Done changing Message contents”);
}
***********************************

Continue reading “Changing objects in flight, without a Debugger”

Share