Class: GlassFish::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/server.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, &block) ⇒ Server

Returns a new instance of Server.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/server.rb', line 62

def initialize(args, &block)

  unless args[:log_level].nil?
    if args[:log_level] > Options::LogLevel::FINE.ordinal
      puts "Arguments: "
      args.each do |k, v|
        puts "\t#{k}=>#{v}"
      end
    end

    if args[:log_level] > Options::LogLevel::INFO.ordinal
      debug = true
    end

  end

  java.lang.System.getProperties().put("jruby.runtime", JRuby.runtime) unless args[:daemon]

  @opts = Options.new
  @opts.runtimes = args[:runtimes]
  @opts.runtimes_min = args[:runtimes_min]
  @opts.runtimes_max = args[:runtimes_max]
  @opts.environment = args[:environment]
  @opts.port = args[:port]
  @opts.address = args[:address]
  @opts.contextRoot = args[:contextroot]
  @opts.appDir = args[:app_dir]
  @opts.daemon = args[:daemon]
  @opts.pid = args[:pid]
  @opts.log = args[:log]
  @opts.log_console = args[:log_console]
  @opts.domainDir = args[:domain_dir]
  @opts.log_level = Options::LogLevel.values()[args[:log_level]]
  @opts.jvm_opts = args[:jvm_options]
  
  unless args[:grizzly_config].nil?
    args[:grizzly_config].each do |key, val|
      case key
        when "chunking-enabled"
          @opts.grizzlyConfig.chunkingEnabled = val unless val.nil?
        when "request-timeout"
          @opts.grizzlyConfig.requestTimeout = val unless val.nil?
        when "send-buffer-size"
          @opts.grizzlyConfig.sendBufferSize = val unless val.nil?
        when "max-keepalive-connextions"
          @opts.grizzlyConfig.maxKeepaliveConnections = val unless val.nil?
        when "keepalive-timeout"
          @opts.grizzlyConfig.keepaliveTimeout = val unless val.nil?
        when "thread-pool"
          unless val.nil?
            val.each do |k, v|
              case k
                when "idle-thread-timeout-seconds"
                  @opts.grizzlyConfig.threadPool.idleThreadTimeoutSeconds = v unless v.nil?
                when "max-queue-size"
                  @opts.grizzlyConfig.threadPool.maxQueueSize = v unless v.nil?
                when "max-thread-pool-size"
                  @opts.grizzlyConfig.threadPool.maxThreadPoolSize = v unless v.nil?
                when "min-thread-pool-size"
                  @opts.grizzlyConfig.threadPool.minThreadPoolSize = v unless v.nil?
              end
            end
          end
      end
    end
  end

  #Create the app using Rack builder
  if block_given?
    app = Rack::Builder.new(&block).to_app
    app = Rack::CommonLogger.new(@app) if debug
    if app.nil?
      app = block
    end
    @opts.app = app;

    java.lang.System.getProperties().put("glassfish.rackupApp", app)
  end
end

Instance Attribute Details

#optsObject

Returns the value of attribute opts.



60
61
62
# File 'lib/server.rb', line 60

def opts
  @opts
end

Class Method Details

.start(args, &block) ⇒ Object



142
143
144
145
146
147
# File 'lib/server.rb', line 142

def self.start(args, &block)
  #Validate the command line options
  args = GlassFish::Config.init_opts.merge! args
  Config.new.validate! args
  new(args, &block).start!
end

Instance Method Details

#nameObject Also known as: to_s



161
162
163
# File 'lib/server.rb', line 161

def name
  "GlassFish v3 server"
end

#startObject Also known as: start!



149
150
151
152
153
154
# File 'lib/server.rb', line 149

def start
  ENV.each do |k,v|
    CLibrary::LIBC.setenv(k, v)
  end
  GlassFishMain.start @opts
end

#stopObject



157
158
159
# File 'lib/server.rb', line 157

def stop
  GlassFishMain.start @opts
end