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 206196
Collapse All | Expand All

(-)a/glassfish.common/nbproject/project.xml (-1 / +1 lines)
Lines 54-60 Link Here
54
                    <compile-dependency/>
54
                    <compile-dependency/>
55
                    <run-dependency>
55
                    <run-dependency>
56
                        <release-version>0</release-version>
56
                        <release-version>0</release-version>
57
                        <specification-version>1.2</specification-version>
57
                        <specification-version>1.19</specification-version>
58
                    </run-dependency>
58
                    </run-dependency>
59
                </dependency>
59
                </dependency>
60
                <dependency>
60
                <dependency>
(-)a/glassfish.common/src/org/netbeans/modules/glassfish/common/CommonServerSupport.java (-15 / +7 lines)
Lines 48-53 Link Here
48
import java.net.InetSocketAddress;
48
import java.net.InetSocketAddress;
49
import java.net.Socket;
49
import java.net.Socket;
50
import java.net.URL;
50
import java.net.URL;
51
import java.util.Arrays;
51
import java.util.Collection;
52
import java.util.Collection;
52
import java.util.Collections;
53
import java.util.Collections;
53
import java.util.HashMap;
54
import java.util.HashMap;
Lines 85-91 Link Here
85
import org.openide.filesystems.FileObject;
86
import org.openide.filesystems.FileObject;
86
import org.openide.filesystems.FileUtil;
87
import org.openide.filesystems.FileUtil;
87
import org.openide.util.ChangeSupport;
88
import org.openide.util.ChangeSupport;
88
import org.openide.util.Exceptions;
89
import org.openide.util.Lookup;
89
import org.openide.util.Lookup;
90
import org.openide.util.NbBundle;
90
import org.openide.util.NbBundle;
91
import org.openide.util.RequestProcessor;
91
import org.openide.util.RequestProcessor;
Lines 357-379 Link Here
357
    private static final RequestProcessor RP = new RequestProcessor("CommonServerSupport - start/stop/refresh",5); // NOI18N
357
    private static final RequestProcessor RP = new RequestProcessor("CommonServerSupport - start/stop/refresh",5); // NOI18N
358
358
359
    @Override
359
    @Override
360
    public Future<OperationState> startServer(final OperationStateListener stateListener) {
360
    public Future<OperationState> startServer(final OperationStateListener stateListener, ServerState endState) {
361
        Logger.getLogger("glassfish").log(Level.FINEST, "CSS.startServer called on thread \"{0}\"", Thread.currentThread().getName()); // NOI18N
361
        Logger.getLogger("glassfish").log(Level.FINEST, "CSS.startServer called on thread \"{0}\"", Thread.currentThread().getName()); // NOI18N
362
        OperationStateListener startServerListener = new StartOperationStateListener(GlassfishModule.ServerState.RUNNING);
362
        OperationStateListener startServerListener = new StartOperationStateListener(endState);
363
        VMIntrospector vmi = Lookups.forPath(Util.GF_LOOKUP_PATH).lookup(VMIntrospector.class);
363
        VMIntrospector vmi = Lookups.forPath(Util.GF_LOOKUP_PATH).lookup(VMIntrospector.class);
364
        FutureTask<OperationState> task = new FutureTask<OperationState>(
364
        FutureTask<OperationState> task = new FutureTask<OperationState>(
365
                new StartTask(this, getRecognizers(), vmi, startServerListener, stateListener));
365
                new StartTask(this, getRecognizers(), vmi,
366
        RP.post(task);
366
                              (FileObject)null,
367
        return task;
367
                              (String[])(endState == ServerState.STOPPED_JVM_PROFILER ? new String[]{""} : null),
368
    }
368
                              startServerListener, stateListener));
369
370
    @Override
371
    public Future<OperationState> startServer(final OperationStateListener stateListener, FileObject jdkRoot, String[] jvmArgs) {
372
        Logger.getLogger("glassfish").log(Level.FINEST, "CSS.startServer called on thread \"{0}\"", Thread.currentThread().getName()); // NOI18N
373
        OperationStateListener startServerListener = new StartOperationStateListener(GlassfishModule.ServerState.STOPPED_JVM_PROFILER);
374
        VMIntrospector vmi = Lookups.forPath(Util.GF_LOOKUP_PATH).lookup(VMIntrospector.class);
375
        FutureTask<OperationState> task = new FutureTask<OperationState>(
376
                new StartTask(this, getRecognizers(), vmi, jdkRoot, jvmArgs, startServerListener, stateListener));
377
        RP.post(task);
369
        RP.post(task);
378
        return task;
370
        return task;
379
    }
371
    }
(-)a/glassfish.common/src/org/netbeans/modules/glassfish/common/GlassfishInstance.java (-5 / +22 lines)
Lines 48-58 Link Here
48
import java.io.FileNotFoundException;
48
import java.io.FileNotFoundException;
49
import java.io.IOException;
49
import java.io.IOException;
50
import java.io.InputStream;
50
import java.io.InputStream;
51
import java.util.ArrayList;
51
import java.util.Collection;
52
import java.util.Collection;
52
import java.util.Collections;
53
import java.util.Collections;
53
import java.util.HashMap;
54
import java.util.HashMap;
54
import java.util.HashSet;
55
import java.util.HashSet;
55
import java.util.LinkedList;
56
import java.util.LinkedList;
57
import java.util.List;
56
import java.util.Map;
58
import java.util.Map;
57
import java.util.Properties;
59
import java.util.Properties;
58
import java.util.Set;
60
import java.util.Set;
Lines 84-96 Link Here
84
import org.openide.util.lookup.AbstractLookup;
86
import org.openide.util.lookup.AbstractLookup;
85
import org.openide.util.lookup.InstanceContent;
87
import org.openide.util.lookup.InstanceContent;
86
import org.openide.util.lookup.Lookups;
88
import org.openide.util.lookup.Lookups;
89
import org.openide.util.lookup.ProxyLookup;
87
import org.openide.windows.InputOutput;
90
import org.openide.windows.InputOutput;
88
91
89
/**
92
/**
90
 *
93
 *
91
 * @author Peter Williams
94
 * @author Peter Williams
92
 */
95
 */
93
public class GlassfishInstance implements ServerInstanceImplementation, LookupListener {
96
public class GlassfishInstance implements ServerInstanceImplementation, Lookup.Provider, LookupListener {
94
97
95
    // Reasonable default values for various server parameters.  Note, don't use
98
    // Reasonable default values for various server parameters.  Note, don't use
96
    // these unless the server's actual setting cannot be determined in any way.
99
    // these unless the server's actual setting cannot be determined in any way.
Lines 111-116 Link Here
111
    private transient CommonServerSupport commonSupport;
114
    private transient CommonServerSupport commonSupport;
112
    private transient InstanceContent ic;
115
    private transient InstanceContent ic;
113
    private transient Lookup lookup;
116
    private transient Lookup lookup;
117
    private transient Lookup full;
114
    final private transient Lookup.Result<GlassfishModuleFactory> lookupResult = Lookups.forPath(Util.GF_LOOKUP_PATH).lookupResult(GlassfishModuleFactory.class);;
118
    final private transient Lookup.Result<GlassfishModuleFactory> lookupResult = Lookups.forPath(Util.GF_LOOKUP_PATH).lookupResult(GlassfishModuleFactory.class);;
115
    private transient Collection<? extends GlassfishModuleFactory> currentFactories = Collections.emptyList();
119
    private transient Collection<? extends GlassfishModuleFactory> currentFactories = Collections.emptyList();
116
    
120
    
Lines 123-128 Link Here
123
        try {
127
        try {
124
            ic = new InstanceContent();
128
            ic = new InstanceContent();
125
            lookup = new AbstractLookup(ic);
129
            lookup = new AbstractLookup(ic);
130
            full = lookup;
126
            this.instanceProvider = instanceProvider;
131
            this.instanceProvider = instanceProvider;
127
            String domainDirPath = ip.get(GlassfishModule.DOMAINS_FOLDER_ATTR);
132
            String domainDirPath = ip.get(GlassfishModule.DOMAINS_FOLDER_ATTR);
128
            String domainName = ip.get(GlassfishModule.DOMAIN_NAME_ATTR);
133
            String domainName = ip.get(GlassfishModule.DOMAIN_NAME_ATTR);
Lines 144-156 Link Here
144
149
145
                ic.add(commonSupport); // Common action support, e.g start/stop, etc.
150
                ic.add(commonSupport); // Common action support, e.g start/stop, etc.
146
                commonInstance = ServerInstanceFactory.createServerInstance(this);
151
                commonInstance = ServerInstanceFactory.createServerInstance(this);
147
                if (updateNow) {
148
                    updateModuleSupport();
149
                }
150
152
151
                // make this instance publicly accessible
153
                // make this instance publicly accessible
152
                instanceProvider.addServerInstance(this);
154
                instanceProvider.addServerInstance(this);
153
            }
155
            }
156
            if (updateNow) {
157
                updateModuleSupport();
158
            }
154
        } finally {
159
        } finally {
155
            if(deployerUri != null) {
160
            if(deployerUri != null) {
156
                GlassfishInstanceProvider.activeRegistrationSet.remove(deployerUri);
161
                GlassfishInstanceProvider.activeRegistrationSet.remove(deployerUri);
Lines 189-194 Link Here
189
            added.removeAll(currentFactories);
194
            added.removeAll(currentFactories);
190
            currentFactories = factories;
195
            currentFactories = factories;
191
196
197
            List<Lookup> proxies = new ArrayList<Lookup>();
198
            proxies.add(lookup);
192
            for (GlassfishModuleFactory moduleFactory : added) {
199
            for (GlassfishModuleFactory moduleFactory : added) {
193
                if(moduleFactory.isModuleSupported(homeFolder, asenvProps)) {
200
                if(moduleFactory.isModuleSupported(homeFolder, asenvProps)) {
194
                    Object t = moduleFactory.createModule(lookup);
201
                    Object t = moduleFactory.createModule(lookup);
Lines 196-205 Link Here
196
                        Logger.getLogger("glassfish").log(Level.WARNING, "{0} created a null module", moduleFactory); // NOI18N
203
                        Logger.getLogger("glassfish").log(Level.WARNING, "{0} created a null module", moduleFactory); // NOI18N
197
                    } else {
204
                    } else {
198
                        ic.add(t);
205
                        ic.add(t);
206
                        if (t instanceof Lookup.Provider) {
207
                            proxies.add(Lookups.proxy((Lookup.Provider) t));
208
                        }
199
                    }
209
                    }
200
                }
210
                }
201
            }
211
            }
212
213
            if (!proxies.isEmpty()) {
214
                full = new ProxyLookup(proxies.toArray(new Lookup[proxies.size()]));
215
            }
202
        }
216
        }
217
203
    }
218
    }
204
    
219
    
205
    void updateModuleSupport() {
220
    void updateModuleSupport() {
Lines 279-285 Link Here
279
    }
294
    }
280
    
295
    
281
    public Lookup getLookup() {
296
    public Lookup getLookup() {
282
        return lookup;
297
        synchronized (lookupResult) {
298
            return full;
299
        }
283
    }
300
    }
284
    
301
    
285
    public void addChangeListener(final ChangeListener listener) {
302
    public void addChangeListener(final ChangeListener listener) {
(-)a/glassfish.common/src/org/netbeans/modules/glassfish/common/RestartTask.java (-1 / +1 lines)
Lines 168-174 Link Here
168
                if (GlassfishModule.PROFILE_MODE.equals(o)) {
168
                if (GlassfishModule.PROFILE_MODE.equals(o)) {
169
                    support.setEnvironmentProperty(GlassfishModule.JVM_MODE, GlassfishModule.NORMAL_MODE, false);
169
                    support.setEnvironmentProperty(GlassfishModule.JVM_MODE, GlassfishModule.NORMAL_MODE, false);
170
                }
170
                }
171
                Future<OperationState> startTask = support.startServer(null);
171
                Future<OperationState> startTask = support.startServer(null, ServerState.RUNNING);
172
                OperationState startResult = OperationState.FAILED;
172
                OperationState startResult = OperationState.FAILED;
173
                try {
173
                try {
174
                    startResult = startTask.get(START_TIMEOUT, TIMEUNIT);
174
                    startResult = startTask.get(START_TIMEOUT, TIMEUNIT);
(-)a/glassfish.common/src/org/netbeans/modules/glassfish/common/StartTask.java (+18 lines)
Lines 62-67 Link Here
62
import java.util.logging.Level;
62
import java.util.logging.Level;
63
import java.util.logging.Logger;
63
import java.util.logging.Logger;
64
import javax.swing.SwingUtilities;
64
import javax.swing.SwingUtilities;
65
import org.netbeans.api.server.StartupArguments;
65
import org.netbeans.modules.glassfish.spi.RegisteredDerbyServer;
66
import org.netbeans.modules.glassfish.spi.RegisteredDerbyServer;
66
import org.netbeans.modules.glassfish.spi.GlassfishModule;
67
import org.netbeans.modules.glassfish.spi.GlassfishModule;
67
import org.netbeans.modules.glassfish.spi.GlassfishModule.OperationState;
68
import org.netbeans.modules.glassfish.spi.GlassfishModule.OperationState;
Lines 696-704 Link Here
696
            throw new ProcessCreationException(ioe,
697
            throw new ProcessCreationException(ioe,
697
                    "MSG_START_SERVER_FAILED_INVALIDPORT", instanceName, debugPortString); //NOI18N
698
                    "MSG_START_SERVER_FAILED_INVALIDPORT", instanceName, debugPortString); //NOI18N
698
        }
699
        }
700
701
        for (StartupArguments args : StartupArguments.getStartupArguments(
702
                support.getInstanceProvider().getInstance(ip.get("url")), getMode(ip.get(GlassfishModule.JVM_MODE)))) {
703
            for (String singleArg : args.getArguments()) {
704
                argumentBuf.append(' ').append(singleArg);
705
            }
706
        }
699
        return argumentBuf;
707
        return argumentBuf;
700
    }
708
    }
701
709
710
    private static StartupArguments.StartMode getMode(String gfMode) {
711
        if (GlassfishModule.PROFILE_MODE.equals(gfMode)) {
712
            return StartupArguments.StartMode.PROFILE;
713
        } else if (GlassfishModule.DEBUG_MODE.equals(gfMode)) {
714
            return StartupArguments.StartMode.DEBUG;
715
        } else {
716
            return StartupArguments.StartMode.NORMAL;
717
        }
718
    }
719
702
    private String selectDebugPort() throws IOException {
720
    private String selectDebugPort() throws IOException {
703
        int debugPort = 9009;
721
        int debugPort = 9009;
704
        ServerSocket t = null;
722
        ServerSocket t = null;
(-)a/glassfish.common/src/org/netbeans/modules/glassfish/common/actions/DebugAction.java (-1 / +1 lines)
Lines 73-79 Link Here
73
    
73
    
74
    private static void performActionImpl(final GlassfishModule commonSupport) {
74
    private static void performActionImpl(final GlassfishModule commonSupport) {
75
        commonSupport.setEnvironmentProperty(GlassfishModule.JVM_MODE, GlassfishModule.DEBUG_MODE, true);
75
        commonSupport.setEnvironmentProperty(GlassfishModule.JVM_MODE, GlassfishModule.DEBUG_MODE, true);
76
        commonSupport.startServer(null);
76
        commonSupport.startServer(null, ServerState.RUNNING);
77
    }
77
    }
78
78
79
    protected boolean enable(Node[] activatedNodes) {
79
    protected boolean enable(Node[] activatedNodes) {
(-)a/glassfish.common/src/org/netbeans/modules/glassfish/common/actions/ProfileAction.java (-13 / +3 lines)
Lines 47-54 Link Here
47
import org.netbeans.modules.glassfish.common.Util;
47
import org.netbeans.modules.glassfish.common.Util;
48
import org.netbeans.modules.glassfish.spi.GlassfishModule;
48
import org.netbeans.modules.glassfish.spi.GlassfishModule;
49
import org.netbeans.modules.glassfish.spi.GlassfishModule.ServerState;
49
import org.netbeans.modules.glassfish.spi.GlassfishModule.ServerState;
50
import org.netbeans.modules.glassfish.spi.ProfilerCookie;
51
import org.openide.filesystems.FileObject;
52
import org.openide.nodes.Node;
50
import org.openide.nodes.Node;
53
import org.openide.util.HelpCtx;
51
import org.openide.util.HelpCtx;
54
import org.openide.util.NbBundle;
52
import org.openide.util.NbBundle;
Lines 73-87 Link Here
73
    
71
    
74
    private static void performActionImpl(final GlassfishModule commonSupport, Node node) {
72
    private static void performActionImpl(final GlassfishModule commonSupport, Node node) {
75
        commonSupport.setEnvironmentProperty(GlassfishModule.JVM_MODE, GlassfishModule.PROFILE_MODE, true);
73
        commonSupport.setEnvironmentProperty(GlassfishModule.JVM_MODE, GlassfishModule.PROFILE_MODE, true);
76
        // get the cookie
74
        
77
        ProfilerCookie pc = node.getLookup().lookup(ProfilerCookie.class);
75
        commonSupport.startServer(null, ServerState.STOPPED_JVM_PROFILER);
78
        if (null != pc) {
79
            Object[] pcData = pc.getData();
80
            FileObject jdkHome = (FileObject) pcData[0];
81
            String[] jvmArgs = (String[]) pcData[1];
82
            if (jvmArgs != null && jvmArgs.length > 0)
83
                commonSupport.startServer(null,jdkHome,jvmArgs);
84
        }
85
    }
76
    }
86
77
87
    protected boolean enable(Node[] activatedNodes) {
78
    protected boolean enable(Node[] activatedNodes) {
Lines 104-111 Link Here
104
    }
95
    }
105
    
96
    
106
    private static boolean enableImpl(GlassfishModule commonSupport, Node node) {
97
    private static boolean enableImpl(GlassfishModule commonSupport, Node node) {
107
        ProfilerCookie pc = node.getLookup().lookup(ProfilerCookie.class);
98
        return commonSupport.getServerState() == ServerState.STOPPED &&
108
        return null != pc && commonSupport.getServerState() == ServerState.STOPPED &&
109
                null != commonSupport.getInstanceProperties().get(GlassfishModule.DOMAINS_FOLDER_ATTR) &&
99
                null != commonSupport.getInstanceProperties().get(GlassfishModule.DOMAINS_FOLDER_ATTR) &&
110
                Util.isDefaultOrServerTarget(commonSupport.getInstanceProperties());
100
                Util.isDefaultOrServerTarget(commonSupport.getInstanceProperties());
111
    }
101
    }
(-)a/glassfish.common/src/org/netbeans/modules/glassfish/common/actions/StartServerAction.java (-1 / +1 lines)
Lines 71-77 Link Here
71
    
71
    
72
    private static void performActionImpl(GlassfishModule commonSupport) {
72
    private static void performActionImpl(GlassfishModule commonSupport) {
73
        commonSupport.setEnvironmentProperty(GlassfishModule.JVM_MODE, GlassfishModule.NORMAL_MODE, true);
73
        commonSupport.setEnvironmentProperty(GlassfishModule.JVM_MODE, GlassfishModule.NORMAL_MODE, true);
74
        commonSupport.startServer(null);
74
        commonSupport.startServer(null, ServerState.RUNNING);
75
    }
75
    }
76
    
76
    
77
    @Override
77
    @Override
(-)a/glassfish.common/src/org/netbeans/modules/glassfish/spi/GlassfishModule.java (-13 / +2 lines)
Lines 178-199 Link Here
178
     * 
178
     * 
179
     * @param stateListener listener to listen message describing the startup 
179
     * @param stateListener listener to listen message describing the startup 
180
     *   process as it progresses.  Can be null.
180
     *   process as it progresses.  Can be null.
181
     * 
181
     * @param endState {@linkplain ServerState} the server is to be put to upon successful startup
182
     * @return Future instance that finishes when the server startup has
182
     * @return Future instance that finishes when the server startup has
183
     *   completed (or failed).
183
     *   completed (or failed).
184
     */
184
     */
185
    public Future<OperationState> startServer(OperationStateListener stateListener);
185
    public Future<OperationState> startServer(OperationStateListener stateListener, ServerState endState);
186
187
    /**
188
     * Start the server with a specific JDK.
189
     * 
190
     * @param stateListener listener to listen message describing the startup 
191
     *   process as it progresses.  Can be null.
192
     * 
193
     * @return Future instance that finishes when the server startup has
194
     *   completed (or failed).
195
     */
196
    public Future<OperationState> startServer(OperationStateListener stateListener,FileObject jdkRoot, String[] jvmArgs);
197
186
198
    /**
187
    /**
199
     * Stop the server.
188
     * Stop the server.
(-)a/glassfish.common/src/org/netbeans/modules/glassfish/spi/ProfilerCookie.java (-63 lines)
Removed Link Here
1
// <editor-fold defaultstate="collapsed" desc=" License Header ">
2
/*
3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
 *
5
 * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
6
 *
7
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
8
 * Other names may be trademarks of their respective owners.
9
 *
10
 * The contents of this file are subject to the terms of either the GNU
11
 * General Public License Version 2 only ("GPL") or the Common
12
 * Development and Distribution License("CDDL") (collectively, the
13
 * "License"). You may not use this file except in compliance with the
14
 * License. You can obtain a copy of the License at
15
 * http://www.netbeans.org/cddl-gplv2.html
16
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
17
 * specific language governing permissions and limitations under the
18
 * License.  When distributing the software, include this License Header
19
 * Notice in each file and include the License file at
20
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
21
 * particular file as subject to the "Classpath" exception as provided
22
 * by Oracle in the GPL Version 2 section of the License file that
23
 * accompanied this code. If applicable, add the following below the
24
 * License Header, with the fields enclosed by brackets [] replaced by
25
 * your own identifying information:
26
 * "Portions Copyrighted [year] [name of copyright owner]"
27
 * 
28
 * If you wish your version of this file to be governed by only the CDDL
29
 * or only the GPL Version 2, indicate your decision by adding
30
 * "[Contributor] elects to include this software in this distribution
31
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
32
 * single choice of license, a recipient has the option to distribute
33
 * your version of this file under either the CDDL, the GPL Version 2 or
34
 * to extend the choice of license to its licensees as provided above.
35
 * However, if you add GPL Version 2 code and therefore, elected the GPL
36
 * Version 2 license, then the option applies only if the new code is
37
 * made subject to such option by the copyright holder.
38
 * 
39
 * Contributor(s):
40
 * 
41
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
42
 */
43
//</editor-fold>
44
45
package org.netbeans.modules.glassfish.spi;
46
47
/**
48
 *
49
 * @author vkraemer
50
 */
51
public interface ProfilerCookie {
52
    /**
53
     * This is a conduit for data that the we need to get from the profiler that
54
     * is buried in org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler
55
     * as org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings
56
     * 
57
     * @return a two element array. Object[0] is a FileObject that is the root
58
     * directory of the JDK to use for running the app server. Object[0] is a
59
     * String[] of extra arguments that need to be used to start the JVM in
60
     * profiled mode.
61
     */
62
    public Object[] getData();
63
}
(-)a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Hk2StartServer.java (-11 / +4 lines)
Lines 72-83 Link Here
72
import org.netbeans.modules.glassfish.spi.GlassfishModule;
72
import org.netbeans.modules.glassfish.spi.GlassfishModule;
73
import org.netbeans.modules.glassfish.spi.GlassfishModule.OperationState;
73
import org.netbeans.modules.glassfish.spi.GlassfishModule.OperationState;
74
import org.netbeans.modules.glassfish.spi.OperationStateListener;
74
import org.netbeans.modules.glassfish.spi.OperationStateListener;
75
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
76
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport;
75
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport;
77
import org.openide.DialogDescriptor;
76
import org.openide.DialogDescriptor;
78
import org.openide.DialogDisplayer;
77
import org.openide.DialogDisplayer;
79
import org.openide.NotifyDescriptor;
78
import org.openide.NotifyDescriptor;
80
import org.openide.filesystems.FileObject;
81
import org.openide.util.NbBundle;
79
import org.openide.util.NbBundle;
82
80
83
/**
81
/**
Lines 152-158 Link Here
152
                                CommandType.START, translateState(newState), ActionType.EXECUTE,
150
                                CommandType.START, translateState(newState), ActionType.EXECUTE,
153
                                message));
151
                                message));
154
                    }
152
                    }
155
                });
153
                }, GlassfishModule.ServerState.RUNNING);
156
            } else if (commonSupport != null) { // this is the remote case
154
            } else if (commonSupport != null) { // this is the remote case
157
                commonSupport.setEnvironmentProperty(GlassfishModule.JVM_MODE, GlassfishModule.NORMAL_MODE, true);
155
                commonSupport.setEnvironmentProperty(GlassfishModule.JVM_MODE, GlassfishModule.NORMAL_MODE, true);
158
                commonSupport.restartServer(new OperationStateListener() {
156
                commonSupport.restartServer(new OperationStateListener() {
Lines 242-248 Link Here
242
                                CommandType.START, translateState(newState), ActionType.EXECUTE,
240
                                CommandType.START, translateState(newState), ActionType.EXECUTE,
243
                                message));
241
                                message));
244
                    }
242
                    }
245
                });
243
                }, GlassfishModule.ServerState.RUNNING);
246
            } else if  (null != commonSupport) { // this is the remote case
244
            } else if  (null != commonSupport) { // this is the remote case
247
                commonSupport.setEnvironmentProperty(GlassfishModule.JVM_MODE, GlassfishModule.DEBUG_MODE, true);
245
                commonSupport.setEnvironmentProperty(GlassfishModule.JVM_MODE, GlassfishModule.DEBUG_MODE, true);
248
                commonSupport.restartServer(new OperationStateListener() {
246
                commonSupport.restartServer(new OperationStateListener() {
Lines 431-437 Link Here
431
    }
429
    }
432
430
433
    @Override
431
    @Override
434
    public ProgressObject startProfiling(Target target, ProfilerServerSettings settings) {
432
    public ProgressObject startProfiling(Target target) {
435
        if (ProfilerSupport.getState() == ProfilerSupport.STATE_BLOCKING) {
433
        if (ProfilerSupport.getState() == ProfilerSupport.STATE_BLOCKING) {
436
            fireHandleProgressEvent(null, new Hk2DeploymentStatus(
434
            fireHandleProgressEvent(null, new Hk2DeploymentStatus(
437
                    CommandType.START, StateType.RUNNING, ActionType.EXECUTE,
435
                    CommandType.START, StateType.RUNNING, ActionType.EXECUTE,
Lines 453-463 Link Here
453
//            String domainLocation = commonSupport.getInstanceProperties().get(GlassfishModule.DOMAINS_FOLDER_ATTR);
451
//            String domainLocation = commonSupport.getInstanceProperties().get(GlassfishModule.DOMAINS_FOLDER_ATTR);
454
//            String domainName = commonSupport.getInstanceProperties().get(GlassfishModule.DOMAIN_NAME_ATTR);
452
//            String domainName = commonSupport.getInstanceProperties().get(GlassfishModule.DOMAIN_NAME_ATTR);
455
            commonSupport.setEnvironmentProperty(GlassfishModule.JVM_MODE, GlassfishModule.PROFILE_MODE, true);
453
            commonSupport.setEnvironmentProperty(GlassfishModule.JVM_MODE, GlassfishModule.PROFILE_MODE, true);
456
            Iterator<FileObject> iter = settings.getJavaPlatform().getInstallFolders().iterator();
457
            FileObject jdkRoot = null;
458
            if (iter.hasNext()) {
459
                jdkRoot = iter.next();
460
            }
461
            commonSupport.startServer(new OperationStateListener() {
454
            commonSupport.startServer(new OperationStateListener() {
462
455
463
                @Override
456
                @Override
Lines 486-492 Link Here
486
                        CommandType.START, translateState(newState), ActionType.EXECUTE,
479
                        CommandType.START, translateState(newState), ActionType.EXECUTE,
487
                        message));
480
                        message));
488
                }
481
                }
489
            }, jdkRoot, settings.getJvmArgs());
482
            }, GlassfishModule.ServerState.STOPPED_JVM_PROFILER);
490
        }
483
        }
491
        return this;
484
        return this;
492
    }
485
    }
(-)a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/JavaEEServerModule.java (-27 / +29 lines)
Lines 44-59 Link Here
44
44
45
import java.util.Collection;
45
import java.util.Collection;
46
import java.util.Collections;
46
import java.util.Collections;
47
import org.netbeans.api.java.platform.JavaPlatform;
48
import org.netbeans.modules.glassfish.eecommon.api.LogHyperLinkSupport;
47
import org.netbeans.modules.glassfish.eecommon.api.LogHyperLinkSupport;
49
import org.netbeans.modules.glassfish.spi.ProfilerCookie;
50
import org.netbeans.modules.glassfish.spi.Recognizer;
48
import org.netbeans.modules.glassfish.spi.Recognizer;
51
import org.netbeans.modules.glassfish.spi.RecognizerCookie;
49
import org.netbeans.modules.glassfish.spi.RecognizerCookie;
52
import org.netbeans.modules.glassfish.spi.RemoveCookie;
50
import org.netbeans.modules.glassfish.spi.RemoveCookie;
51
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
52
import org.netbeans.modules.j2ee.deployment.devmodules.api.InstanceRemovedException;
53
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
54
import org.netbeans.modules.j2ee.deployment.devmodules.api.ServerInstance;
53
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
55
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
54
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
56
import org.openide.util.Exceptions;
55
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler;
56
import org.openide.util.Lookup;
57
import org.openide.util.Lookup;
58
import org.openide.util.lookup.Lookups;
59
import org.openide.util.lookup.ProxyLookup;
57
import org.openide.windows.OutputListener;
60
import org.openide.windows.OutputListener;
58
61
59
62
Lines 61-80 Link Here
61
 *
64
 *
62
 * @author Peter Williams
65
 * @author Peter Williams
63
 */
66
 */
64
public class JavaEEServerModule implements RemoveCookie, ProfilerCookie, RecognizerCookie {
67
public class JavaEEServerModule implements Lookup.Provider, RemoveCookie, RecognizerCookie {
65
68
66
    private final InstanceProperties instanceProperties;
69
    private final InstanceProperties instanceProperties;
67
    private final LogHyperLinkSupport.AppServerLogSupport logSupport;
70
    private final LogHyperLinkSupport.AppServerLogSupport logSupport;
68
    
71
72
    private final Lookup lookup;
73
69
    JavaEEServerModule(Lookup instanceLookup, InstanceProperties ip) {
74
    JavaEEServerModule(Lookup instanceLookup, InstanceProperties ip) {
70
        instanceProperties = ip;
75
        instanceProperties = ip;
71
        logSupport = new LogHyperLinkSupport.AppServerLogSupport("", "/");
76
        logSupport = new LogHyperLinkSupport.AppServerLogSupport("", "/");
77
78
        // is this ok, can platform change ?
79
        ServerInstance inst = Deployment.getDefault().getServerInstance(
80
                instanceProperties.getProperty(InstanceProperties.URL_ATTR));
81
        J2eePlatform platform = null;
82
        try {
83
            platform = inst.getJ2eePlatform();
84
        } catch (InstanceRemovedException ex) {
85
        }
86
        lookup = platform != null
87
                ? new ProxyLookup(Lookups.fixed(platform, ip), Lookups.proxy(platform))
88
                : Lookup.EMPTY;
72
    }
89
    }
73
90
74
    public InstanceProperties getInstanceProperties() {
91
    public InstanceProperties getInstanceProperties() {
75
        return instanceProperties;
92
        return instanceProperties;
76
    }
93
    }
77
    
94
95
    @Override
96
    public Lookup getLookup() {
97
        return lookup;
98
    }
99
78
    // ------------------------------------------------------------------------
100
    // ------------------------------------------------------------------------
79
    // RemoveCookie support
101
    // RemoveCookie support
80
    // ------------------------------------------------------------------------
102
    // ------------------------------------------------------------------------
Lines 83-108 Link Here
83
    }
105
    }
84
106
85
    // ------------------------------------------------------------------------
107
    // ------------------------------------------------------------------------
86
    // ProfilerCookie support
87
    // ------------------------------------------------------------------------
88
    public Object[] getData() {
89
        Profiler profiler = Lookup.getDefault().lookup(Profiler.class);
90
        Object[] retVal = new Object[2];
91
        retVal[0] = JavaPlatform.getDefault().getInstallFolders().iterator().next();
92
        retVal[1] = new String[0];
93
        if (profiler == null) {
94
            return retVal;
95
        }
96
        final ProfilerServerSettings settings = profiler.getSettings(instanceProperties.getProperty(InstanceProperties.URL_ATTR));
97
        if (settings == null) {
98
            return retVal;
99
        }
100
        retVal[0] = settings.getJavaPlatform().getInstallFolders().iterator().next();
101
        retVal[1] = settings.getJvmArgs();
102
        return retVal;
103
    }
104
105
    // ------------------------------------------------------------------------
106
    // RecognizerCookie support
108
    // RecognizerCookie support
107
    // ------------------------------------------------------------------------
109
    // ------------------------------------------------------------------------
108
    public Collection<? extends Recognizer> getRecognizers() {
110
    public Collection<? extends Recognizer> getRecognizers() {
(-)a/j2ee.ant/antsrc/org/netbeans/modules/j2ee/ant/StartProfiledServer.java (-6 / +1 lines)
Lines 53-59 Link Here
53
import org.netbeans.api.java.platform.JavaPlatformManager;
53
import org.netbeans.api.java.platform.JavaPlatformManager;
54
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
54
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
55
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler;
55
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler;
56
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
57
import org.openide.filesystems.*;
56
import org.openide.filesystems.*;
58
import org.netbeans.api.project.FileOwnerQuery;
57
import org.netbeans.api.project.FileOwnerQuery;
59
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
58
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
Lines 102-116 Link Here
102
        if (envvar == null) {
101
        if (envvar == null) {
103
            envvar = new String[0];
102
            envvar = new String[0];
104
        }
103
        }
105
        ProfilerServerSettings settings = new ProfilerServerSettings(
106
                                                    platform,
107
                                                    jvmarg.getVmCommand().getArguments(), 
108
                                                    envvar);
109
        FileObject fo = FileUtil.toFileObject(getProject().getBaseDir());
104
        FileObject fo = FileUtil.toFileObject(getProject().getBaseDir());
110
        fo.refresh(); // without this the "build" directory is not found in filesystems
105
        fo.refresh(); // without this the "build" directory is not found in filesystems
111
        J2eeModuleProvider jmp = (J2eeModuleProvider)FileOwnerQuery.getOwner(fo).getLookup().lookup(J2eeModuleProvider.class);
106
        J2eeModuleProvider jmp = (J2eeModuleProvider)FileOwnerQuery.getOwner(fo).getLookup().lookup(J2eeModuleProvider.class);
112
        ServerInstance si = ServerRegistry.getInstance().getServerInstance(jmp.getServerInstanceID());
107
        ServerInstance si = ServerRegistry.getInstance().getServerInstance(jmp.getServerInstanceID());
113
        if (!si.startProfile(settings, forceRestart, this)) {
108
        if (!si.startProfile(forceRestart, this)) {
114
            String msg = NbBundle.getMessage(StartProfiledServer.class, "MSG_StartupFailed");
109
            String msg = NbBundle.getMessage(StartProfiledServer.class, "MSG_StartupFailed");
115
            throw new BuildException(msg);
110
            throw new BuildException(msg);
116
        }
111
        }
(-)a/j2ee.jboss4/nbproject/project.xml (-1 / +10 lines)
Lines 134-140 Link Here
134
                    <compile-dependency/>
134
                    <compile-dependency/>
135
                    <run-dependency>
135
                    <run-dependency>
136
                        <release-version>4</release-version>
136
                        <release-version>4</release-version>
137
                        <specification-version>1.72</specification-version>
137
                        <specification-version>1.88</specification-version>
138
                    </run-dependency>
138
                    </run-dependency>
139
                </dependency>
139
                </dependency>
140
                <dependency>
140
                <dependency>
Lines 162-167 Link Here
162
                    </run-dependency>
162
                    </run-dependency>
163
                </dependency>
163
                </dependency>
164
                <dependency>
164
                <dependency>
165
                    <code-name-base>org.netbeans.modules.server</code-name-base>
166
                    <build-prerequisite/>
167
                    <compile-dependency/>
168
                    <run-dependency>
169
                        <release-version>0-1</release-version>
170
                        <specification-version>1.19</specification-version>
171
                    </run-dependency>
172
                </dependency>
173
                <dependency>
165
                    <code-name-base>org.openide.actions</code-name-base>
174
                    <code-name-base>org.openide.actions</code-name-base>
166
                    <build-prerequisite/>
175
                    <build-prerequisite/>
167
                    <compile-dependency/>
176
                    <compile-dependency/>
(-)a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartRunnable.java (-12 / +22 lines)
Lines 62-70 Link Here
62
import javax.enterprise.deploy.shared.CommandType;
62
import javax.enterprise.deploy.shared.CommandType;
63
import javax.enterprise.deploy.shared.StateType;
63
import javax.enterprise.deploy.shared.StateType;
64
import org.netbeans.api.java.platform.JavaPlatform;
64
import org.netbeans.api.java.platform.JavaPlatform;
65
import org.netbeans.api.server.StartupArguments;
66
import org.netbeans.modules.j2ee.deployment.plugins.api.CommonServerBridge;
65
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
67
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
66
import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport;
68
import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport;
67
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
68
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
69
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
69
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
70
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
70
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
71
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
Lines 120-132 Link Here
120
    private JBDeploymentManager dm;
121
    private JBDeploymentManager dm;
121
    private String instanceName;
122
    private String instanceName;
122
    private JBStartServer startServer;
123
    private JBStartServer startServer;
123
    private ProfilerServerSettings profilerSettings;
124
124
125
    JBStartRunnable(ProfilerServerSettings profilerSettings, JBDeploymentManager dm, JBStartServer startServer) {
125
    JBStartRunnable(JBDeploymentManager dm, JBStartServer startServer) {
126
        this.dm = dm;
126
        this.dm = dm;
127
        this.instanceName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
127
        this.instanceName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
128
        this.startServer = startServer;
128
        this.startServer = startServer;
129
        this.profilerSettings = profilerSettings;
130
    }
129
    }
131
130
132
    public void run() {
131
    public void run() {
Lines 205-211 Link Here
205
        }
204
        }
206
205
207
        // get Java platform that will run the server
206
        // get Java platform that will run the server
208
        JavaPlatform platform = (startServer.getMode() != JBStartServer.MODE.PROFILE ? properties.getJavaPlatform() : profilerSettings.getJavaPlatform());
207
        JavaPlatform platform = properties.getJavaPlatform();
209
208
210
        if (startServer.getMode() == JBStartServer.MODE.DEBUG && javaOptsBuilder.toString().indexOf("-Xdebug") == -1) { // NOI18N
209
        if (startServer.getMode() == JBStartServer.MODE.DEBUG && javaOptsBuilder.toString().indexOf("-Xdebug") == -1) { // NOI18N
211
            // if in debug mode and the debug options not specified manually
210
            // if in debug mode and the debug options not specified manually
Lines 217-234 Link Here
217
                            append(",server=y,suspend=n"); // NOI18N
216
                            append(",server=y,suspend=n"); // NOI18N
218
217
219
        } else if (startServer.getMode() == JBStartServer.MODE.PROFILE) {
218
        } else if (startServer.getMode() == JBStartServer.MODE.PROFILE) {
220
221
            // get JVM arguments used for starting the server
222
            String[] profJvmArgs = profilerSettings.getJvmArgs();
223
            for (int i = 0; i < profJvmArgs.length; i++) {
224
                javaOptsBuilder.append(" ").append(profJvmArgs[i]); // NOI18N
225
            }
226
            if (properties.isVersion(JBPluginUtils.JBOSS_6_0_0)) {
219
            if (properties.isVersion(JBPluginUtils.JBOSS_6_0_0)) {
227
                javaOptsBuilder.append(" ").append("-Djboss.platform.mbeanserver")
220
                javaOptsBuilder.append(" ").append("-Djboss.platform.mbeanserver")
228
                        .append(" ").append("-Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl");
221
                        .append(" ").append("-Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl");
229
            }
222
            }
230
        }
223
        }
231
224
225
        for (StartupArguments args : StartupArguments.getStartupArguments(
226
                CommonServerBridge.getCommonInstance(ip.getProperty("url")), getMode(startServer.getMode()))) {
227
            for (String singleArg : args.getArguments()) {
228
                javaOptsBuilder.append(' ').append(singleArg);
229
            }
230
        }
231
232
        // create new environment for server
232
        // create new environment for server
233
        javaOpts = javaOptsBuilder.toString();
233
        javaOpts = javaOptsBuilder.toString();
234
        String javaHome = getJavaHome(platform);
234
        String javaHome = getJavaHome(platform);
Lines 241-247 Link Here
241
        };
241
        };
242
        return envp;
242
        return envp;
243
    }
243
    }
244
    
244
245
    private static StartupArguments.StartMode getMode(JBStartServer.MODE jbMode) {
246
        if (JBStartServer.MODE.PROFILE.equals(jbMode)) {
247
            return StartupArguments.StartMode.PROFILE;
248
        } else if (JBStartServer.MODE.DEBUG.equals(jbMode)) {
249
            return StartupArguments.StartMode.DEBUG;
250
        } else {
251
            return StartupArguments.StartMode.NORMAL;
252
        }
253
    }
254
245
    private boolean checkPorts(final InstanceProperties ip) {
255
    private boolean checkPorts(final InstanceProperties ip) {
246
256
247
        try {
257
        try {
(-)a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartServer.java (-5 / +4 lines)
Lines 45-51 Link Here
45
45
46
import java.net.URISyntaxException;
46
import java.net.URISyntaxException;
47
import java.util.Collections;
47
import java.util.Collections;
48
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
49
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
48
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
50
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
49
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
51
import java.io.IOException;
50
import java.io.IOException;
Lines 117-123 Link Here
117
        String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
116
        String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
118
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_SERVER_IN_PROGRESS", serverName))); //NOI18N
117
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_SERVER_IN_PROGRESS", serverName))); //NOI18N
119
        mode = MODE.DEBUG;
118
        mode = MODE.DEBUG;
120
        RequestProcessor.getDefault().post(new JBStartRunnable(null, dm, this), 0, Thread.NORM_PRIORITY);
119
        RequestProcessor.getDefault().post(new JBStartRunnable(dm, this), 0, Thread.NORM_PRIORITY);
121
        addDebugModeUri();
120
        addDebugModeUri();
122
        return this;
121
        return this;
123
    }
122
    }
Lines 151-161 Link Here
151
    /**
150
    /**
152
     * Starts the server in profiling mode.
151
     * Starts the server in profiling mode.
153
     */
152
     */
154
    public ProgressObject startProfiling(Target target, ProfilerServerSettings settings) {
153
    public ProgressObject startProfiling(Target target) {
155
        String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
154
        String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
156
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_PROFILED_SERVER_IN_PROGRESS", serverName))); //NOI18N
155
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_PROFILED_SERVER_IN_PROGRESS", serverName))); //NOI18N
157
        mode = MODE.PROFILE;
156
        mode = MODE.PROFILE;
158
        RequestProcessor.getDefault().post(new JBStartRunnable(settings, dm, this), 0, Thread.NORM_PRIORITY);
157
        RequestProcessor.getDefault().post(new JBStartRunnable(dm, this), 0, Thread.NORM_PRIORITY);
159
        removeDebugModeUri();
158
        removeDebugModeUri();
160
        return this;
159
        return this;
161
    }
160
    }
Lines 188-194 Link Here
188
        String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
187
        String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
189
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_SERVER_IN_PROGRESS", serverName)));//NOI18N
188
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_SERVER_IN_PROGRESS", serverName)));//NOI18N
190
        mode = MODE.RUN;
189
        mode = MODE.RUN;
191
        RequestProcessor.getDefault().post(new JBStartRunnable(null, dm, this), 0, Thread.NORM_PRIORITY);
190
        RequestProcessor.getDefault().post(new JBStartRunnable(dm, this), 0, Thread.NORM_PRIORITY);
192
        removeDebugModeUri();
191
        removeDebugModeUri();
193
        return this;
192
        return this;
194
    }
193
    }
(-)a/j2ee.weblogic9/nbproject/project.xml (-1 / +10 lines)
Lines 149-155 Link Here
149
                    <compile-dependency/>
149
                    <compile-dependency/>
150
                    <run-dependency>
150
                    <run-dependency>
151
                        <release-version>4</release-version>
151
                        <release-version>4</release-version>
152
                        <specification-version>1.78</specification-version>
152
                        <specification-version>1.88</specification-version>
153
                    </run-dependency>
153
                    </run-dependency>
154
                </dependency>
154
                </dependency>
155
                <dependency>
155
                <dependency>
Lines 204-209 Link Here
204
                    </run-dependency>
204
                    </run-dependency>
205
                </dependency>
205
                </dependency>
206
                <dependency>
206
                <dependency>
207
                    <code-name-base>org.netbeans.modules.server</code-name-base>
208
                    <build-prerequisite/>
209
                    <compile-dependency/>
210
                    <run-dependency>
211
                        <release-version>0-1</release-version>
212
                        <specification-version>1.19</specification-version>
213
                    </run-dependency>
214
                </dependency>
215
                <dependency>
207
                    <code-name-base>org.openide.actions</code-name-base>
216
                    <code-name-base>org.openide.actions</code-name-base>
208
                    <build-prerequisite/>
217
                    <build-prerequisite/>
209
                    <compile-dependency/>
218
                    <compile-dependency/>
(-)a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/optional/WLStartServer.java (-30 / +32 lines)
Lines 69-86 Link Here
69
import org.netbeans.api.extexecution.input.InputProcessors;
69
import org.netbeans.api.extexecution.input.InputProcessors;
70
import org.netbeans.api.extexecution.input.InputReaderTask;
70
import org.netbeans.api.extexecution.input.InputReaderTask;
71
import org.netbeans.api.extexecution.input.InputReaders;
71
import org.netbeans.api.extexecution.input.InputReaders;
72
import org.netbeans.api.java.platform.JavaPlatform;
72
import org.netbeans.api.server.StartupArguments;
73
import org.netbeans.modules.j2ee.deployment.plugins.api.CommonServerBridge;
73
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
74
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
74
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
75
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
75
import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport;
76
import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport;
76
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
77
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
77
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
78
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport;
78
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport;
79
import org.netbeans.modules.j2ee.weblogic9.deploy.WLDeploymentManager;
79
import org.netbeans.modules.j2ee.weblogic9.deploy.WLDeploymentManager;
80
import org.netbeans.modules.j2ee.weblogic9.WLDeploymentFactory;
80
import org.netbeans.modules.j2ee.weblogic9.WLDeploymentFactory;
81
import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties;
81
import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties;
82
import org.openide.filesystems.FileObject;
83
import org.openide.filesystems.FileUtil;
84
import org.openide.util.NbBundle;
82
import org.openide.util.NbBundle;
85
import org.openide.util.Utilities;
83
import org.openide.util.Utilities;
86
import org.openide.windows.InputOutput;
84
import org.openide.windows.InputOutput;
Lines 202-209 Link Here
202
     * @see org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer#startProfiling(javax.enterprise.deploy.spi.Target, org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings)
200
     * @see org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer#startProfiling(javax.enterprise.deploy.spi.Target, org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings)
203
     */
201
     */
204
    @Override
202
    @Override
205
    public ProgressObject startProfiling( Target target,
203
    public ProgressObject startProfiling( Target target )
206
            ProfilerServerSettings settings )
207
    {
204
    {
208
        LOGGER.log(Level.FINER, "Starting server in profiling mode"); // NOI18N
205
        LOGGER.log(Level.FINER, "Starting server in profiling mode"); // NOI18N
209
206
Lines 215-221 Link Here
215
                NbBundle.getMessage(WLStartServer.class, "MSG_START_SERVER_IN_PROGRESS", serverName));
212
                NbBundle.getMessage(WLStartServer.class, "MSG_START_SERVER_IN_PROGRESS", serverName));
216
213
217
        String uri = dm.getUri();
214
        String uri = dm.getUri();
218
        service.submit(new WLProfilingStartTask(uri, serverProgress, dm, settings));
215
        service.submit(new WLProfilingStartTask(uri, serverProgress, dm));
219
216
220
        removeServerInDebug(uri);
217
        removeServerInDebug(uri);
221
        return serverProgress;
218
        return serverProgress;
Lines 364-376 Link Here
364
361
365
    private class WLProfilingStartTask extends WLStartTask {
362
    private class WLProfilingStartTask extends WLStartTask {
366
363
367
        private final ProfilerServerSettings mySettings;
368
369
        public WLProfilingStartTask(String uri, WLServerProgress serverProgress,
364
        public WLProfilingStartTask(String uri, WLServerProgress serverProgress,
370
                WLDeploymentManager dm, ProfilerServerSettings settings) {
365
                WLDeploymentManager dm) {
371
366
372
            super( uri , serverProgress, dm );
367
            super( uri , serverProgress, dm );
373
            mySettings = settings;
374
        }
368
        }
375
369
376
        /* (non-Javadoc)
370
        /* (non-Javadoc)
Lines 409-428 Link Here
409
            }*/
403
            }*/
410
404
411
            StringBuilder javaOptsBuilder = new StringBuilder();
405
            StringBuilder javaOptsBuilder = new StringBuilder();
412
            String[] profJvmArgs = getSettings().getJvmArgs();
413
            for (int i = 0; i < profJvmArgs.length; i++) {
414
                javaOptsBuilder.append(" ").append(profJvmArgs[i]);         // NOI18N
415
            }
416
            String javaOpts = dm.getInstanceProperties().getProperty(
406
            String javaOpts = dm.getInstanceProperties().getProperty(
417
                    WLPluginProperties.JAVA_OPTS);
407
                    WLPluginProperties.JAVA_OPTS);
418
            if ( javaOpts!= null && javaOpts.trim().length() >0 ){
408
            if ( javaOpts!= null && javaOpts.trim().length() >0 ){
419
                javaOptsBuilder.append( " " );                              // NOI18N
409
                javaOptsBuilder.append( " " );                              // NOI18N
420
                javaOptsBuilder.append( javaOpts.trim() );
410
                javaOptsBuilder.append( javaOpts.trim() );
421
            }
411
            }
422
            
412
423
            if ( profJvmArgs.length >0 ){
413
            for (StartupArguments args : StartupArguments.getStartupArguments(
414
                        CommonServerBridge.getCommonInstance(dm.getUri()), StartupArguments.StartMode.PROFILE)) {
415
                for (String singleArg : args.getArguments()) {
416
                    javaOptsBuilder.append(' ').append(singleArg);
417
                }
418
            }
419
            String toAdd = javaOptsBuilder.toString().trim();
420
            if (!toAdd.isEmpty()){
424
                result = result.addEnvironmentVariable(JAVA_OPTIONS_VARIABLE, 
421
                result = result.addEnvironmentVariable(JAVA_OPTIONS_VARIABLE, 
425
                    javaOptsBuilder.toString());
422
                    toAdd);
426
            }
423
            }
427
            return result;
424
            return result;
428
        }
425
        }
Lines 438-452 Link Here
438
            }
435
            }
439
            return super.isRunning();
436
            return super.isRunning();
440
        }
437
        }
441
442
        private String getJavaHome(JavaPlatform platform) {
443
            FileObject fo = (FileObject)platform.getInstallFolders().iterator().next();
444
            return FileUtil.toFile(fo).getAbsolutePath();
445
        }
446
447
        private ProfilerServerSettings getSettings() {
448
            return mySettings;
449
        }
450
    }
438
    }
451
439
452
    private class WLDebugStartTask extends WLStartTask {
440
    private class WLDebugStartTask extends WLStartTask {
Lines 476-481 Link Here
476
            javaOptsBuilder.append("-Xdebug -Xnoagent -Djava.compiler=none ");  // NOI18N
464
            javaOptsBuilder.append("-Xdebug -Xnoagent -Djava.compiler=none ");  // NOI18N
477
            javaOptsBuilder.append("-Xrunjdwp:server=y,suspend=n,transport=dt_socket,address=");// NOI18N
465
            javaOptsBuilder.append("-Xrunjdwp:server=y,suspend=n,transport=dt_socket,address=");// NOI18N
478
            javaOptsBuilder.append( debugPort );
466
            javaOptsBuilder.append( debugPort );
467
            for (StartupArguments args : StartupArguments.getStartupArguments(
468
                        CommonServerBridge.getCommonInstance(dm.getUri()), StartupArguments.StartMode.DEBUG)) {
469
                for (String singleArg : args.getArguments()) {
470
                    javaOptsBuilder.append(' ').append(singleArg);
471
                }
472
            }
479
            ExternalProcessBuilder result = builder.addEnvironmentVariable(
473
            ExternalProcessBuilder result = builder.addEnvironmentVariable(
480
                    JAVA_OPTIONS_VARIABLE,
474
                    JAVA_OPTIONS_VARIABLE,
481
                    javaOptsBuilder.toString());   
475
                    javaOptsBuilder.toString());   
Lines 657-665 Link Here
657
        {
651
        {
658
            ExternalProcessBuilder result = builder;
652
            ExternalProcessBuilder result = builder;
659
            String javaOpts = dm.getInstanceProperties().getProperty(WLPluginProperties.JAVA_OPTS);
653
            String javaOpts = dm.getInstanceProperties().getProperty(WLPluginProperties.JAVA_OPTS);
660
            if ( javaOpts!= null && javaOpts.trim().length() >0 ){
654
            StringBuilder sb = new StringBuilder((javaOpts!= null && javaOpts.trim().length() > 0)
661
                result = builder.addEnvironmentVariable(JAVA_OPTIONS_VARIABLE,          
655
                    ? javaOpts.trim() : "");
662
                        javaOpts.trim());
656
            for (StartupArguments args : StartupArguments.getStartupArguments(
657
                        CommonServerBridge.getCommonInstance(dm.getUri()), StartupArguments.StartMode.NORMAL)) {
658
                for (String singleArg : args.getArguments()) {
659
                    sb.append(' ').append(singleArg);
660
                }
661
            }
662
            if (sb.length() > 0) {
663
                result = builder.addEnvironmentVariable(JAVA_OPTIONS_VARIABLE,
664
                        sb.toString());
663
            }
665
            }
664
            return result;
666
            return result;
665
        }
667
        }
(-)a/j2eeserver/apichanges.xml (+18 lines)
Lines 116-121 Link Here
116
    <!-- ACTUAL CHANGES BEGIN HERE: -->
116
    <!-- ACTUAL CHANGES BEGIN HERE: -->
117
117
118
    <changes>
118
    <changes>
119
       <change id="commonBridge">
120
    	    <api name="j2eeserver"/>
121
            <summary>
122
                Added CommonBridge utility class to provide mapping of
123
                instance url to common api server instance.
124
            </summary>
125
            <version major="1" minor="88"/>
126
            <date day="6" month="1" year="2012"/>
127
            <author login="dkonecny"/>
128
            <compatibility binary="compatible" source="compatible" semantic="compatible" addition="yes"/>
129
            <description>
130
                <p>
131
                    Added CommonBridge utility class to provide mapping of
132
                    instance url to common api server instance.
133
                </p>
134
            </description>
135
            <class package="org.netbeans.modules.j2ee.deployment.plugins.api" name="CommonBridge"/>
136
        </change>
119
       <change id="nonPersistentServer">
137
       <change id="nonPersistentServer">
120
    	    <api name="j2eeserver"/>
138
    	    <api name="j2eeserver"/>
121
            <summary>
139
            <summary>
(-)a/j2eeserver/nbproject/project.properties (-1 / +1 lines)
Lines 42-48 Link Here
42
42
43
is.autoload=true
43
is.autoload=true
44
javac.source=1.6
44
javac.source=1.6
45
spec.version.base=1.87.0
45
spec.version.base=1.88.0
46
46
47
javadoc.arch=${basedir}/arch.xml
47
javadoc.arch=${basedir}/arch.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/ServerManager.java (-14 / +2 lines)
Lines 53-58 Link Here
53
import org.netbeans.modules.j2ee.deployment.impl.bridge.BridgingServerInstanceProvider;
53
import org.netbeans.modules.j2ee.deployment.impl.bridge.BridgingServerInstanceProvider;
54
import org.netbeans.modules.j2ee.deployment.impl.bridge.ServerInstanceProviderLookup;
54
import org.netbeans.modules.j2ee.deployment.impl.bridge.ServerInstanceProviderLookup;
55
import org.netbeans.modules.j2ee.deployment.impl.ui.wizard.AddServerInstanceWizard;
55
import org.netbeans.modules.j2ee.deployment.impl.ui.wizard.AddServerInstanceWizard;
56
import org.netbeans.modules.j2ee.deployment.plugins.api.CommonServerBridge;
56
57
57
/**
58
/**
58
 * ServerManager class provides access to the Server Manager dialog.
59
 * ServerManager class provides access to the Server Manager dialog.
Lines 80-99 Link Here
80
     */
81
     */
81
    public static void showCustomizer(String serverInstanceID) {
82
    public static void showCustomizer(String serverInstanceID) {
82
        // bridge to new infrastructure (common server)
83
        // bridge to new infrastructure (common server)
83
        ServerInstance bridgingInstance = null;
84
        ServerInstance bridgingInstance = CommonServerBridge.getCommonInstance(serverInstanceID);
84
        org.netbeans.modules.j2ee.deployment.impl.ServerInstance j2eeInstance =
85
                ServerRegistry.getInstance().getServerInstance(serverInstanceID);
86
        if (j2eeInstance != null) {
87
            Collection<? extends org.netbeans.spi.server.ServerInstanceProvider> providers = ServerInstanceProviderLookup.getInstance().lookupAll(org.netbeans.spi.server.ServerInstanceProvider.class);
88
            for (org.netbeans.spi.server.ServerInstanceProvider provider : providers) {
89
                if (provider instanceof BridgingServerInstanceProvider) {
90
                    bridgingInstance = ((BridgingServerInstanceProvider) provider).getBridge(j2eeInstance);
91
                    if (bridgingInstance != null) {
92
                        break;
93
                    }
94
                }
95
            }
96
        }
97
        CommonServerUIs.showCustomizer(bridgingInstance);
85
        CommonServerUIs.showCustomizer(bridgingInstance);
98
    }
86
    }
99
    
87
    
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/ServerInstance.java (-17 / +7 lines)
Lines 66-72 Link Here
66
import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
66
import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
67
import org.netbeans.modules.j2ee.deployment.devmodules.spi.ArtifactListener.Artifact;
67
import org.netbeans.modules.j2ee.deployment.devmodules.spi.ArtifactListener.Artifact;
68
import org.netbeans.modules.j2ee.deployment.plugins.spi.JDBCDriverDeployer;
68
import org.netbeans.modules.j2ee.deployment.plugins.spi.JDBCDriverDeployer;
69
import org.openide.filesystems.*;
70
import java.util.*;
69
import java.util.*;
71
import java.util.concurrent.TimeoutException;
70
import java.util.concurrent.TimeoutException;
72
import java.util.logging.Level;
71
import java.util.logging.Level;
Lines 94-100 Link Here
94
import org.netbeans.modules.j2ee.deployment.plugins.spi.MessageDestinationDeployment;
93
import org.netbeans.modules.j2ee.deployment.plugins.spi.MessageDestinationDeployment;
95
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor;
94
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor;
96
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryManager;
95
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryManager;
97
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
98
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport;
96
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport;
99
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler;
97
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler;
100
import org.openide.nodes.Node;
98
import org.openide.nodes.Node;
Lines 180-186 Link Here
180
    private final ChangeSupport managerChangeSupport = new ChangeSupport(this);
178
    private final ChangeSupport managerChangeSupport = new ChangeSupport(this);
181
    
179
    
182
    private volatile static ServerInstance profiledServerInstance;
180
    private volatile static ServerInstance profiledServerInstance;
183
    private ProfilerServerSettings  profilerSettings;
184
    
181
    
185
    private final DebuggerStateListener debuggerStateListener;
182
    private final DebuggerStateListener debuggerStateListener;
186
    
183
    
Lines 1113-1123 Link Here
1113
    }
1110
    }
