- package com.perforce.p4java.util;
-
- import java.net.URISyntaxException;
-
- import org.apache.log4j.Logger;
-
- import com.perforce.p4java.exception.AccessException;
- import com.perforce.p4java.exception.ConfigException;
- import com.perforce.p4java.exception.ConnectionException;
- import com.perforce.p4java.exception.NoSuchObjectException;
- import com.perforce.p4java.exception.RequestException;
- import com.perforce.p4java.exception.ResourceException;
- import com.perforce.p4java.exceptions.P4ConnectionException;
- import com.perforce.p4java.server.IServer;
- import com.perforce.p4java.server.ServerFactory;
-
- /**
- * This class is used to create a connection to the
- * perforce server on a given port abstracting away
- * the functionality from ServerFactory and Server implementations.
- *
- * @author tpethiyagoda
- *
- */
- public class P4JavaConnection {
-
- private static final Logger LOGGER_= Logger.getLogger(P4JavaConnection.class);
-
- /**
- * Creates a connection to Helix.
- *
- * @param serverName The name of the server in this form : p4java://server.perforce.com:1666
- * @throws P4ConnectionException which is a RuntimeException
- *
- */
- public IServer connect(String serverName)
- {
- try {
- IServer p4server = ServerFactory.getServer(serverName, null);//use IOptionServer here
- p4server.connect();
- return p4server;
-
- } catch (ConnectionException e) {
- LOGGER_.error(e.getMessage(), e);
- throw new P4ConnectionException(e.getMessage(), e);
- } catch (NoSuchObjectException e) {
- LOGGER_.error(e.getMessage(), e);
- throw new P4ConnectionException(e.getMessage(), e);
- } catch (ConfigException e) {
- LOGGER_.error(e.getMessage(), e);
- throw new P4ConnectionException(e.getMessage(), e);
- } catch (ResourceException e) {
- LOGGER_.error(e.getMessage(), e);
- throw new P4ConnectionException(e.getMessage(), e);
- } catch (URISyntaxException e) {
- LOGGER_.error(e.getMessage(), e);
- throw new P4ConnectionException(e.getMessage(), e);
- } catch (AccessException e) {
- LOGGER_.error(e.getMessage(), e);
- throw new P4ConnectionException(e.getMessage(), e);
- } catch (RequestException e) {
- LOGGER_.error(e.getMessage(), e);
- throw new P4ConnectionException(e.getMessage(), e);
- }
-
- }
- }
# |
Change |
User |
Description |
Committed |
|
#2
|
21573 |
tpeths |
Refactoring unit tests to be more independent |
8 years ago
|
|
#1
|
21561 |
tpeths |
Initial checkin |
8 years ago
|
|