This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 190432
Collapse All | Expand All

(-)a/ruby.railsprojects/src/org/netbeans/modules/ruby/railsprojects/server/Bundle.properties (+2 lines)
Lines 49-54 Link Here
49
LBL_Passenger=Passenger {0}
49
LBL_Passenger=Passenger {0}
50
# 0 - version
50
# 0 - version
51
LBL_GlassFish=GlassFish Gem {0}
51
LBL_GlassFish=GlassFish Gem {0}
52
# 0 - version
53
LBL_Trinidad=Trinidad {0}
52
# 0 - server label, 1 - platform label
54
# 0 - server label, 1 - platform label
53
LBL_ServerNodeName={0} ({1})
55
LBL_ServerNodeName={0} ({1})
54
# 0..project 1..port
56
# 0..project 1..port
(-)a/ruby.railsprojects/src/org/netbeans/modules/ruby/railsprojects/server/GlassFishGem.java (-209 / +14 lines)
Lines 64-71 Link Here
64
 * 
64
 * 
65
 * @author Peter Williams
65
 * @author Peter Williams
66
 * @author Erno Mononen
66
 * @author Erno Mononen
67
 * @author David Calavera
67
 */
68
 */
68
class GlassFishGem implements RubyServer, ServerInstanceImplementation {
69
class GlassFishGem extends JRubyServerBase {
69
70
70
    static final String GEM_NAME = "glassfish";
71
    static final String GEM_NAME = "glassfish";
71
    /**
72
    /**
Lines 76-302 Link Here
76
        Pattern.compile(".*Press Ctrl\\+C to stop\\..*", Pattern.DOTALL),
77
        Pattern.compile(".*Press Ctrl\\+C to stop\\..*", Pattern.DOTALL),
77
        Pattern.compile(".*[0-9] milliseconds.*", Pattern.DOTALL)
78
        Pattern.compile(".*[0-9] milliseconds.*", Pattern.DOTALL)
78
    };
79
    };
79
    
80
80
    private final List<RailsApplication> applications = new ArrayList<RailsApplication>();
81
    private static final String LABEL = "LBL_GlassFish";
81
    private final RubyPlatform platform;
82
    private final String version;
83
    private final String location;
84
    private final ChangeSupport changeSupport = new ChangeSupport(this);
85
    
86
    private Node node;
87
82
88
    GlassFishGem(RubyPlatform platform, GemInfo gemInfo) {
83
    GlassFishGem(RubyPlatform platform, GemInfo gemInfo) {
89
        Parameters.notNull("platform", platform); //NOI18N
84
        super(platform, gemInfo);
90
        this.platform = platform;
91
        this.version = gemInfo.getVersion();
92
        this.location = getGemFolder(gemInfo.getSpecFile());
93
    }
85
    }
94
86
95
    private String getGemFolder(File specFile) {
87
    @Override
96
        String gemFolderName = specFile.getName();
97
        if(gemFolderName.endsWith(".gemspec")) {
98
            gemFolderName = gemFolderName.substring(0, gemFolderName.length() - 8);
99
        }
100
        
101
        return new File(specFile.getParentFile().getParentFile(),
102
                "gems" + File.separatorChar + gemFolderName).getAbsolutePath();
103
    }
104
105
    private Node getNode() {
106
        if (this.node == null) {
107
            this.node = new RubyServerNode(this);
108
        }
109
        return node;
110
    }
111
    
112
    // RubyServer  methods
113
    public String getNodeName() {
114
        return NbBundle.getMessage(GlassFishGem.class, "LBL_ServerNodeName", getDisplayName(), platform.getLabel());
115
    }
116
    
117
    public String getLocation() {
118
        return location;
119
    }
120
121
    public List<String> getStartupParams(RailsVersion version) {
122
        return Collections.emptyList();
123
    }
124
125
    public String getScriptPrefix() {
126
        return "-S";
127
    }
128
129
    public String getServerPath(RailsVersion version) {
88
    public String getServerPath(RailsVersion version) {
130
        // glassfish_rails is deprecated in 0.9.4 and newer
89
        // glassfish_rails is deprecated in 0.9.4 and newer
131
        return compareVersion("0.9.4") >= 0 ? "glassfish" : "glassfish_rails";
90
        return compareVersion("0.9.4") >= 0 ? "glassfish" : "glassfish_rails";
132
    }
91
    }
133
92
134
    public boolean isStartupMsg(String outputLine) {
135
        for (Pattern each : PATTERNS) {
136
            if (each.matcher(outputLine).matches()) {
137
                return true;
138
            }
139
        }
140
        return false;
141
    }
142
143
    public List<RailsApplication> getApplications() {
144
        return Collections.unmodifiableList(applications);
145
    }
146
147
    public boolean addApplication(RailsApplication application) {
148
        boolean result = applications.add(application);
149
        changeSupport.fireChange();
150
        return result;
151
    }
152
153
    public boolean removeApplication(int port) {
154
        boolean result = false;
155
        for (RailsApplication app : applications) {
156
            if (app.getPort() == port) {
157
                result = applications.remove(app);
158
                changeSupport.fireChange();
159
                break;
160
            }
161
        }
162
163
        return result;
164
    }
165
166
    public void addChangeListener(ChangeListener listener) {
167
        changeSupport.addChangeListener(listener);
168
    }
169
170
    public void removeChangeListener(ChangeListener listener) {
171
        changeSupport.removeChangeListener(listener);
172
    }
173
174
    public int compareVersion(String targetVersion) {
175
        int [] sv = extractVersion(version);
176
        int [] tv = extractVersion(targetVersion);
177
        for(int i = 0; i < 3; i++) {
178
            if(sv[i] < tv[i]) {
179
                return -1;
180
            } else if(sv[i] > tv[i]) {
181
                return 1;
182
            }
183
        }
184
        return 0;
185
    }
186
187
    private int [] extractVersion(String vs) {
188
        int [] v = new int [] { 0, 0, 0 };
189
        String [] parts = vs.split("\\.");
190
        for(int i = 0; i < 3 && i < parts.length; i++) {
191
            v[i] = Integer.valueOf(parts[i]);
192
        }
193
        return v;
194
    }
195
196
    // ServerInstanceImplementation methods
197
    public String getServerDisplayName() {
198
        return getNodeName();
199
    }
200
201
    public Node getFullNode() {
202
        return getNode();
203
    }
204
205
    public Node getBasicNode() {
206
        return getNode();
207
    }
208
209
    public JComponent getCustomizer() {
210
        return null;
211
    }
212
213
    public void remove() {
214
        throw new UnsupportedOperationException("Not supported yet.");
215
    }
216
217
    public boolean isRemovable() {
218
        return false;
219
    }
220
221
    // RubyInstance methods 
222
    public String getServerUri() {
223
        return "GLASSFISH";
224
    }
225
226
    public String getDisplayName() {
227
        return NbBundle.getMessage(GlassFishGem.class, "LBL_GlassFish", version);
228
    }
229
230
    public ServerState getServerState() {
231
        // TODO: currently handled in Rails project
232
        return null;
233
    }
234
235
    public Future<OperationState> startServer(RubyPlatform platform) {
236
        throw new UnsupportedOperationException("Not supported yet.");
237
    }
238
239
    public Future<OperationState> stopServer() {
240
        throw new UnsupportedOperationException("Not supported yet.");
241
    }
242
243
    public Future<OperationState> deploy(String applicationName, File applicationDir) {
244
        throw new UnsupportedOperationException("Not supported yet.");
245
    }
246
247
    public Future<OperationState> stop(String applicationName) {
248
        throw new UnsupportedOperationException("Not supported yet.");
249
    }
250
251
    public Future<OperationState> runApplication(RubyPlatform platform, String applicationName, File applicationDir) {
252
        throw new UnsupportedOperationException("Not supported yet.");
253
    }
254
    
255
    public boolean isPlatformSupported(RubyPlatform platform) {
256
        return this.platform.equals(platform);
257
    }
258
259
    public String getContextRoot(String applicationName) {
260
        return ""; // NOI18N
261
    }
262
263
    public int getRailsPort() {
264
        return 3000;
265
    }
266
    
267
    public String getServerCommand(RubyPlatform platform, String classpath, 
268
            File applicationDir, int httpPort, boolean debug) {
269
        throw new UnsupportedOperationException("Not supported yet.");
270
    }
271
    
272
    
273
    @Override
93
    @Override
274
    public boolean equals(Object obj) {
94
    protected String getLabel() {
275
        if (obj == null) {
95
        return LABEL;
276
            return false;
277
        }
278
        if (getClass() != obj.getClass()) {
279
            return false;
280
        }
281
        final GlassFishGem other = (GlassFishGem) obj;
282
        if (this.platform != other.platform && (this.platform == null || !this.platform.equals(other.platform))) {
283
            return false;
284
        }
285
        if (this.version != other.version && (this.version == null || !this.version.equals(other.version))) {
286
            return false;
287
        }
288
        if (this.location != other.location && (this.location == null || !this.location.equals(other.location))) {
289
            return false;
290
        }
291
        return true;
292
    }
96
    }
293
97
294
    @Override
98
    @Override
295
    public int hashCode() {
99
    protected Pattern[] getPatterns() {
296
        int hash = 3;
100
        return PATTERNS;
297
        hash = 47 * hash + (this.platform != null ? this.platform.hashCode() : 0);
298
        hash = 47 * hash + (this.version != null ? this.version.hashCode() : 0);
299
        return hash;
300
    }
101
    }
301
102
103
    @Override
104
    protected String getGemName() {
105
        return GEM_NAME;
106
    }
302
}
107
}
(-)70a422f5c2a9 (+313 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.ruby.railsprojects.server;
44
45
import java.io.File;
46
import java.util.ArrayList;
47
import java.util.Collections;
48
import java.util.List;
49
import java.util.concurrent.Future;
50
import java.util.regex.Pattern;
51
import javax.swing.JComponent;
52
import javax.swing.event.ChangeListener;
53
import org.netbeans.api.ruby.platform.RubyPlatform;
54
import org.netbeans.modules.ruby.platform.gems.GemInfo;
55
import org.netbeans.modules.ruby.railsprojects.RailsProjectUtil.RailsVersion;
56
import org.netbeans.modules.ruby.railsprojects.server.nodes.RubyServerNode;
57
import org.netbeans.spi.server.ServerInstanceImplementation;
58
import org.openide.nodes.Node;
59
import org.openide.util.ChangeSupport;
60
import org.openide.util.NbBundle;
61
import org.openide.util.Parameters;
62
63
/**
64
 *
65
 * @author David Calavera
66
 */
67
public abstract class JRubyServerBase implements RubyServer, ServerInstanceImplementation {
68
69
    private final List<RailsApplication> applications = new ArrayList<RailsApplication>();
70
    private final RubyPlatform platform;
71
    private final String version;
72
    private final String location;
73
    private final ChangeSupport changeSupport = new ChangeSupport(this);
74
    private Node node;
75
76
    /* abstract methods */
77
    protected abstract String getLabel();
78
    protected abstract Pattern[] getPatterns();
79
    protected abstract String getGemName();
80
81
    JRubyServerBase(RubyPlatform platform, GemInfo gemInfo) {
82
        Parameters.notNull("platform", platform); //NOI18N
83
        this.platform = platform;
84
        this.version = gemInfo.getVersion();
85
        this.location = getGemFolder(gemInfo.getSpecFile());
86
    }
87
88
    private String getGemFolder(File specFile) {
89
        String gemFolderName = specFile.getName();
90
        if(gemFolderName.endsWith(".gemspec")) {
91
            gemFolderName = gemFolderName.substring(0, gemFolderName.length() - 8);
92
        }
93
94
        return new File(specFile.getParentFile().getParentFile(),
95
                "gems" + File.separatorChar + gemFolderName).getAbsolutePath();
96
    }
97
98
    private Node getNode() {
99
        if (this.node == null) {
100
            this.node = new RubyServerNode(this);
101
        }
102
        return node;
103
    }
104
105
    @Override
106
    public String getNodeName() {
107
        return NbBundle.getMessage(getClass(), "LBL_ServerNodeName", getDisplayName(), platform.getLabel());
108
    }
109
110
    @Override
111
    public String getLocation() {
112
        return location;
113
    }
114
115
    @Override
116
    public List<String> getStartupParams(RailsVersion version) {
117
        return Collections.emptyList();
118
    }
119
120
    @Override
121
    public String getScriptPrefix() {
122
        return "-S";
123
    }
124
125
    @Override
126
    public String getServerPath(RailsVersion version) {
127
        return getGemName().toLowerCase();
128
    }
129
130
    public boolean isStartupMsg(String outputLine) {
131
        for (Pattern each : getPatterns()) {
132
            if (each.matcher(outputLine).matches()) {
133
                return true;
134
            }
135
        }
136
        return false;
137
    }
138
139
    @Override
140
    public List<RailsApplication> getApplications() {
141
        return Collections.unmodifiableList(applications);
142
    }
143
144
    @Override
145
    public boolean addApplication(RailsApplication application) {
146
        boolean result = applications.add(application);
147
        changeSupport.fireChange();
148
        return result;
149
    }
150
151
    @Override
152
    public boolean removeApplication(int port) {
153
        boolean result = false;
154
        for (RailsApplication app : applications) {
155
            if (app.getPort() == port) {
156
                result = applications.remove(app);
157
                changeSupport.fireChange();
158
                break;
159
            }
160
        }
161
162
        return result;
163
    }
164
165
    public void addChangeListener(ChangeListener listener) {
166
        changeSupport.addChangeListener(listener);
167
    }
168
169
    public void removeChangeListener(ChangeListener listener) {
170
        changeSupport.removeChangeListener(listener);
171
    }
172
173
    public int compareVersion(String targetVersion) {
174
        int [] sv = extractVersion(version);
175
        int [] tv = extractVersion(targetVersion);
176
        for(int i = 0; i < 3; i++) {
177
            if(sv[i] < tv[i]) {
178
                return -1;
179
            } else if(sv[i] > tv[i]) {
180
                return 1;
181
            }
182
        }
183
        return 0;
184
    }
185
186
    private int [] extractVersion(String vs) {
187
        int [] v = new int [] { 0, 0, 0 };
188
        String [] parts = vs.split("\\.");
189
        for(int i = 0; i < 3 && i < parts.length; i++) {
190
            v[i] = Integer.valueOf(parts[i]);
191
        }
192
        return v;
193
    }
194
195
    @Override
196
    public String getServerUri() {
197
        return getGemName().toUpperCase();
198
    }
199
200
    @Override
201
    public String getDisplayName() {
202
        return NbBundle.getMessage(getClass(), getLabel(), version);
203
    }
204
205
    @Override
206
    public ServerState getServerState() {
207
        return null;
208
    }
209
210
    @Override
211
    public Future<OperationState> startServer(RubyPlatform platform) {
212
        throw new UnsupportedOperationException("Not supported yet.");
213
    }
214
215
    @Override
216
    public Future<OperationState> stopServer() {
217
        throw new UnsupportedOperationException("Not supported yet.");
218
    }
219
220
    @Override
221
    public Future<OperationState> deploy(String applicationName, File applicationDir) {
222
        throw new UnsupportedOperationException("Not supported yet.");
223
    }
224
225
    @Override
226
    public Future<OperationState> stop(String applicationName) {
227
        throw new UnsupportedOperationException("Not supported yet.");
228
    }
229
230
    @Override
231
    public Future<OperationState> runApplication(RubyPlatform platform, String applicationName, File applicationDir) {
232
        throw new UnsupportedOperationException("Not supported yet.");
233
    }
234
235
    @Override
236
    public boolean isPlatformSupported(RubyPlatform platform) {
237
        return this.platform.equals(platform);
238
    }
239
240
    @Override
241
    public String getContextRoot(String applicationName) {
242
        return "";
243
    }
244
245
    @Override
246
    public int getRailsPort() {
247
        return 3000;
248
    }
249
250
    @Override
251
    public String getServerCommand(RubyPlatform platform, String classpath, File applicationDir, int httpPort, boolean debug) {
252
        throw new UnsupportedOperationException("Not supported yet.");
253
    }
254
255
    @Override
256
    public String getServerDisplayName() {
257
        return getNodeName();
258
    }
259
260
    @Override
261
    public Node getFullNode() {
262
        return getNode();
263
    }
264
265
    @Override
266
    public Node getBasicNode() {
267
        return getNode();
268
    }
269
270
    @Override
271
    public JComponent getCustomizer() {
272
        return null;
273
    }
274
275
    @Override
276
    public void remove() {
277
        throw new UnsupportedOperationException("Not supported yet.");
278
    }
279
280
    @Override
281
    public boolean isRemovable() {
282
        return false;
283
    }
284
285
    @Override
286
    public boolean equals(Object obj) {
287
        if (obj == null) {
288
            return false;
289
        }
290
        if (getClass() != obj.getClass()) {
291
            return false;
292
        }
293
        final JRubyServerBase other = (JRubyServerBase) obj;
294
        if (this.platform != other.platform && (this.platform == null || !this.platform.equals(other.platform))) {
295
            return false;
296
        }
297
        if (this.version != other.version && (this.version == null || !this.version.equals(other.version))) {
298
            return false;
299
        }
300
        if (this.location != other.location && (this.location == null || !this.location.equals(other.location))) {
301
            return false;
302
        }
303
        return true;
304
    }
305
306
    @Override
307
    public int hashCode() {
308
        int hash = 3;
309
        hash = 47 * hash + (this.platform != null ? this.platform.hashCode() : 0);
310
        hash = 47 * hash + (this.version != null ? this.version.hashCode() : 0);
311
        return hash;
312
    }
313
}
(-)a/ruby.railsprojects/src/org/netbeans/modules/ruby/railsprojects/server/ServerRegistry.java (-52 / +36 lines)
Lines 50-60 Link Here
50
import java.util.Collections;
50
import java.util.Collections;
51
import java.util.Comparator;
51
import java.util.Comparator;
52
import java.util.HashMap;
52
import java.util.HashMap;
53
import java.util.HashSet;
54
import java.util.Iterator;
53
import java.util.Iterator;
55
import java.util.List;
54
import java.util.List;
56
import java.util.Map;
55
import java.util.Map;
57
import java.util.Set;
58
import org.netbeans.api.ruby.platform.RubyPlatform;
56
import org.netbeans.api.ruby.platform.RubyPlatform;
59
import org.netbeans.api.ruby.platform.RubyPlatformManager;
57
import org.netbeans.api.ruby.platform.RubyPlatformManager;
60
import org.netbeans.modules.ruby.platform.gems.GemInfo;
58
import org.netbeans.modules.ruby.platform.gems.GemInfo;
Lines 166-171 Link Here
166
            }
164
            }
167
            RubyServerFactory result = new RubyServerFactory(platform);
165
            RubyServerFactory result = new RubyServerFactory(platform);
168
            result.initGlassFish();
166
            result.initGlassFish();
167
            result.initTrinidad();
169
            result.initMongrel();
168
            result.initMongrel();
170
            result.initWEBrick();
169
            result.initWEBrick();
171
            if (ENABLE_PASSENGER) {
170
            if (ENABLE_PASSENGER) {
Lines 181-236 Link Here
181
            return Collections.<RubyServer>unmodifiableList(servers);
180
            return Collections.<RubyServer>unmodifiableList(servers);
182
        }
181
        }
183
182
184
        private void initGlassFish() {
183
        private RubyServer createInstance(Class clazz, GemInfo gemInfo) {
185
            if (platform.isJRuby()) {
184
            if (clazz == Trinidad.class) {
186
                GemManager gemManager = platform.getGemManager();
185
                return new Trinidad(platform, gemInfo);
187
                if (gemManager == null) {
186
            } else if (clazz == GlassFishGem.class) {
188
                    return;
187
                return new GlassFishGem(platform, gemInfo);
189
                }
188
            } else if (clazz == Mongrel.class) {
190
189
                return new Mongrel(platform, gemInfo.getVersion());
191
                List<GemInfo> versions = gemManager.getVersions(GlassFishGem.GEM_NAME);
190
            } else if (clazz == Passenger.class) {
192
                GemInfo glassFishGemInfo = versions.isEmpty() ? null : versions.get(0);
191
                return new Passenger(platform, gemInfo.getVersion());
193
                if (glassFishGemInfo == null) {
194
                    // remove all glassfish from gems
195
                    for (Iterator<RubyServer> it = servers.iterator(); it.hasNext();) {
196
                        if (it.next() instanceof GlassFishGem) {
197
                            it.remove();
198
                        }
199
                    }
200
                    return;
201
202
                }
203
204
                GlassFishGem candidate = new GlassFishGem(platform, glassFishGemInfo);
205
                if (!servers.contains(candidate)) {
206
                    servers.add(candidate);
207
                }
208
            }
192
            }
193
            return null;
209
        }
194
        }
