Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-07-19 08:22:04 +0000
committerEike Stepper2012-07-19 08:22:04 +0000
commit1460904fd3c193ffaf809913b2983a400fce9d94 (patch)
tree72f3a17b75fedba3ae1060df1d32c9c7889be954 /plugins/org.eclipse.net4j.examples
parent5f360965ae87478e0681899bf310a210cafc2c44 (diff)
downloadcdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.gz
cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.xz
cdo-1460904fd3c193ffaf809913b2983a400fce9d94.zip
Fix line endings in master (dos2unix)
Diffstat (limited to 'plugins/org.eclipse.net4j.examples')
-rw-r--r--plugins/org.eclipse.net4j.examples/.settings/org.eclipse.core.resources.prefs6
-rw-r--r--plugins/org.eclipse.net4j.examples/EchoSSLClient.launch24
-rw-r--r--plugins/org.eclipse.net4j.examples/EchoSSLServer.launch24
-rw-r--r--plugins/org.eclipse.net4j.examples/about.properties62
-rw-r--r--plugins/org.eclipse.net4j.examples/copyright.txt14
-rw-r--r--plugins/org.eclipse.net4j.examples/plugin.properties30
-rw-r--r--plugins/org.eclipse.net4j.examples/plugin.xml104
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/EchoProtocol.java44
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoClient.java124
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoClientProtocol.java56
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoRequest.java86
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoSSLClient.java132
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoIndication.java84
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoSSLServer.java124
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServer.java124
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServerProtocol.java118
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadClientAction.java352
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadProtocol.java48
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadSSLClientAction.java356
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadSSLServer.java340
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadServer.java336
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/internal/examples/bundle/OM.java90
22 files changed, 1339 insertions, 1339 deletions
diff --git a/plugins/org.eclipse.net4j.examples/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.net4j.examples/.settings/org.eclipse.core.resources.prefs
index 625048d95c..5f86dafd0e 100644
--- a/plugins/org.eclipse.net4j.examples/.settings/org.eclipse.core.resources.prefs
+++ b/plugins/org.eclipse.net4j.examples/.settings/org.eclipse.core.resources.prefs
@@ -1,3 +1,3 @@
-#Mon Jul 04 13:02:35 CEST 2011
-eclipse.preferences.version=1
-encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8
+#Mon Jul 04 13:02:35 CEST 2011
+eclipse.preferences.version=1
+encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8
diff --git a/plugins/org.eclipse.net4j.examples/EchoSSLClient.launch b/plugins/org.eclipse.net4j.examples/EchoSSLClient.launch
index d19ecb9176..d0b8e74ca6 100644
--- a/plugins/org.eclipse.net4j.examples/EchoSSLClient.launch
+++ b/plugins/org.eclipse.net4j.examples/EchoSSLClient.launch
@@ -1,12 +1,12 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoSSLClient.java"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.net4j.examples.echo.client.EchoSSLClient"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.net4j.examples"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.eclipse.net4j.tcp.ssl.passphrase=ab987c -Dorg.eclipse.net4j.tcp.ssl.trust=file:///${workspace_loc:org.eclipse.net4j.examples}/sslKey/testTrust -Dorg.eclipse.net4j.tcp.ssl.key=file:///${workspace_loc:org.eclipse.net4j.examples}/sslKey/testKeys"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoSSLClient.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.net4j.examples.echo.client.EchoSSLClient"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.net4j.examples"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.eclipse.net4j.tcp.ssl.passphrase=ab987c -Dorg.eclipse.net4j.tcp.ssl.trust=file:///${workspace_loc:org.eclipse.net4j.examples}/sslKey/testTrust -Dorg.eclipse.net4j.tcp.ssl.key=file:///${workspace_loc:org.eclipse.net4j.examples}/sslKey/testKeys"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.net4j.examples/EchoSSLServer.launch b/plugins/org.eclipse.net4j.examples/EchoSSLServer.launch
index 171049d332..295d2c0604 100644
--- a/plugins/org.eclipse.net4j.examples/EchoSSLServer.launch
+++ b/plugins/org.eclipse.net4j.examples/EchoSSLServer.launch
@@ -1,12 +1,12 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoSSLServer.java"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.net4j.examples.echo.server.EchoSSLServer"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.net4j.examples"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.eclipse.net4j.tcp.ssl.passphrase=ab987c -Dorg.eclipse.net4j.tcp.ssl.trust=file:///${workspace_loc:org.eclipse.net4j.examples}/sslKey/testTrust -Dorg.eclipse.net4j.tcp.ssl.key=file:///${workspace_loc:org.eclipse.net4j.examples}/sslKey/testKeys"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoSSLServer.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.net4j.examples.echo.server.EchoSSLServer"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.net4j.examples"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.eclipse.net4j.tcp.ssl.passphrase=ab987c -Dorg.eclipse.net4j.tcp.ssl.trust=file:///${workspace_loc:org.eclipse.net4j.examples}/sslKey/testTrust -Dorg.eclipse.net4j.tcp.ssl.key=file:///${workspace_loc:org.eclipse.net4j.examples}/sslKey/testKeys"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.net4j.examples/about.properties b/plugins/org.eclipse.net4j.examples/about.properties
index f00c739c16..0b0afaf998 100644
--- a/plugins/org.eclipse.net4j.examples/about.properties
+++ b/plugins/org.eclipse.net4j.examples/about.properties
@@ -1,31 +1,31 @@
-# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
-# All rights reserved. This program and the accompanying materials
-# 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
-
-# NLS_MESSAGEFORMAT_VAR
-
-# ==============================================================================
-# Do not change the properties between this line and the last line containing:
-# %%% END OF TRANSLATED PROPERTIES %%%
-# Instead, either redefine an existing property, or create a new property,
-# append it to the end of the file, and change the code to use the new name.
-# ==============================================================================
-
-featureName = Net4j Signalling Platform Examples
-featureText = Net4j Signalling Platform Examples\n\
-Version: {featureVersion}\n\
-Build id: {0}\n\
-\n\
-Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. All rights reserved.\n\
-\n\
-Visit http://wiki.eclipse.org/Net4j
-
-# ==============================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# The above properties have been shipped for translation.
-# ==============================================================================
+# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+# All rights reserved. This program and the accompanying materials
+# 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
+
+# NLS_MESSAGEFORMAT_VAR
+
+# ==============================================================================
+# Do not change the properties between this line and the last line containing:
+# %%% END OF TRANSLATED PROPERTIES %%%
+# Instead, either redefine an existing property, or create a new property,
+# append it to the end of the file, and change the code to use the new name.
+# ==============================================================================
+
+featureName = Net4j Signalling Platform Examples
+featureText = Net4j Signalling Platform Examples\n\
+Version: {featureVersion}\n\
+Build id: {0}\n\
+\n\
+Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. All rights reserved.\n\
+\n\
+Visit http://wiki.eclipse.org/Net4j
+
+# ==============================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# The above properties have been shipped for translation.
+# ==============================================================================
diff --git a/plugins/org.eclipse.net4j.examples/copyright.txt b/plugins/org.eclipse.net4j.examples/copyright.txt
index 8f6328980e..0a0f67e6d7 100644
--- a/plugins/org.eclipse.net4j.examples/copyright.txt
+++ b/plugins/org.eclipse.net4j.examples/copyright.txt
@@ -1,8 +1,8 @@
-Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
-All rights reserved. This program and the accompanying materials
-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:
+Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+All rights reserved. This program and the accompanying materials
+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 \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.examples/plugin.properties b/plugins/org.eclipse.net4j.examples/plugin.properties
index e41bbfbf6b..2f54fc750c 100644
--- a/plugins/org.eclipse.net4j.examples/plugin.properties
+++ b/plugins/org.eclipse.net4j.examples/plugin.properties
@@ -1,16 +1,16 @@
-# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
-# All rights reserved. This program and the accompanying materials
-# 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
-
-pluginName = Net4j Signalling Platform Examples
-providerName = Eclipse Modeling Project
-
-actionSet.label = Net4j Examples
-menu.label = Net4j Examples
-action.label = Upload File
+# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+# All rights reserved. This program and the accompanying materials
+# 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
+
+pluginName = Net4j Signalling Platform Examples
+providerName = Eclipse Modeling Project
+
+actionSet.label = Net4j Examples
+menu.label = Net4j Examples
+action.label = Upload File
action.tooltip = Upload file to Net4j server \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.examples/plugin.xml b/plugins/org.eclipse.net4j.examples/plugin.xml
index 039ceb7a38..88e25477a5 100644
--- a/plugins/org.eclipse.net4j.examples/plugin.xml
+++ b/plugins/org.eclipse.net4j.examples/plugin.xml
@@ -1,52 +1,52 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.3"?>
-<!--
- Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- All rights reserved. This program and the accompanying materials
- 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
--->
-
-<plugin>
-
- <extension point="org.eclipse.net4j.util.factories">
- <factory
- class="org.eclipse.net4j.examples.echo.server.EchoServerProtocol$Factory"
- productGroup="org.eclipse.net4j.serverProtocols"
- type="echo"/>
- <factory
- class="org.eclipse.net4j.examples.transfer.UploadServer$ProtocolFactory"
- productGroup="org.eclipse.net4j.serverProtocols"
- type="upload"/>
- </extension>
-
- <extension
- point="org.eclipse.ui.actionSets">
- <actionSet
- id="org.eclipse.net4j.examples.actionSet"
- label="%actionSet.label"
- visible="true">
- <menu
- id="sampleMenu"
- label="%menu.label">
- <separator
- name="sampleGroup">
- </separator>
- </menu>
- <action
- class="org.eclipse.net4j.examples.transfer.UploadClientAction"
- icon="icons/sample.gif"
- id="org.eclipse.net4j.examples.transfer.TransferClientAction"
- label="%action.label"
- menubarPath="sampleMenu/sampleGroup"
- toolbarPath="sampleGroup"
- tooltip="%action.tooltip">
- </action>
- </actionSet>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.3"?>
+<!--
+ Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ All rights reserved. This program and the accompanying materials
+ 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
+-->
+
+<plugin>
+
+ <extension point="org.eclipse.net4j.util.factories">
+ <factory
+ class="org.eclipse.net4j.examples.echo.server.EchoServerProtocol$Factory"
+ productGroup="org.eclipse.net4j.serverProtocols"
+ type="echo"/>
+ <factory
+ class="org.eclipse.net4j.examples.transfer.UploadServer$ProtocolFactory"
+ productGroup="org.eclipse.net4j.serverProtocols"
+ type="upload"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.actionSets">
+ <actionSet
+ id="org.eclipse.net4j.examples.actionSet"
+ label="%actionSet.label"
+ visible="true">
+ <menu
+ id="sampleMenu"
+ label="%menu.label">
+ <separator
+ name="sampleGroup">
+ </separator>
+ </menu>
+ <action
+ class="org.eclipse.net4j.examples.transfer.UploadClientAction"
+ icon="icons/sample.gif"
+ id="org.eclipse.net4j.examples.transfer.TransferClientAction"
+ label="%action.label"
+ menubarPath="sampleMenu/sampleGroup"
+ toolbarPath="sampleGroup"
+ tooltip="%action.tooltip">
+ </action>
+ </actionSet>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/EchoProtocol.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/EchoProtocol.java
index 92aa6b8f68..14dac501e2 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/EchoProtocol.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/EchoProtocol.java
@@ -1,22 +1,22 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- */
-package org.eclipse.net4j.examples.echo;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public interface EchoProtocol
-{
- public static final String PROTOCOL_NAME = "echo"; //$NON-NLS-1$
-
- public static final short ECHO_SIGNAL = 1;
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ */
+package org.eclipse.net4j.examples.echo;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public interface EchoProtocol
+{
+ public static final String PROTOCOL_NAME = "echo"; //$NON-NLS-1$
+
+ public static final short ECHO_SIGNAL = 1;
+}
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoClient.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoClient.java
index dfd8881595..278ec1b67f 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoClient.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoClient.java
@@ -1,62 +1,62 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- */
-package org.eclipse.net4j.examples.echo.client;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.tcp.TCPUtil;
-import org.eclipse.net4j.util.container.ContainerUtil;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.log.PrintLogHandler;
-import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public class EchoClient
-{
- public static void main(String[] args) throws Exception
- {
- // Send all traces and logs to the console
- OMPlatform.INSTANCE.setDebugging(true);
- OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
- OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
-
- // Use this container to create and wire the components
- IManagedContainer container = ContainerUtil.createContainer();
- Net4jUtil.prepareContainer(container);
- TCPUtil.prepareContainer(container);
- container.activate();
-
- try
- {
- // Start a connector that represents the client side of a physical connection
- IConnector connector = Net4jUtil.getConnector(container, "tcp", "localhost:2036"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // Open a virtual channel with the ECHO protocol, send an ECHO request and close the channel
- EchoClientProtocol protocol = new EchoClientProtocol(connector);
- EchoRequest request = new EchoRequest(protocol, "My cool message"); //$NON-NLS-1$
- String echo = request.send();
- protocol.close();
-
- System.out.println();
- System.out.println("ECHO: " + echo); //$NON-NLS-1$
- System.out.println();
- }
- finally
- {
- LifecycleUtil.deactivate(container);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ */
+package org.eclipse.net4j.examples.echo.client;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.tcp.TCPUtil;
+import org.eclipse.net4j.util.container.ContainerUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.log.PrintLogHandler;
+import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class EchoClient
+{
+ public static void main(String[] args) throws Exception
+ {
+ // Send all traces and logs to the console
+ OMPlatform.INSTANCE.setDebugging(true);
+ OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
+
+ // Use this container to create and wire the components
+ IManagedContainer container = ContainerUtil.createContainer();
+ Net4jUtil.prepareContainer(container);
+ TCPUtil.prepareContainer(container);
+ container.activate();
+
+ try
+ {
+ // Start a connector that represents the client side of a physical connection
+ IConnector connector = Net4jUtil.getConnector(container, "tcp", "localhost:2036"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // Open a virtual channel with the ECHO protocol, send an ECHO request and close the channel
+ EchoClientProtocol protocol = new EchoClientProtocol(connector);
+ EchoRequest request = new EchoRequest(protocol, "My cool message"); //$NON-NLS-1$
+ String echo = request.send();
+ protocol.close();
+
+ System.out.println();
+ System.out.println("ECHO: " + echo); //$NON-NLS-1$
+ System.out.println();
+ }
+ finally
+ {
+ LifecycleUtil.deactivate(container);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoClientProtocol.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoClientProtocol.java
index 946d366e38..57bc0818e4 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoClientProtocol.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoClientProtocol.java
@@ -1,28 +1,28 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- */
-package org.eclipse.net4j.examples.echo.client;
-
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.examples.echo.EchoProtocol;
-import org.eclipse.net4j.signal.SignalProtocol;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public class EchoClientProtocol extends SignalProtocol<Object> implements EchoProtocol
-{
- public EchoClientProtocol(IConnector connector)
- {
- super(PROTOCOL_NAME);
- open(connector);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ */
+package org.eclipse.net4j.examples.echo.client;
+
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.examples.echo.EchoProtocol;
+import org.eclipse.net4j.signal.SignalProtocol;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class EchoClientProtocol extends SignalProtocol<Object> implements EchoProtocol
+{
+ public EchoClientProtocol(IConnector connector)
+ {
+ super(PROTOCOL_NAME);
+ open(connector);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoRequest.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoRequest.java
index 7b29e49048..ba55c592fe 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoRequest.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoRequest.java
@@ -1,43 +1,43 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- */
-package org.eclipse.net4j.examples.echo.client;
-
-import org.eclipse.net4j.examples.echo.EchoProtocol;
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public class EchoRequest extends RequestWithConfirmation<String>
-{
- private String message;
-
- public EchoRequest(EchoClientProtocol protocol, String message)
- {
- super(protocol, EchoProtocol.ECHO_SIGNAL);
- this.message = message;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeString(message);
- }
-
- @Override
- protected String confirming(ExtendedDataInputStream in) throws Exception
- {
- return in.readString();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ */
+package org.eclipse.net4j.examples.echo.client;
+
+import org.eclipse.net4j.examples.echo.EchoProtocol;
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class EchoRequest extends RequestWithConfirmation<String>
+{
+ private String message;
+
+ public EchoRequest(EchoClientProtocol protocol, String message)
+ {
+ super(protocol, EchoProtocol.ECHO_SIGNAL);
+ this.message = message;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeString(message);
+ }
+
+ @Override
+ protected String confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return in.readString();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoSSLClient.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoSSLClient.java
index 25d19d9d06..970d51135e 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoSSLClient.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoSSLClient.java
@@ -1,66 +1,66 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - initial API and implementation
- */
-package org.eclipse.net4j.examples.echo.client;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.tcp.ssl.SSLUtil;
-import org.eclipse.net4j.util.container.ContainerUtil;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.log.PrintLogHandler;
-import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
-
-/**
- * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
- * @since 4.0
- */
-public class EchoSSLClient
-{
- public static void main(String[] args) throws Exception
- {
- // Send all traces and logs to the console
- OMPlatform.INSTANCE.setDebugging(true);
- OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
- OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
-
- // Use this container to create and wire the components
- IManagedContainer container = ContainerUtil.createContainer();
- Net4jUtil.prepareContainer(container);
- SSLUtil.prepareContainer(container);
- container.activate();
-
- try
- {
- // Start a connector that represents the client side of a physical connection
- IConnector connector = Net4jUtil.getConnector(container, "ssl", "localhost:2036"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // Open a virtual channel with the ECHO protocol, send an ECHO request and close the channel
- EchoClientProtocol protocol = new EchoClientProtocol(connector);
- EchoRequest request = new EchoRequest(protocol, "My cool message"); //$NON-NLS-1$
- String echo = request.send();
- protocol.close();
-
- System.out.println();
- System.out.println("ECHO: " + echo); //$NON-NLS-1$
- System.out.println();
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- finally
- {
- LifecycleUtil.deactivate(container);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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:
+ * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - initial API and implementation
+ */
+package org.eclipse.net4j.examples.echo.client;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.tcp.ssl.SSLUtil;
+import org.eclipse.net4j.util.container.ContainerUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.log.PrintLogHandler;
+import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
+
+/**
+ * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
+ * @since 4.0
+ */
+public class EchoSSLClient
+{
+ public static void main(String[] args) throws Exception
+ {
+ // Send all traces and logs to the console
+ OMPlatform.INSTANCE.setDebugging(true);
+ OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
+
+ // Use this container to create and wire the components
+ IManagedContainer container = ContainerUtil.createContainer();
+ Net4jUtil.prepareContainer(container);
+ SSLUtil.prepareContainer(container);
+ container.activate();
+
+ try
+ {
+ // Start a connector that represents the client side of a physical connection
+ IConnector connector = Net4jUtil.getConnector(container, "ssl", "localhost:2036"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // Open a virtual channel with the ECHO protocol, send an ECHO request and close the channel
+ EchoClientProtocol protocol = new EchoClientProtocol(connector);
+ EchoRequest request = new EchoRequest(protocol, "My cool message"); //$NON-NLS-1$
+ String echo = request.send();
+ protocol.close();
+
+ System.out.println();
+ System.out.println("ECHO: " + echo); //$NON-NLS-1$
+ System.out.println();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ finally
+ {
+ LifecycleUtil.deactivate(container);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoIndication.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoIndication.java
index dfb186d4aa..d8700d9cba 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoIndication.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoIndication.java
@@ -1,42 +1,42 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- */
-package org.eclipse.net4j.examples.echo.server;
-
-import org.eclipse.net4j.examples.echo.EchoProtocol;
-import org.eclipse.net4j.signal.IndicationWithResponse;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public class EchoIndication extends IndicationWithResponse implements EchoProtocol
-{
- private String message;
-
- public EchoIndication(EchoServerProtocol protocol)
- {
- super(protocol, ECHO_SIGNAL);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- message = in.readString();
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out) throws Exception
- {
- out.writeString(message);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ */
+package org.eclipse.net4j.examples.echo.server;
+
+import org.eclipse.net4j.examples.echo.EchoProtocol;
+import org.eclipse.net4j.signal.IndicationWithResponse;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class EchoIndication extends IndicationWithResponse implements EchoProtocol
+{
+ private String message;
+
+ public EchoIndication(EchoServerProtocol protocol)
+ {
+ super(protocol, ECHO_SIGNAL);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ message = in.readString();
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeString(message);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoSSLServer.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoSSLServer.java
index cff5e2d790..e08b697de6 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoSSLServer.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoSSLServer.java
@@ -1,62 +1,62 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - initial API and implementation
- */
-package org.eclipse.net4j.examples.echo.server;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.acceptor.IAcceptor;
-import org.eclipse.net4j.internal.examples.bundle.OM;
-import org.eclipse.net4j.tcp.ssl.SSLUtil;
-import org.eclipse.net4j.util.container.ContainerUtil;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.log.PrintLogHandler;
-import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
-
-/**
- * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
- * @since 4.0
- */
-public class EchoSSLServer
-{
- public static void main(String[] args) throws Exception
- {
- // Send all traces and logs to the console
- OMPlatform.INSTANCE.setDebugging(true);
- OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
- OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
-
- // Use this container to create and wire the components
- IManagedContainer container = ContainerUtil.createContainer();
- Net4jUtil.prepareContainer(container);
- SSLUtil.prepareContainer(container);
- container.registerFactory(new EchoServerProtocol.Factory());
- container.activate();
-
- try
- {
- // Start an acceptor
- IAcceptor acceptor = (IAcceptor)container.getElement("org.eclipse.net4j.acceptors", "ssl", "0.0.0.0:2036"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- OM.LOG.info("Accepting connections: " + acceptor); //$NON-NLS-1$
-
- System.out.println("Press any key to shutdown"); //$NON-NLS-1$
- while (IOUtil.IN().read() == -1)
- {
- Thread.sleep(200);
- }
- }
- finally
- {
- LifecycleUtil.deactivate(container);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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:
+ * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - initial API and implementation
+ */
+package org.eclipse.net4j.examples.echo.server;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.acceptor.IAcceptor;
+import org.eclipse.net4j.internal.examples.bundle.OM;
+import org.eclipse.net4j.tcp.ssl.SSLUtil;
+import org.eclipse.net4j.util.container.ContainerUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.log.PrintLogHandler;
+import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
+
+/**
+ * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
+ * @since 4.0
+ */
+public class EchoSSLServer
+{
+ public static void main(String[] args) throws Exception
+ {
+ // Send all traces and logs to the console
+ OMPlatform.INSTANCE.setDebugging(true);
+ OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
+
+ // Use this container to create and wire the components
+ IManagedContainer container = ContainerUtil.createContainer();
+ Net4jUtil.prepareContainer(container);
+ SSLUtil.prepareContainer(container);
+ container.registerFactory(new EchoServerProtocol.Factory());
+ container.activate();
+
+ try
+ {
+ // Start an acceptor
+ IAcceptor acceptor = (IAcceptor)container.getElement("org.eclipse.net4j.acceptors", "ssl", "0.0.0.0:2036"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ OM.LOG.info("Accepting connections: " + acceptor); //$NON-NLS-1$
+
+ System.out.println("Press any key to shutdown"); //$NON-NLS-1$
+ while (IOUtil.IN().read() == -1)
+ {
+ Thread.sleep(200);
+ }
+ }
+ finally
+ {
+ LifecycleUtil.deactivate(container);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServer.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServer.java
index 2d743dbca3..47ff821808 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServer.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServer.java
@@ -1,62 +1,62 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- */
-package org.eclipse.net4j.examples.echo.server;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.acceptor.IAcceptor;
-import org.eclipse.net4j.internal.examples.bundle.OM;
-import org.eclipse.net4j.tcp.TCPUtil;
-import org.eclipse.net4j.util.container.ContainerUtil;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.log.PrintLogHandler;
-import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public class EchoServer
-{
- public static void main(String[] args) throws Exception
- {
- // Send all traces and logs to the console
- OMPlatform.INSTANCE.setDebugging(true);
- OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
- OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
-
- // Use this container to create and wire the components
- IManagedContainer container = ContainerUtil.createContainer();
- Net4jUtil.prepareContainer(container);
- TCPUtil.prepareContainer(container);
- container.registerFactory(new EchoServerProtocol.Factory());
- container.activate();
-
- try
- {
- // Start an acceptor
- IAcceptor acceptor = (IAcceptor)container.getElement("org.eclipse.net4j.acceptors", "tcp", "0.0.0.0:2036"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- OM.LOG.info("Accepting connections: " + acceptor); //$NON-NLS-1$
-
- System.out.println("Press any key to shutdown"); //$NON-NLS-1$
- while (IOUtil.IN().read() == -1)
- {
- Thread.sleep(200);
- }
- }
- finally
- {
- LifecycleUtil.deactivate(container);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ */
+package org.eclipse.net4j.examples.echo.server;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.acceptor.IAcceptor;
+import org.eclipse.net4j.internal.examples.bundle.OM;
+import org.eclipse.net4j.tcp.TCPUtil;
+import org.eclipse.net4j.util.container.ContainerUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.log.PrintLogHandler;
+import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class EchoServer
+{
+ public static void main(String[] args) throws Exception
+ {
+ // Send all traces and logs to the console
+ OMPlatform.INSTANCE.setDebugging(true);
+ OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
+
+ // Use this container to create and wire the components
+ IManagedContainer container = ContainerUtil.createContainer();
+ Net4jUtil.prepareContainer(container);
+ TCPUtil.prepareContainer(container);
+ container.registerFactory(new EchoServerProtocol.Factory());
+ container.activate();
+
+ try
+ {
+ // Start an acceptor
+ IAcceptor acceptor = (IAcceptor)container.getElement("org.eclipse.net4j.acceptors", "tcp", "0.0.0.0:2036"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ OM.LOG.info("Accepting connections: " + acceptor); //$NON-NLS-1$
+
+ System.out.println("Press any key to shutdown"); //$NON-NLS-1$
+ while (IOUtil.IN().read() == -1)
+ {
+ Thread.sleep(200);
+ }
+ }
+ finally
+ {
+ LifecycleUtil.deactivate(container);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServerProtocol.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServerProtocol.java
index 8c75c5b979..ebf4532dd8 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServerProtocol.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServerProtocol.java
@@ -1,59 +1,59 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- */
-package org.eclipse.net4j.examples.echo.server;
-
-import org.eclipse.net4j.examples.echo.EchoProtocol;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.signal.SignalReactor;
-import org.eclipse.net4j.util.factory.ProductCreationException;
-
-import org.eclipse.spi.net4j.ServerProtocolFactory;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public class EchoServerProtocol extends SignalProtocol<Object> implements EchoProtocol
-{
- public EchoServerProtocol()
- {
- super(PROTOCOL_NAME);
- }
-
- @Override
- protected SignalReactor createSignalReactor(short signalID)
- {
- switch (signalID)
- {
- case ECHO_SIGNAL:
- return new EchoIndication(this);
-
- default:
- return super.createSignalReactor(signalID);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class Factory extends ServerProtocolFactory
- {
- public Factory()
- {
- super(PROTOCOL_NAME);
- }
-
- public Object create(String description) throws ProductCreationException
- {
- return new EchoServerProtocol();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ */
+package org.eclipse.net4j.examples.echo.server;
+
+import org.eclipse.net4j.examples.echo.EchoProtocol;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.signal.SignalReactor;
+import org.eclipse.net4j.util.factory.ProductCreationException;
+
+import org.eclipse.spi.net4j.ServerProtocolFactory;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class EchoServerProtocol extends SignalProtocol<Object> implements EchoProtocol
+{
+ public EchoServerProtocol()
+ {
+ super(PROTOCOL_NAME);
+ }
+
+ @Override
+ protected SignalReactor createSignalReactor(short signalID)
+ {
+ switch (signalID)
+ {
+ case ECHO_SIGNAL:
+ return new EchoIndication(this);
+
+ default:
+ return super.createSignalReactor(signalID);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Factory extends ServerProtocolFactory
+ {
+ public Factory()
+ {
+ super(PROTOCOL_NAME);
+ }
+
+ public Object create(String description) throws ProductCreationException
+ {
+ return new EchoServerProtocol();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadClientAction.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadClientAction.java
index 977079a256..2a707dfb26 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadClientAction.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadClientAction.java
@@ -1,176 +1,176 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- */
-package org.eclipse.net4j.examples.transfer;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.internal.examples.bundle.OM;
-import org.eclipse.net4j.signal.RequestWithMonitoring;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.util.container.IPluginContainer;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.om.monitor.EclipseMonitor;
-import org.eclipse.net4j.util.om.monitor.MonitorCanceledException;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public class UploadClientAction implements IWorkbenchWindowActionDelegate, UploadProtocol
-{
- private IWorkbenchWindow window;
-
- public UploadClientAction()
- {
- }
-
- public void init(IWorkbenchWindow window)
- {
- this.window = window;
- }
-
- public void run(IAction action)
- {
- FileDialog fileDialog = new FileDialog(window.getShell());
- final String path = fileDialog.open();
- if (path != null)
- {
- final File file = new File(path);
- new Job("Uploading file") //$NON-NLS-1$
- {
- @Override
- protected IStatus run(IProgressMonitor monitor)
- {
- try
- {
- boolean replaced = transferFile(file, monitor);
- OM.LOG.info("File " + path + (replaced ? " replaced" : " stored") + " on the Net4j server."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- return Status.OK_STATUS;
- }
- catch (MonitorCanceledException ex)
- {
- return Status.CANCEL_STATUS;
- }
- catch (Exception ex)
- {
- return new Status(IStatus.ERROR, OM.BUNDLE_ID, "Problem with upload of " + path, ex); //$NON-NLS-1$
- }
- finally
- {
- monitor.done();
- }
- }
- }.schedule();
- }
- }
-
- public void selectionChanged(IAction action, ISelection selection)
- {
- }
-
- public void dispose()
- {
- }
-
- private boolean transferFile(final File file, IProgressMonitor monitor) throws Exception
- {
- SignalProtocol<Object> protocol = null;
-
- try
- {
- // Start a connector that represents the client side of a physical connection
- IConnector connector = Net4jUtil.getConnector(IPluginContainer.INSTANCE, "tcp", "localhost:2036");
-
- // Open a virtual channel with the ECHO protocol, send an ECHO request and close the channel
- protocol = new SignalProtocol<Object>(PROTOCOL_NAME);
- protocol.open(connector);
-
- UploadRequest request = new UploadRequest(protocol, file);
- return request.send(new EclipseMonitor(monitor));
- }
- finally
- {
- protocol.close();
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class UploadRequest extends RequestWithMonitoring<Boolean>
- {
- private File file;
-
- public UploadRequest(SignalProtocol<?> protocol, File file)
- {
- super(protocol, UPLOAD_SIGNAL_ID);
- this.file = file;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
- {
- long size = file.length();
- out.writeLong(size);
- out.writeString(file.getName());
-
- monitor.begin((int)size);
- BufferedInputStream in = null;
-
- try
- {
- in = new BufferedInputStream(new FileInputStream(file));
- while (size != 0L)
- {
- int chunk = BUFFER_SIZE;
- if (size < BUFFER_SIZE)
- {
- chunk = (int)size;
- }
-
- byte[] buffer = new byte[chunk];
- in.read(buffer);
- out.writeByteArray(buffer);
-
- monitor.worked(chunk);
- size -= chunk;
- }
- }
- finally
- {
- monitor.done();
- in.close();
- }
- }
-
- @Override
- protected Boolean confirming(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
- {
- return in.readBoolean();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ */
+package org.eclipse.net4j.examples.transfer;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.internal.examples.bundle.OM;
+import org.eclipse.net4j.signal.RequestWithMonitoring;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.container.IPluginContainer;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.om.monitor.EclipseMonitor;
+import org.eclipse.net4j.util.om.monitor.MonitorCanceledException;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class UploadClientAction implements IWorkbenchWindowActionDelegate, UploadProtocol
+{
+ private IWorkbenchWindow window;
+
+ public UploadClientAction()
+ {
+ }
+
+ public void init(IWorkbenchWindow window)
+ {
+ this.window = window;
+ }
+
+ public void run(IAction action)
+ {
+ FileDialog fileDialog = new FileDialog(window.getShell());
+ final String path = fileDialog.open();
+ if (path != null)
+ {
+ final File file = new File(path);
+ new Job("Uploading file") //$NON-NLS-1$
+ {
+ @Override
+ protected IStatus run(IProgressMonitor monitor)
+ {
+ try
+ {
+ boolean replaced = transferFile(file, monitor);
+ OM.LOG.info("File " + path + (replaced ? " replaced" : " stored") + " on the Net4j server."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ return Status.OK_STATUS;
+ }
+ catch (MonitorCanceledException ex)
+ {
+ return Status.CANCEL_STATUS;
+ }
+ catch (Exception ex)
+ {
+ return new Status(IStatus.ERROR, OM.BUNDLE_ID, "Problem with upload of " + path, ex); //$NON-NLS-1$
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+ }.schedule();
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection selection)
+ {
+ }
+
+ public void dispose()
+ {
+ }
+
+ private boolean transferFile(final File file, IProgressMonitor monitor) throws Exception
+ {
+ SignalProtocol<Object> protocol = null;
+
+ try
+ {
+ // Start a connector that represents the client side of a physical connection
+ IConnector connector = Net4jUtil.getConnector(IPluginContainer.INSTANCE, "tcp", "localhost:2036");
+
+ // Open a virtual channel with the ECHO protocol, send an ECHO request and close the channel
+ protocol = new SignalProtocol<Object>(PROTOCOL_NAME);
+ protocol.open(connector);
+
+ UploadRequest request = new UploadRequest(protocol, file);
+ return request.send(new EclipseMonitor(monitor));
+ }
+ finally
+ {
+ protocol.close();
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class UploadRequest extends RequestWithMonitoring<Boolean>
+ {
+ private File file;
+
+ public UploadRequest(SignalProtocol<?> protocol, File file)
+ {
+ super(protocol, UPLOAD_SIGNAL_ID);
+ this.file = file;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
+ {
+ long size = file.length();
+ out.writeLong(size);
+ out.writeString(file.getName());
+
+ monitor.begin((int)size);
+ BufferedInputStream in = null;
+
+ try
+ {
+ in = new BufferedInputStream(new FileInputStream(file));
+ while (size != 0L)
+ {
+ int chunk = BUFFER_SIZE;
+ if (size < BUFFER_SIZE)
+ {
+ chunk = (int)size;
+ }
+
+ byte[] buffer = new byte[chunk];
+ in.read(buffer);
+ out.writeByteArray(buffer);
+
+ monitor.worked(chunk);
+ size -= chunk;
+ }
+ }
+ finally
+ {
+ monitor.done();
+ in.close();
+ }
+ }
+
+ @Override
+ protected Boolean confirming(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
+ {
+ return in.readBoolean();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadProtocol.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadProtocol.java
index 6e52b9d9a5..e0fa4a3e89 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadProtocol.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadProtocol.java
@@ -1,24 +1,24 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- */
-package org.eclipse.net4j.examples.transfer;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public interface UploadProtocol
-{
- public static final String PROTOCOL_NAME = "upload"; //$NON-NLS-1$
-
- public static final short UPLOAD_SIGNAL_ID = 1;
-
- public static final int BUFFER_SIZE = 8192;
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ */
+package org.eclipse.net4j.examples.transfer;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public interface UploadProtocol
+{
+ public static final String PROTOCOL_NAME = "upload"; //$NON-NLS-1$
+
+ public static final short UPLOAD_SIGNAL_ID = 1;
+
+ public static final int BUFFER_SIZE = 8192;
+}
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadSSLClientAction.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadSSLClientAction.java
index e60dcc8870..0f389636c2 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadSSLClientAction.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadSSLClientAction.java
@@ -1,178 +1,178 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - initial API and implementation
- */
-package org.eclipse.net4j.examples.transfer;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.internal.examples.bundle.OM;
-import org.eclipse.net4j.signal.RequestWithMonitoring;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.util.container.IPluginContainer;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.om.monitor.EclipseMonitor;
-import org.eclipse.net4j.util.om.monitor.MonitorCanceledException;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-
-/**
- * Need to change to this class in plugin.xml
- *
- * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
- * @since 4.0
- */
-public class UploadSSLClientAction implements IWorkbenchWindowActionDelegate, UploadProtocol
-{
- private IWorkbenchWindow window;
-
- public UploadSSLClientAction()
- {
- }
-
- public void init(IWorkbenchWindow window)
- {
- this.window = window;
- }
-
- public void run(IAction action)
- {
- FileDialog fileDialog = new FileDialog(window.getShell());
- final String path = fileDialog.open();
- if (path != null)
- {
- final File file = new File(path);
- new Job("Uploading file") //$NON-NLS-1$
- {
- @Override
- protected IStatus run(IProgressMonitor monitor)
- {
- try
- {
- boolean replaced = transferFile(file, monitor);
- OM.LOG.info("File " + path + (replaced ? " replaced" : " stored") + " on the Net4j server."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- return Status.OK_STATUS;
- }
- catch (MonitorCanceledException ex)
- {
- return Status.CANCEL_STATUS;
- }
- catch (Exception ex)
- {
- return new Status(IStatus.ERROR, OM.BUNDLE_ID, "Problem with upload of " + path, ex); //$NON-NLS-1$
- }
- finally
- {
- monitor.done();
- }
- }
- }.schedule();
- }
- }
-
- public void selectionChanged(IAction action, ISelection selection)
- {
- }
-
- public void dispose()
- {
- }
-
- private boolean transferFile(final File file, IProgressMonitor monitor) throws Exception
- {
- SignalProtocol<Object> protocol = null;
-
- try
- {
- // Start a connector that represents the client side of a physical connection
- IConnector connector = Net4jUtil.getConnector(IPluginContainer.INSTANCE, "ssl", "localhost:2036");
-
- // Open a virtual channel with the ECHO protocol, send an ECHO request and close the channel
- protocol = new SignalProtocol<Object>(PROTOCOL_NAME);
- protocol.open(connector);
-
- UploadRequest request = new UploadRequest(protocol, file);
- return request.send(new EclipseMonitor(monitor));
- }
- finally
- {
- protocol.close();
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class UploadRequest extends RequestWithMonitoring<Boolean>
- {
- private File file;
-
- public UploadRequest(SignalProtocol<?> protocol, File file)
- {
- super(protocol, UPLOAD_SIGNAL_ID);
- this.file = file;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
- {
- long size = file.length();
- out.writeLong(size);
- out.writeString(file.getName());
-
- monitor.begin((int)size);
- BufferedInputStream in = null;
-
- try
- {
- in = new BufferedInputStream(new FileInputStream(file));
- while (size != 0L)
- {
- int chunk = BUFFER_SIZE;
- if (size < BUFFER_SIZE)
- {
- chunk = (int)size;
- }
-
- byte[] buffer = new byte[chunk];
- in.read(buffer);
- out.writeByteArray(buffer);
-
- monitor.worked(chunk);
- size -= chunk;
- }
- }
- finally
- {
- monitor.done();
- in.close();
- }
- }
-
- @Override
- protected Boolean confirming(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
- {
- return in.readBoolean();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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:
+ * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - initial API and implementation
+ */
+package org.eclipse.net4j.examples.transfer;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.internal.examples.bundle.OM;
+import org.eclipse.net4j.signal.RequestWithMonitoring;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.container.IPluginContainer;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.om.monitor.EclipseMonitor;
+import org.eclipse.net4j.util.om.monitor.MonitorCanceledException;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+
+/**
+ * Need to change to this class in plugin.xml
+ *
+ * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
+ * @since 4.0
+ */
+public class UploadSSLClientAction implements IWorkbenchWindowActionDelegate, UploadProtocol
+{
+ private IWorkbenchWindow window;
+
+ public UploadSSLClientAction()
+ {
+ }
+
+ public void init(IWorkbenchWindow window)
+ {
+ this.window = window;
+ }
+
+ public void run(IAction action)
+ {
+ FileDialog fileDialog = new FileDialog(window.getShell());
+ final String path = fileDialog.open();
+ if (path != null)
+ {
+ final File file = new File(path);
+ new Job("Uploading file") //$NON-NLS-1$
+ {
+ @Override
+ protected IStatus run(IProgressMonitor monitor)
+ {
+ try
+ {
+ boolean replaced = transferFile(file, monitor);
+ OM.LOG.info("File " + path + (replaced ? " replaced" : " stored") + " on the Net4j server."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ return Status.OK_STATUS;
+ }
+ catch (MonitorCanceledException ex)
+ {
+ return Status.CANCEL_STATUS;
+ }
+ catch (Exception ex)
+ {
+ return new Status(IStatus.ERROR, OM.BUNDLE_ID, "Problem with upload of " + path, ex); //$NON-NLS-1$
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+ }.schedule();
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection selection)
+ {
+ }
+
+ public void dispose()
+ {
+ }
+
+ private boolean transferFile(final File file, IProgressMonitor monitor) throws Exception
+ {
+ SignalProtocol<Object> protocol = null;
+
+ try
+ {
+ // Start a connector that represents the client side of a physical connection
+ IConnector connector = Net4jUtil.getConnector(IPluginContainer.INSTANCE, "ssl", "localhost:2036");
+
+ // Open a virtual channel with the ECHO protocol, send an ECHO request and close the channel
+ protocol = new SignalProtocol<Object>(PROTOCOL_NAME);
+ protocol.open(connector);
+
+ UploadRequest request = new UploadRequest(protocol, file);
+ return request.send(new EclipseMonitor(monitor));
+ }
+ finally
+ {
+ protocol.close();
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class UploadRequest extends RequestWithMonitoring<Boolean>
+ {
+ private File file;
+
+ public UploadRequest(SignalProtocol<?> protocol, File file)
+ {
+ super(protocol, UPLOAD_SIGNAL_ID);
+ this.file = file;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
+ {
+ long size = file.length();
+ out.writeLong(size);
+ out.writeString(file.getName());
+
+ monitor.begin((int)size);
+ BufferedInputStream in = null;
+
+ try
+ {
+ in = new BufferedInputStream(new FileInputStream(file));
+ while (size != 0L)
+ {
+ int chunk = BUFFER_SIZE;
+ if (size < BUFFER_SIZE)
+ {
+ chunk = (int)size;
+ }
+
+ byte[] buffer = new byte[chunk];
+ in.read(buffer);
+ out.writeByteArray(buffer);
+
+ monitor.worked(chunk);
+ size -= chunk;
+ }
+ }
+ finally
+ {
+ monitor.done();
+ in.close();
+ }
+ }
+
+ @Override
+ protected Boolean confirming(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
+ {
+ return in.readBoolean();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadSSLServer.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadSSLServer.java
index ca0810a821..88c4b2a1ca 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadSSLServer.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadSSLServer.java
@@ -1,170 +1,170 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - initial API and implementation
- */
-package org.eclipse.net4j.examples.transfer;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.acceptor.IAcceptor;
-import org.eclipse.net4j.internal.examples.bundle.OM;
-import org.eclipse.net4j.signal.IndicationWithMonitoring;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.signal.SignalReactor;
-import org.eclipse.net4j.tcp.ssl.SSLUtil;
-import org.eclipse.net4j.util.container.ContainerUtil;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.factory.ProductCreationException;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.log.PrintLogHandler;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
-
-import org.eclipse.spi.net4j.ServerProtocolFactory;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-
-/**
- * Need to change to this class in plugin.xml
- *
- * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
- * @since 4.0
- */
-public class UploadSSLServer implements UploadProtocol
-{
- public static final String FOLDER_NAME = "/temp"; //$NON-NLS-1$
-
- public static void main(String[] args) throws Exception
- {
- // Send all traces and logs to the console
- OMPlatform.INSTANCE.setDebugging(true);
- OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
- OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
-
- // Use this container to create and wire the components
- IManagedContainer container = ContainerUtil.createContainer();
- Net4jUtil.prepareContainer(container);
- SSLUtil.prepareContainer(container);
- container.registerFactory(new ProtocolFactory());
- container.activate();
-
- try
- {
- // Start an acceptor
- IAcceptor acceptor = (IAcceptor)container.getElement("org.eclipse.net4j.acceptors", "ssl", "0.0.0.0:2036"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- OM.LOG.info("Accepting connections: " + acceptor); //$NON-NLS-1$
-
- new File(FOLDER_NAME).mkdirs();
- OM.LOG.info("Upload folder: " + FOLDER_NAME); //$NON-NLS-1$
-
- System.out.println("Press any key to shutdown"); //$NON-NLS-1$
- while (System.in.read() == -1)
- {
- Thread.sleep(200);
- }
- }
- finally
- {
- LifecycleUtil.deactivate(container);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class ProtocolFactory extends ServerProtocolFactory
- {
- public ProtocolFactory()
- {
- super(PROTOCOL_NAME);
- }
-
- public Object create(String description) throws ProductCreationException
- {
- return new SignalProtocol<Object>(PROTOCOL_NAME)
- {
- @Override
- protected SignalReactor createSignalReactor(short signalID)
- {
- switch (signalID)
- {
- case UPLOAD_SIGNAL_ID:
- return new UploadIndication(this);
-
- default:
- return super.createSignalReactor(signalID);
- }
- }
- };
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class UploadIndication extends IndicationWithMonitoring
- {
- private boolean replaced;
-
- public UploadIndication(SignalProtocol<Object> protocol)
- {
- super(protocol, UPLOAD_SIGNAL_ID);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
- {
- long size = in.readLong();
- String fileName = in.readString();
- File file = new File(FOLDER_NAME, fileName);
- replaced = file.exists();
- System.out.println((replaced ? "Replacing " : "Storing ") + file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
-
- monitor.begin((int)size);
- BufferedOutputStream out = null;
-
- try
- {
- out = new BufferedOutputStream(new FileOutputStream(file));
- while (size != 0L)
- {
- int chunk = BUFFER_SIZE;
- if (size < BUFFER_SIZE)
- {
- chunk = (int)size;
- }
-
- byte[] buffer = in.readByteArray();
- out.write(buffer);
-
- monitor.worked(chunk);
- size -= chunk;
- }
- }
- finally
- {
- monitor.done();
- if (out != null)
- {
- out.close();
- }
- }
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
- {
- out.writeBoolean(replaced);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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:
+ * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - initial API and implementation
+ */
+package org.eclipse.net4j.examples.transfer;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.acceptor.IAcceptor;
+import org.eclipse.net4j.internal.examples.bundle.OM;
+import org.eclipse.net4j.signal.IndicationWithMonitoring;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.signal.SignalReactor;
+import org.eclipse.net4j.tcp.ssl.SSLUtil;
+import org.eclipse.net4j.util.container.ContainerUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.factory.ProductCreationException;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.log.PrintLogHandler;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
+
+import org.eclipse.spi.net4j.ServerProtocolFactory;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+
+/**
+ * Need to change to this class in plugin.xml
+ *
+ * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
+ * @since 4.0
+ */
+public class UploadSSLServer implements UploadProtocol
+{
+ public static final String FOLDER_NAME = "/temp"; //$NON-NLS-1$
+
+ public static void main(String[] args) throws Exception
+ {
+ // Send all traces and logs to the console
+ OMPlatform.INSTANCE.setDebugging(true);
+ OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
+
+ // Use this container to create and wire the components
+ IManagedContainer container = ContainerUtil.createContainer();
+ Net4jUtil.prepareContainer(container);
+ SSLUtil.prepareContainer(container);
+ container.registerFactory(new ProtocolFactory());
+ container.activate();
+
+ try
+ {
+ // Start an acceptor
+ IAcceptor acceptor = (IAcceptor)container.getElement("org.eclipse.net4j.acceptors", "ssl", "0.0.0.0:2036"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ OM.LOG.info("Accepting connections: " + acceptor); //$NON-NLS-1$
+
+ new File(FOLDER_NAME).mkdirs();
+ OM.LOG.info("Upload folder: " + FOLDER_NAME); //$NON-NLS-1$
+
+ System.out.println("Press any key to shutdown"); //$NON-NLS-1$
+ while (System.in.read() == -1)
+ {
+ Thread.sleep(200);
+ }
+ }
+ finally
+ {
+ LifecycleUtil.deactivate(container);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class ProtocolFactory extends ServerProtocolFactory
+ {
+ public ProtocolFactory()
+ {
+ super(PROTOCOL_NAME);
+ }
+
+ public Object create(String description) throws ProductCreationException
+ {
+ return new SignalProtocol<Object>(PROTOCOL_NAME)
+ {
+ @Override
+ protected SignalReactor createSignalReactor(short signalID)
+ {
+ switch (signalID)
+ {
+ case UPLOAD_SIGNAL_ID:
+ return new UploadIndication(this);
+
+ default:
+ return super.createSignalReactor(signalID);
+ }
+ }
+ };
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class UploadIndication extends IndicationWithMonitoring
+ {
+ private boolean replaced;
+
+ public UploadIndication(SignalProtocol<Object> protocol)
+ {
+ super(protocol, UPLOAD_SIGNAL_ID);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
+ {
+ long size = in.readLong();
+ String fileName = in.readString();
+ File file = new File(FOLDER_NAME, fileName);
+ replaced = file.exists();
+ System.out.println((replaced ? "Replacing " : "Storing ") + file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
+
+ monitor.begin((int)size);
+ BufferedOutputStream out = null;
+
+ try
+ {
+ out = new BufferedOutputStream(new FileOutputStream(file));
+ while (size != 0L)
+ {
+ int chunk = BUFFER_SIZE;
+ if (size < BUFFER_SIZE)
+ {
+ chunk = (int)size;
+ }
+
+ byte[] buffer = in.readByteArray();
+ out.write(buffer);
+
+ monitor.worked(chunk);
+ size -= chunk;
+ }
+ }
+ finally
+ {
+ monitor.done();
+ if (out != null)
+ {
+ out.close();
+ }
+ }
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
+ {
+ out.writeBoolean(replaced);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadServer.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadServer.java
index 28577145f6..7a35e4679c 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadServer.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/transfer/UploadServer.java
@@ -1,168 +1,168 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- */
-package org.eclipse.net4j.examples.transfer;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.acceptor.IAcceptor;
-import org.eclipse.net4j.internal.examples.bundle.OM;
-import org.eclipse.net4j.signal.IndicationWithMonitoring;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.signal.SignalReactor;
-import org.eclipse.net4j.tcp.TCPUtil;
-import org.eclipse.net4j.util.container.ContainerUtil;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.factory.ProductCreationException;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.log.PrintLogHandler;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
-
-import org.eclipse.spi.net4j.ServerProtocolFactory;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public class UploadServer implements UploadProtocol
-{
- public static final String FOLDER_NAME = "/temp"; //$NON-NLS-1$
-
- public static void main(String[] args) throws Exception
- {
- // Send all traces and logs to the console
- OMPlatform.INSTANCE.setDebugging(true);
- OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
- OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
-
- // Use this container to create and wire the components
- IManagedContainer container = ContainerUtil.createContainer();
- Net4jUtil.prepareContainer(container);
- TCPUtil.prepareContainer(container);
- container.registerFactory(new ProtocolFactory());
- container.activate();
-
- try
- {
- // Start an acceptor
- IAcceptor acceptor = (IAcceptor)container.getElement("org.eclipse.net4j.acceptors", "tcp", "0.0.0.0:2036"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- OM.LOG.info("Accepting connections: " + acceptor); //$NON-NLS-1$
-
- new File(FOLDER_NAME).mkdirs();
- OM.LOG.info("Upload folder: " + FOLDER_NAME); //$NON-NLS-1$
-
- System.out.println("Press any key to shutdown"); //$NON-NLS-1$
- while (System.in.read() == -1)
- {
- Thread.sleep(200);
- }
- }
- finally
- {
- LifecycleUtil.deactivate(container);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class ProtocolFactory extends ServerProtocolFactory
- {
- public ProtocolFactory()
- {
- super(PROTOCOL_NAME);
- }
-
- public Object create(String description) throws ProductCreationException
- {
- return new SignalProtocol<Object>(PROTOCOL_NAME)
- {
- @Override
- protected SignalReactor createSignalReactor(short signalID)
- {
- switch (signalID)
- {
- case UPLOAD_SIGNAL_ID:
- return new UploadIndication(this);
-
- default:
- return super.createSignalReactor(signalID);
- }
- }
- };
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class UploadIndication extends IndicationWithMonitoring
- {
- private boolean replaced;
-
- public UploadIndication(SignalProtocol<Object> protocol)
- {
- super(protocol, UPLOAD_SIGNAL_ID);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
- {
- long size = in.readLong();
- String fileName = in.readString();
- File file = new File(FOLDER_NAME, fileName);
- replaced = file.exists();
- System.out.println((replaced ? "Replacing " : "Storing ") + file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
-
- monitor.begin((int)size);
- BufferedOutputStream out = null;
-
- try
- {
- out = new BufferedOutputStream(new FileOutputStream(file));
- while (size != 0L)
- {
- int chunk = BUFFER_SIZE;
- if (size < BUFFER_SIZE)
- {
- chunk = (int)size;
- }
-
- byte[] buffer = in.readByteArray();
- out.write(buffer);
-
- monitor.worked(chunk);
- size -= chunk;
- }
- }
- finally
- {
- monitor.done();
- if (out != null)
- {
- out.close();
- }
- }
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
- {
- out.writeBoolean(replaced);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ */
+package org.eclipse.net4j.examples.transfer;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.acceptor.IAcceptor;
+import org.eclipse.net4j.internal.examples.bundle.OM;
+import org.eclipse.net4j.signal.IndicationWithMonitoring;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.signal.SignalReactor;
+import org.eclipse.net4j.tcp.TCPUtil;
+import org.eclipse.net4j.util.container.ContainerUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.factory.ProductCreationException;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.log.PrintLogHandler;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
+
+import org.eclipse.spi.net4j.ServerProtocolFactory;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class UploadServer implements UploadProtocol
+{
+ public static final String FOLDER_NAME = "/temp"; //$NON-NLS-1$
+
+ public static void main(String[] args) throws Exception
+ {
+ // Send all traces and logs to the console
+ OMPlatform.INSTANCE.setDebugging(true);
+ OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
+
+ // Use this container to create and wire the components
+ IManagedContainer container = ContainerUtil.createContainer();
+ Net4jUtil.prepareContainer(container);
+ TCPUtil.prepareContainer(container);
+ container.registerFactory(new ProtocolFactory());
+ container.activate();
+
+ try
+ {
+ // Start an acceptor
+ IAcceptor acceptor = (IAcceptor)container.getElement("org.eclipse.net4j.acceptors", "tcp", "0.0.0.0:2036"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ OM.LOG.info("Accepting connections: " + acceptor); //$NON-NLS-1$
+
+ new File(FOLDER_NAME).mkdirs();
+ OM.LOG.info("Upload folder: " + FOLDER_NAME); //$NON-NLS-1$
+
+ System.out.println("Press any key to shutdown"); //$NON-NLS-1$
+ while (System.in.read() == -1)
+ {
+ Thread.sleep(200);
+ }
+ }
+ finally
+ {
+ LifecycleUtil.deactivate(container);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class ProtocolFactory extends ServerProtocolFactory
+ {
+ public ProtocolFactory()
+ {
+ super(PROTOCOL_NAME);
+ }
+
+ public Object create(String description) throws ProductCreationException
+ {
+ return new SignalProtocol<Object>(PROTOCOL_NAME)
+ {
+ @Override
+ protected SignalReactor createSignalReactor(short signalID)
+ {
+ switch (signalID)
+ {
+ case UPLOAD_SIGNAL_ID:
+ return new UploadIndication(this);
+
+ default:
+ return super.createSignalReactor(signalID);
+ }
+ }
+ };
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class UploadIndication extends IndicationWithMonitoring
+ {
+ private boolean replaced;
+
+ public UploadIndication(SignalProtocol<Object> protocol)
+ {
+ super(protocol, UPLOAD_SIGNAL_ID);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
+ {
+ long size = in.readLong();
+ String fileName = in.readString();
+ File file = new File(FOLDER_NAME, fileName);
+ replaced = file.exists();
+ System.out.println((replaced ? "Replacing " : "Storing ") + file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
+
+ monitor.begin((int)size);
+ BufferedOutputStream out = null;
+
+ try
+ {
+ out = new BufferedOutputStream(new FileOutputStream(file));
+ while (size != 0L)
+ {
+ int chunk = BUFFER_SIZE;
+ if (size < BUFFER_SIZE)
+ {
+ chunk = (int)size;
+ }
+
+ byte[] buffer = in.readByteArray();
+ out.write(buffer);
+
+ monitor.worked(chunk);
+ size -= chunk;
+ }
+ }
+ finally
+ {
+ monitor.done();
+ if (out != null)
+ {
+ out.close();
+ }
+ }
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
+ {
+ out.writeBoolean(replaced);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/internal/examples/bundle/OM.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/internal/examples/bundle/OM.java
index 56dd200031..6bf85f859c 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/internal/examples/bundle/OM.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/internal/examples/bundle/OM.java
@@ -1,45 +1,45 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- */
-package org.eclipse.net4j.internal.examples.bundle;
-
-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.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Eike Stepper
- * @since 2.0
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.net4j.examples"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ */
+package org.eclipse.net4j.internal.examples.bundle;
+
+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.trace.OMTracer;
+
+/**
+ * The <em>Operations & Maintenance</em> class of this bundle.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public abstract class OM
+{
+ public static final String BUNDLE_ID = "org.eclipse.net4j.examples"; //$NON-NLS-1$
+
+ public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
+
+ public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
+
+ public static final OMLogger LOG = BUNDLE.logger();
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Activator extends OSGiActivator
+ {
+ public Activator()
+ {
+ super(BUNDLE);
+ }
+ }
+}

Back to the top