Created
May 10, 2010 17:39
-
-
Save mkristian/396297 to your computer and use it in GitHub Desktop.
This file contains 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 Adapter { | |
public String name(){ | |
return "god"; | |
} | |
} |
This file contains 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 AdapterFactory { | |
public Adapter newAdapter(){ | |
return new MyAdapter(); | |
} | |
} | |
This file contains 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
casting $ javac *java | |
casting $ java -cp .:$HOME/.m2/repository/org/jruby/jruby-complete/1.5.0.RC3/jruby-complete-1.5.0.RC3.jar org.jruby.Main -S irb | |
irb(main):001:0> require 'java' | |
=> true | |
irb(main):002:0> java_import "AdapterFactory" | |
=> Java::Default::AdapterFactory | |
irb(main):003:0> f = AdapterFactory.new | |
=> #<Java::Default::AdapterFactory:0x1d8417c> | |
irb(main):004:0> a = f.new_adapter | |
=> #<Java::Default::MyAdapter:0x11fc4b8> | |
irb(main):005:0> a.name = "bla" | |
=> "bla" | |
irb(main):006:0> a.name | |
=> "bla" | |
irb(main):007:0> |
This file contains 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 MyAdapter extends Adapter { | |
private String name; | |
public void setName(String name){ | |
this.name = name; | |
} | |
public String name(){ | |
return name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment