alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.openide.debugger;

import java.util.Collections;
import java.util.Enumeration;
import java.util.Set;
import org.openide.ErrorManager;

import org.openide.execution.ExecInfo;
import org.openide.ServiceType;
import org.openide.util.HelpCtx;
import org.openide.loaders.DataObject;
import org.openide.cookies.ArgumentsCookie;
import org.openide.util.Lookup;
import org.openide.util.WeakSet;

/** Defines one debugger type. It has method start that accepts ExecInfo and should
* probably create new DebuggerInfo and call Debugger.startDebug (debuggerInfo).
* The type should be serializable, so it can be attached to file attributes
* of any object that wishes to be especially debugged.
*
* 

This class currently has a property editor in the IDE's * default editor search path. * * @deprecated Use new Debugger API (http://www.netbeans.org/download/dev/javadoc/). * @author Jaroslav Tulach */ public abstract class DebuggerType extends ServiceType { static final long serialVersionUID =-3659300496270314301L; /** Should start the debugging of this type. * @param info class and parameters to run * @param stopOnMain should the debugging stop on main method or go to first breakpoint * @exception DebuggerException if debugger is not installed or cannot be started * @deprecated This method is a relic of Java-specific execution. New DebuggerType * implementations are encouraged to implement this method to throw an * exception, and override {@link #startDebugger(DataObject,boolean)} to be the actual implementation. * More info */ public abstract void startDebugger (ExecInfo info, boolean stopOnMain) throws DebuggerException; private final static Set warnedClasses = new WeakSet(); // Set /** Starts debugging for a data object. * The default implementation assumes this object behaves akin to a Java class * by having a package-qualified object name and arguments as given by * {@link ArgumentsCookie} and delegates to {@link #startDebugger(ExecInfo,boolean)}. * Must be overridden. * @param obj object to run * @param stopOnMain should the debugging stop on main method or go to first breakpoint * @exception DebuggerException if debugger is not installed or cannot be started */ public void startDebugger(DataObject obj, boolean stopOnMain) throws DebuggerException { throw new DebuggerException("No longer works!"); // NOI18N /* Class c = getClass(); synchronized (warnedClasses) { if (warnedClasses.add(c)) { ErrorManager.getDefault().log(ErrorManager.WARNING, "Warning - " + c.getName() + " should have overridden startDebugger(DataObject,boolean); falling back on deprecated ExecInfo usage; see: http://www.netbeans.org/download/dev/javadoc/OpenAPIs/org/openide/doc-files/upgrade.html#3.5i-sep-II-ExecInfo"); } } String[] params; ArgumentsCookie ac = (ArgumentsCookie) obj.getCookie(getKlass("org.openide.cookies.ArgumentsCookie")); if (ac != null) { params = ac.getArguments(); } else { params = new String[0]; } startDebugger(new ExecInfo(obj.getPrimaryFile().getPackageName ('.'), params), stopOnMain); */ } public HelpCtx getHelpCtx () { return new HelpCtx (DebuggerType.class); } /** Get all registered executors in the system's execution engine. * @return enumeration of DebuggerTypes * @deprecated Please use {@link org.openide.util.Lookup} instead. */ public static Enumeration debuggerTypes () { return Collections.enumeration(Lookup.getDefault().lookup(new Lookup.Template(DebuggerType.class)).allInstances()); } /** Find the * debugger implemented as a given class, among the executors registered to the * execution engine. *

* This should be used during (de-)serialization * of the specific debugger for a data object: only store its class name * and then try to find the debugger implemented by that class later. * * @param clazz the class of the debugger looked for * @return the desired debugger or null if it does not exist * @deprecated Please use {@link org.openide.util.Lookup} instead. */ public static DebuggerType find (Class clazz) { return (DebuggerType)Lookup.getDefault().lookup(clazz); } /** Find the * debugger with requested name, among the executors registered to the * execution engine. *

* This should be used during (de-)serialization * of the specific debugger for a data object: only store its name * and then try to find the debugger later. * * @param name (display) name of debugger to find * @return the desired debugger or null if it does not exist */ public static DebuggerType find (String name) { ServiceType.Registry r = (ServiceType.Registry)Lookup.getDefault().lookup(ServiceType.Registry.class); ServiceType t = r.find (name); if (t instanceof DebuggerType) { return (DebuggerType)t; } else { return null; } } /** Get the default debugger for the system's execution engine. *

You may actually want {@link org.openide.loaders.ExecSupport#getExecutor}. * @return the default debugger * @deprecated There is probably not a single debugger type meaningfully applicable to all file types. * If you explicitly want to invoke the plain Debugger interfaces, use {@link DebuggerType.Default} instead. */ public static DebuggerType getDefault () { Enumeration en = debuggerTypes (); if (en.hasMoreElements ()) { return (DebuggerType)en.nextElement (); } else { return new Default (); } } // lazily loads a class private final Class getKlass(String name) { try { return Class.forName(name, false, getClass().getClassLoader()); } catch (ClassNotFoundException e) { throw new NoClassDefFoundError(e.getLocalizedMessage()); } } /** Default debugger type. */ public static class Default extends DebuggerType { static final long serialVersionUID =6286540187114472027L; /* Gets the display name for this debugger type. */ public String displayName() { return org.openide.util.NbBundle.getBundle( Default.class ).getString("LAB_DefaultDebuggerType"); } public HelpCtx getHelpCtx () { return new HelpCtx (Default.class); } /* Starts the debugger. */ public void startDebugger(ExecInfo info, boolean stopOnMain) throws DebuggerException { Debugger d = (Debugger)Lookup.getDefault().lookup(Debugger.class); if (stopOnMain) d.startDebugger(new DebuggerInfo( info.getClassName(), info.getArguments())); else d.startDebugger(new DebuggerInfo( info.getClassName(), info.getArguments(), null)); } } // end of inner class DefaultDebuggerType }

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.