From f15f97b3dd048670bc50c8476d099bf1d2028470 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Thu, 29 Jul 2010 12:50:40 +0000 Subject: [PATCH] Delete unused objects git-svn-id: https://svn.argeo.org/slc/trunk@3726 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../spring/ApplicationContextTracker.java | 66 ----------- .../spring/SpringExtensionFactory.java | 105 ------------------ .../src/org/argeo/eclipse/ui/TreeObject.java | 26 ----- .../src/org/argeo/eclipse/ui/TreeParent.java | 44 -------- 4 files changed, 241 deletions(-) delete mode 100644 eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/spring/ApplicationContextTracker.java delete mode 100644 eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/spring/SpringExtensionFactory.java delete mode 100644 eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/ui/TreeObject.java delete mode 100644 eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/ui/TreeParent.java diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/spring/ApplicationContextTracker.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/spring/ApplicationContextTracker.java deleted file mode 100644 index be53a97fc..000000000 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/spring/ApplicationContextTracker.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.argeo.eclipse.spring; - -import static java.text.MessageFormat.format; - -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.util.tracker.ServiceTracker; -import org.springframework.context.ApplicationContext; - -/** - * @author Heiko Seeberger - */ -public class ApplicationContextTracker { - - private static final String FILTER = "(&(objectClass=org.springframework.context.ApplicationContext)" //$NON-NLS-1$ - + "(org.springframework.context.service.name={0}))"; //$NON-NLS-1$ - - private ServiceTracker applicationContextServiceTracker; - - /** - * @param contributorBundle - * OSGi bundle for which the Spring application context is to be - * tracked. Must not be null! - * @param factoryBundleContext - * BundleContext object which can be used to track services - * @throws IllegalArgumentException - * if the given bundle is null. - */ - public ApplicationContextTracker(final Bundle contributorBundle, final BundleContext factoryBundleContext) { - final String filter = format(FILTER, contributorBundle.getSymbolicName()); - try { - applicationContextServiceTracker = new ServiceTracker( - factoryBundleContext, FrameworkUtil.createFilter(filter), null); - applicationContextServiceTracker.open(); - } catch (final InvalidSyntaxException e) { - e.printStackTrace(); - } - } - - public void close() { - if (applicationContextServiceTracker != null) { - applicationContextServiceTracker.close(); - } - } - - public ApplicationContext getApplicationContext() { - ApplicationContext applicationContext = null; - if (applicationContextServiceTracker != null) { - try { - applicationContext = (ApplicationContext) applicationContextServiceTracker - .waitForService(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - return applicationContext; - } - - @Override - protected void finalize() throws Throwable { - close(); - super.finalize(); - } -} diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/spring/SpringExtensionFactory.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/spring/SpringExtensionFactory.java deleted file mode 100644 index 7e38dde33..000000000 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/spring/SpringExtensionFactory.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.argeo.eclipse.spring; - -import org.argeo.slc.client.ui.ClientUiPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExecutableExtension; -import org.eclipse.core.runtime.IExecutableExtensionFactory; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.Platform; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleException; -import org.springframework.context.ApplicationContext; - -/** - * The Spring Extension Factory builds a bridge between the Eclipse Extension - * Registry and the Spring Framework (especially Spring Dynamic Modules). - * - * It allows you to define your extension as a spring bean within the spring - * application context of your bundle. If you would like to use this bean as an - * instance of an extension (an Eclipse RCP view, for example) you define the - * extension with this spring extension factory as the class to be created. - * - * To let the spring extension factory pick the right bean from your application - * context you need to set the bean id to the same value as the id of the view - * within the view definition, for example. This is important if your extension - * definition contains more than one element, where each element has its own id. - * - * If the extension definition elements themselves have no id attribute the - * spring extension factory uses the id of the extension itself to identify the - * bean. - * - * @author Martin Lippert - */ -public class SpringExtensionFactory implements IExecutableExtensionFactory, - IExecutableExtension { - - private Object bean; - - public Object create() throws CoreException { - return bean; - } - - public void setInitializationData(IConfigurationElement config, - String propertyName, Object data) throws CoreException { - String beanName = getBeanName(data, config); - ApplicationContext appContext = getApplicationContext(config); - - if (beanName != null && appContext != null) { - this.bean = appContext.getBean(beanName); - if (this.bean instanceof IExecutableExtension) { - ((IExecutableExtension) this.bean).setInitializationData( - config, propertyName, data); - } - } - } - - private String getBeanName(Object data, IConfigurationElement config) { - - // try the specific bean id the extension defines - if (data != null && data.toString().length() > 0) { - return data.toString(); - } - - // try the id of the config element - if (config.getAttribute("id") != null) { - return config.getAttribute("id"); - } - - // try the id of the extension element itself - if (config.getParent() != null - && config.getParent() instanceof IExtension) { - IExtension extensionDefinition = (IExtension) config.getParent(); - return extensionDefinition.getSimpleIdentifier(); - } - - return null; - } - - private ApplicationContext getApplicationContext( - IConfigurationElement config) { - String contributorName = config.getContributor().getName(); - Bundle contributorBundle = Platform.getBundle(contributorName); - - if (contributorBundle.getState() != Bundle.ACTIVE && contributorBundle.getState() != Bundle.STARTING) { - try { - System.out.println("starting bundle: " + contributorBundle.getSymbolicName()); - contributorBundle.start(); - } catch (BundleException e) { - e.printStackTrace(); - } - } - - final ApplicationContextTracker applicationContextTracker = new ApplicationContextTracker( - contributorBundle, ClientUiPlugin.getDefault().getBundleContext()); - ApplicationContext applicationContext = null; - try { - applicationContext = applicationContextTracker - .getApplicationContext(); - } finally { - applicationContextTracker.close(); - } - return applicationContext; - } - -} diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/ui/TreeObject.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/ui/TreeObject.java deleted file mode 100644 index d75db780e..000000000 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/ui/TreeObject.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.argeo.eclipse.ui; - -public class TreeObject { - private String name; - private TreeParent parent; - - public TreeObject(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setParent(TreeParent parent) { - this.parent = parent; - } - - public TreeParent getParent() { - return parent; - } - - public String toString() { - return getName(); - } -} diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/ui/TreeParent.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/ui/TreeParent.java deleted file mode 100644 index d45844de2..000000000 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/eclipse/ui/TreeParent.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.argeo.eclipse.ui; - -import java.util.ArrayList; -import java.util.List; - -public class TreeParent extends TreeObject { - private List children; - - private boolean loaded; - - public TreeParent(String name) { - super(name); - children = new ArrayList(); - loaded = false; - } - - public synchronized void addChild(TreeObject child) { - loaded = true; - children.add(child); - child.setParent(this); - } - - public synchronized void removeChild(TreeObject child) { - children.remove(child); - child.setParent(null); - } - - public synchronized void clearChildren() { - loaded = false; - children.clear(); - } - - public synchronized TreeObject[] getChildren() { - return (TreeObject[]) children.toArray(new TreeObject[children.size()]); - } - - public synchronized boolean hasChildren() { - return children.size() > 0; - } - - public synchronized Boolean isLoaded() { - return loaded; - } -} -- 2.39.2