ExampleService.java :  » Net » hyperpool-0.4.0 » examples » Java Open Source

Java Open Source » Net » hyperpool 0.4.0 
hyperpool 0.4.0 » examples » ExampleService.java
package examples;

import vicazh.hyperpool.stream.net.http.*;

public class ExampleService extends Service implements ExampleServiceMBean {
  private boolean client;

  /**
   * Set the clients parameter
   */
  public void setClient(boolean client) {
    this.client = client;
  }

  /**
   * Return clients parameter
   */
  public boolean isClient() {
    return client;
  }

  private boolean server;

  /**
   * Set the servers parameter
   */
  public void setServer(boolean server) {
    this.server = server;
  }

  /**
   * Return servers parameter
   */
  public boolean isServer() {
    return server;
  }

  synchronized void print(String s) {
    StringBuffer sb = new StringBuffer();
    sb.append("---------------------------------------------------\r\n");
    sb.append("\r\n");
    sb.append(s + "\r\n");
    sb.append("---------------------------------------------------\r\n");
    String result = sb.toString();
    System.out.println(result);
    sendAttribute(ExampleServiceMBean.PRINT, result);
  }

  public Connection getConnection() {
    return new ExampleServiceConnection(this);
  }

  public void setAttribute(String name, Object value) throws Exception {
    if (name.equals(ExampleServiceMBean.CLIENT))
      setClient((Boolean) value);
    else if (name.equals(ExampleServiceMBean.SERVER))
      setServer((Boolean) value);
    super.setAttribute(name, value);
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.