Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-12-21 18:29:01 +0000
committerEike Stepper2010-12-21 18:29:01 +0000
commit7eba4b0444b3c6c43b3c6dc7bcf70333b313fddf (patch)
tree8299b24484ccdf5bd44b68d0661cddc1c7b8eaab /plugins
parent8dcd7476ad955bc0e2caca3b8090fb070da2e119 (diff)
downloadcdo-7eba4b0444b3c6c43b3c6dc7bcf70333b313fddf.tar.gz
cdo-7eba4b0444b3c6c43b3c6dc7bcf70333b313fddf.tar.xz
cdo-7eba4b0444b3c6c43b3c6dc7bcf70333b313fddf.zip
[332355] Provide OSGi console commands to start/stop/list/export/import repositories
https://bugs.eclipse.org/bugs/show_bug.cgi?id=332355
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/internal/ui/bundle/OM.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.util/src/org/eclipse/emf/cdo/dawn/internal/util/bundle/OM.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/internal/dawn/bundle/OM.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/bundle/Net4jAppExtension.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/bundle/OM.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOCommandProvider.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOServerApplication.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.shared/src/org/eclipse/emf/cdo/ui/internal/icons/bundle/OM.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java9
-rw-r--r--plugins/org.eclipse.net4j.ui.shared/src/org/eclipse/net4j/ui/internal/icons/bundle/OM.java5
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/OM.java5
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/bundle/OM.java5
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIActivator.java3
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4jCommandProvider.java111
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OM.java6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Channel.java7
16 files changed, 156 insertions, 36 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/internal/ui/bundle/OM.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/internal/ui/bundle/OM.java
index 8703491dd8..d48735dba1 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/internal/ui/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/internal/ui/bundle/OM.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Martin Fluegge - initial API and implementation
******************************************************************************/
@@ -14,7 +14,6 @@ import org.eclipse.net4j.util.om.OMBundle;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.OSGiActivator;
import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.pref.OMPreferences;
import org.eclipse.net4j.util.om.trace.OMTracer;
/**
@@ -32,8 +31,6 @@ public abstract class OM
public static final OMLogger LOG = BUNDLE.logger();
- public static final OMPreferences PREFS = BUNDLE.preferences();
-
/**
* @author Martin Fluegge
* @since 1.0
diff --git a/plugins/org.eclipse.emf.cdo.dawn.util/src/org/eclipse/emf/cdo/dawn/internal/util/bundle/OM.java b/plugins/org.eclipse.emf.cdo.dawn.util/src/org/eclipse/emf/cdo/dawn/internal/util/bundle/OM.java
index 11a91f6f39..a41a2e24a7 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.util/src/org/eclipse/emf/cdo/dawn/internal/util/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.util/src/org/eclipse/emf/cdo/dawn/internal/util/bundle/OM.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Martin Fluegge - initial API and implementation
******************************************************************************/
@@ -14,7 +14,6 @@ import org.eclipse.net4j.util.om.OMBundle;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.OSGiActivator;
import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.pref.OMPreferences;
import org.eclipse.net4j.util.om.trace.OMTracer;
/**
@@ -32,8 +31,6 @@ public abstract class OM
public static final OMLogger LOG = BUNDLE.logger();
- public static final OMPreferences PREFS = BUNDLE.preferences();
-
/**
* @author Martin Fluegge
* @since 1.0
diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/internal/dawn/bundle/OM.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/internal/dawn/bundle/OM.java
index 31d28bdebd..5037672fd1 100644
--- a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/internal/dawn/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/internal/dawn/bundle/OM.java
@@ -13,7 +13,6 @@ package org.eclipse.emf.cdo.internal.dawn.bundle;
import org.eclipse.net4j.util.om.OMBundle;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.pref.OMPreferences;
import org.eclipse.net4j.util.om.trace.OMTracer;
/**
@@ -30,6 +29,4 @@ public abstract class OM
public static final OMTracer DEBUG_OBJECT = DEBUG.tracer("object"); //$NON-NLS-1$
public static final OMLogger LOG = BUNDLE.logger();
-
- public static final OMPreferences PREFS = BUNDLE.preferences();
}
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/bundle/Net4jAppExtension.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/bundle/Net4jAppExtension.java
index 0e8ebe347c..b8e3bd2e24 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/bundle/Net4jAppExtension.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/bundle/Net4jAppExtension.java
@@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.spi.server.IAppExtension;
import org.eclipse.net4j.TransportConfigurator;
import org.eclipse.net4j.acceptor.IAcceptor;
+import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.container.IPluginContainer;
import java.io.File;
@@ -32,7 +33,7 @@ public class Net4jAppExtension implements IAppExtension
public void start(File configFile) throws Exception
{
OM.LOG.info("Net4j extension starting"); //$NON-NLS-1$
- TransportConfigurator net4jConfigurator = new TransportConfigurator(IPluginContainer.INSTANCE);
+ TransportConfigurator net4jConfigurator = new TransportConfigurator(getContainer());
acceptors = net4jConfigurator.configure(configFile);
if (acceptors == null || acceptors.length == 0)
{
@@ -55,4 +56,9 @@ public class Net4jAppExtension implements IAppExtension
OM.LOG.info("Net4j extension stopped"); //$NON-NLS-1$
}
+
+ public static IManagedContainer getContainer()
+ {
+ return IPluginContainer.INSTANCE;
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/bundle/OM.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/bundle/OM.java
index 98d0105012..451d3ff07d 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/bundle/OM.java
@@ -18,7 +18,7 @@ import org.eclipse.net4j.util.om.trace.OMTracer;
/**
* The <em>Operations & Maintenance</em> class of this bundle.
- *
+ *
* @author Eike Stepper
*/
public abstract class OM
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOCommandProvider.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOCommandProvider.java
index 43b26fcd6a..a6bfb5457c 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOCommandProvider.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOCommandProvider.java
@@ -15,7 +15,7 @@ import org.eclipse.emf.cdo.spi.server.InternalSessionManager;
import org.eclipse.emf.cdo.spi.server.InternalView;
import org.eclipse.emf.cdo.spi.server.RepositoryFactory;
-import org.eclipse.net4j.util.container.IPluginContainer;
+import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.io.IOUtil;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
@@ -124,7 +124,7 @@ public class CDOCommandProvider implements CommandProvider
protected void list(CommandInterpreter interpreter) throws Exception
{
- IPluginContainer container = CDOServerApplication.getContainer();
+ IManagedContainer container = CDOServerApplication.getContainer();
for (Object element : container.getElements(RepositoryFactory.PRODUCT_GROUP))
{
if (element instanceof InternalRepository)
@@ -139,7 +139,7 @@ public class CDOCommandProvider implements CommandProvider
{
String configFile = nextArgument(interpreter, "Syntax: cdo start <config-file>");
- IPluginContainer container = CDOServerApplication.getContainer();
+ IManagedContainer container = CDOServerApplication.getContainer();
RepositoryConfigurator repositoryConfigurator = new RepositoryConfigurator(container);
IRepository[] repositories = repositoryConfigurator.configure(new File(configFile));
@@ -196,7 +196,7 @@ public class CDOCommandProvider implements CommandProvider
CDOServerImporter.XML importer = new CDOServerImporter.XML(repository);
importer.importRepository(in);
- IPluginContainer container = CDOServerApplication.getContainer();
+ IManagedContainer container = CDOServerApplication.getContainer();
CDOServerUtil.addRepository(container, repository);
interpreter.println("Repository imported");
@@ -276,7 +276,7 @@ public class CDOCommandProvider implements CommandProvider
private InternalRepository getRepository(String name)
{
- IPluginContainer container = CDOServerApplication.getContainer();
+ IManagedContainer container = CDOServerApplication.getContainer();
for (Object element : container.getElements(RepositoryFactory.PRODUCT_GROUP))
{
if (element instanceof InternalRepository)
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOServerApplication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOServerApplication.java
index 4a4e63ab0c..12bcb7b7ba 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOServerApplication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOServerApplication.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.internal.server.messages.Messages;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.spi.server.IAppExtension;
+import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.OMPlatform;
@@ -50,7 +51,7 @@ public class CDOServerApplication extends OSGiApplication
protected void doStart() throws Exception
{
super.doStart();
- IPluginContainer container = getContainer();
+ IManagedContainer container = getContainer();
OM.LOG.info(Messages.getString("CDOServerApplication.1")); //$NON-NLS-1$
File configFile = OMPlatform.INSTANCE.getConfigFile("cdo-server.xml"); //$NON-NLS-1$
@@ -129,7 +130,7 @@ public class CDOServerApplication extends OSGiApplication
}
}
- public static IPluginContainer getContainer()
+ public static IManagedContainer getContainer()
{
return IPluginContainer.INSTANCE;
}
diff --git a/plugins/org.eclipse.emf.cdo.ui.shared/src/org/eclipse/emf/cdo/ui/internal/icons/bundle/OM.java b/plugins/org.eclipse.emf.cdo.ui.shared/src/org/eclipse/emf/cdo/ui/internal/icons/bundle/OM.java
index 6b18fbcd2c..589c8557c9 100644
--- a/plugins/org.eclipse.emf.cdo.ui.shared/src/org/eclipse/emf/cdo/ui/internal/icons/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.ui.shared/src/org/eclipse/emf/cdo/ui/internal/icons/bundle/OM.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.util.om.OMBundle;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.OSGiActivator;
import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.pref.OMPreferences;
import org.eclipse.net4j.util.om.trace.OMTracer;
/**
@@ -35,8 +34,6 @@ public abstract class OM
public static final OMLogger LOG = BUNDLE.logger();
- public static final OMPreferences PREFS = BUNDLE.preferences();
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java
index 1f8ab76cab..508312d6b4 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Eike Stepper - initial API and implementation
* Victor Roldan Betancort - maintenance
@@ -65,4 +65,11 @@ public class OpenSessionDialog extends TitleAreaDialog
sessionComposite = new SessionComposite(parent, SWT.NONE);
return sessionComposite;
}
+
+ @Override
+ protected void okPressed()
+ {
+ sessionComposite.rememberSettings();
+ super.okPressed();
+ }
}
diff --git a/plugins/org.eclipse.net4j.ui.shared/src/org/eclipse/net4j/ui/internal/icons/bundle/OM.java b/plugins/org.eclipse.net4j.ui.shared/src/org/eclipse/net4j/ui/internal/icons/bundle/OM.java
index d98ae742f9..8da88da97b 100644
--- a/plugins/org.eclipse.net4j.ui.shared/src/org/eclipse/net4j/ui/internal/icons/bundle/OM.java
+++ b/plugins/org.eclipse.net4j.ui.shared/src/org/eclipse/net4j/ui/internal/icons/bundle/OM.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Martin Fluegge - initial API and implementation
*/
@@ -14,7 +14,6 @@ import org.eclipse.net4j.util.om.OMBundle;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.OSGiActivator;
import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.pref.OMPreferences;
import org.eclipse.net4j.util.om.trace.OMTracer;
/**
@@ -32,8 +31,6 @@ public abstract class OM
public static final OMLogger LOG = BUNDLE.logger();
- public static final OMPreferences PREFS = BUNDLE.preferences();
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/OM.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/OM.java
index caa1adfe6a..3a9a8655ae 100644
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/OM.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/OM.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Eike Stepper - initial API and implementation
*/
@@ -13,7 +13,6 @@ package org.eclipse.net4j.internal.ui.bundle;
import org.eclipse.net4j.util.om.OMBundle;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.pref.OMPreferences;
import org.eclipse.net4j.util.om.trace.OMTracer;
import org.eclipse.net4j.util.ui.UIActivator;
@@ -32,8 +31,6 @@ public abstract class OM
public static final OMLogger LOG = BUNDLE.logger();
- public static final OMPreferences PREFS = BUNDLE.preferences();
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/bundle/OM.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/bundle/OM.java
index 0e17fef23e..a00b0e71fb 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/bundle/OM.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/bundle/OM.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Eike Stepper - initial API and implementation
*/
@@ -13,7 +13,6 @@ package org.eclipse.net4j.util.internal.ui.bundle;
import org.eclipse.net4j.util.om.OMBundle;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.pref.OMPreferences;
import org.eclipse.net4j.util.om.trace.OMTracer;
import org.eclipse.net4j.util.ui.UIActivator;
@@ -34,8 +33,6 @@ public abstract class OM
public static final OMLogger LOG = BUNDLE.logger();
- public static final OMPreferences PREFS = BUNDLE.preferences();
-
public static ImageDescriptor getImageDescriptor(String imageFilePath)
{
return Activator.imageDescriptorFromPlugin(BUNDLE_ID, imageFilePath);
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIActivator.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIActivator.java
index fcdb99516d..2343127f3f 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIActivator.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIActivator.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.net4j.util.ui;
+import org.eclipse.net4j.internal.util.bundle.AbstractBundle;
import org.eclipse.net4j.util.om.OMBundle;
import org.eclipse.net4j.util.om.OSGiActivator;
import org.eclipse.net4j.util.om.OSGiActivator.StateHandler;
@@ -54,6 +55,7 @@ public class UIActivator extends AbstractUIPlugin
{
super.start(context);
omBundle.setBundleContext(context);
+ ((AbstractBundle)omBundle).start();
doStart();
}
catch (Error error)
@@ -80,6 +82,7 @@ public class UIActivator extends AbstractUIPlugin
try
{
doStop();
+ ((AbstractBundle)omBundle).stop();
omBundle.setBundleContext(null);
super.stop(context);
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4jCommandProvider.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4jCommandProvider.java
new file mode 100644
index 0000000000..4e9b924dc7
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4jCommandProvider.java
@@ -0,0 +1,111 @@
+package org.eclipse.internal.net4j.bundle;
+
+import org.eclipse.net4j.acceptor.IAcceptor;
+import org.eclipse.net4j.channel.IChannel;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.util.container.IPluginContainer;
+
+import org.eclipse.osgi.framework.console.CommandInterpreter;
+import org.eclipse.osgi.framework.console.CommandProvider;
+import org.eclipse.spi.net4j.AcceptorFactory;
+import org.eclipse.spi.net4j.ConnectorFactory;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * @author Eike Stepper
+ */
+public class Net4jCommandProvider implements CommandProvider
+{
+ public Net4jCommandProvider(BundleContext bundleContext)
+ {
+ bundleContext.registerService(CommandProvider.class.getName(), this, null);
+ }
+
+ public String getHelp()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("---Net4j commands---\n");
+ buffer.append("\tacceptors list - list all active acceptors, their connectors and channels\n");
+ buffer.append("\tconnectors list - list all active connectors and their channels\n");
+ return buffer.toString();
+ }
+
+ public Object _acceptors(CommandInterpreter interpreter)
+ {
+ try
+ {
+ String cmd = interpreter.nextArgument();
+ if ("list".equals(cmd))
+ {
+ acceptorsList(interpreter);
+ return null;
+ }
+
+ interpreter.println(getHelp());
+ }
+ catch (Exception ex)
+ {
+ interpreter.printStackTrace(ex);
+ }
+
+ return null;
+ }
+
+ public Object _connectors(CommandInterpreter interpreter)
+ {
+ try
+ {
+ String cmd = interpreter.nextArgument();
+ if ("list".equals(cmd))
+ {
+ connectorsList(interpreter);
+ return null;
+ }
+
+ interpreter.println(getHelp());
+ }
+ catch (Exception ex)
+ {
+ interpreter.printStackTrace(ex);
+ }
+
+ return null;
+ }
+
+ protected void acceptorsList(CommandInterpreter interpreter) throws Exception
+ {
+ for (Object element : IPluginContainer.INSTANCE.getElements(AcceptorFactory.PRODUCT_GROUP))
+ {
+ if (element instanceof IAcceptor)
+ {
+ IAcceptor acceptor = (IAcceptor)element;
+ interpreter.println(acceptor);
+ for (IConnector connector : acceptor.getAcceptedConnectors())
+ {
+ interpreter.println(" " + connector);
+ for (IChannel channel : connector.getChannels())
+ {
+ interpreter.println(" " + channel);
+ }
+ }
+ }
+ }
+ }
+
+ protected void connectorsList(CommandInterpreter interpreter) throws Exception
+ {
+ for (Object element : IPluginContainer.INSTANCE.getElements(ConnectorFactory.PRODUCT_GROUP))
+ {
+ if (element instanceof IConnector)
+ {
+ IConnector connector = (IConnector)element;
+ interpreter.println(connector);
+ for (IChannel channel : connector.getChannels())
+ {
+ interpreter.println(" " + channel);
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OM.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OM.java
index 5dcbdc830c..f77ce86e9b 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OM.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/OM.java
@@ -55,5 +55,11 @@ public abstract class OM
{
super(BUNDLE);
}
+
+ @Override
+ protected void doStart() throws Exception
+ {
+ new Net4jCommandProvider(bundleContext);
+ }
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Channel.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Channel.java
index f79095f3aa..f2400e0b49 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Channel.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Channel.java
@@ -15,6 +15,7 @@ import org.eclipse.net4j.buffer.BufferState;
import org.eclipse.net4j.buffer.IBuffer;
import org.eclipse.net4j.buffer.IBufferHandler;
import org.eclipse.net4j.channel.IChannelMultiplexer;
+import org.eclipse.net4j.protocol.IProtocol;
import org.eclipse.net4j.util.concurrent.IWorkSerializer;
import org.eclipse.net4j.util.concurrent.QueueWorkerWorkSerializer;
import org.eclipse.net4j.util.concurrent.SynchronousWorkSerializer;
@@ -248,6 +249,12 @@ public class Channel extends Lifecycle implements InternalChannel
@Override
public String toString()
{
+ if (receiveHandler instanceof IProtocol)
+ {
+ IProtocol<?> protocol = (IProtocol<?>)receiveHandler;
+ return MessageFormat.format("Channel[{0}, {1}, {2}]", id, getLocation(), protocol.getType()); //$NON-NLS-1$
+ }
+
return MessageFormat.format("Channel[{0}, {1}]", id, getLocation()); //$NON-NLS-1$
}

Back to the top