Author: chris.laprun(a)jboss.com
Date: 2009-12-18 09:11:36 -0500 (Fri, 18 Dec 2009)
New Revision: 1068
Modified:
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/configuration/JCRProducerConfigurationService.java
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java
Log:
- Yet another non-working version of JCRPersister committed for backup purpose.
Modified:
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java
===================================================================
---
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java 2009-12-18
13:08:05 UTC (rev 1067)
+++
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java 2009-12-18
14:11:36 UTC (rev 1068)
@@ -29,8 +29,8 @@
import org.chromattic.api.format.ObjectFormatter;
import org.chromattic.spi.jcr.SessionLifeCycle;
import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.services.jcr.RepositoryService;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.ext.common.SessionProvider;
@@ -46,29 +46,11 @@
public class JCRPersister
{
private Chromattic chrome;
- public static final String WSRP_SERVICES_PATH = "wsrp:";
- private final SessionProvider provider;
- private final ManageableRepository repository;
- private final String workspaceName;
+ private static final String WORKSPACE_NAME = "wsrp-system";
+ private static final String REPOSITORY_NAME = "repository";
- static ThreadLocal<JCRPersister> PERSISTER = new
ThreadLocal<JCRPersister>();
-
- public JCRPersister(ExoContainer container) throws RepositoryException
+ public JCRPersister(ExoContainer container)
{
- try
- {
- RepositoryService repoService =
(RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
- repository = repoService.getRepository("repository");
- }
- catch (RepositoryConfigurationException e)
- {
- throw new RepositoryException(e);
- }
-
- //
- this.provider = SessionProvider.createSystemProvider();
- this.workspaceName = "wsrp-system";
- PERSISTER.set(this);
}
public void initializeBuilderFor(List<Class> mappingClasses) throws Exception
@@ -102,15 +84,38 @@
public static class WSRPSessionLifeCycle implements SessionLifeCycle
{
+ private static boolean initialized = false;
+ private static ManageableRepository repository;
+ private static SessionProvider provider;
public WSRPSessionLifeCycle()
{
+ init();
}
+ private static void init()
+ {
+ if (!initialized)
+ {
+ try
+ {
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ RepositoryService repoService =
(RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
+ repository = repoService.getRepository(REPOSITORY_NAME);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ provider = SessionProvider.createSystemProvider();
+ initialized = true;
+ }
+ }
+
public Session login() throws RepositoryException
{
- JCRPersister persister = PERSISTER.get();
- return persister.provider.getSession(persister.workspaceName,
persister.repository);
+ return provider.getSession(WORKSPACE_NAME, repository);
}
public Session login(String s) throws RepositoryException
Modified:
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java
===================================================================
---
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java 2009-12-18
13:08:05 UTC (rev 1067)
+++
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java 2009-12-18
14:11:36 UTC (rev 1068)
@@ -26,7 +26,6 @@
import org.chromattic.api.ChromatticSession;
import org.exoplatform.container.ExoContainer;
import org.gatein.portal.wsrp.state.JCRPersister;
-import org.gatein.portal.wsrp.state.NewJCRPersister;
import org.gatein.portal.wsrp.state.consumer.mapping.EndpointInfoMapping;
import org.gatein.portal.wsrp.state.consumer.mapping.ProducerInfoMapping;
import org.gatein.portal.wsrp.state.consumer.mapping.ProducerInfosMapping;
@@ -49,19 +48,20 @@
*/
public class JCRConsumerRegistry extends AbstractConsumerRegistry
{
- private NewJCRPersister persister;
+// private NewJCRPersister persister;
+ private JCRPersister persister;
private static final String PRODUCER_INFOS_PATH = ProducerInfosMapping.NODE_NAME;
public JCRConsumerRegistry(ExoContainer container) throws Exception
{
- /*List<Class> mappingClasses = new ArrayList<Class>(6);
+ List<Class> mappingClasses = new ArrayList<Class>(6);
Collections.addAll(mappingClasses, ProducerInfosMapping.class,
ProducerInfoMapping.class,
EndpointInfoMapping.class, RegistrationInfoMapping.class,
RegistrationPropertyMapping.class,
RegistrationPropertyDescriptionMapping.class);
persister = new JCRPersister(container);
- persister.initializeBuilderFor(mappingClasses);*/
- persister = NewJCRPersister.getInstance(container);
+ persister.initializeBuilderFor(mappingClasses);
+// persister = NewJCRPersister.getInstance(container);
}
@Override
Modified:
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/configuration/JCRProducerConfigurationService.java
===================================================================
---
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/configuration/JCRProducerConfigurationService.java 2009-12-18
13:08:05 UTC (rev 1067)
+++
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/configuration/JCRProducerConfigurationService.java 2009-12-18
14:11:36 UTC (rev 1068)
@@ -25,7 +25,6 @@
import org.chromattic.api.ChromatticSession;
import org.exoplatform.container.ExoContainer;
import org.gatein.portal.wsrp.state.JCRPersister;
-import org.gatein.portal.wsrp.state.NewJCRPersister;
import org.gatein.portal.wsrp.state.mapping.RegistrationPropertyDescriptionMapping;
import
org.gatein.portal.wsrp.state.producer.configuration.mapping.ProducerConfigurationMapping;
import
org.gatein.portal.wsrp.state.producer.configuration.mapping.RegistrationRequirementsMapping;
@@ -47,18 +46,19 @@
private static String PRODUCER_CONFIGURATION_PATH =
ProducerConfigurationMapping.NODE_NAME;
private InputStream defaultConfigurationIS;
- private NewJCRPersister persister;
+// private NewJCRPersister persister;
+ private JCRPersister persister;
public JCRProducerConfigurationService(ExoContainer container) throws Exception
{
- /*List<Class> mappingClasses = new ArrayList<Class>(3);
+ List<Class> mappingClasses = new ArrayList<Class>(3);
Collections.addAll(mappingClasses, ProducerConfigurationMapping.class,
RegistrationRequirementsMapping.class,
RegistrationPropertyDescriptionMapping.class);
persister = new JCRPersister(container);
- persister.initializeBuilderFor(mappingClasses);*/
+ persister.initializeBuilderFor(mappingClasses);
- persister = NewJCRPersister.getInstance(container);
+// persister = NewJCRPersister.getInstance(container);
}
/**
Modified:
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java
===================================================================
---
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java 2009-12-18
13:08:05 UTC (rev 1067)
+++
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java 2009-12-18
14:11:36 UTC (rev 1068)
@@ -25,7 +25,6 @@
import org.chromattic.api.ChromatticSession;
import org.exoplatform.container.ExoContainer;
import org.gatein.portal.wsrp.state.JCRPersister;
-import org.gatein.portal.wsrp.state.NewJCRPersister;
import
org.gatein.portal.wsrp.state.producer.registrations.mapping.ConsumerCapabilitiesMapping;
import org.gatein.portal.wsrp.state.producer.registrations.mapping.ConsumerGroupMapping;
import org.gatein.portal.wsrp.state.producer.registrations.mapping.ConsumerMapping;
@@ -50,20 +49,21 @@
*/
public class JCRRegistrationPersistenceManager extends
RegistrationPersistenceManagerImpl
{
- private NewJCRPersister persister;
+// private NewJCRPersister persister;
+ private JCRPersister persister;
private ConsumersAndGroupsMapping mappings;
public JCRRegistrationPersistenceManager(ExoContainer container) throws Exception
{
- /*persister = new JCRPersister(container);
+ persister = new JCRPersister(container);
List<Class> mappingClasses = new ArrayList<Class>(5);
Collections.addAll(mappingClasses, ConsumersAndGroupsMapping.class,
ConsumerMapping.class, ConsumerGroupMapping.class,
RegistrationMapping.class, ConsumerCapabilitiesMapping.class);
- persister.initializeBuilderFor(mappingClasses);*/
+ persister.initializeBuilderFor(mappingClasses);
- persister = NewJCRPersister.getInstance(container);
+// persister = NewJCRPersister.getInstance(container);
ChromatticSession session = persister.getSession();
mappings = session.findByPath(ConsumersAndGroupsMapping.class,
ConsumersAndGroupsMapping.NODE_NAME);