Exemple #1
0
 public boolean connect() {
   ExpCoordinator.printer.print("NCCPConnection.connect", 3);
   if (host.length() == 0) {
     ExpCoordinator.printer.print("NCCPConnection.connect host is not set", 6);
     return false;
   }
   if (proxy == null && nonProxy == null) {
     ExpCoordinator.printer.print("NCCPConnection.connect proxy null");
     return false;
   }
   if (ExpCoordinator.isSPPMon()) return (connectSPPMon());
   if (state == ConnectionEvent.CONNECTION_CLOSED || state == ConnectionEvent.CONNECTION_FAILED) {
     state = ConnectionEvent.CONNECTION_PENDING;
     if (proxy != null) {
       proxy.openConnection(this);
     }
   }
   /*
   if (nonProxy != null && proxy == null)
   {
   	return (nonProxy.connect());
   }
   */
   return true;
 }
Exemple #2
0
 public void write(ONL.Writer wrtr) throws java.io.IOException {
   wrtr.writeString(host);
   wrtr.writeInt(port);
   short cid = 0;
   if (proxy != null) cid = proxy.getConnectionID(this);
   wrtr.writeShort(cid);
 }
Exemple #3
0
  void enableLionFS() {
    try {
      String version = System.getProperty("os.version");
      String[] tokens = version.split("\\.");
      int major = Integer.parseInt(tokens[0]), minor = 0;
      if (tokens.length > 1) minor = Integer.parseInt(tokens[1]);
      if (major < 10 || (major == 10 && minor < 7))
        throw new Exception("Operating system version is " + version);

      Class fsuClass = Class.forName("com.apple.eawt.FullScreenUtilities");
      Class argClasses[] = new Class[] {Window.class, Boolean.TYPE};
      Method setWindowCanFullScreen = fsuClass.getMethod("setWindowCanFullScreen", argClasses);
      setWindowCanFullScreen.invoke(fsuClass, this, true);

      Class fsListenerClass = Class.forName("com.apple.eawt.FullScreenListener");
      InvocationHandler fsHandler = new MyInvocationHandler(cc);
      Object proxy =
          Proxy.newProxyInstance(
              fsListenerClass.getClassLoader(), new Class[] {fsListenerClass}, fsHandler);
      argClasses = new Class[] {Window.class, fsListenerClass};
      Method addFullScreenListenerTo = fsuClass.getMethod("addFullScreenListenerTo", argClasses);
      addFullScreenListenerTo.invoke(fsuClass, this, proxy);

      canDoLionFS = true;
    } catch (Exception e) {
      vlog.debug("Could not enable OS X 10.7+ full-screen mode:");
      vlog.debug("  " + e.toString());
    }
  }
 /**
  * Builds a new AgentMBeanServerConnectionFactory and returns the underlying
  * MBeanServerConnection
  *
  * @return a new MBeanServerConnection
  */
 public MBeanServerConnection build() {
   final String key = buildKey();
   MBeanServerConnection conn = INSTANCES.get(key);
   if (conn == null) {
     synchronized (INSTANCES) {
       conn = INSTANCES.get(key);
       if (conn == null) {
         conn =
             (MBeanServerConnection)
                 Proxy.newProxyInstance(
                     Thread.currentThread().getContextClassLoader(),
                     new Class[] {MBeanServerConnection.class},
                     new AgentMBeanServerConnectionFactory(this));
         INSTANCES.put(key, conn);
         channel
             .getCloseFuture()
             .addListener(
                 new ChannelFutureListener() {
                   @Override
                   public void operationComplete(ChannelFuture future) throws Exception {
                     INSTANCES.remove(key);
                   }
                 });
       }
     }
   }
   return conn;
 }
 ConnectionWrapper(Connection con) {
   this.connection =
       (Connection)
           Proxy.newProxyInstance(
               con.getClass().getClassLoader(), con.getClass().getInterfaces(), this);
   m_originConnection = con;
 }
  /**
   * Creates a new proxy with the specified URL. The returned object is a proxy with the interface
   * specified by api.
   *
   * <pre>
   * String url = "http://localhost:8080/ejb/hello");
   * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
   * </pre>
   *
   * @param api the interface the proxy class needs to implement
   * @param url the URL where the client object is located.
   * @return a proxy to the object with the specified interface.
   */
  public Object create(Class api, String urlName, ClassLoader loader) throws MalformedURLException {
    URL url = new URL(urlName);

    HessianProxy handler = new HessianProxy(this, url);

    return Proxy.newProxyInstance(
        api.getClassLoader(), new Class[] {api, HessianRemoteObject.class}, handler);
  }
Exemple #7
0
 public void read(ONL.Reader rdr) throws java.io.IOException {
   setHost(new String(rdr.readString()));
   setPort(rdr.readInt());
   short cid = (short) rdr.readShort();
   ExpCoordinator.print(
       new String("NCCPConnection.read host:" + getHost() + " port:" + getPort() + " cid:" + cid),
       5);
   if (proxy != null) proxy.setConnectionID(this, cid);
 }
  private ConnectivitySettings proxyToCs(Proxy proxy, URI uri) {
    ConnectivitySettings cs = new ConnectivitySettings();
    InetSocketAddress isa = (InetSocketAddress) proxy.address();
    switch (proxy.type()) {
      case HTTP:
        setupProxy(cs, ConnectivitySettings.CONNECTION_VIA_HTTPS, isa);
        break;
      case SOCKS:
        setupProxy(cs, ConnectivitySettings.CONNECTION_VIA_SOCKS, isa);
        break;
      default:
    }

    String prosyUser = NetworkSettings.getAuthenticationUsername(uri);
    if (prosyUser != null && !prosyUser.isEmpty()) {
      cs.setProxyUsername(prosyUser);
      cs.setProxyPassword(Keyring.read(NetworkSettings.getKeyForAuthenticationPassword(uri)));
    }
    return cs;
  }
Exemple #9
0
 public void setConnectionID(short cid) {
   ExpCoordinator.print(
       new String(
           "NCCPConnection.setConnectionID host:"
               + getHost()
               + " port:"
               + getPort()
               + " cid:"
               + cid),
       5);
   if (proxy != null) proxy.setConnectionID(this, cid);
 }
Exemple #10
0
 public void sendMessage(NCCP.Message msg) {
   if (isClosed() || isFailed()) connect();
   if (isConnected()) {
     ExpCoordinator.printer.print("NCCPConnection::sendMessage", 5);
     if (proxy != null) proxy.sendMessage(msg, this);
     else {
       if (nonProxy != null) nonProxy.sendMessage(msg);
     }
   } else // still can't connect
   {
     pendingMessages.add(msg);
   }
 }
Exemple #11
0
 public void close() {
   if (proxy != null && isConnected()) {
     proxy.closeConnection(this);
     setConnected(false);
   } else {
     if (nonProxy != null && isConnected()) {
       try {
         Thread.sleep(1000);
       } catch (java.lang.InterruptedException e2) {
       }
       nonProxy.close();
       setConnected(false);
     }
   }
 }
Exemple #12
0
 public short getConnectionID() {
   if (proxy != null) return ((short) proxy.getConnectionID(this));
   else return ((short) 0);
 }
Exemple #13
0
 public void setProxy(Proxy p) {
   proxy = p;
   proxy.addConnection(this);
 }