Package org.objectweb.speedo.mim.api

Examples of org.objectweb.speedo.mim.api.PersistentObjectItf


      Object elem = iElem.getElement((POManagerItf) pm);
      Object clone = null;
      //if it is a persistent object, detach it
      if (elem instanceof PersistentObjectItf) {
        //get the speedo po associated
        PersistentObjectItf sp = (PersistentObjectItf) elem;
        if(map != null)
          clone = map.get(sp);
        //detach only if not already done before
        if (clone == null) {
          synchronized(currentFgHints){
View Full Code Here


    while(it.hasNext()){
      Object elem = it.next();
      //if it is a persistent object
      if (elem instanceof PersistentObjectItf) {
        //get the detached speedo po
        PersistentObjectItf spDetached = (PersistentObjectItf) elem;
        PersistentObjectItf sp = (PersistentObjectItf) map.get(spDetached);
        if(sp == null){
          map.put(spDetached, sp);
          sp = (PersistentObjectItf) pm.speedoAttachCopy(spDetached, map);
        }
        //put the element of the collection attribute in the elements attribute (the opposite of the jdoDetachCopy method)
View Full Code Here

    Iterator it = elements.iterator();
    while(it.hasNext()){
      //get the PIndexElement
      CollectionElem iElem = (CollectionElem) it.next();
      //get the po associated
      PersistentObjectItf sp = (PersistentObjectItf) iElem.getElement(pm);
      if(map != null && !map.containsKey(sp.getPName())){
        synchronized(fgHints){
          if (refresh) { //refresh
                        pm.speedoRefresh(sp, map, fgHints);
          } else { //retrieve
                        pm.speedoRetrieve(sp, map, fgHints);
View Full Code Here

        if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG, "read ctx=" + context
                    + " / oid=" + oid
                    + " / obj.class=" + obj.getClass().getName());
        StateItf state = (StateItf) obj;
    PersistentObjectItf pb = (PersistentObjectItf) state.getSpeedoPO();
    int speedoStatus = state.speedoGetStatus();
    if (pb.getStatus() == PBinding.LIFECYCLE_DELTOWRITE
            && speedoStatus != LifeCycle.PERSISTENT_DELETED
            && speedoStatus != LifeCycle.PERSISTENT_NEW_DELETED) {
        throw new PersistenceException(
                "Concurrency problem, transaction must be rolledback");
    }
        try {
            pb.read(context, state);
            context.getWorkingSet().bind(state, oid, WorkingSet.UNKNOWN_INTENTION);
            //modified with rebind
            state.indexFieldModified(Integer.MAX_VALUE, true);
          pb.speedoGetHome().sendEvent(HomeItf.POST_LOAD, pb, null);
        } catch (PExceptionNoDSI e) {
      if (logger.isLoggable(BasicLevel.DEBUG)) {
              logger.log(BasicLevel.DEBUG, "read ==> NO DSI");
      }
      throw new NoDSIPersistenceException(e);
View Full Code Here

            logger.log(BasicLevel.DEBUG, "read conn=" + conn
                    + " / oid=" + oid
                    + " / obj.class=" + obj.getClass().getName()
                    + " / tx=" + ws);
        StateItf state = (StateItf) obj;
    PersistentObjectItf pb = (PersistentObjectItf) state.getSpeedoPO();
    int speedoStatus = state.speedoGetStatus();
    if (pb.getStatus() == PBinding.LIFECYCLE_DELTOWRITE
            && speedoStatus != LifeCycle.PERSISTENT_DELETED
            && speedoStatus != LifeCycle.PERSISTENT_NEW_DELETED) {
        throw new PersistenceException(
                "Concurrency problem, transaction must be rolledback");
    }
    Object ctx = usePrefetchBuffer(ws, oid) ? ws : null;
        try {
            pb.read(conn, state, ctx, forUpdate);
            ws.bind(state, oid, WorkingSet.UNKNOWN_INTENTION);
            //modified with rebind
            state.indexFieldModified(Integer.MAX_VALUE, true);
          pb.speedoGetHome().sendEvent(HomeItf.POST_LOAD, pb, null);
    } catch (PExceptionNoDSI e) {
      if (logger.isLoggable(BasicLevel.DEBUG)) {
              logger.log(BasicLevel.DEBUG, "read ==> NO DSI");
      }
      throw new NoDSIPersistenceException(e);
View Full Code Here

            throw new PersistenceException(ie);
        }
    }

    public void write(ConnectionHolder context, Object oid, State obj) throws PersistenceException {
    PersistentObjectItf pb = (PersistentObjectItf) obj.getCacheEntry();
        if (logger.isLoggable(BasicLevel.DEBUG)) {
            logger.log(BasicLevel.DEBUG, "write ctx=" + context
                    + " / oid=" + oid
                    + " / obj.class=" + obj.getClass().getName()
                    + " / binding.status=" + pb.getStatus());
        }
        int s = pb.getStatus();
      int preEvent = 0;
      int postEvent = 0;
      switch(s) {
      case  PBinding.LIFECYCLE_ACTIVEFORIO:
        preEvent = HomeItf.PRE_UPDATE;
        postEvent = HomeItf.POST_UPDATE;
        break;
      case  PBinding.LIFECYCLE_NEWTOWRITE:
        preEvent = HomeItf.PRE_CREATE;
        postEvent = HomeItf.POST_CREATE;
        break;
      case  PBinding.LIFECYCLE_DELTOWRITE:
        preEvent = HomeItf.PRE_DELETE;
        postEvent = HomeItf.POST_DELETE;
        break;
      }
         if (preEvent != 0 && postEvent != 0) {
          pb.speedoGetHome().sendEvent(preEvent, pb, null);
      try {
        pb.write(context, (PAccessor) obj);
      } catch (PExceptionNoDSI e) {
        throw new NoDSIPersistenceException(e);
      } catch (PException e) {
        throw new PersistenceException(e);
      }
             pb.speedoGetHome().sendEvent(postEvent, pb, null);
    }
    }
View Full Code Here

  private HomeItf getHome(Object o) {
    if (o == null) {
      logger.log(BasicLevel.WARN, "Impossible to find the home: null object");
      return null;
    } else if (o instanceof PersistentObjectItf) {
            PersistentObjectItf po =(PersistentObjectItf) o;
      HomeItf h = po.speedoGetHome();
      if (h == null) {
                if (o instanceof SpeedoGenClassPO) {
                    PName pn = po.getPName();
                    if (pn == null) {
                        h = (HomeItf) ((PBinder) pn.getPNameManager()).getBinderClassMapping();
                    } else {
                        h = (HomeItf) jf.getGenClassMapping(
                                ((SpeedoGenClassPO) po).speedoGetGenClassId());
View Full Code Here

      }
      className = type.getJormName();
      int idx = className.indexOf(JormPathHelper.SEP);
      PClassMapping pcm = ((PBinder) pn.getPNameManager())
          .getBinderClassMapping();
      PersistentObjectItf sp = null;
      if ((pcm instanceof AbstractGenClassHome) && idx != -1) {
        // This is a Generic class
        className = getGCClassName(className.substring(0, idx));
        sp = (PersistentObjectItf) Class.forName(className).newInstance();
      } else {
        if (pcm != null) {
          className = pcm.getClassName();
        }
        ClassLoader cl = jf.getClassLoader(className);
        if (cl == null) {
          cl = oid.getClass().getClassLoader();
          if (cl == null) {
            cl = ClassLoader.getSystemClassLoader();
          }
        }
        sp = (PersistentObjectItf)
            cl.loadClass(className).newInstance();
      }
            sp.speedoSetReferenceState(null);
      return sp;
    } catch (PException e) {
      throw new PersistenceException(
          "Impossible to analyze the object identifier" + oid, e);
    } catch (Exception e) {
View Full Code Here

  public State createState(CacheEntry ce) {
    return ((PersistentObjectItf) ce).speedoCreateState();
  }

  public State createState(State s) {
    PersistentObjectItf sp = (PersistentObjectItf) s.getCacheEntry();
    StateItf sa = sp.speedoCreateState();
    sp.speedoCopyState(((StateItf) s), sa);
    return sa;
  }
View Full Code Here

  public void setReferenceState(CacheEntry ce, State state) {
    if (state == ((PersistentObjectItf) ce).speedoGetReferenceState()) {
      return;
    }
    PersistentObjectItf sp = (PersistentObjectItf) ce;
    if (sp.speedoIsActive() && state == null) {
        sp.speedoGetHome().sendEvent(HomeItf.PRE_CLEAR, sp, null);
    }
      sp.speedoSetReferenceState((StateItf) state);
    if (sp.speedoIsActive() && state == null) {
        sp.speedoGetHome().sendEvent(HomeItf.POST_CLEAR, sp, null);
    }
  }
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.mim.api.PersistentObjectItf

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.