Examples of DataManager


Examples of com.sun.sgs.app.DataManager

    /**
     * Log the user in from the specificed session.
     * @param session
     */
    public void login(WonderlandClientID clientID) {
        DataManager dm = AppContext.getDataManager();
        dm.markForUpdate(this);

        // issue 963: session could be null if client is in the process of
        // logging out
        if (clientID.getSession() == null) {
            return;
        }
        String name = clientID.getSession().getName();

        // find the user object from the database, create it if necessary
        UserMO user = getUserMO(name);
        if (user==null) {
            user = createUserMO(name);
        }
       
        // user is now logged in
        user.login(clientID);
       
        // add this session to our map
        clientToUser.put(clientID, user.getReference());

        // notify listeners for just this user
        for (ManagedReference<UserListener> listenerRef : user.getUserListeners()) {
            AppContext.getTaskManager().scheduleTask(
                    new UserListenerNotifier(listenerRef,
                                             dm.createReference(user),
                                             null,
                                             clientID,
                                             NotificationType.LOGIN));
        }

        // notify listeners for all users
        for (ManagedReference<UserListener> listenerRef : userListeners) {
            AppContext.getTaskManager().scheduleTask(
                    new UserListenerNotifier(listenerRef,
                                             dm.createReference(user),
                                             null,
                                             clientID,
                                             NotificationType.LOGIN));
        }
    }
View Full Code Here

Examples of com.sun.sgs.app.DataManager

     * @param clientID the id of the client to end the logout process for
     * @throws IllegalArgumentException if no user is associated with the given
     * client id.
     */
    public void finishLogout(WonderlandClientID clientID) {
        DataManager dm = AppContext.getDataManager();

        // make sure there is a user
        UserMO user = getUser(clientID);
        if (user == null) {
            throw new IllegalArgumentException("Client " + clientID +
                                               " not logged in.");
        }

        // get the task queue to use
        Queue<Task> tasks = user.getLogoutTasks(clientID);
       
        // add listener notification tasks to the queue, starting with
        // per-user listeners
        for (ManagedReference<UserListener> listener : user.getUserListeners()) {
            tasks.add(new UserListenerNotifier(listener,
                                               dm.createReference(user),
                                               dm.createReference(tasks),
                                               clientID,
                                               NotificationType.LOGOUT));
        }
       
        // next add global listeners
        for (ManagedReference<UserListener> listener : userListeners) {
            tasks.add(new UserListenerNotifier(listener,
                                               dm.createReference(user),
                                               dm.createReference(tasks),
                                               clientID,
                                               NotificationType.LOGOUT));
        }

        // now that we have collected all logout tasks, start running them
        AppContext.getTaskManager().scheduleTask(
                new LogoutTask(clientID, dm.createReference(tasks)));
    }
View Full Code Here

Examples of com.sun.sgs.app.DataManager

         *
         * @code prev the {@code Element} after this {@code Element}
         *       in the deque
         */
        void setNext(Element<E> next) {
            DataManager dm = AppContext.getDataManager();
            ManagedReference<Element<E>> ref =
                    (next == null) ? null : dm.createReference(next);

            dm.markForUpdate(this);
            nextElement = ref;
        }
View Full Code Here

Examples of com.sun.sgs.app.DataManager

         *
         * @code prev the {@code Element} before this {@code Element}
         *       in the deque
         */
        void setPrev(Element<E> prev) {
            DataManager dm = AppContext.getDataManager();
            ManagedReference<Element<E>> ref =
                    (prev == null) ? null : dm.createReference(prev);

            dm.markForUpdate(this);
            prevElement = ref;
        }
View Full Code Here

