Package org.chromattic.api

Examples of org.chromattic.api.ChromatticSession


   @Override
   protected ConsumerSPI internalSaveChangesTo(Consumer consumer)
   {
      ConsumerSPI consumerSPI = super.internalSaveChangesTo(consumer);

      ChromatticSession session = persister.getSession();
      try
      {
         ConsumerMapping cm = session.findById(ConsumerMapping.class, consumer.getPersistentKey());
         cm.initFrom(consumer);
         persister.closeSession(session, true);
      }
      catch (Exception e)
      {
View Full Code Here


   @Override
   protected ConsumerGroupSPI internalCreateConsumerGroup(String name)
   {
      ConsumerGroupSPI group = super.internalCreateConsumerGroup(name);

      ChromatticSession session = persister.getSession();
      try
      {
         ConsumerGroupMapping cgm = mappings.createConsumerGroup(name);
         mappings.getConsumerGroups().add(cgm);
         group.setPersistentKey(cgm.getPersistentKey());
View Full Code Here

   }

   protected void loadConfiguration() throws Exception
   {
      // Try loading configuration from JCR first
      ChromatticSession session = persister.getSession();
      ProducerConfigurationMapping pcm = session.findByPath(ProducerConfigurationMapping.class, PRODUCER_CONFIGURATION_PATH);

      // if we don't have a configuration persisted in JCR already, force a reload from XML and save the resulting configuration
      if (pcm == null)
      {
         pcm = session.insert(ProducerConfigurationMapping.class, PRODUCER_CONFIGURATION_PATH);

         ProducerConfigurationService service = new SimpleXMLProducerConfigurationService(defaultConfigurationIS);

         service.reloadConfiguration();
         configuration = service.getConfiguration();
View Full Code Here

    }

    public <A> A adapt(ModelData modelData, Class<A> type, boolean create) {
        try {
            POMSession pomSession = pomMgr.getSession();
            ChromatticSession chromSession = pomSession.getSession();

            // TODO: Deal with the case where modelData is not persisted before invocation to adapt
            // Get the workspace object
            Object o = pomSession.findObjectById(modelData.getStorageId());

            A a = chromSession.getEmbedded(o, type);
            if (a == null && create) {
                a = chromSession.create(type);
                chromSession.setEmbedded(o, type, a);
            }

            return a;
        } catch (Exception ex) {
            ex.printStackTrace();
View Full Code Here

      throw new UndeclaredRepositoryException(e);
    }
  }

  public void execute(SessionTask task) throws Throwable {
    ChromatticSession session = openSession();

    //
    try {
      task.execute(session);
    }
    finally {
      session.close();
    }
  }
View Full Code Here

            }
         }
      }

      // Temporary work around, to fix in MOP and then remove
      ChromatticSession session;
      try
      {
         Field f = ModelImpl.class.getDeclaredField("session");
         f.setAccessible(true);
         session = (ChromatticSession)f.get(model);
      }
      catch (Exception e)
      {
         throw new Error(e);
      }
      Class<O> mappedClass = (Class<O>)mapping.get(type);
      return session.createQueryBuilder(mappedClass).where(statement).get().objects();
   }
View Full Code Here

    public boolean isModified() {
        if (modified) {
            return true;
        }
        try {
            ChromatticSession session = getSession();
            Session jcrSession = session.getJCRSession();
            modified = jcrSession.hasPendingChanges();
        } catch (RepositoryException e) {
            throw new UndeclaredRepositoryException(e);
        }
        return modified;
View Full Code Here

                statement = "jcr:path LIKE ''";
            }
        }

        // Temporary work around, to fix in MOP and then remove
        ChromatticSession session = context.getSession();
        Class<O> mappedClass = (Class<O>) mapping.get(type);
        return session.createQueryBuilder(mappedClass).where(statement).get().objects((long) offset, (long) limit);
    }
View Full Code Here

   protected abstract void setBuilderOptions(ChromatticBuilder builder);

   public ChromatticSession getSession()
   {
      ChromatticSession chromatticSession = sessionHolder.get();
      if (chromatticSession == null)
      {
         ChromatticSession session = chrome.openSession();
         sessionHolder.set(session);
         return session;
      }
      else
      {
View Full Code Here

      }
   }

   public void closeSession(boolean save)
   {
      ChromatticSession session = getOpenedSessionOrFail();
      if (save)
      {
         synchronized (this)
         {
            session.save();
         }
      }
      session.close();
      sessionHolder.set(null);
   }
View Full Code Here

TOP

Related Classes of org.chromattic.api.ChromatticSession

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.