Package org.chromattic.api

Examples of org.chromattic.api.ChromatticSession


      {
         throw new IllegalArgumentException("ProducerInfo '" + producerInfo.getId()
            + "' hasn't been persisted and thus cannot be updated.");
      }

      ChromatticSession session = persister.getSession();
      ProducerInfoMapping pim = session.findById(ProducerInfoMapping.class, key);
      if (pim == null)
      {
         throw new IllegalArgumentException("Couldn't find ProducerInfoMapping associated with key " + key);
      }
      String oldId = pim.getId();
View Full Code Here


   }

   public GadgetRegistry getRegistry()
   {
      Chromattic chromattic = chromatticLifeCycle.getChromattic();
      ChromatticSession session = chromattic.openSession();
      GadgetRegistry registry = session.findByPath(GadgetRegistry.class, "app:gadgets");
      if (registry == null)
      {
         registry = session.insert(GadgetRegistry.class, "app:gadgets");
      }
      return registry;
   }
View Full Code Here

   }

   @Override
   protected Iterator<ProducerInfo> getProducerInfosFromStorage()
   {
      ChromatticSession session = persister.getSession();
      ProducerInfosMapping producerInfosMapping = getProducerInfosMapping(session);

      List<ProducerInfoMapping> mappings = producerInfosMapping.getProducerInfos();

      persister.closeSession(session, true);
View Full Code Here

      //
      SessionContext context = test1LF.openContext();
      try
      {
         ChromatticSession session = test1LF.getChromattic().openSession();
         FooEntity foo = session.create(FooEntity.class);
         assertEquals("portal-test", foo.getWorkspace());
         jcrSession = session.getJCRSession();
         assertTrue(jcrSession.isLive());
         Workspace workspace = jcrSession.getWorkspace();
         assertEquals("portal-test", workspace.getName());

         session.close();
         assertTrue(jcrSession.isLive());
      }
      finally
      {
         test1LF.closeContext(false);
View Full Code Here

         // No context should be open
         assertNull(test1LF.getContext(true));

         // Opens a session with the provided Chromattic
         ChromatticSession session = chromattic.openSession();

         // Now we should have a context
         SessionContext context = test1LF.getContext(true);
         assertNotNull(context);

         // Register synchronzation with event queue
         context.addSynchronizationListener(queue);

         // Check how chromattic see the session
         FooEntity foo = session.create(FooEntity.class);
         assertEquals("portal-test", foo.getWorkspace());

         // Check related JCR session
         jcrSession = session.getJCRSession();
         assertTrue(jcrSession.isLive());
         Workspace workspace = jcrSession.getWorkspace();
         assertEquals("portal-test", workspace.getName());

         // Closing chromattic session should not close the underlying JCR session
         session.close();
         assertTrue(jcrSession.isLive());

         // Queue should be empty up to here
         queue.assertEmpty();
      }
View Full Code Here

   }

   public void testPersistence() throws Exception {

      chromatticManager.beginRequest();
      ChromatticSession session = test1LF.getChromattic().openSession();
      FooEntity foo = session.create(FooEntity.class);
      String fooId = session.persist(foo, "testPersistence");
      session.save();
      chromatticManager.endRequest(true);

      chromatticManager.beginRequest();
      session = test1LF.getChromattic().openSession();
      foo = session.findById(FooEntity.class, fooId);
      session.close();
      chromatticManager.endRequest(false);

      assertNotNull(foo);
   }
View Full Code Here

      persister.initializeBuilderFor(mappingClasses);

//      persister = NewJCRPersister.getInstance(container);

      ChromatticSession session = persister.getSession();
      mappings = session.findByPath(ConsumersAndGroupsMapping.class, ConsumersAndGroupsMapping.NODE_NAME);
      if (mappings == null)
      {
         mappings = session.insert(ConsumersAndGroupsMapping.class, ConsumersAndGroupsMapping.NODE_NAME);
      }
      persister.save(session); // needed right now as the session must still be open to iterate over nodes

      for (ConsumerGroupMapping cgm : mappings.getConsumerGroups())
      {
View Full Code Here

   }

   @Override
   protected RegistrationSPI internalCreateRegistration(ConsumerSPI consumer, Map registrationProperties)
   {
      ChromatticSession session = persister.getSession();
      RegistrationSPI registration = null;
      try
      {
         ConsumerMapping cm = session.findById(ConsumerMapping.class, consumer.getPersistentKey());
         RegistrationMapping rm = cm.createAndAddRegistrationMappingFrom(null);
         registration = newRegistrationSPI(consumer, registrationProperties, rm.getPersistentKey());
         rm.initFrom(registration);
         persister.closeSession(session, true);
      }
View Full Code Here

      return super.internalRemoveConsumer(consumerId);
   }

   private void remove(String id, Class clazz)
   {
      ChromatticSession session = persister.getSession();
      session.remove(session.findById(clazz, id));
      persister.closeSession(session, true);
   }
View Full Code Here

   @Override
   protected ConsumerSPI internalCreateConsumer(String consumerId, String consumerName)
   {
      ConsumerSPI consumer = super.internalCreateConsumer(consumerId, consumerName);

      ChromatticSession session = persister.getSession();
      mappings = session.findByPath(ConsumersAndGroupsMapping.class, ConsumersAndGroupsMapping.NODE_NAME); // todo: needed?
      try
      {
         ConsumerMapping cm = mappings.createConsumer(consumerId);
         mappings.getConsumers().add(cm);
         cm.initFrom(consumer);
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.