Package com.sun.sgs.service

Examples of com.sun.sgs.service.DataService


   * also removes the protocol descriptors for the node
   * specified during construction.
   */
  public void run() {
      String sessionServerKey = getClientSessionServerKey(nodeId);
      DataService dataService = getDataService();
      try {
    dataService.removeObject(
        dataService.getServiceBinding(sessionServerKey));
    getProtocolDescriptorsMap().remove(nodeId);
      } catch (NameNotBoundException e) {
    // already removed
    return;
      } catch (ObjectNotFoundException e) {
      }
      dataService.removeServiceBinding(sessionServerKey);
  }
View Full Code Here


            this.properties = properties;
        }

        /** Starts the application, throwing an exception on failure. */
        public void run() throws Exception {
            DataService dataService =
                Kernel.proxy.getService(DataService.class);
            try {
                // test to see if this name if the listener is already bound...
                dataService.getServiceBinding(StandardProperties.APP_LISTENER);
            } catch (NameNotBoundException nnbe) {
                // ...if it's not, create and then bind the listener
                AppListener listener =
                    (new PropertiesWrapper(properties)).
                    getClassInstanceProperty(StandardProperties.APP_LISTENER,
                                             AppListener.class, new Class[] {});
                if (listener instanceof ManagedObject) {
                    dataService.setServiceBinding(
                            StandardProperties.APP_LISTENER, listener);
                } else {
                    dataService.setServiceBinding(
                            StandardProperties.APP_LISTENER,
                            new ManagedSerializable<AppListener>(listener));
                }

                // since we created the listener, we're the first one to
View Full Code Here

   
    /** {@inheritDoc} */
    @SuppressWarnings("unchecked")
    public V remove(Object key) {
  checkKey("key", key);
  DataService dataService = BindingKeyedCollectionsImpl.getDataService();
  String bindingName = getBindingName((String) key);
  V value = null;
  try {
      ManagedObject v = dataService.getServiceBinding(bindingName);
      if (v instanceof Wrapper) {
    value = (V) ((Wrapper) v).get();
    dataService.removeObject(v);
      } else {
    value = (V) v;
      }
      dataService.removeServiceBinding(bindingName);
  } catch (NameNotBoundException e) {
  }
  return value;
    }
View Full Code Here

     * @param  keyPrefix a key prefix
     * @returns  {@code true} if the {@code keyPrefix} corresponds to an
     *    empty map
     */
    private static boolean isEmptyInternal(String keyPrefix) {
  DataService dataService = BindingKeyedCollectionsImpl.getDataService();
  String key = dataService.nextServiceBoundName(keyPrefix);
  return key == null || !key.startsWith(keyPrefix);
    }
View Full Code Here

    /**
     * Returns {@code true} if a service binding with the specified
     * {@code bindingName} exists.
     */
    private static boolean containsKeyInternal(String bindingName) {
  DataService dataService = BindingKeyedCollectionsImpl.getDataService();
  boolean containsKey = false;
  try {
      dataService.getServiceBinding(bindingName);
      containsKey = true;
  } catch (NameNotBoundException e) {
  } catch (ObjectNotFoundException e) {
      containsKey = true;
  }
View Full Code Here

     * {@code false}.
     */
    private static boolean removeOverrideInternal(String bindingName) {
  boolean previouslyMapped = containsKeyInternal(bindingName);
  if (previouslyMapped) {
      DataService dataService =
    BindingKeyedCollectionsImpl.getDataService();
      try {
    removeValue(bindingName);
      } catch (ObjectNotFoundException ignore) {
      }
      dataService.removeServiceBinding(bindingName);
  }
  return previouslyMapped;
    }
View Full Code Here

     * @throws  NameNotBoundException if the service binding does not exist
     * @throws  ObjectNotFoundException if the value associated with the
     *    specified {@code bindingName} has been removed
     */
    private static void removeValue(String bindingName) {
  DataService dataService =
      BindingKeyedCollectionsImpl.getDataService();
  ManagedObject v = dataService.getServiceBinding(bindingName);
  if (v instanceof Wrapper) {
      dataService.removeObject(v);
  }
    }
View Full Code Here

  this.identity = identity;
  this.deliveries = deliveries;
  this.nodeId = sessionService.getLocalNodeId();
        this.maxMessageLength = maxMessageLength;
  writeBufferCapacity = sessionService.getWriteBufferSize();
  DataService dataService = sessionService.getDataService();
  ManagedReference<ClientSessionImpl> sessionRef =
      dataService.createReference(this);
  id = sessionRef.getId();
  this.wrappedSessionRef =
      dataService.createReference(new ClientSessionWrapper(sessionRef));
  idBytes = id.toByteArray();
  // TBD: these service bindings could be stored in a BindingKeyedMap
  // instead.
  dataService.setServiceBinding(getSessionKey(), this);
  dataService.setServiceBinding(getSessionNodeKey(), this);
  dataService.setServiceBinding(getEventQueueKey(), new EventQueue(this));
  logger.log(Level.FINEST, "Stored session, identity:{0} id:{1}",
       identity, id);
    }
View Full Code Here

  if (newNodeId != sessionService.getLocalNodeId()) {
      throw new IllegalArgumentException(
    "newNodeId:" + newNodeId + " must match the local node ID:" +
    sessionService.getLocalNodeId());
  }
  DataService dataService = sessionService.getDataService();
  dataService.markForUpdate(this);
  dataService.removeServiceBinding(getSessionNodeKey());
  nodeId = newNodeId;
  // TBD: this could use a BindingKeyedMap.
  dataService.setServiceBinding(getSessionNodeKey(), this);
    }
View Full Code Here

     * Returns the event queue for the client session with the specified
     * {@code sessionId}, or null if the event queue is not bound in the
     * data service.
     */
    private static EventQueue getEventQueue(byte[] sessionId) {
  DataService dataService =
      ClientSessionServiceImpl.getInstance().getDataService();
  String eventQueueKey = getEventQueueKey(sessionId);
  try {
      return (EventQueue) dataService.getServiceBinding(eventQueueKey);
  } catch (NameNotBoundException e) {
      return null;
  }
    }
View Full Code Here

TOP

Related Classes of com.sun.sgs.service.DataService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.