Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-06-06 18:05:10 +0000
committerEike Stepper2012-06-06 18:05:10 +0000
commit4a711b5a64c086bd1aec35465e96807cd7572dc0 (patch)
tree1f094a2acda82566abd8de555f21044dfdf16a40 /plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnectorFactory.java
parentbc6860460ea734dc2dfa4cc82238486f53c81d41 (diff)
downloadcdo-4a711b5a64c086bd1aec35465e96807cd7572dc0.tar.gz
cdo-4a711b5a64c086bd1aec35465e96807cd7572dc0.tar.xz
cdo-4a711b5a64c086bd1aec35465e96807cd7572dc0.zip
[381472] Design a repository administration API
https://bugs.eclipse.org/bugs/show_bug.cgi?id=381472
Diffstat (limited to 'plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnectorFactory.java')
-rw-r--r--plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnectorFactory.java200
1 files changed, 99 insertions, 101 deletions
diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnectorFactory.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnectorFactory.java
index f7281a5dae..3982bedbdd 100644
--- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnectorFactory.java
+++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnectorFactory.java
@@ -1,101 +1,99 @@
-/*
- * 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
- * Caspar De Groot - maintenance
- */
-package org.eclipse.net4j.internal.tcp;
-
-import org.eclipse.net4j.tcp.ITCPConnector;
-import org.eclipse.net4j.util.StringUtil;
-import org.eclipse.net4j.util.factory.ProductCreationException;
-
-import org.eclipse.spi.net4j.ConnectorFactory;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/**
- * @author Eike Stepper
- */
-public class TCPConnectorFactory extends ConnectorFactory
-{
- public static final String TYPE = "tcp"; //$NON-NLS-1$
-
- private static final String URL_SCHEME = "http://"; //$NON-NLS-1$
-
- public TCPConnectorFactory()
- {
- super(TYPE);
- }
-
- /**
- * Allows derived classes to override the TYPE identifier
- */
- protected TCPConnectorFactory(String type)
- {
- super(type);
- }
-
- public TCPConnector create(String description)
- {
- try
- {
- // TODO Don't use URL
- // Scheme "tcp://" would be rejected!
- URL url = new URL(URL_SCHEME + description);
- String userID = url.getUserInfo();
- String host = url.getHost();
- int port = url.getPort();
- if (port == -1)
- {
- port = ITCPConnector.DEFAULT_PORT;
- }
-
- TCPConnector connector = createConnector();
- connector.setUserID(userID);
- connector.setHost(host);
- connector.setPort(port);
- return connector;
- }
- catch (MalformedURLException ex)
- {
- throw new ProductCreationException(ex);
- }
- }
-
- protected TCPConnector createConnector()
- {
- return new TCPClientConnector();
- }
-
- @Override
- public String getDescriptionFor(Object object)
- {
- if (object instanceof TCPConnector)
- {
- TCPConnector connector = (TCPConnector)object;
- String description = connector.getHost();
- String userID = connector.getUserID();
- if (!StringUtil.isEmpty(userID))
- {
- description = userID + "@" + description; //$NON-NLS-1$
- }
-
- int port = connector.getPort();
- if (port != ITCPConnector.DEFAULT_PORT)
- {
- description = description + ":" + port; //$NON-NLS-1$
- }
-
- return description;
- }
-
- return null;
- }
-}
+/*
+ * 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
+ * Caspar De Groot - maintenance
+ */
+package org.eclipse.net4j.internal.tcp;
+
+import org.eclipse.net4j.tcp.ITCPConnector;
+import org.eclipse.net4j.util.StringUtil;
+import org.eclipse.net4j.util.factory.ProductCreationException;
+
+import org.eclipse.spi.net4j.ConnectorFactory;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * @author Eike Stepper
+ */
+public class TCPConnectorFactory extends ConnectorFactory
+{
+ public static final String TYPE = "tcp"; //$NON-NLS-1$
+
+ public TCPConnectorFactory()
+ {
+ super(TYPE);
+ }
+
+ /**
+ * Allows derived classes to override the TYPE identifier
+ */
+ protected TCPConnectorFactory(String type)
+ {
+ super(type);
+ }
+
+ public TCPConnector create(String description)
+ {
+ try
+ {
+ // TODO Don't use URL
+ // Scheme "tcp://" would be rejected!
+ URL url = new URL("http://" + description);
+ String userID = url.getUserInfo();
+ String host = url.getHost();
+ int port = url.getPort();
+ if (port == -1)
+ {
+ port = ITCPConnector.DEFAULT_PORT;
+ }
+
+ TCPConnector connector = createConnector();
+ connector.setUserID(userID);
+ connector.setHost(host);
+ connector.setPort(port);
+ return connector;
+ }
+ catch (MalformedURLException ex)
+ {
+ throw new ProductCreationException(ex);
+ }
+ }
+
+ protected TCPConnector createConnector()
+ {
+ return new TCPClientConnector();
+ }
+
+ @Override
+ public String getDescriptionFor(Object object)
+ {
+ if (object instanceof TCPConnector)
+ {
+ TCPConnector connector = (TCPConnector)object;
+ String description = connector.getHost();
+ String userID = connector.getUserID();
+ if (!StringUtil.isEmpty(userID))
+ {
+ description = userID + "@" + description; //$NON-NLS-1$
+ }
+
+ int port = connector.getPort();
+ if (port != ITCPConnector.DEFAULT_PORT)
+ {
+ description = description + ":" + port; //$NON-NLS-1$
+ }
+
+ return description;
+ }
+
+ return null;
+ }
+}

Back to the top