210
195
211
        private void initMongrel() {
196
        private void initServer(Class clazz, String gemName) {
212
            GemManager gemManager = platform.getGemManager();
197
            GemManager gemManager = platform.getGemManager();
213
            if (gemManager == null) {
198
            if (gemManager == null) {
214
                return;
199
                return;
215
            }
200
            }
216
201
217
            String mongrelVersion = gemManager.getLatestVersion(Mongrel.GEM_NAME);
202
            List<GemInfo> versions = gemManager.getVersions(gemName);
218
            if (mongrelVersion == null) {
203
            GemInfo gemInfo = versions.isEmpty() ? null : versions.get(0);
219
                // remove all mongrels
204
            if (gemInfo == null) {
205
                // remove all glassfish from gems
220
                for (Iterator<RubyServer> it = servers.iterator(); it.hasNext();) {
206
                for (Iterator<RubyServer> it = servers.iterator(); it.hasNext();) {
221
                    if (it.next() instanceof Mongrel) {
207
                    if (it.next().getClass() == clazz) {
222
                        it.remove();
208
                        it.remove();
223
                    }
209
                    }
224
                }
210
                }
225
                return;
211
                return;
226
212
227
            }
213
            }
228
            Mongrel candidate = new Mongrel(platform, mongrelVersion);
214
215
            RubyServer candidate = createInstance(clazz, gemInfo);
229
            if (!servers.contains(candidate)) {
216
            if (!servers.contains(candidate)) {
230
                servers.add(candidate);
217
                servers.add(candidate);
231
            }
218
            }
232
        }
219
        }
