Author: chris.laprun(a)jboss.com
Date: 2012-11-22 08:21:48 -0500 (Thu, 22 Nov 2012)
New Revision: 8966
Modified:
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-component/src/main/java/org/gatein/integration/wsrp/jcr/JCRPersister.java
Log:
Bug 879258 - Failed to Retrieve Registration Information Exception during Load Testing
Modified:
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-component/src/main/java/org/gatein/integration/wsrp/jcr/JCRPersister.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-component/src/main/java/org/gatein/integration/wsrp/jcr/JCRPersister.java 2012-11-19
00:47:09 UTC (rev 8965)
+++
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-component/src/main/java/org/gatein/integration/wsrp/jcr/JCRPersister.java 2012-11-22
13:21:48 UTC (rev 8966)
@@ -23,30 +23,20 @@
package org.gatein.integration.wsrp.jcr;
-import org.chromattic.api.Chromattic;
import org.chromattic.api.ChromatticBuilder;
-import org.chromattic.api.ChromatticSession;
import org.chromattic.api.format.FormatterContext;
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.container.component.ComponentRequestLifecycle;
import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.ext.common.SessionProvider;
-import org.gatein.common.util.ParameterValidation;
import org.gatein.wsrp.jcr.BaseChromatticPersister;
-import org.gatein.wsrp.jcr.mapping.BaseMapping;
import javax.jcr.Credentials;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -76,12 +66,12 @@
}
}
- public static class WSRPSessionLifeCycle implements SessionLifeCycle
+ public static abstract class AbstractSessionLifeCycle implements SessionLifeCycle
{
private ManageableRepository repository;
- private SessionProvider provider;
+ private ThreadLocal<SessionProvider> provider = new
ThreadLocal<SessionProvider>();
- public WSRPSessionLifeCycle()
+ public AbstractSessionLifeCycle()
{
try
{
@@ -93,15 +83,22 @@
{
throw new RuntimeException(e);
}
-
- provider = SessionProvider.createSystemProvider();
}
public Session login() throws RepositoryException
{
- return provider.getSession(WSRP_WORKSPACE_NAME, repository);
+ SessionProvider sessionProvider = provider.get();
+ if (sessionProvider == null)
+ {
+ sessionProvider = SessionProvider.createSystemProvider();
+ provider.set(sessionProvider);
+ }
+
+ return sessionProvider.getSession(getWorkspaceName(), repository);
}
+ protected abstract String getWorkspaceName();
+
public Session login(String s) throws RepositoryException
{
throw new UnsupportedOperationException();
@@ -128,56 +125,22 @@
}
}
- public static class PortletStatesSessionLifeCycle implements SessionLifeCycle
+ public static class WSRPSessionLifeCycle extends AbstractSessionLifeCycle
{
- private ManageableRepository repository;
- private SessionProvider provider;
-
- public PortletStatesSessionLifeCycle()
+ @Override
+ protected String getWorkspaceName()
{
- 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();
+ return WSRP_WORKSPACE_NAME;
}
+ }
- public Session login() throws RepositoryException
+ public static class PortletStatesSessionLifeCycle extends AbstractSessionLifeCycle
+ {
+ @Override
+ protected String getWorkspaceName()
{
- return provider.getSession(PORTLET_STATES_WORKSPACE_NAME, repository);
+ return PORTLET_STATES_WORKSPACE_NAME;
}
-
- public Session login(String s) throws RepositoryException
- {
- throw new UnsupportedOperationException();
- }
-
- public Session login(Credentials credentials, String s) throws RepositoryException
- {
- throw new UnsupportedOperationException();
- }
-
- public Session login(Credentials credentials) throws RepositoryException
- {
- throw new UnsupportedOperationException();
- }
-
- public void save(Session session) throws RepositoryException
- {
- session.save();
- }
-
- public void close(Session session)
- {
- session.logout();
- }
}
public static class QNameFormatter implements ObjectFormatter
@@ -245,4 +208,4 @@
return s.replace(SLASH, SLASH_REPLACEMENT);
}
}
-}
+}
\ No newline at end of file