Class: Asciidoctor::Diagram::Java::CommandServer
- Inherits:
-
Object
- Object
- Asciidoctor::Diagram::Java::CommandServer
- Defined in:
- lib/asciidoctor-diagram/util/java_socket.rb
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(java, classpath) ⇒ CommandServer
constructor
A new instance of CommandServer.
- #io ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(java, classpath) ⇒ CommandServer
Returns a new instance of CommandServer.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/asciidoctor-diagram/util/java_socket.rb', line 12 def initialize(java, classpath) args = [] args << '-Djava.awt.headless=true' args << '-cp' args << classpath.flatten.join(File::PATH_SEPARATOR) args << 'org.asciidoctor.diagram.CommandServer' @server = IO.popen([java, *args]) @port = @server.readline.strip.to_i @client = TCPSocket.new 'localhost', port end |
Instance Attribute Details
#port ⇒ Object (readonly)
Returns the value of attribute port.
10 11 12 |
# File 'lib/asciidoctor-diagram/util/java_socket.rb', line 10 def port @port end |
Instance Method Details
#io ⇒ Object
24 25 26 |
# File 'lib/asciidoctor-diagram/util/java_socket.rb', line 24 def io @client end |
#shutdown ⇒ Object
28 29 30 31 |
# File 'lib/asciidoctor-diagram/util/java_socket.rb', line 28 def shutdown # KILL is a bit heavy handed, but TERM does not seem to shut down the JVM on Windows. Process.kill('KILL', @server.pid) end |