1114
    
1111
    
1115
    /** Start the admin server in the profile mode. Show UI feedback. 
1112
    /** Start the admin server in the profile mode. Show UI feedback. 
1116
     * @param settings settings that will be used to start the server
1117
     *
1113
     *
1118
     * @throws ServerException if the server cannot be started.
1114
     * @throws ServerException if the server cannot be started.
1119
     */
1115
     */
1120
    public void startProfile(ProfilerServerSettings settings, boolean forceRestart, ProgressUI ui) 
1116
    public void startProfile(boolean forceRestart, ProgressUI ui) 
1121
    throws ServerException {
1117
    throws ServerException {
1122
        // check whether another server not already running in profile mode
1118
        // check whether another server not already running in profile mode
1123
        // and ask whether it is ok to stop it
1119
        // and ask whether it is ok to stop it
Lines 1137-1143 Link Here
1137
        try {
1133
        try {
1138
            setServerState(STATE_WAITING);
1134
            setServerState(STATE_WAITING);
1139
            // target == null - admin server
1135
            // target == null - admin server
1140
            _startProfile(null, settings, forceRestart, ui);
1136
            _startProfile(null, forceRestart, ui);
1141
        } finally {
1137
        } finally {
1142
            refresh();
1138
            refresh();
1143
        }
1139
        }
Lines 1161-1167 Link Here
1161
            if (stopped) {
1157
            if (stopped) {
1162
                // restart in the mode the server was running in before
1158
                // restart in the mode the server was running in before
1163
                if (inProfile) {
1159
                if (inProfile) {
1164
                    _startProfile(null, profilerSettings, true, ui);
1160
                    _startProfile(null, true, ui);
1165
                } else if (inDebug) {
1161
                } else if (inDebug) {
1166
                    startDebugTarget(null, ui);
1162
                    startDebugTarget(null, ui);
1167
                } else {
1163
                } else {
Lines 1267-1278 Link Here
1267
     *
1263
     *
1268
     * @throws ServerException if the server cannot be started.
1264
     * @throws ServerException if the server cannot be started.
1269
     */
1265
     */
1270
    public boolean startProfile(final ProfilerServerSettings settings, boolean forceRestart, Deployment.Logger logger) {
1266
    public boolean startProfile(boolean forceRestart, Deployment.Logger logger) {
1271
        String title = NbBundle.getMessage(ServerInstance.class, "LBL_StartServerInProfileMode", getDisplayName());
1267
        String title = NbBundle.getMessage(ServerInstance.class, "LBL_StartServerInProfileMode", getDisplayName());
1272
        ProgressUI ui = new ProgressUI(title, false, logger);
1268
        ProgressUI ui = new ProgressUI(title, false, logger);
1273
        try {
1269
        try {
1274
            ui.start();
1270
            ui.start();
1275
            startProfile(settings, forceRestart, ui);
1271
            startProfile(forceRestart, ui);
1276
            return true;
1272
            return true;
1277
        } catch (ServerException ex) {
1273
        } catch (ServerException ex) {
1278
            return false;
1274
            return false;
Lines 1500-1514 Link Here
1500
    /** start server in the profile mode */
1496
    /** start server in the profile mode */
1501
    private void _startProfile(
1497
    private void _startProfile(
1502
                                    Target target, 
1498
                                    Target target, 
1503
                                    ProfilerServerSettings settings,
1504
                                    boolean forceRestart,
1499
                                    boolean forceRestart,
1505
                                    ProgressUI ui) throws ServerException {
1500
                                    ProgressUI ui) throws ServerException {
1506
        ProfilerServerSettings  tmpProfilerSettings;
1507
        synchronized (this) {
1508
            tmpProfilerSettings = profilerSettings;
1509
        }
1510
        ServerInstance tmpProfiledServerInstance = profiledServerInstance;
1501
        ServerInstance tmpProfiledServerInstance = profiledServerInstance;
1511
        if (tmpProfiledServerInstance == this && !forceRestart && settings.equals(tmpProfilerSettings)) {
1502
        if (tmpProfiledServerInstance == this && !forceRestart) {
1512
            return; // server is already runnning in profile mode, no need to restart the server
1503
            return; // server is already runnning in profile mode, no need to restart the server
1513
        }
1504
        }
1514
        if (tmpProfiledServerInstance != null && tmpProfiledServerInstance != this) {
1505
        if (tmpProfiledServerInstance != null && tmpProfiledServerInstance != this) {
Lines 1528-1534 Link Here
1528
            throw new ServerException(NbBundle.getMessage(ServerInstance.class, "MSG_ProfilerNotRegistered"));
1519
            throw new ServerException(NbBundle.getMessage(ServerInstance.class, "MSG_ProfilerNotRegistered"));
1529
        }
1520
        }
1530
        profiler.notifyStarting();
1521
        profiler.notifyStarting();
1531
        ProgressObject po = getStartServer().startProfiling(target, settings);
1522
        ProgressObject po = getStartServer().startProfiling(target);
1532
        try {
1523
        try {
1533
            boolean completedSuccessfully = ProgressObjectUtil.trackProgressObject(ui, po, DEFAULT_TIMEOUT);
1524
            boolean completedSuccessfully = ProgressObjectUtil.trackProgressObject(ui, po, DEFAULT_TIMEOUT);
1534
            if (!completedSuccessfully) {
1525
            if (!completedSuccessfully) {
Lines 1540-1546 Link Here
1540
        }
1531
        }
1541
        profiledServerInstance = this;
1532
        profiledServerInstance = this;
1542
        synchronized (this) {
1533
        synchronized (this) {
1543
            profilerSettings = settings;
1544
            managerStartedByIde = true;
1534
            managerStartedByIde = true;
1545
//            coTarget = null;
1535
//            coTarget = null;
1546
//            targets = null;
1536
//            targets = null;
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/TargetServer.java (-5 / +1 lines)
Lines 93-102 Link Here
93
import org.netbeans.modules.j2ee.deployment.plugins.spi.IncrementalDeployment2;
93
import org.netbeans.modules.j2ee.deployment.plugins.spi.IncrementalDeployment2;
94
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfiguration;
94
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfiguration;
95
import org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver;
95
import org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver;
96
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
97
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler;
98
import org.openide.util.Exceptions;
96
import org.openide.util.Exceptions;
99
import org.openide.util.Lookup;
100
97
101
/**
98
/**
102
 * Encapsulates a set of ServerTarget(s), provides a wrapper for deployment
99
 * Encapsulates a set of ServerTarget(s), provides a wrapper for deployment
Lines 519-525 Link Here
519
                    break;
516
                    break;
520
                }
517
                }
521
                case PROFILE: {
518
                case PROFILE: {
522
                    ProfilerServerSettings settings = Lookup.getDefault().lookup(Profiler.class).getSettings(instance.getUrl(), false);
523
                    final CountDownLatch latch = new CountDownLatch(1);
519
                    final CountDownLatch latch = new CountDownLatch(1);
524
                    ServerInstance.StateListener sl = new ServerInstance.StateListener() {
520
                    ServerInstance.StateListener sl = new ServerInstance.StateListener() {
525
521
Lines 534-540 Link Here
534
530
535
                    instance.addStateListener(sl);
531
                    instance.addStateListener(sl);
536
                    try {
532
                    try {
537
                        instance.startProfile(settings, false, ui);
533
                        instance.startProfile(false, ui);
538
                        try {
534
                        try {
539
                            // need to wait for profiler to load the agent etc.
535
                            // need to wait for profiler to load the agent etc.
540
                            // 60 seconds timeout; instrumentation may slow down the startup significantly
536
                            // 60 seconds timeout; instrumentation may slow down the startup significantly
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/bridge/BridgingServerInstance.java (-2 / +17 lines)
Lines 52-71 Link Here
52
import org.netbeans.modules.j2ee.deployment.impl.ui.actions.CustomizerAction;
52
import org.netbeans.modules.j2ee.deployment.impl.ui.actions.CustomizerAction;
53
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
53
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
54
import org.netbeans.spi.server.ServerInstanceFactory;
54
import org.netbeans.spi.server.ServerInstanceFactory;
55
import org.netbeans.api.server.CommonServerUIs;
56
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
55
import org.netbeans.spi.server.ServerInstanceImplementation;
57
import org.netbeans.spi.server.ServerInstanceImplementation;
56
import org.netbeans.api.server.CommonServerUIs;
57
import org.openide.nodes.FilterNode;
58
import org.openide.nodes.FilterNode;
58
import org.openide.nodes.Node;
59
import org.openide.nodes.Node;
59
import org.openide.util.HelpCtx;
60
import org.openide.util.HelpCtx;
61
import org.openide.util.Lookup;
60
import org.openide.util.NbBundle;
62
import org.openide.util.NbBundle;
61
import org.openide.util.actions.NodeAction;
63
import org.openide.util.actions.NodeAction;
62
import org.openide.util.actions.SystemAction;
64
import org.openide.util.actions.SystemAction;
65
import org.openide.util.lookup.Lookups;
66
import org.openide.util.lookup.ProxyLookup;
63
67
64
/**
68
/**
65
 *
69
 *
66
 * @author Petr Hejl
70
 * @author Petr Hejl
67
 */
71
 */
68
public class BridgingServerInstance implements ServerInstanceImplementation, Node.Cookie {
72
public class BridgingServerInstance implements ServerInstanceImplementation, Lookup.Provider, Node.Cookie {
69
73
70
    private final org.netbeans.modules.j2ee.deployment.impl.ServerInstance instance;
74
    private final org.netbeans.modules.j2ee.deployment.impl.ServerInstance instance;
71
75
Lines 135-140 Link Here
135
        instance.remove();
139
        instance.remove();
136
    }
140
    }
137
141
142
    @Override
143
    public Lookup getLookup() {
144
        J2eePlatform platform = instance.getJ2eePlatform();
145
146
        if (platform == null) { // can happen when J2EE is activated and J2SE is not !?@#
147
            return Lookups.singleton(instance.getInstanceProperties());
148
        } else {
149
            return new ProxyLookup(Lookups.fixed(platform, instance.getInstanceProperties()), Lookups.proxy(platform));
150
        }
151
    }
152
138
    public ServerInstance getCommonInstance() {
153
    public ServerInstance getCommonInstance() {
139
        synchronized (this) {
154
        synchronized (this) {
140
            return commonInstance;
155
            return commonInstance;
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/ui/actions/ProfileAction.java (-12 / +9 lines)
Lines 47-56 Link Here
47
47
48
import org.netbeans.modules.j2ee.deployment.impl.ServerException;
48
import org.netbeans.modules.j2ee.deployment.impl.ServerException;
49
import org.netbeans.modules.j2ee.deployment.impl.ServerInstance;
49
import org.netbeans.modules.j2ee.deployment.impl.ServerInstance;
50
import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry;
51
import org.netbeans.modules.j2ee.deployment.impl.ui.ProgressUI;
50
import org.netbeans.modules.j2ee.deployment.impl.ui.ProgressUI;
52
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
53
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler;
54
import org.openide.DialogDisplayer;
51
import org.openide.DialogDisplayer;
55
import org.openide.NotifyDescriptor;
52
import org.openide.NotifyDescriptor;
56
import org.openide.nodes.Node;
53
import org.openide.nodes.Node;
Lines 92-112 Link Here
92
        }
89
        }
93
        final ServerInstance si = (ServerInstance)nodes[0].getCookie(ServerInstance.class);
90
        final ServerInstance si = (ServerInstance)nodes[0].getCookie(ServerInstance.class);
94
        if (si != null) {
91
        if (si != null) {
95
            Profiler profiler = ServerRegistry.getProfiler();
92
//            Profiler profiler = ServerRegistry.getProfiler();
96
            if (profiler == null) {
93
//            if (profiler == null) {
97
                return;
94
//                return;
98
            }
95
//            }
99
            final ProfilerServerSettings settings = profiler.getSettings(si.getUrl());
96
//            final ProfilerServerSettings settings = profiler.getSettings(si.getUrl());
100
            if (settings == null) {
97
//            if (settings == null) {
101
                return;
98
//                return;
102
            }
99
//            }
103
            RP.post(new Runnable() {
100
            RP.post(new Runnable() {
104
                public void run() {
101
                public void run() {
105
                    String title = NbBundle.getMessage(DebugAction.class, "LBL_Profiling", si.getDisplayName());
102
                    String title = NbBundle.getMessage(DebugAction.class, "LBL_Profiling", si.getDisplayName());
106
                    ProgressUI progressUI = new ProgressUI(title, false);
103
                    ProgressUI progressUI = new ProgressUI(title, false);
107
                    try {
104
                    try {
108
                        progressUI.start();
105
                        progressUI.start();
109
                        si.startProfile(settings, false, progressUI);
106
                        si.startProfile(false, progressUI);
110
                    } catch (ServerException ex) {
107
                    } catch (ServerException ex) {
111
                        String msg = ex.getLocalizedMessage();
108
                        String msg = ex.getLocalizedMessage();
112
                        NotifyDescriptor desc = new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE);
109
                        NotifyDescriptor desc = new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE);
(-)5554c9288ff0 (+100 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 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 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.j2ee.deployment.plugins.api;
43
44
import java.util.Collection;
45
import java.util.logging.Level;
46
import java.util.logging.Logger;
47
import org.netbeans.api.annotations.common.NonNull;
48
import org.netbeans.api.server.ServerInstance;
49
import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry;
50
import org.netbeans.modules.j2ee.deployment.impl.bridge.BridgingServerInstanceProvider;
51
import org.netbeans.modules.j2ee.deployment.impl.bridge.ServerInstanceProviderLookup;
52
import org.netbeans.spi.server.ServerInstanceProvider;
53
import org.openide.util.Parameters;
54
55
/**
56
 * The utility class providing bridge to API classes of the common server.
57
 *
58
 * @author Petr Hejl
59
 * @since 1.88
60
 */
61
public final class CommonServerBridge {
62
63
    private CommonServerBridge() {
64
        super();
65
    }
66
67
    private static final Logger LOGGER = Logger.getLogger(CommonServerBridge.class.getName());
68
69
    /**
70
     * Returns the {@link ServerInstance} corresponding to the server instance
71
     * identified by the given url.
72
     *
73
     * @param instanceUrl the server instance url
74
     * @return the {@link ServerInstance} corresponding to the server instance
75
     *             identified by the given url
76
     */
77
    @NonNull
78
    public static ServerInstance getCommonInstance(@NonNull String instanceUrl) {
79
        Parameters.notNull("instanceUrl", instanceUrl);
80
81
        org.netbeans.modules.j2ee.deployment.impl.ServerInstance instance =
82
                ServerRegistry.getInstance().getServerInstance(instanceUrl);
83
        ServerInstance bridgingInstance = null;
84
        Collection<? extends ServerInstanceProvider> providers =
85
                ServerInstanceProviderLookup.getInstance().lookupAll(ServerInstanceProvider.class);
86
        for (ServerInstanceProvider provider : providers) {
87
            if (provider instanceof BridgingServerInstanceProvider) {
88
                bridgingInstance = ((BridgingServerInstanceProvider) provider).getBridge(instance);
89
                if (bridgingInstance != null) {
90
                    break;
91
                }
92
            }
93
        }
94
        if (bridgingInstance == null) {
95
            LOGGER.log(Level.INFO, "No bridging instance for {0}", instance);
96
            throw new IllegalStateException("Instance registered without UI. No common instance available.");
97
        }
98
        return bridgingInstance;
99
    }
100
}
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/StartServer.java (-3 / +1 lines)
Lines 48-54 Link Here
48
import javax.enterprise.deploy.spi.Target;
48
import javax.enterprise.deploy.spi.Target;
49
import javax.enterprise.deploy.spi.status.ProgressObject;
49
import javax.enterprise.deploy.spi.status.ProgressObject;
50
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
50
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
51
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
52
51
53
/**
52
/**
54
 * Server lifecycle services from the IDE.  J2eeserver will use these
53
 * Server lifecycle services from the IDE.  J2eeserver will use these
Lines 247-259 Link Here
247
     *
246
     *
248
     * @param target          the target server in question, null target implies 
247
     * @param target          the target server in question, null target implies 
249
     *                        the admin server.
248
     *                        the admin server.
250
     * @param settings        profiler server settings.
251
     *
249
     *
252
     * @return ServerProgress object to monitor progress on start operation.
250
     * @return ServerProgress object to monitor progress on start operation.
253
     *
251
     *
254
     * @since 1.9
252
     * @since 1.9
255
     */
253
     */
256
    public ProgressObject startProfiling(Target target, ProfilerServerSettings settings) {
254
    public ProgressObject startProfiling(Target target) {
257
        throw new UnsupportedOperationException("Starting in profile mode is not supported by this server."); // NIO18N
255
        throw new UnsupportedOperationException("Starting in profile mode is not supported by this server."); // NIO18N
258
    }
256
    }
259
    
257
    
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/profiler/api/ProfilerServerSettings.java (+3 lines)
Lines 54-60 Link Here
54
 * Settings that will be used for profiled server startup.
54
 * Settings that will be used for profiled server startup.
55
 *
55
 *
56
 * @author sherold
56
 * @author sherold
57
 * 
58
 * @deprecated 
57
 */
59
 */
60
@Deprecated
58
public final class ProfilerServerSettings {
61
public final class ProfilerServerSettings {
59
62
60
    private JavaPlatform    javaPlatform;
63
    private JavaPlatform    javaPlatform;
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/profiler/spi/Profiler.java (+6 lines)
Lines 81-87 Link Here
81
     *
81
     *
82
     * @return  required settings or <code>null</code> if user cancelled starting 
82
     * @return  required settings or <code>null</code> if user cancelled starting 
83
     *          the server.
83
     *          the server.
84
     * 
85
     * @deprecated 
84
     */
86
     */
87
    @Deprecated
85
    ProfilerServerSettings getSettings(String serverInstanceID);
88
    ProfilerServerSettings getSettings(String serverInstanceID);
86
89
87
    /**
90
    /**
Lines 94-100 Link Here
94
     *
97
     *
95
     * @return  required settings or <code>null</code> if user cancelled starting
98
     * @return  required settings or <code>null</code> if user cancelled starting
96
     *          the server.
99
     *          the server.
100
     * 
101
     * @deprecated
97
     */
102
     */
103
    @Deprecated
98
    ProfilerServerSettings getSettings(String serverInstanceID, boolean verbose);
104
    ProfilerServerSettings getSettings(String serverInstanceID, boolean verbose);
99
    
105
    
100
    /**
106
    /**
(-)a/profiler.j2ee/nbproject/project.xml (+9 lines)
Lines 260-265 Link Here
260
                    </run-dependency>
260
                    </run-dependency>
261
                </dependency>
261
                </dependency>
262
                <dependency>
262
                <dependency>
263
                    <code-name-base>org.netbeans.modules.server</code-name-base>
264
                    <build-prerequisite/>
265
                    <compile-dependency/>
266
                    <run-dependency>
267
                        <release-version>0-1</release-version>
268
                        <specification-version>1.19</specification-version>
269
                    </run-dependency>
270
                </dependency>
271
                <dependency>
263
                    <code-name-base>org.openide.awt</code-name-base>
272
                    <code-name-base>org.openide.awt</code-name-base>
264
                    <build-prerequisite/>
273
                    <build-prerequisite/>
265
                    <compile-dependency/>
274
                    <compile-dependency/>
(-)a/profiler.j2ee/src/org/netbeans/modules/profiler/j2ee/J2EEProfilerSPI.java (-5 / +8 lines)
Lines 170-177 Link Here
170
    private boolean refreshServerInstance = false;
170
    private boolean refreshServerInstance = false;
171
    private boolean serverStartedFromIDE = false;
171
    private boolean serverStartedFromIDE = false;
172
    private /*static final*/ int STARTING_STATE_TIMEOUT = 20000; // timeout for starting the agent [ms]
172
    private /*static final*/ int STARTING_STATE_TIMEOUT = 20000; // timeout for starting the agent [ms]
173
    private int profilerAgentID = -111; // should differ from default J2EEProjectTypeProfiler.getLastAgentID()
174
    private int profilerAgentPort = 0; // should differ from default J2EEProjectTypeProfiler.getLastAgentPort()
175
    private long profilerAgentStartingTime = -1;
173
    private long profilerAgentStartingTime = -1;
176
174
177
    //~ Constructors -------------------------------------------------------------------------------------------------------------
175
    //~ Constructors -------------------------------------------------------------------------------------------------------------
Lines 349-354 Link Here
349
     * @return state of Profiler agent instance.
347
     * @return state of Profiler agent instance.
350
     */
348
     */
351
    public synchronized int getState() {
349
    public synchronized int getState() {
350
        int profilerAgentID = J2EEProjectProfilingSupportProvider.getLastAgentID();
351
        int profilerAgentPort = J2EEProjectProfilingSupportProvider.getLastAgentPort();
352
        int agentState = checkState();
352
        int agentState = checkState();
353
        ProfilerLogger.log(">>> Profiler agent [port=" + profilerAgentPort + ", id=" + profilerAgentID + "]: "
353
        ProfilerLogger.log(">>> Profiler agent [port=" + profilerAgentPort + ", id=" + profilerAgentID + "]: "
354
                           + getPublicAgentStateString(agentState)); // NOI18N
354
                           + getPublicAgentStateString(agentState)); // NOI18N
Lines 418-426 Link Here
418
     * allows the Profiler to correctly detect STATE_STARTING.
418
     * allows the Profiler to correctly detect STATE_STARTING.
419
     */
419
     */
420
    public void notifyStarting() {
420
    public void notifyStarting() {
421
        profilerAgentID = J2EEProjectProfilingSupportProvider.getLastAgentID();
421
        int profilerAgentPort = J2EEProjectProfilingSupportProvider.getLastAgentPort();
422
        profilerAgentPort = J2EEProjectProfilingSupportProvider.getLastAgentPort();
423
424
        NetBeansProfiler.getDefaultNB().cleanForProfilingOnPort(profilerAgentPort); // try to kill an agent on port if some exists
422
        NetBeansProfiler.getDefaultNB().cleanForProfilingOnPort(profilerAgentPort); // try to kill an agent on port if some exists
425
423
426
        profilerAgentStartingTime = System.currentTimeMillis();
424
        profilerAgentStartingTime = System.currentTimeMillis();
Lines 491-496 Link Here
491
489
492
                    // we only stop the agent if in STATE_BLOCKING state
490
                    // we only stop the agent if in STATE_BLOCKING state
493
                    if (getState() == ProfilerSupport.STATE_BLOCKING) {
491
                    if (getState() == ProfilerSupport.STATE_BLOCKING) {
492
                        int profilerAgentID = J2EEProjectProfilingSupportProvider.getLastAgentID();
493
                        int profilerAgentPort = J2EEProjectProfilingSupportProvider.getLastAgentPort();
494
                        Profiler.getDefault().shutdownBlockedAgent("localhost", profilerAgentPort, profilerAgentID); // NOI18N
494
                        Profiler.getDefault().shutdownBlockedAgent("localhost", profilerAgentPort, profilerAgentID); // NOI18N
495
495
496
                        for (int i = 0; i < 60; i++) { // 30sec timeout on profiled application shutdown (thread sleeps 500ms)
496
                        for (int i = 0; i < 60; i++) { // 30sec timeout on profiled application shutdown (thread sleeps 500ms)
Lines 517-522 Link Here
517
                } finally {
517
                } finally {
518
                    // reset the shutdown progress flag
518
                    // reset the shutdown progress flag
519
                    profilerAgentShutdownProgress = false;
519
                    profilerAgentShutdownProgress = false;
520
                    J2EEProjectProfilingSupportProvider.resetLastValues();
520
                }
521
                }
521
            }
522
            }
522
        };
523
        };
Lines 614-619 Link Here
614
615
615
    // --- Private implementation ------------------------------------------------
616
    // --- Private implementation ------------------------------------------------
616
    private int checkState() {
617
    private int checkState() {
618
        int profilerAgentID = J2EEProjectProfilingSupportProvider.getLastAgentID();
619
        int profilerAgentPort = J2EEProjectProfilingSupportProvider.getLastAgentPort();
617
        int currentAgentState = NetBeansProfiler.getDefault().getAgentState("localhost", profilerAgentPort, profilerAgentID); // NOI18N
620
        int currentAgentState = NetBeansProfiler.getDefault().getAgentState("localhost", profilerAgentPort, profilerAgentID); // NOI18N
618
                                                                                                                              //System.err.println(">>> Detected internal agent state: " + getInternalAgentStateString(currentAgentState));
621
                                                                                                                              //System.err.println(">>> Detected internal agent state: " + getInternalAgentStateString(currentAgentState));
619
622
(-)a/profiler.j2ee/src/org/netbeans/modules/profiler/j2ee/J2EEProjectProfilingSupportProvider.java (+5 lines)
Lines 179-184 Link Here
179
    public static int getLastAgentPort() {
179
    public static int getLastAgentPort() {
180
        return lastAgentPort;
180
        return lastAgentPort;
181
    }
181
    }
182
    
183
    public static void resetLastValues() {
184
        lastAgentID = -1;
185
        lastAgentPort = -1;
186
    }
182
187
183
    public static String getServerInstanceID(final Project project) {
188
    public static String getServerInstanceID(final Project project) {
184
        J2eeModuleProvider serverInstanceModuleProvider = project.getLookup().lookup(J2eeModuleProvider.class);
189
        J2eeModuleProvider serverInstanceModuleProvider = project.getLookup().lookup(J2eeModuleProvider.class);
(-)5554c9288ff0 (+44 lines)
Added Link Here
1
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
#
3
# Copyright 1997-2011 Oracle and/or its affiliates. All rights reserved.
4
#
5
# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
6
# Other names may be trademarks of their respective owners.
7
#
8
# The contents of this file are subject to the terms of either the GNU
9
# General Public License Version 2 only ("GPL") or the Common
10
# Development and Distribution License("CDDL") (collectively, the
11
# "License"). You may not use this file except in compliance with the
12
# License. You can obtain a copy of the License at
13
# http://www.netbeans.org/cddl-gplv2.html
14
# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
15
# specific language governing permissions and limitations under the
16
# License.  When distributing the software, include this License Header
17
# Notice in each file and include the License file at
18
# nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
19
# particular file as subject to the "Classpath" exception as provided
20
# by Oracle in the GPL Version 2 section of the License file that
21
# accompanied this code. If applicable, add the following below the
22
# License Header, with the fields enclosed by brackets [] replaced by
23
# your own identifying information:
24
# "Portions Copyrighted [year] [name of copyright owner]"
25
#
26
# Contributor(s):
27
#
28
# The Original Software is NetBeans. The Initial Developer of the Original
29
# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
30
# Microsystems, Inc. All Rights Reserved.
31
#
32
# If you wish your version of this file to be governed by only the CDDL
33
# or only the GPL Version 2, indicate your decision by adding
34
# "[Contributor] elects to include this software in this distribution
35
# under the [CDDL or GPL Version 2] license." If you do not indicate a
36
# single choice of license, a recipient has the option to distribute
37
# your version of this file under either the CDDL, the GPL Version 2 or
38
# to extend the choice of license to its licensees as provided above.
39
# However, if you add GPL Version 2 code and therefore, elected the GPL
40
# Version 2 license, then the option applies only if the new code is
41
# made subject to such option by the copyright holder.
42
43
## Resource bundle for package org.netbeans.modules.profiler.j2ee.impl
44
DESC_Profiler=NetBeans Profiler
(-)5554c9288ff0 (+75 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 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 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.profiler.j2ee.impl;
43
44
import java.util.Arrays;
45
import java.util.Collections;
46
import java.util.List;
47
import org.netbeans.api.server.ServerInstance;
48
import org.netbeans.api.server.StartupArguments.StartMode;
49
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
50
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler;
51
import org.netbeans.spi.server.StartupArgumentsProvider;
52
import org.openide.util.Lookup;
53
import org.openide.util.NbBundle;
54
55
/**
56
 *
57
 * @author Jaroslav Bachorik <jaroslav.bachorik@oracle.com>
58
 */
59
@StartupArgumentsProvider.Registration(position=100, displayName="#DESC_Profiler",
60
        startModes=StartMode.PROFILE)
61
public class ProfilerArgsProvider implements StartupArgumentsProvider {
62
63
    @Override
64
    public List<String> getArguments(ServerInstance instance, StartMode mode) {
65
        if (mode == StartMode.PROFILE) {
66
            Profiler p = Lookup.getDefault().lookup(Profiler.class);
67
            InstanceProperties ip = instance.getLookup().lookup(InstanceProperties.class);
68
            if (ip != null) {
69
                return Arrays.asList(p.getSettings(ip.getProperty("url"), false).getJvmArgs()); //NOI18N
70
            }
71
        }
72
        return Collections.EMPTY_LIST;
73
    }
74
75
}
(-)a/profiler.j2ee/src/org/netbeans/modules/profiler/j2ee/mf-layer.xml (+8 lines)
Lines 253-256 Link Here
253
            </folder>
253
            </folder>
254
        </folder>
254
        </folder>
255
    </folder>
255
    </folder>
256
    <folder name="Servers">
257
        <folder name="VmArgumentProviders">
258
            <file name="org-netbeans-modules-profiler-j2ee-impl-ProfilerArgsProvider.instance">
259
                <attr name="position" intvalue="2147483647"/>
260
            </file>
261
            <file name="org-netbeans-modules-profiler-j2ee-impl-ProfilerVMArgsProvider.instance_hidden"/>
262
        </folder>
263
    </folder>
256
</filesystem>
264
</filesystem>
(-)a/server/apichanges.xml (+16 lines)
Lines 110-115 Link Here
110
    <!-- ACTUAL CHANGES BEGIN HERE: -->
110
    <!-- ACTUAL CHANGES BEGIN HERE: -->
111
111
112
    <changes>
112
    <changes>
113
        <change id="vm.arguments">
114
            <api name="common_server_api"/>
115
            <summary>SPI to allow passing additional arguments to server VM</summary>
116
            <version major="1" minor="19"/>
117
            <date day="6" month="1" year="2012"/>
118
            <author login="phejl"/>
119
            <compatibility addition="yes"/>
120
            <description>
121
                This API/SPI allow third party plugins (such as JRebel) to
122
                register providers of VM arguments. The server plugin may
123
                optionaly query such arguments and pass them to server VM.
124
            </description>
125
            <class package="org.netbeans.api.server" name="StartupArguments"/>
126
            <class package="org.netbeans.spi.server" name="StartupArgumentsProvider"/>
127
            <issue number="206196"/>
128
        </change>
113
        <change id="CommonServerUIs-showAddServerInstanceWizard">
129
        <change id="CommonServerUIs-showAddServerInstanceWizard">
114
            <api name="common_server_api"/>
130
            <api name="common_server_api"/>
115
            <summary>Added UI helper method CommonServerUIs.showAddServerInstanceWizard</summary>
131
            <summary>Added UI helper method CommonServerUIs.showAddServerInstanceWizard</summary>
(-)a/server/arch.xml (-2 / +24 lines)
Lines 60-66 Link Here
60
  </p>  
60
  </p>  
61
  <p>
61
  <p>
62
   Clients can provide its instances through the SPI. They can also provide
62
   Clients can provide its instances through the SPI. They can also provide
63
   wizards to define UI way for the server or cloud instance addition. It is done with
63
   wizards to define UI way for the server or cloud instance addition. There
64
   is also provider of VM arguments which can be registered in layer. It is done with
64
   <api group="layer" name="CommonServerLayerSPI" type="export" category="devel" url="@TOP@overview-summary.html"/>
65
   <api group="layer" name="CommonServerLayerSPI" type="export" category="devel" url="@TOP@overview-summary.html"/>
65
   where the SPIs implementation must be registered.
66
   where the SPIs implementation must be registered.
66
  </p>
67
  </p>
Lines 81-86 Link Here
81
            can extend the list of popup actions on Cloud node in
82
            can extend the list of popup actions on Cloud node in
82
            Services tab.
83
            Services tab.
83
      </api>
84
      </api>
85
      <api group="layer" name="StartupArgumentsProvider" type="export" category="devel">
86
            By registering providers to <code>Servers/StartupArgumentsProviders</code> you
87
            can register your additional VM arguments provider.
88
      </api>
84
      <api group="property" name="serverNodeHidden" type="export" category="friend">
89
      <api group="property" name="serverNodeHidden" type="export" category="friend">
85
            If the action registered in <code>Servers/Actions</code> or <code>Cloud/Actions</code> folder
90
            If the action registered in <code>Servers/Actions</code> or <code>Cloud/Actions</code> folder
86
            has <code>getValue("serverNodeHidden") == Boolean.TRUE</code>, then
91
            has <code>getValue("serverNodeHidden") == Boolean.TRUE</code>, then
Lines 236-242 Link Here
236
    can be used. It provides a way how to store and retrieve properties of
241
    can be used. It provides a way how to store and retrieve properties of
237
    the server instance.
242
    the server instance.
238
   </p>
243
   </p>
239
  </usecase>   
244
  </usecase>
245
  <usecase id="startup-arguments" name="Providing additional VM arguments">
246
   <p>
247
    The third party plugin may want to be able provide additional arguments
248
    for the server in a standardized way. In order to do so it will register
249
    a implementation of
250
    <a href="@TOP@org/netbeans/spi/server/StartupArgumentsProvider.html">StartupArgumentsProvider</a>
251
    to the layer folder Servers/VMArgumentProviders. The annotation
252
    <a href="@TOP@org/netbeans/spi/server/StartupArgumentsProvider.Registration.html">StartupArgumentsProvider.Registration</a>
253
    can be used for that.
254
   </p>
255
   <p>
256
    The clients (server plugin implementations) may query the providers via the
257
    API class
258
    <a href="@TOP@org/netbeans/api/server/StartupArguments.html">StartupArguments</a>
259
    and use the additional arguments for the server.
260
   </p>
261
  </usecase>
240
 </answer>
262
 </answer>
241
263
242
264
(-)a/server/manifest.mf (-1 / +1 lines)
Lines 2-8 Link Here
2
OpenIDE-Module: org.netbeans.modules.server/0
2
OpenIDE-Module: org.netbeans.modules.server/0
3
OpenIDE-Module-Layer: org/netbeans/modules/server/resources/layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/server/resources/layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/server/resources/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/server/resources/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.18
5
OpenIDE-Module-Specification-Version: 1.19
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
7
OpenIDE-Module-Provides: org.netbeans.modules.server
7
OpenIDE-Module-Provides: org.netbeans.modules.server
8
8
(-)a/server/src/org/netbeans/api/server/ServerInstance.java (-2 / +15 lines)
Lines 46-51 Link Here
46
import org.netbeans.spi.server.ServerInstanceFactory;
46
import org.netbeans.spi.server.ServerInstanceFactory;
47
import org.netbeans.spi.server.ServerInstanceImplementation;
47
import org.netbeans.spi.server.ServerInstanceImplementation;
48
import org.openide.nodes.Node;
48
import org.openide.nodes.Node;
49
import org.openide.util.Lookup;
49
50
50
/**
51
/**
51
 * The API representation of the single server instance. Class describes
52
 * The API representation of the single server instance. Class describes
Lines 56-62 Link Here
56
 * 
57
 * 
57
 * @author Petr Hejl
58
 * @author Petr Hejl
58
 */
59
 */
59
public final class ServerInstance {
60
public final class ServerInstance implements Lookup.Provider {
60
61
61
    static {
62
    static {
62
        ServerInstanceFactory.Accessor.DEFAULT = new ServerInstanceFactory.Accessor() {
63
        ServerInstanceFactory.Accessor.DEFAULT = new ServerInstanceFactory.Accessor() {
Lines 142-146 Link Here
142
    public boolean isRemovable() {
143
    public boolean isRemovable() {
143
        return delegate.isRemovable();
144
        return delegate.isRemovable();
144
    }
145
    }
145
    
146
147
    /**
148
     * Returns the lookup associated with this instance.
149
     *
150
     * @return the lookup associated with this instance
151
     * @since 1.19
152
     */
153
    public Lookup getLookup() {
154
        if (delegate instanceof Lookup.Provider) {
155
            return ((Lookup.Provider) delegate).getLookup();
156
        }
157
        return Lookup.EMPTY;
158
    }
146
}
159
}
(-)5554c9288ff0 (+152 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 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 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.api.server;
43
44
import java.util.ArrayList;
45
import java.util.List;
46
import org.netbeans.api.annotations.common.NonNull;
47
import org.netbeans.modules.server.annotations.StartupArgumentsRegistrationProcessor;
48
import org.netbeans.spi.server.StartupArgumentsProvider;
49
import org.openide.util.Lookup;
50
import org.openide.util.NbBundle;
51
import org.openide.util.Parameters;
52
import org.openide.util.lookup.Lookups;
53
54
/**
55
 * The API class allowing clients, typically server plugins, to query additional
56
 * groups of arguments it may pass to VM.
57
 *
58
 * @author Petr Hejl
59
 * @since 1.19
60
 * @see StartupArgumentsProvider
61
 */
62
public final class StartupArguments {
63
64
    private final String description;
65
66
    private final List<String> arguments;
67
68
    private StartupArguments(String description, List<String> arguments) {
69
        this.description = description;
70
        this.arguments = arguments;
71
    }
72
73
    /**
74
     * Returns the groups of arguments provided by all registered
75
     * {@link StartupArgumentsProvider} for the given start mode.
76
     *
77
     * @param instance the server instance being started
78
     * @param mode the VM mode the client is going to use
79
     * @return the groups of arguments provided by all registered
80
     *             {@link StartupArgumentsProvider}
81
     */
82
    @NonNull
83
    public static List<StartupArguments> getStartupArguments(
84
            @NonNull ServerInstance instance, @NonNull StartMode mode) {
85
        Parameters.notNull("instance", instance);
86
        Parameters.notNull("mode", mode);
87
88
        Lookup lkp = Lookups.forPath(StartupArgumentsRegistrationProcessor.PATH);
89
90
        List<StartupArguments> res = new ArrayList<StartupArguments>();
91
        for (Lookup.Item<StartupArgumentsProvider> item : lkp.lookupResult(StartupArgumentsProvider.class).allItems()) {
92
            res.add(new StartupArguments(item.getDisplayName(),
93
                    item.getInstance().getArguments(instance, mode)));
94
        }
95
        return res;
96
    }
97
98
    /**
99
     * Returns the description of group of arguments.
100
     *
101
     * @return the description of group of arguments
102
     */
103
    @NonNull
104
    public String getDescription() {
105
        return description;
106
    }
107
108
    /**
109
     * The list of the VM arguments.
110
     *
111
     * @return list of the VM arguments
112
     */
113
    @NonNull
114
    public List<String> getArguments() {
115
        return arguments;
116
    }
117
118
    /**
119
     * Class representing the startup mode of the VM.
120
     */
121
    public static enum StartMode {
122
123
        /**
124
         * The normal startup mode.
125
         */
126
        @NbBundle.Messages("StartMode_Normal=Normal")
127
        NORMAL(Bundle.StartMode_Normal()),
128
129
        /**
130
         * The debug startup mode.
131
         */
132
        @NbBundle.Messages("StartMode_Debug=Debug")
133
        DEBUG(Bundle.StartMode_Debug()),
134
135
        /**
136
         * The profile startup mode.
137
         */
138
        @NbBundle.Messages("StartMode_Profile=Profile")
139
        PROFILE(Bundle.StartMode_Profile());
140
141
        private final String mode;
142
143
        private StartMode(String mode) {
144
           this.mode = mode;
145
        }
146
147
        @Override
148
        public String toString() {
149
            return mode;
150
        }
151
    }
152
}
(-)5554c9288ff0 (+115 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.server;
43
44
import java.util.Collections;
45
import java.util.EnumSet;
46
import java.util.HashSet;
47
import java.util.List;
48
import java.util.Map;
49
import java.util.Set;
50
import org.netbeans.api.server.ServerInstance;
51
import org.netbeans.api.server.StartupArguments.StartMode;
52
import org.netbeans.modules.server.annotations.StartupArgumentsRegistrationProcessor;
53
import org.netbeans.spi.server.StartupArgumentsProvider;
54
55
/**
56
 *
57
 * @author Petr Hejl
58
 */
59
public class ProxyStartupArgumentsProvider implements StartupArgumentsProvider {
60
61
    private final Map attributes;
62
63
    private final Set<StartMode> startModes;
64
65
    private StartupArgumentsProvider delegate;
66
67
    private ProxyStartupArgumentsProvider(Map attributes) {
68
        this.attributes = attributes;
69
70
        String startModesValue = (String) attributes.get(
71
                StartupArgumentsRegistrationProcessor.START_MODES_ATTRIBUTE);
72
        if (startModesValue == null) {
73
            startModes = EnumSet.noneOf(StartMode.class);
74
        } else {
75
            Set<StartMode> result = new HashSet<StartMode>();
76
            for (String value : startModesValue.split(",")) {
77
                result.add(StartMode.valueOf(value));
78
            }
79
            startModes = EnumSet.copyOf(result);
80
        }
81
    }
82
83
    public static ProxyStartupArgumentsProvider create(Map map) {
84
        return new ProxyStartupArgumentsProvider(map);
85
    }
86
87
    @Override
88
    public List<String> getArguments(ServerInstance instance, StartMode mode) {
89
        if (startModes.contains(mode)) {
90
            return getDelegate().getArguments(instance, mode);
91
        }
92
        return Collections.emptyList();
93
    }
94
95
    private StartupArgumentsProvider getDelegate() {
96
        synchronized (this) {
97
            if (delegate != null) {
98
                return delegate;
99
            }
100
        }
101
102
        StartupArgumentsProvider provider = (StartupArgumentsProvider) attributes.get(
103
                StartupArgumentsRegistrationProcessor.DELEGATE_ATTRIBUTE);
104
        if (provider == null) {
105
            throw new IllegalStateException("Delegate must not be null");
106
        }
107
108
        synchronized (this) {
109
            if (delegate == null) {
110
                delegate = provider;
111
            }
112
            return delegate;
113
        }
114
    }
115
}
(-)5554c9288ff0 (+98 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 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 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.server.annotations;
43
44
import java.util.Set;
45
import javax.annotation.processing.Processor;
46
import javax.annotation.processing.RoundEnvironment;
47
import javax.annotation.processing.SupportedAnnotationTypes;
48
import javax.annotation.processing.SupportedSourceVersion;
49
import javax.lang.model.SourceVersion;
50
import javax.lang.model.element.Element;
51
import javax.lang.model.element.TypeElement;
52
import org.netbeans.api.server.StartupArguments.StartMode;
53
import org.netbeans.modules.server.ProxyStartupArgumentsProvider;
54
import org.netbeans.spi.server.StartupArgumentsProvider;
55
import org.openide.filesystems.annotations.LayerBuilder.File;
56
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
57
import org.openide.filesystems.annotations.LayerGenerationException;
58
import org.openide.util.lookup.ServiceProvider;
59
60
/**
61
 *
62
 * @author Petr Hejl
63
 */
64
@SupportedAnnotationTypes("org.netbeans.spi.server.StartupArgumentsProvider.Registration")
65
@ServiceProvider(service = Processor.class)
66
@SupportedSourceVersion(SourceVersion.RELEASE_6)
67
public class StartupArgumentsRegistrationProcessor extends LayerGeneratingProcessor {
68
69
    public static final String PATH = "Servers/StartupArgumentProviders"; // NOI18N
70
71
    public static final String DELEGATE_ATTRIBUTE = "delegate"; // NOI18N
72
73
    public static final String START_MODES_ATTRIBUTE = "startModes"; // NOI18N
74
75
    @Override
76
    protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
77
        for (Element element : roundEnv.getElementsAnnotatedWith(
78
                StartupArgumentsProvider.Registration.class)) {
79
80
            StringBuilder builder = new StringBuilder();
81
            for (StartMode mode : element.getAnnotation(StartupArgumentsProvider.Registration.class).startModes()) {
82
                builder.append(mode.name()).append(",");
83
            }
84
            if (builder.length() > 0) {
85
                builder.setLength(builder.length() - 1);
86
            }
87
            File f = layer(element).instanceFile(PATH, null)
88
                    .instanceAttribute(DELEGATE_ATTRIBUTE, StartupArgumentsProvider.class)
89
                    .stringvalue(START_MODES_ATTRIBUTE, builder.toString())
90
                    .bundlevalue("displayName", element.getAnnotation(StartupArgumentsProvider.Registration.class).displayName()) // NOI18N
91
                    .methodvalue("instanceCreate", ProxyStartupArgumentsProvider.class.getName(), "create") // NOI18N
92
                    .intvalue("position", element.getAnnotation(StartupArgumentsProvider.Registration.class).position()); // NOI18N
93
            f.write();
94
        }
95
        return true;
96
    }
97
98
}
(-)5554c9288ff0 (+100 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 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 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.spi.server;
43
44
import java.lang.annotation.ElementType;
45
import java.lang.annotation.Retention;
46
import java.lang.annotation.RetentionPolicy;
47
import java.lang.annotation.Target;
48
import java.util.List;
49
import org.netbeans.api.annotations.common.NonNull;
50
import org.netbeans.api.server.ServerInstance;
51
import org.netbeans.api.server.StartupArguments;
52
53
/**
54
 * Provides the additional arguments to server VM. Typically the server plugin
55
 * implementor will query the arguments via API counterpart {@link StartupArguments}.
56
 * Of course it is not mandatary for server plugin to use such arguments and
57
 * there is no way to force it.
58
 *
59
 * @author Petr Hejl
60
 * @since 1.19
61
 * @see StartupArguments
62
 */
63
public interface StartupArgumentsProvider {
64
65
    /**
66
     * Returns the list of arguments to pass to the server VM for the given
67
     * start mode.
68
     *
69
     * @param instance the server instance being started
70
     * @param mode the VM mode the client is going to use
71
     * @return the list of arguments to pass to the server VM
72
     */
73
    @NonNull
74
    List<String> getArguments(@NonNull ServerInstance instance, @NonNull StartupArguments.StartMode mode);
75
76
    /**
77
     * Annotation used to properly register the SPI implementations.
78
     */
79
    @Retention(RetentionPolicy.SOURCE)
80
    @Target({ElementType.TYPE, ElementType.METHOD})
81
    public @interface Registration {
82
83
        /**
84
         * The human readable description of the provider. May be a bundle key.
85
         * For example this might be "JRebel", "Profiler" etc.
86
         */
87
        String displayName();
88
89
        /**
90
         * Modes to which the provider will respond.
91
         */
92
        StartupArguments.StartMode[] startModes();
93
94
        /**
95
         * Position of the provider in the list of providers.
96
         */
97
        int position() default Integer.MAX_VALUE;
98
99
    }
100
}
(-)a/tomcat5/nbproject/project.xml (-1 / +10 lines)
Lines 176-182 Link Here
176
                    <compile-dependency/>
176
                    <compile-dependency/>
177
                    <run-dependency>
177
                    <run-dependency>
178
                        <release-version>4</release-version>
178
                        <release-version>4</release-version>
179
                        <specification-version>1.66</specification-version>
179
                        <specification-version>1.88</specification-version>
180
                    </run-dependency>
180
                    </run-dependency>
181
                </dependency>
181
                </dependency>
182
                <dependency>
182
                <dependency>
Lines 213-218 Link Here
213
                    </run-dependency>
213
                    </run-dependency>
214
                </dependency>
214
                </dependency>
215
                <dependency>
215
                <dependency>
216
                    <code-name-base>org.netbeans.modules.server</code-name-base>
217
                    <build-prerequisite/>
218
                    <compile-dependency/>
219
                    <run-dependency>
220
                        <release-version>0-1</release-version>
221
                        <specification-version>1.19</specification-version>
222
                    </run-dependency>
223
                </dependency>
224
                <dependency>
216
                    <code-name-base>org.openide.actions</code-name-base>
225
                    <code-name-base>org.openide.actions</code-name-base>
217
                    <build-prerequisite/>
226
                    <build-prerequisite/>
218
                    <compile-dependency/>
227
                    <compile-dependency/>
(-)a/tomcat5/src/org/netbeans/modules/tomcat5/ide/StartTomcat.java (-60 / +29 lines)
Lines 69-74 Link Here
69
import javax.enterprise.deploy.spi.status.ProgressListener;
69
import javax.enterprise.deploy.spi.status.ProgressListener;
70
import javax.enterprise.deploy.spi.status.ProgressObject;
70
import javax.enterprise.deploy.spi.status.ProgressObject;
71
import org.netbeans.api.java.platform.JavaPlatform;
71
import org.netbeans.api.java.platform.JavaPlatform;
72
import org.netbeans.api.server.StartupArguments;
73
import org.netbeans.modules.j2ee.deployment.plugins.api.CommonServerBridge;
72
import org.netbeans.modules.tomcat5.progress.ProgressEventSupport;
74
import org.netbeans.modules.tomcat5.progress.ProgressEventSupport;
73
import org.netbeans.modules.tomcat5.progress.Status;
75
import org.netbeans.modules.tomcat5.progress.Status;
74
import org.netbeans.modules.tomcat5.util.LogManager;
76
import org.netbeans.modules.tomcat5.util.LogManager;
Lines 78-84 Link Here
78
import org.openide.util.RequestProcessor;
80
import org.openide.util.RequestProcessor;
79
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
81
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
80
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
82
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
81
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
82
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport;
83
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport;
83
import org.netbeans.modules.tomcat5.TomcatManager;
84
import org.netbeans.modules.tomcat5.TomcatManager;
84
import org.netbeans.modules.tomcat5.util.TomcatProperties;
85
import org.netbeans.modules.tomcat5.util.TomcatProperties;
Lines 164-170 Link Here
164
    public ProgressObject startDeploymentManager () {
165
    public ProgressObject startDeploymentManager () {
165
        LOGGER.log(Level.FINE, "StartTomcat.startDeploymentManager called on " + tm);    // NOI18N
166
        LOGGER.log(Level.FINE, "StartTomcat.startDeploymentManager called on " + tm);    // NOI18N
166
        pes.fireHandleProgressEvent (null, new Status (ActionType.EXECUTE, CommandType.START, "", StateType.RUNNING));
167
        pes.fireHandleProgressEvent (null, new Status (ActionType.EXECUTE, CommandType.START, "", StateType.RUNNING));
167
        SERVER_CONTROL_RP.post(new StartRunnable(MODE_RUN, CommandType.START, null),
168
        SERVER_CONTROL_RP.post(new StartRunnable(MODE_RUN, CommandType.START),
168
                0, Thread.NORM_PRIORITY);
169
                0, Thread.NORM_PRIORITY);
169
        isDebugModeUri.remove(tm.getUri());
170
        isDebugModeUri.remove(tm.getUri());
170
        return this;
171
        return this;
Lines 227-233 Link Here
227
    public ProgressObject stopDeploymentManager() { 
228
    public ProgressObject stopDeploymentManager() { 
228
        LOGGER.log(Level.FINE, "StartTomcat.stopDeploymentManager called on " + tm);    // NOI18N
229
        LOGGER.log(Level.FINE, "StartTomcat.stopDeploymentManager called on " + tm);    // NOI18N
229
        pes.fireHandleProgressEvent (null, new Status (ActionType.EXECUTE, CommandType.STOP, "", StateType.RUNNING));
230
        pes.fireHandleProgressEvent (null, new Status (ActionType.EXECUTE, CommandType.STOP, "", StateType.RUNNING));
230
        SERVER_CONTROL_RP.post(new StartRunnable(MODE_RUN, CommandType.STOP, null),
231
        SERVER_CONTROL_RP.post(new StartRunnable(MODE_RUN, CommandType.STOP),
231
                0, Thread.NORM_PRIORITY);
232
                0, Thread.NORM_PRIORITY);
232
        isDebugModeUri.remove(tm.getUri());
233
        isDebugModeUri.remove(tm.getUri());
233
        return this;
234
        return this;
Lines 243-261 Link Here
243
    public ProgressObject startDebugging(Target target) {
244
    public ProgressObject startDebugging(Target target) {
244
        LOGGER.log(Level.FINE, "StartTomcat.startDebugging called on " + tm);    // NOI18N
245
        LOGGER.log(Level.FINE, "StartTomcat.startDebugging called on " + tm);    // NOI18N
245
        pes.fireHandleProgressEvent (null, new Status (ActionType.EXECUTE, CommandType.START, "", StateType.RUNNING));
246
        pes.fireHandleProgressEvent (null, new Status (ActionType.EXECUTE, CommandType.START, "", StateType.RUNNING));
246
        SERVER_CONTROL_RP.post(new StartRunnable(MODE_DEBUG, CommandType.START, null),
247
        SERVER_CONTROL_RP.post(new StartRunnable(MODE_DEBUG, CommandType.START),
247
                0, Thread.NORM_PRIORITY);
248
                0, Thread.NORM_PRIORITY);
248
        return this;
249
        return this;
249
    }
250
    }
250
    
251
    
251
    public ProgressObject startProfiling(Target target, ProfilerServerSettings settings) {
252
    public ProgressObject startProfiling(Target target) {
252
        LOGGER.log(Level.FINE, "StartTomcat.startProfiling called on " + tm); // NOI18N
253
        LOGGER.log(Level.FINE, "StartTomcat.startProfiling called on " + tm); // NOI18N
253
        pes.fireHandleProgressEvent(null, new Status(
254
        pes.fireHandleProgressEvent(null, new Status(
254
                                                ActionType.EXECUTE, 
255
                                                ActionType.EXECUTE, 
255
                                                CommandType.START, 
256
                                                CommandType.START, 
256
                                                "",  // NOI18N
257
                                                "",  // NOI18N
257
                                                StateType.RUNNING));
258
                                                StateType.RUNNING));
258
        SERVER_CONTROL_RP.post(new StartRunnable(MODE_PROFILE, CommandType.START, settings),
259
        SERVER_CONTROL_RP.post(new StartRunnable(MODE_PROFILE, CommandType.START),
259
                0, Thread.NORM_PRIORITY);
260
                0, Thread.NORM_PRIORITY);
260
        return this;
261
        return this;
261
    }
262
    }
Lines 275-286 Link Here
275
        
276
        
276
        private int mode;
277
        private int mode;
277
        private CommandType command = CommandType.START;
278
        private CommandType command = CommandType.START;
278
        private ProfilerServerSettings profilerSettings;
279
        
279
        
280
        public StartRunnable(int mode, CommandType command, ProfilerServerSettings profilerSettings) {
280
        public StartRunnable(int mode, CommandType command) {
281
            this.mode = mode;
281
            this.mode = mode;
282
            this.command = command;
282
            this.command = command;
283
            this.profilerSettings = profilerSettings;
284
        }
283
        }
285
        
284
        
286
        public synchronized void run () {
285
        public synchronized void run () {
Lines 398-408 Link Here
398
                        }
397
                        }
399
                    }
398
                    }
400
                }
399
                }
400
401
402
                for (StartupArguments args : StartupArguments.getStartupArguments(
403
                        CommonServerBridge.getCommonInstance(tm.getUri()), getMode(mode))) {
404
                    for (String singleArg : args.getArguments()) {
405
                        sb.append(' ').append(singleArg);
406
                    }
407
                }
401
                javaOpts = sb.toString();
408
                javaOpts = sb.toString();
402
            }
409
            }
403
            
410
            
404
            JavaPlatform platform = mode == MODE_PROFILE ? profilerSettings.getJavaPlatform()
411
            JavaPlatform platform = getJavaPlatform();
405
                                                         : getJavaPlatform();
406
            String jdkVersion = platform.getSpecification().getVersion().toString();
412
            String jdkVersion = platform.getSpecification().getVersion().toString();
407
            
413
            
408
            if (tm.isBundledTomcat()) {
414
            if (tm.isBundledTomcat()) {
Lines 460-513 Link Here
460
                            startupScript.getAbsolutePath(), StateType.FAILED);
466
                            startupScript.getAbsolutePath(), StateType.FAILED);
461
                    return;
467
                    return;
462
                }
468
                }
463
            } else if ((mode == MODE_PROFILE) && (command == CommandType.START)) {
464
                NbProcessDescriptor pd  = null;
465
                if (tp.getSecManager()) {
466
                    pd = defaultExecDesc(TAG_EXEC_CMD, TAG_EXEC_STARTUP, TAG_SECURITY_OPT);
467
                } else {
468
                    pd = defaultExecDesc(TAG_EXEC_CMD, TAG_EXEC_STARTUP);
469
                }
470
                try {
471
                    fireCmdExecProgressEvent("MSG_StartingInProfileMode", StateType.RUNNING);
472
                    Process p = null;
473
                    
474
                    String[] profJvmArgs = profilerSettings.getJvmArgs();
475
                    // TODO solve conflicts between profiler and tomcat vm args
476
                    StringBuffer catalinaOpts = new StringBuffer();
477
                    for (int i = 0; i < profJvmArgs.length; i++) {
478
                        catalinaOpts.append(profJvmArgs[i]).append(" "); // NOI18N
479
                    }
480
                    String[] defaultEnv = new String[] {
481
                        "JAVA_HOME="        + getJavaHome(platform),        // NOI18N
482
                        "JRE_HOME=",  // NOI18N ensure that JRE_HOME system property won't be used instead of JAVA_HOME
483
                        "JAVA_OPTS="        + javaOpts,             // NOI18N
484
                        "CATALINA_OPTS="    + catalinaOpts.toString(),      // NOI18N
485
                        "CATALINA_HOME="    + homeDir.getAbsolutePath(),    // NOI18N
486
                        "CATALINA_BASE="    + baseDir.getAbsolutePath(),    // NOI18N
487
                        // this is used in the setclasspath.sb/bat script for work-arounding 
488
                        // problems caused by the compatibility pack when running on 1.5
489
                        "NB_TOMCAT_JDK="    + jdkVersion,       // NOI18N
490
                        TomcatManager.KEY_UUID + "=" + tm.getUri()
491
                    };
492
                    String[] profEnv = profilerSettings.getEnv();
493
                    // merge Tomcat and profiler env properties
494
                    String[] envp = new String[defaultEnv.length + profEnv.length];
495
                    System.arraycopy(profEnv,       0, envp, 0,              profEnv.length);
496
                    System.arraycopy(defaultEnv,    0, envp, profEnv.length, defaultEnv.length);
497
                    p = pd.exec(
498
                        new TomcatFormat(startupScript, homeDir),
499
                        envp,
500
                        true,
501
                        new File(homeDir, "bin") // NOI18N
502
                    );
503
                    tm.setTomcatProcess(p);
504
                    openLogs();
505
                } catch (java.io.IOException ioe) {
506
                    LOGGER.log(Level.FINE, null, ioe);
507
                    fireCmdExecProgressEvent(command == CommandType.START ? "MSG_StartFailedIOE" : "MSG_StopFailedIOE",
508
                            startupScript.getAbsolutePath(), StateType.FAILED);
509
                    return;
510
                }
511
            } else {
469
            } else {
512
                NbProcessDescriptor pd = null;
470
                NbProcessDescriptor pd = null;
513
                if (command == CommandType.START) {
471
                if (command == CommandType.START) {
Lines 573-579 Link Here
573
                                         StateType.FAILED);
531
                                         StateType.FAILED);
574
            }
532
            }
575
        }
533
        }
576
        
534
535
        private StartupArguments.StartMode getMode(int mode) {
536
            switch (mode) {
537
                case MODE_PROFILE:
538
                    return StartupArguments.StartMode.PROFILE;
539
                case MODE_DEBUG:
540
                    return StartupArguments.StartMode.DEBUG;
541
                default:
542
                    return StartupArguments.StartMode.NORMAL;
543
            }
544
        }
545
577
        /** Open JULI log and server output */
546
        /** Open JULI log and server output */
578
        private void openLogs() {
547
        private void openLogs() {
579
            LogManager logManager = tm.logManager();
548
            LogManager logManager = tm.logManager();

Return to bug 206196