glassfish 0.9.2-universal-java → 0.9.3-universal-java
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/gfrake +67 -0
- data/bin/glassfish +54 -39
- data/bin/glassfish_rails +54 -39
- data/domains/domain1/config/domain.xml +1 -1
- data/domains/domain1/config/glassfish_gem_version.yml +7 -0
- data/domains/domain1/config/logging.properties +2 -2
- data/generators/gfrake/templates/glassfish.yml +97 -0
- data/{modules → lib}/asadmin.rb +0 -0
- data/lib/command_line_parser.rb +226 -0
- data/lib/config.rb +198 -0
- data/{modules/glassfish.rb → lib/gfraker.rb} +4 -21
- data/lib/glassfish.rb +78 -0
- data/{modules → lib}/rdoc_usage.rb +0 -0
- data/lib/templates/domain.xml +1 -1
- data/{modules → lib}/version.rb +2 -3
- data/modules/admin-cli.jar +0 -0
- data/modules/akuma.jar +0 -0
- data/modules/api-exporter.jar +0 -0
- data/modules/asm-all-repackaged.jar +0 -0
- data/modules/auto-depends.jar +0 -0
- data/modules/branding.jar +0 -0
- data/modules/cli-framework.jar +0 -0
- data/modules/common-util.jar +0 -0
- data/modules/config-api.jar +0 -0
- data/modules/config.jar +0 -0
- data/modules/deployment-admin.jar +0 -0
- data/modules/deployment-autodeploy.jar +0 -0
- data/modules/deployment-common.jar +0 -0
- data/modules/flashlight-agent.jar +0 -0
- data/modules/flashlight-framework.jar +0 -0
- data/modules/gf-jruby-connector.jar +0 -0
- data/modules/glassfish-api.jar +0 -0
- data/modules/glassfish-gem.jar +0 -0
- data/modules/glassfish.jar +0 -0
- data/modules/grizzly-framework.jar +0 -0
- data/modules/grizzly-http.jar +0 -0
- data/modules/grizzly-jruby-module.jar +0 -0
- data/modules/grizzly-jruby.jar +0 -0
- data/modules/grizzly-portunif.jar +0 -0
- data/modules/grizzly-rcm.jar +0 -0
- data/modules/grizzly-utils.jar +0 -0
- data/modules/hk2-core.jar +0 -0
- data/modules/hk2.jar +0 -0
- data/modules/internal-api.jar +0 -0
- data/modules/kernel.jar +0 -0
- data/modules/launcher.jar +0 -0
- data/modules/tiger-types-osgi.jar +0 -0
- metadata +115 -110
- data/bin/gfadmin +0 -5
- data/lib/jndi-properties.jar +0 -0
- data/lib/package-appclient.xml +0 -185
- data/lib/processLauncher.properties +0 -25
- data/lib/processLauncher.xml +0 -189
- data/modules/command_line_parser.rb +0 -94
data/bin/gfrake
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
#--
|
2
|
+
#DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
3
|
+
#
|
4
|
+
#Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
|
5
|
+
#
|
6
|
+
#The contents of this file are subject to the terms of either the GNU
|
7
|
+
#General Public License Version 2 only ("GPL") or the Common Development
|
8
|
+
#and Distribution License("CDDL") (collectively, the "License"). You
|
9
|
+
#may not use this file except in compliance with the License. You can obtain
|
10
|
+
#a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
|
11
|
+
#or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
|
12
|
+
#language governing permissions and limitations under the License.
|
13
|
+
#
|
14
|
+
#When distributing the software, include this License Header Notice in each
|
15
|
+
#file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
|
16
|
+
#Sun designates this particular file as subject to the "Classpath" exception
|
17
|
+
#as provided by Sun in the GPL Version 2 section of the License file that
|
18
|
+
#accompanied this code. If applicable, add the following below the License
|
19
|
+
#Header, with the fields enclosed by brackets [] replaced by your own
|
20
|
+
#identifying information: "Portions Copyrighted [year]
|
21
|
+
#[name of copyright owner]"
|
22
|
+
#
|
23
|
+
#Contributor(s):
|
24
|
+
#
|
25
|
+
#If you wish your version of this file to be governed by only the CDDL or
|
26
|
+
#only the GPL Version 2, indicate your decision by adding "[Contributor]
|
27
|
+
#elects to include this software in this distribution under the [CDDL or GPL
|
28
|
+
#Version 2] license." If you don't indicate a single choice of license, a
|
29
|
+
#recipient has the option to distribute your version of this file under
|
30
|
+
#either the CDDL, the GPL Version 2 or to extend the choice of license to
|
31
|
+
#its licensees as provided above. However, if you add GPL Version 2 code
|
32
|
+
#and therefore, elected the GPL Version 2 license, then the option applies
|
33
|
+
#only if the new code is made subject to such option by the copyright
|
34
|
+
#holder.
|
35
|
+
#++
|
36
|
+
|
37
|
+
require 'rubygems'
|
38
|
+
require 'rake'
|
39
|
+
require 'gfraker'
|
40
|
+
|
41
|
+
application = Rake.application
|
42
|
+
application.standard_exception_handling do
|
43
|
+
application.init
|
44
|
+
|
45
|
+
desc "Generate a configuration file to customize GlassFish gem"
|
46
|
+
task :config do
|
47
|
+
if File.exists?(GlassFish::Config::FILE) && ENV["FORCE"].nil?
|
48
|
+
puts "(file #{GlassFish::Config::FILE} already exists. Pass argument FORCE=1 to override)"
|
49
|
+
elsif !File.directory?("config")
|
50
|
+
puts "(directory 'config' is missing)"
|
51
|
+
else
|
52
|
+
cp "#{GlassFish::HOME}/generators/gfrake/templates/glassfish.yml", GlassFish::Config::FILE
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Clean GlassFish generated temporary files (tmp/.glassfish)"
|
57
|
+
task :clean do
|
58
|
+
rm_rf "tmp/.glassfish"
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Display version of warbler"
|
62
|
+
task :version do
|
63
|
+
require 'version'
|
64
|
+
puts "#{GlassFish::FULLVERSION}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
application.top_level
|
data/bin/glassfish
CHANGED
@@ -1,42 +1,57 @@
|
|
1
|
-
|
1
|
+
# == Synopsis
|
2
|
+
#
|
3
|
+
# glassfish: GlassFish v3 server for Rack based frameworks such as: Rails, Merb, Sinatra...
|
4
|
+
#
|
5
|
+
# == Usage:
|
6
|
+
#
|
7
|
+
# glassfish [OPTION] APPLICATION_PATH
|
8
|
+
#
|
9
|
+
# -h, --help::
|
10
|
+
# show help
|
11
|
+
#
|
12
|
+
# -c, --contextroot PATH::
|
13
|
+
# change the context root (default: '/')
|
14
|
+
#
|
15
|
+
# -p, --port PORT::
|
16
|
+
# change server port (default: 3000)
|
17
|
+
#
|
18
|
+
# -e, --environment ENV::
|
19
|
+
# change rails environment (default: development)
|
20
|
+
#
|
21
|
+
# -n --runtimes NUMBER::
|
22
|
+
# Number of JRuby runtimes to create initially
|
23
|
+
#
|
24
|
+
# --runtimes-min NUMBER::
|
25
|
+
# Minimum JRuby runtimes to create
|
26
|
+
#
|
27
|
+
# --runtimes-max NUMBER::
|
28
|
+
# Maximum number of JRuby runtimes to create
|
29
|
+
#
|
30
|
+
# -d, --daemon::
|
31
|
+
# Run GlassFish as daemon. Currently works with Linux and Solaris OS.
|
32
|
+
#
|
33
|
+
# -P, --pid FILE::
|
34
|
+
# PID file where PID will be written. Applicable when used with -d option. The default pid file is tmp/pids/glassfish-<PID>.pid
|
35
|
+
#
|
36
|
+
# -l, --log FILE::
|
37
|
+
# Log file, where the server log messages will go. By default the server logs go to log/glassfish.log file.
|
38
|
+
#
|
39
|
+
# --log-level LEVEL::
|
40
|
+
# Log level 0 to 7. 0:OFF, 1:SEVERE, 2:WARNING, 3:INFO (default), 4:FINE, 5:FINER, 6:FINEST, 7:ALL.
|
41
|
+
#
|
42
|
+
# --config FILE::
|
43
|
+
# Configuration file location. Use glassfish.yml as template. Generate it using 'gfrake config' command.
|
44
|
+
#
|
45
|
+
# APPLICATION_PATH (optional): Path to the application to be run (default: current).
|
46
|
+
# For further configuration, run GlassFish rake command 'gfrake -T'
|
2
47
|
|
3
|
-
|
4
|
-
#
|
5
|
-
|
6
|
-
#
|
7
|
-
# == Usage:
|
8
|
-
#
|
9
|
-
# glassfish [OPTION] APPLICATION_PATH
|
10
|
-
#
|
11
|
-
# -h, --help::
|
12
|
-
# show help
|
13
|
-
#
|
14
|
-
# -c, --contextroot PATH::
|
15
|
-
# change the context root (default: '/')
|
16
|
-
#
|
17
|
-
# -p, --port PORT::
|
18
|
-
# change server port (default: 3000)
|
19
|
-
#
|
20
|
-
# -e, --environment ENV::
|
21
|
-
# change rails environment (default: development)
|
22
|
-
#
|
23
|
-
# -n --runtimes NUMBER::
|
24
|
-
# Number of JRuby runtimes to crete initially
|
25
|
-
#
|
26
|
-
# --runtimes-min NUMBER::
|
27
|
-
# Minimum JRuby runtimes to crete
|
28
|
-
#
|
29
|
-
# --runtimes-max NUMBER::
|
30
|
-
# Maximum number of JRuby runtimes to crete
|
31
|
-
#
|
32
|
-
# APPLICATION_PATH (optional): Path to the application to be run (default: current).
|
48
|
+
require "java"
|
49
|
+
$LOAD_PATH << "#{File.dirname(__FILE__)}/../modules"
|
50
|
+
$LOAD_PATH << "#{File.dirname(__FILE__)}/../lib"
|
33
51
|
|
34
|
-
require
|
35
|
-
|
52
|
+
require 'command_line_parser'
|
53
|
+
require 'glassfish'
|
36
54
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
options = CommandLineParser.new.parse
|
41
|
-
gf = GlassFish::Server.new
|
42
|
-
gf.startup(options)
|
55
|
+
options = GlassFish::CommandLineParser.new.parse
|
56
|
+
gf = GlassFish::Server.new
|
57
|
+
gf.startup(options)
|
data/bin/glassfish_rails
CHANGED
@@ -1,42 +1,57 @@
|
|
1
|
-
|
1
|
+
# == Synopsis
|
2
|
+
#
|
3
|
+
# glassfish: GlassFish v3 server for Rack based frameworks such as: Rails, Merb, Sinatra...
|
4
|
+
#
|
5
|
+
# == Usage:
|
6
|
+
#
|
7
|
+
# glassfish [OPTION] APPLICATION_PATH
|
8
|
+
#
|
9
|
+
# -h, --help::
|
10
|
+
# show help
|
11
|
+
#
|
12
|
+
# -c, --contextroot PATH::
|
13
|
+
# change the context root (default: '/')
|
14
|
+
#
|
15
|
+
# -p, --port PORT::
|
16
|
+
# change server port (default: 3000)
|
17
|
+
#
|
18
|
+
# -e, --environment ENV::
|
19
|
+
# change rails environment (default: development)
|
20
|
+
#
|
21
|
+
# -n --runtimes NUMBER::
|
22
|
+
# Number of JRuby runtimes to create initially
|
23
|
+
#
|
24
|
+
# --runtimes-min NUMBER::
|
25
|
+
# Minimum JRuby runtimes to create
|
26
|
+
#
|
27
|
+
# --runtimes-max NUMBER::
|
28
|
+
# Maximum number of JRuby runtimes to create
|
29
|
+
#
|
30
|
+
# -d, --daemon::
|
31
|
+
# Run GlassFish as daemon. Currently works with Linux and Solaris OS.
|
32
|
+
#
|
33
|
+
# -P, --pid FILE::
|
34
|
+
# PID file where PID will be written. Applicable when used with -d option. The default pid file is tmp/pids/glassfish-<PID>.pid
|
35
|
+
#
|
36
|
+
# -l, --log FILE::
|
37
|
+
# Log file, where the server log messages will go. By default the server logs go to log/glassfish.log file.
|
38
|
+
#
|
39
|
+
# --log-level LEVEL::
|
40
|
+
# Log level 0 to 7. 0:OFF, 1:SEVERE, 2:WARNING, 3:INFO (default), 4:FINE, 5:FINER, 6:FINEST, 7:ALL.
|
41
|
+
#
|
42
|
+
# --config FILE::
|
43
|
+
# Configuration file location. Use glassfish.yml as template. Generate it using 'gfrake config' command.
|
44
|
+
#
|
45
|
+
# APPLICATION_PATH (optional): Path to the application to be run (default: current).
|
46
|
+
# For further configuration, run GlassFish rake command 'gfrake -T'
|
2
47
|
|
3
|
-
|
4
|
-
#
|
5
|
-
|
6
|
-
#
|
7
|
-
# == Usage:
|
8
|
-
#
|
9
|
-
# glassfish [OPTION] APPLICATION_PATH
|
10
|
-
#
|
11
|
-
# -h, --help::
|
12
|
-
# show help
|
13
|
-
#
|
14
|
-
# -c, --contextroot PATH::
|
15
|
-
# change the context root (default: '/')
|
16
|
-
#
|
17
|
-
# -p, --port PORT::
|
18
|
-
# change server port (default: 3000)
|
19
|
-
#
|
20
|
-
# -e, --environment ENV::
|
21
|
-
# change rails environment (default: development)
|
22
|
-
#
|
23
|
-
# -n --runtimes NUMBER::
|
24
|
-
# Number of JRuby runtimes to crete initially
|
25
|
-
#
|
26
|
-
# --runtimes-min NUMBER::
|
27
|
-
# Minimum JRuby runtimes to crete
|
28
|
-
#
|
29
|
-
# --runtimes-max NUMBER::
|
30
|
-
# Maximum number of JRuby runtimes to crete
|
31
|
-
#
|
32
|
-
# APPLICATION_PATH (optional): Path to the application to be run (default: current).
|
48
|
+
require "java"
|
49
|
+
$LOAD_PATH << "#{File.dirname(__FILE__)}/../modules"
|
50
|
+
$LOAD_PATH << "#{File.dirname(__FILE__)}/../lib"
|
33
51
|
|
34
|
-
require
|
35
|
-
|
52
|
+
require 'command_line_parser'
|
53
|
+
require 'glassfish'
|
36
54
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
options = CommandLineParser.new.parse
|
41
|
-
gf = GlassFish::Server.new
|
42
|
-
gf.startup(options)
|
55
|
+
options = GlassFish::CommandLineParser.new.parse
|
56
|
+
gf = GlassFish::Server.new
|
57
|
+
gf.startup(options)
|
@@ -76,7 +76,7 @@
|
|
76
76
|
<jms-host host="laturbie.sfbay.sun.com" name="default_JMS_host"/>
|
77
77
|
</jms-service>
|
78
78
|
|
79
|
-
<log-service file="${
|
79
|
+
<log-service file="${jruby.log.location}" log-rotation-limit-in-bytes="2000000">
|
80
80
|
<module-log-levels/>
|
81
81
|
</log-service>
|
82
82
|
|
@@ -27,7 +27,7 @@
|
|
27
27
|
# // implementation of Handler interface
|
28
28
|
# }
|
29
29
|
|
30
|
-
handlers=
|
30
|
+
handlers=
|
31
31
|
|
32
32
|
# To also add the FileHandler, use the following line instead.
|
33
33
|
#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
|
@@ -51,7 +51,7 @@ handlers= java.util.logging.ConsoleHandler
|
|
51
51
|
# GlassFish will register this handler automtically as it is
|
52
52
|
# and HK2 component like described above.
|
53
53
|
# rotates the file based on time or size.
|
54
|
-
com.sun.enterprise.server.logging.FileandSyslogHandler.file
|
54
|
+
com.sun.enterprise.server.logging.FileandSyslogHandler.file=${jruby.log.location}
|
55
55
|
# rotation time in minutes (takes precedence on size if defined),
|
56
56
|
# 0 for no rotation based on time
|
57
57
|
com.sun.enterprise.server.logging.FileandSyslogHandler.rotationTimelimitInMinutes=0
|
@@ -0,0 +1,97 @@
|
|
1
|
+
#
|
2
|
+
# GlassFish configuration.
|
3
|
+
#
|
4
|
+
# Please read the comments for each configuration settings before modifying.
|
5
|
+
#
|
6
|
+
|
7
|
+
# application environment. Default value development
|
8
|
+
environment: development
|
9
|
+
|
10
|
+
|
11
|
+
# HTTP configuration
|
12
|
+
http:
|
13
|
+
|
14
|
+
# port
|
15
|
+
port: 3000
|
16
|
+
|
17
|
+
# context root. The default value is '/'
|
18
|
+
contextroot: /
|
19
|
+
|
20
|
+
|
21
|
+
#Logging configuration
|
22
|
+
log:
|
23
|
+
|
24
|
+
# Log file location. Default log file is log/<environment>.log. For
|
25
|
+
# example, if you are running in development environment, then the log
|
26
|
+
# file would be log/development.log.
|
27
|
+
#
|
28
|
+
# The log-file value must be either an absolute path or relative to your
|
29
|
+
# application directory.
|
30
|
+
|
31
|
+
#log-file:
|
32
|
+
|
33
|
+
# Logging level. Log level 0 to 7. 0:OFF, 1:SEVERE, 2:WARNING,
|
34
|
+
# 3:INFO (default), 4:FINE, 5:FINER, 6:FINEST, 7:ALL.
|
35
|
+
log-level: 3
|
36
|
+
|
37
|
+
#
|
38
|
+
# Runtime configuration
|
39
|
+
# If you are using Rails ver < 2.1.x, you should configure the JRuby runtime
|
40
|
+
# pool for increased scalability.
|
41
|
+
jruby-runtime-pool:
|
42
|
+
|
43
|
+
# Initial number of jruby runtimes that Glassfish starts with. It defaults
|
44
|
+
# to one. It also represents the lowest value that Glassfish will use for
|
45
|
+
# the maximum and the highest value that Glassfish will accept for the
|
46
|
+
# minimum. As of this time, setting this number too high may cause
|
47
|
+
# undesirable behavior. Default value is .
|
48
|
+
initial: 1
|
49
|
+
|
50
|
+
# Minimum number of jruby runtimes that will be available in the pool.
|
51
|
+
# It defaults to one. The pool will always be at least this large, but
|
52
|
+
# may well be larger than this. Default value is 1.
|
53
|
+
min: 1
|
54
|
+
|
55
|
+
|
56
|
+
# Maximum number of jruby runtimes that may be available in the pool.
|
57
|
+
# It defaults to two. The pool will not neccessarily be this large.
|
58
|
+
# Values that are too high may result in OutOfMemory errors, either in
|
59
|
+
# the heap or in the PermGen. Default value is 1.
|
60
|
+
max: 1
|
61
|
+
|
62
|
+
daemon:
|
63
|
+
# Run GlassFish as a daemon. GlassFish may not run as a daemon process
|
64
|
+
# on all platforms. Default value is false.
|
65
|
+
enable: false
|
66
|
+
|
67
|
+
# File where the process id of GlassFish is saved when run as daemon.
|
68
|
+
# The location must be either an absolute path or relative to your
|
69
|
+
# application directory.
|
70
|
+
# default PID file is tmp/pids/glassfish-<PID>.pid
|
71
|
+
|
72
|
+
#pid:
|
73
|
+
|
74
|
+
# Like JRuby GlassFish gem runs on Java Virtual Machine. You can pass
|
75
|
+
# JVM properties using 'jvm-options' property. The JVM options must be
|
76
|
+
# SPACE seprated.
|
77
|
+
# 'jvm-options. property can ONLY be used only in daemon
|
78
|
+
# mode. The numbers below are to give an ideas. The numbers in your case
|
79
|
+
# would vary based on the hardware capabilities of machine you are
|
80
|
+
# running. See what is a server class machine
|
81
|
+
# http://java.sun.com/javase/6/docs/technotes/guides/vm/server-class.html
|
82
|
+
|
83
|
+
# GlassFish gem runs with these default options
|
84
|
+
#
|
85
|
+
#jvm-options: -server -Xmx512m -XX:MaxPermSize=192m -XX:NewRatio=2 -XX:+DisableExplicitGC -Dhk2.file.directory.changeIntervalTimer=6000
|
86
|
+
|
87
|
+
# Values below are given for a Sun Fire x4100, 4x Dual Core Opteron, 8G
|
88
|
+
# mem machine. You may like to changes these values according to the
|
89
|
+
# hardware you plan to run your application on. For details see
|
90
|
+
# JVM ergonomics document,
|
91
|
+
# http://java.sun.com/javase/6/docs/technotes/guides/vm/gc-ergonomics.html
|
92
|
+
#
|
93
|
+
#jvm-options: -server -Xmx2500m -Xms64m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:NewRatio=2 -XX:+DisableExplicitGC -Dhk2.file.directory.changeIntervalTimer=6000
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
data/{modules → lib}/asadmin.rb
RENAMED
File without changes
|
@@ -0,0 +1,226 @@
|
|
1
|
+
#--
|
2
|
+
#DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
3
|
+
#
|
4
|
+
#Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
|
5
|
+
#
|
6
|
+
#The contents of this file are subject to the terms of either the GNU
|
7
|
+
#General Public License Version 2 only ("GPL") or the Common Development
|
8
|
+
#and Distribution License("CDDL") (collectively, the "License"). You
|
9
|
+
#may not use this file except in compliance with the License. You can obtain
|
10
|
+
#a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
|
11
|
+
#or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
|
12
|
+
#language governing permissions and limitations under the License.
|
13
|
+
#
|
14
|
+
#When distributing the software, include this License Header Notice in each
|
15
|
+
#file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
|
16
|
+
#Sun designates this particular file as subject to the "Classpath" exception
|
17
|
+
#as provided by Sun in the GPL Version 2 section of the License file that
|
18
|
+
#accompanied this code. If applicable, add the following below the License
|
19
|
+
#Header, with the fields enclosed by brackets [] replaced by your own
|
20
|
+
#identifying information: "Portions Copyrighted [year]
|
21
|
+
#[name of copyright owner]"
|
22
|
+
#
|
23
|
+
#Contributor(s):
|
24
|
+
#
|
25
|
+
#If you wish your version of this file to be governed by only the CDDL or
|
26
|
+
#only the GPL Version 2, indicate your decision by adding "[Contributor]
|
27
|
+
#elects to include this software in this distribution under the [CDDL or GPL
|
28
|
+
#Version 2] license." If you don't indicate a single choice of license, a
|
29
|
+
#recipient has the option to distribute your version of this file under
|
30
|
+
#either the CDDL, the GPL Version 2 or to extend the choice of license to
|
31
|
+
#its licensees as provided above. However, if you add GPL Version 2 code
|
32
|
+
#and therefore, elected the GPL Version 2 license, then the option applies
|
33
|
+
#only if the new code is made subject to such option by the copyright
|
34
|
+
#holder.
|
35
|
+
#++
|
36
|
+
|
37
|
+
require 'rdoc_usage'
|
38
|
+
require 'getoptlong'
|
39
|
+
require 'pathname'
|
40
|
+
require 'config'
|
41
|
+
require 'java'
|
42
|
+
|
43
|
+
#
|
44
|
+
# Parses command line options
|
45
|
+
#
|
46
|
+
module GlassFish
|
47
|
+
class CommandLineParser
|
48
|
+
|
49
|
+
def init_opts
|
50
|
+
@@config ||= {
|
51
|
+
:runtimes => 1,
|
52
|
+
:runtimes_min => 1,
|
53
|
+
:runtimes_max => 1,
|
54
|
+
:contextroot => '/',
|
55
|
+
:environment => "development",
|
56
|
+
:app_dir => Dir.pwd,
|
57
|
+
:port => 3000,
|
58
|
+
:pid => Config::PID_FILE,
|
59
|
+
:log => nil,
|
60
|
+
:log_level => 1,
|
61
|
+
:daemon => false,
|
62
|
+
:jvm_options => nil
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
def parse
|
67
|
+
|
68
|
+
check_java
|
69
|
+
|
70
|
+
config = init_opts
|
71
|
+
|
72
|
+
opts = GetoptLong.new(
|
73
|
+
[ '--port', '-p', GetoptLong::REQUIRED_ARGUMENT ],
|
74
|
+
[ '--environment', '-e', GetoptLong::REQUIRED_ARGUMENT ],
|
75
|
+
[ '--contextroot', '-c', GetoptLong::REQUIRED_ARGUMENT ],
|
76
|
+
[ '--config', GetoptLong::REQUIRED_ARGUMENT ],
|
77
|
+
[ '--daemon', '-d', GetoptLong::NO_ARGUMENT ],
|
78
|
+
[ '--pid', '-P', GetoptLong::REQUIRED_ARGUMENT ],
|
79
|
+
[ '--log', '-l', GetoptLong::REQUIRED_ARGUMENT ],
|
80
|
+
[ '--log-level', GetoptLong::REQUIRED_ARGUMENT ],
|
81
|
+
[ '--runtimes', '-n', GetoptLong::REQUIRED_ARGUMENT ],
|
82
|
+
[ '--runtimes-min', GetoptLong::REQUIRED_ARGUMENT ],
|
83
|
+
[ '--runtimes-max', GetoptLong::REQUIRED_ARGUMENT ],
|
84
|
+
[ '--version', '-v', GetoptLong::NO_ARGUMENT ],
|
85
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ]
|
86
|
+
)
|
87
|
+
|
88
|
+
config_file = File.join(config[:app_dir], "config", "glassfish.yml")
|
89
|
+
opts.each do |opt, arg|
|
90
|
+
case opt
|
91
|
+
when '--version'
|
92
|
+
require 'version'
|
93
|
+
puts "#{GlassFish::FULLVERSION}"
|
94
|
+
exit(0)
|
95
|
+
when '--help'
|
96
|
+
RDoc::usage
|
97
|
+
when '--contextroot'
|
98
|
+
config[:contextroot] = arg
|
99
|
+
when '--port'
|
100
|
+
config[:port] = arg.to_i
|
101
|
+
when '--environment'
|
102
|
+
config[:environment] = arg
|
103
|
+
when '--runtimes'
|
104
|
+
config[:runtimes] = arg.to_i
|
105
|
+
when '--runtimes-min'
|
106
|
+
config[:runtimes_min] = arg.to_i
|
107
|
+
when '--runtimes-max'
|
108
|
+
config[:runtimes_max] = arg.to_i
|
109
|
+
when '--daemon'
|
110
|
+
config[:daemon] = true
|
111
|
+
when '--pid'
|
112
|
+
if(!ARGV.include?'-d' and !ARGV.include?'--daemon')
|
113
|
+
GlassFish::Config::fail("--pid option can only be used with --daemon.")
|
114
|
+
end
|
115
|
+
config[:pid] = arg
|
116
|
+
when '--log'
|
117
|
+
config[:log] = arg
|
118
|
+
when '--log-level'
|
119
|
+
config[:log_level] = arg.to_i
|
120
|
+
when '--config'
|
121
|
+
config_file = arg
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
config[:app_dir] = ARGV.shift unless ARGV.empty?
|
127
|
+
|
128
|
+
config[:log] = absolutize config[:app_dir], config[:log]
|
129
|
+
config[:pid] = absolutize config[:app_dir], config[:pid]
|
130
|
+
#Validate the command line options
|
131
|
+
Config.new.validate config
|
132
|
+
|
133
|
+
#Read the config file from config/glasfish.yml
|
134
|
+
config_file = absolutize config[:app_dir],config_file
|
135
|
+
read_glassfish_config(config_file, config)
|
136
|
+
|
137
|
+
config
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
private
|
142
|
+
|
143
|
+
# Read glassfish config file from config/glassfish.yml. CLI options will
|
144
|
+
# override the glassfish.yml configurations
|
145
|
+
def read_glassfish_config(cfile, config)
|
146
|
+
|
147
|
+
#If there is no config file we return
|
148
|
+
if(!File::exists?(cfile))
|
149
|
+
return config
|
150
|
+
end
|
151
|
+
|
152
|
+
puts "Parsing config file: #{cfile}"
|
153
|
+
data = YAML::load(File::open(cfile))
|
154
|
+
|
155
|
+
data.each do |opt, arg|
|
156
|
+
case opt
|
157
|
+
when 'http'
|
158
|
+
val = arg['port']
|
159
|
+
if(!val.nil?)
|
160
|
+
config[:port] = val.to_i
|
161
|
+
end
|
162
|
+
|
163
|
+
val = arg['contextroot']
|
164
|
+
config[:contextroot] = val unless val.nil?
|
165
|
+
when 'log'
|
166
|
+
val = arg['log-file']
|
167
|
+
if(!val.nil?)
|
168
|
+
config[:log] = absolutize config[:app_dir], val
|
169
|
+
end
|
170
|
+
|
171
|
+
val = arg['log-level']
|
172
|
+
config[:log_level] = val.to_i unless val.nil?
|
173
|
+
when 'jruby-runtime-pool'
|
174
|
+
config[:runtimes] = arg['initial'] unless arg['initial'].nil?
|
175
|
+
config[:runtimes_min] = arg['min'] unless arg['min'].nil?
|
176
|
+
config[:runtimes_max] = arg['max'] unless arg['max'].nil?
|
177
|
+
when 'daemon'
|
178
|
+
config[:daemon] = arg['enable'] unless arg['enable'].nil?
|
179
|
+
if(!arg['pid'].nil?)
|
180
|
+
if(!config[:daemon])
|
181
|
+
Config::fail("glassfish.yml has\n daemon:\n\tpid: #{arg['pid']}\nThe pid option can only be used when daemon is set enable: true.")
|
182
|
+
end
|
183
|
+
config[:pid] = absolutize config[:app_dir], arg['pid']
|
184
|
+
end
|
185
|
+
|
186
|
+
#CLI option are overriden by glassfish.yml settings
|
187
|
+
if(!data['daemon'].nil? and (data['daemon'] or config[:daemon]))
|
188
|
+
config[:jvm_options] = arg['jvm-options'] unless arg['jvm-options'].nil?
|
189
|
+
else
|
190
|
+
STDERR.puts "Ignoring JVM options #{arg}. JVM options can only be passed in daemon mode. To use these, enable daemon mode"
|
191
|
+
end
|
192
|
+
when 'environment'
|
193
|
+
config[:environment] = arg unless arg.nil?
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
#validate the options read from the config file
|
198
|
+
puts "Validating configuration read from glassfish.yml"
|
199
|
+
Config.new.validate config
|
200
|
+
end
|
201
|
+
|
202
|
+
def absolutize(base, path)
|
203
|
+
if path.nil?
|
204
|
+
return nil
|
205
|
+
end
|
206
|
+
p = Pathname.new path
|
207
|
+
if(!p.absolute?)
|
208
|
+
path = File.join(base, path)
|
209
|
+
end
|
210
|
+
path
|
211
|
+
end
|
212
|
+
|
213
|
+
def check_java
|
214
|
+
begin
|
215
|
+
java.lang.Class.forName("javax.xml.ws.Service")
|
216
|
+
rescue
|
217
|
+
#It is not Java6, fail
|
218
|
+
STDERR.puts "ERROR: You are running, Java version: "+java.lang.System.getProperty("java.version")+"."
|
219
|
+
STDERR.puts "ERROR: GlassFish gem needs Java ver. 6.0 or higher!"
|
220
|
+
puts "Please install JDK 6 from: http://java.sun.com/javase/downloads/index.jsp"
|
221
|
+
exit(1);
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
end
|