233
220
221
        private void initGlassFish() {
222
            if (platform.isJRuby()) {
223
                initServer(GlassFishGem.class, GlassFishGem.GEM_NAME);
224
            }
225
        }
226
227
        private void initTrinidad() {
228
            if (platform.isJRuby()) {
229
                initServer(Trinidad.class, Trinidad.GEM_NAME);
230
            }
231
        }
232
233
        private void initMongrel() {
234
            initServer(Mongrel.class, Mongrel.GEM_NAME);
235
        }
236
234
        private void initWEBrick() {
237
        private void initWEBrick() {
235
            WEBrick candidate = new WEBrick(platform);
238
            WEBrick candidate = new WEBrick(platform);
236
            if (!servers.contains(candidate)) {
239
            if (!servers.contains(candidate)) {
Lines 239-264 Link Here
239
        }
242
        }
240
243
241
        private void initPassenger() {
244
        private void initPassenger() {
242
            GemManager gemManager = platform.getGemManager();
245
            initServer(Passenger.class, Passenger.GEM_NAME);
243
            if (gemManager == null) {
244
                return;
245
            }
246
247
            String passengerVersion = gemManager.getLatestVersion(Passenger.GEM_NAME);
248
            if (passengerVersion == null) {
249
                // remove all passengers
250
                for (Iterator<RubyServer> it = servers.iterator(); it.hasNext(); ) {
251
                    if (it.next() instanceof Passenger) {
252
                        it.remove();
253
                    }
254
                }
255
                return;
256
257
            }
258
            Passenger candidate = new Passenger(platform, passengerVersion);
259
            if (!servers.contains(candidate)) {
260
                servers.add(candidate);
261
            }
262
        }
246
        }
263
247
264
        public void propertyChange(PropertyChangeEvent evt) {
248
        public void propertyChange(PropertyChangeEvent evt) {
(-)70a422f5c2a9 (+82 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.ruby.railsprojects.server;
44
45
import java.util.regex.Pattern;
46
import org.netbeans.api.ruby.platform.RubyPlatform;
47
import org.netbeans.modules.ruby.platform.gems.GemInfo;
48
49
/**
50
 *
51
 * @author David Calavera
52
 */
53
public class Trinidad extends JRubyServerBase {
54
55
    static final String GEM_NAME = "trinidad";
56
57
    private static final Pattern[] PATTERNS = {
58
        Pattern.compile(".*org.apache.coyote.http11.Http11Protocol start.*", Pattern.DOTALL),
59
        Pattern.compile(".*INFO: Starting Coyote HTTP/1.1.*", Pattern.DOTALL)
60
    };
61
62
    private static final String LABEL = "LBL_Trinidad";
63
64
    public Trinidad(RubyPlatform platform, GemInfo gemInfo) {
65
        super(platform, gemInfo);
66
    }
67
68
    @Override
69
    protected String getLabel() {
70
        return LABEL;
71
    }
72
73
    @Override
74
    protected Pattern[] getPatterns() {
75
        return PATTERNS;
76
    }
77
78
    @Override
79
    protected String getGemName() {
80
        return GEM_NAME;
81
    }
82
}

Return to bug 190432