[jboss-cvs] jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core ...

Robert Stryker rob.stryker at jboss.com
Mon Apr 16 13:50:45 EDT 2007


  User: rawb    
  Date: 07/04/16 13:50:45

  Added:       core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core   
                        Trace.java ExtensionManager.java
                        PackagesCorePlugin.java
  Log:
  Complete rewrite of the the two plugins leading to a cleaner, leaner project. 
  
  Revision  Changes    Path
  1.6       +0 -0      jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/Trace.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Trace.java
  ===================================================================
  RCS file: Trace.java
  diff -N Trace.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ Trace.java	16 Apr 2007 17:50:45 -0000	1.6
  @@ -0,0 +1,54 @@
  +package org.jboss.ide.eclipse.packages.core;
  +
  +import org.eclipse.core.runtime.Platform;
  +
  +public class Trace {
  +
  +	public static final String DEBUG_OPTION_ROOT = "org.jboss.ide.eclipse.packages.core/debug/";
  +	public static final String DEBUG_OPTION_STREAM_CLOSE = DEBUG_OPTION_ROOT + "streamClose";
  +	
  +	public static boolean isDebugging(String option)
  +	{
  +		return PackagesCorePlugin.getDefault().isDebugging()
  +			&& "true".equalsIgnoreCase(Platform.getDebugOption(option));
  +	}
  +	
  +	public static void trace (Class caller, String message)
  +	{
  +		trace(caller, message, null);
  +	}
  +	
  +	public static void trace (Class caller, String message, String option)
  +	{
  +		trace(caller, message, null, option);
  +	}
  +	
  +	public static void trace (Class caller, Throwable t)
  +	{
  +		trace(caller, t, null);
  +	}
  +	
  +	public static void trace (Class caller, Throwable t, String option)
  +	{
  +		trace(caller, t.getMessage(), t, option);
  +	}
  +	
  +	public static void trace (Class caller, String message, Throwable t, String option)
  +	{
  +		if (!PackagesCorePlugin.getDefault().isDebugging())
  +			return;
  +
  +		if (option != null) {
  +			if (!isDebugging(option))
  +				return;
  +		}
  +		
  +		System.out.println("[" + caller.getName() + "] " + message);
  +		
  +		if (t != null)
  +		{
  +			t.printStackTrace();
  +		}
  +	}
  +	
  +}
  
  
  
  1.10      +0 -0      jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/ExtensionManager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ExtensionManager.java
  ===================================================================
  RCS file: ExtensionManager.java
  diff -N ExtensionManager.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ ExtensionManager.java	16 Apr 2007 17:50:45 -0000	1.10
  @@ -0,0 +1,64 @@
  +package org.jboss.ide.eclipse.packages.core;
  +
  +import java.util.ArrayList;
  +import java.util.Hashtable;
  +
  +import org.eclipse.core.runtime.CoreException;
  +import org.eclipse.core.runtime.IConfigurationElement;
  +import org.eclipse.core.runtime.IExtension;
  +import org.eclipse.core.runtime.IExtensionPoint;
  +import org.eclipse.core.runtime.IExtensionRegistry;
  +import org.eclipse.core.runtime.InvalidRegistryObjectException;
  +import org.eclipse.core.runtime.Platform;
  +import org.jboss.ide.eclipse.packages.core.model.types.IPackageType;
  +
  +public class ExtensionManager {
  +	public static final String PACKAGE_TYPES_EXTENSION_ID = "org.jboss.ide.eclipse.packages.core.packageTypes";
  +	
  +	public static IExtension[] findExtension (String extensionId)
  +	{
  +		IExtensionRegistry registry = Platform.getExtensionRegistry();
  +		IExtensionPoint extensionPoint = registry.getExtensionPoint(extensionId);
  +		return extensionPoint.getExtensions();
  +	}
  +	
  +	public static IPackageType[] findPackageTypes ()
  +	{
  +		ArrayList packageTypes = new ArrayList();
  +		IExtension[] extensions = findExtension(PACKAGE_TYPES_EXTENSION_ID);
  +		
  +		for (int i = 0; i < extensions.length; i++)
  +		{
  +			IConfigurationElement elements[] = extensions[i].getConfigurationElements();
  +			for (int j = 0; j < elements.length; j++)
  +			{
  +				try {
  +					Object executable = elements[j].createExecutableExtension("class");
  +					packageTypes.add((IPackageType)executable);
  +				} catch (InvalidRegistryObjectException e) {
  +					Trace.trace(ExtensionManager.class, e);
  +				} catch( CoreException e ) {
  +					Trace.trace(ExtensionManager.class, e);
  +				}
  +			}
  +		}
  +		
  +		return (IPackageType[]) packageTypes.toArray(new IPackageType[packageTypes.size()]);
  +	}
  +	
  +	private static Hashtable packageTypes;
  +	public static IPackageType getPackageType (String packageType) {
  +		if (packageTypes == null)
  +		{
  +			packageTypes = new Hashtable();
  +			IPackageType[] registeredTypes = ExtensionManager.findPackageTypes();
  +			for (int i = 0; i < registeredTypes.length; i++)	
  +			{
  +				packageTypes.put(registeredTypes[i].getId(), registeredTypes[i]);
  +			}
  +		}
  +		return (IPackageType) packageTypes.get(packageType);
  +	}
  +
  +	
  +}
  
  
  
  1.9       +0 -0      jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/PackagesCorePlugin.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PackagesCorePlugin.java
  ===================================================================
  RCS file: PackagesCorePlugin.java
  diff -N PackagesCorePlugin.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ PackagesCorePlugin.java	16 Apr 2007 17:50:45 -0000	1.9
  @@ -0,0 +1,75 @@
  +/*
  + * JBoss, a division of Red Hat
  + * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
  + * by the @authors tag. See the copyright.txt in the distribution for a
  + * full listing of individual contributors.
  + *
  + * This is free software; you can redistribute it and/or modify it
  + * under the terms of the GNU Lesser General Public License as
  + * published by the Free Software Foundation; either version 2.1 of
  + * the License, or (at your option) any later version.
  + *
  + * This software is distributed in the hope that it will be useful,
  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  + * Lesser General Public License for more details.
  + *
  + * You should have received a copy of the GNU Lesser General Public
  + * License along with this software; if not, write to the Free
  + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  + */
  +package org.jboss.ide.eclipse.packages.core;
  +
  +import org.eclipse.core.runtime.Plugin;
  +import org.jboss.ide.eclipse.packages.core.model.internal.xb.XMLBinding;
  +import org.osgi.framework.BundleContext;
  +
  +/**
  + * The activator class controls the plug-in life cycle
  + */
  +public class PackagesCorePlugin extends Plugin {
  +
  +	// The plug-in ID
  +	public static final String PLUGIN_ID = "org.jboss.ide.eclipse.packages.core";
  +
  +	// The shared instance
  +	private static PackagesCorePlugin plugin;
  +	
  +	/**
  +	 * The constructor
  +	 */
  +	public PackagesCorePlugin() {
  +		plugin = this;
  +	}
  +
  +	/*
  +	 * (non-Javadoc)
  +	 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
  +	 */
  +	public void start(BundleContext context) throws Exception {
  +		super.start(context);
  +		
  +		// force JBossXB initialization
  +		XMLBinding.init();
  +	}
  +
  +	/*
  +	 * (non-Javadoc)
  +	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
  +	 */
  +	public void stop(BundleContext context) throws Exception {
  +		plugin = null;
  +		super.stop(context);
  +	}
  +
  +	/**
  +	 * Returns the shared instance
  +	 *
  +	 * @return the shared instance
  +	 */
  +	public static PackagesCorePlugin getDefault() {
  +		return plugin;
  +	}
  +
  +}
  
  
  



More information about the jboss-cvs-commits mailing list