Examples of com.sun.sgs.app.DataManager

    public String getIDFor(ProximityListenerSrv listener) {
        // issue #1101: if the listener is a managed object, generate
        // and ID based on the ID of the underlying managed object.
        if (listener instanceof ManagedObject) {
            DataManager dm = AppContext.getDataManager();
            return cellID + "." + dm.createReference(listener).getId();
        } else {
            // the object is not a managed object, so return a newly assigned
            // id
            return cellID + "." + nextID++;
        }
View Full Code Here

Examples of com.sun.sgs.app.DataManager

  // Schedule asynchronous task here
  // which will delete the list
  AppContext.getTaskManager().scheduleTask(clearTask);

  // Remove the dummy connectors
  DataManager dm = AppContext.getDataManager();
  dm.removeObject(headRef.get());
  dm.removeObject(tailRef.get());
    }
View Full Code Here

Examples of com.sun.sgs.app.DataManager

        private String id;

        public ManagedProximityListenerWrapper(ProximityListenerSrv listener, String id) {
            this.id = id;

            DataManager dm = AppContext.getDataManager();
            dm.setBinding(BINDING_NAME + id, listener);
        }
View Full Code Here

Examples of com.sun.sgs.app.DataManager

     * regarding the structure's performance.
     */
    public ScalableDeque() {
        backingMap = new ScalableHashMap<Element<E>, Long>();

        DataManager dm = AppContext.getDataManager();
        backingMapRef = dm.createReference(backingMap);

        // initialize the pointers to the front and end of the deque
        // to null.  However, the reference to these pointers will
        // always be non-null
        ManagedSerializable<ManagedReference<Element<E>>> head =
                new ManagedSerializable<ManagedReference<Element<E>>>(null);
        ManagedSerializable<Long> headCount =
                new ManagedSerializable<Long>(-1L);

        ManagedSerializable<ManagedReference<Element<E>>> tail =
                new ManagedSerializable<ManagedReference<Element<E>>>(null);
        ManagedSerializable<Long> tailCount =
                new ManagedSerializable<Long>(0L);

        headElement = dm.createReference(head);
        headCounter = dm.createReference(headCount);
        tailElement = dm.createReference(tail);
        tailCounter = dm.createReference(tailCount);
    }
View Full Code Here

Examples of com.sun.sgs.app.DataManager

        updateWorldBounds(worldTransform);
    }

    void setLive(boolean isLive, final CellMO cell, UniverseManager mgr) {
        DataManager dm = AppContext.getDataManager();

        if (isLive) {
            Map<CellID, Integer> indexMap = new ScalableHashMap<CellID, Integer>();
            dm.setBinding(BINDING_NAME + id, indexMap);

            mgr.addTransformChangeListener(cell, this);
            mgr.addViewUpdateListener(cell, this);

            // issue #727: if the cell has not yet been added (because the job
            // to add it is scheduled but hasn't run), this may return null.
            // In that case, just return, since the listener will be notified
            // with the actual bounds once the cell is fully inserted into the
            // world
            CellTransform worldTransform = cell.getWorldTransform(null);
            if (worldTransform != null) {
                // Issue #721: we need to set the transform to the cell's transform
                // here, since the cell may already exist and we can't count on
                // getting a transform changed notification until the cell moves
                updateWorldBounds(worldTransform);
            }
        } else {
            mgr.removeTransformChangeListener(cell, this);
            mgr.removeViewUpdateListener(cell, this);

            try {
                dm.removeBinding(BINDING_NAME + id);
            } catch (NameNotBoundException nnbe) {
                // we can safely ignore this -- this just means the component
                // is being added before the cell is live, so the first time
                // setLive is called, the binding hasn't been created
                logger.log(Level.FINE, null, nnbe);
View Full Code Here

Examples of com.sun.sgs.app.DataManager

     *
     * @param e the new head {@code Element}.
     */
    private void addToHead(Element<E> e) {

        DataManager dm = AppContext.getDataManager();

        // short-circuit case if this element is the only element in
        // the deque (i.e. the deque was empty)
        if (headElement.get().get() == null) {
            ManagedReference<Element<E>> ref = dm.createReference(e);
            headElement.get().set(ref);
            tailElement.get().set(ref);
            return;
        }

        Element<E> oldHead = headElement();
        headElement.get().set(dm.createReference(e));
        e.setPrev(null);
        e.setNext(oldHead);
        oldHead.setPrev(e);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.