Author: julien(a)jboss.com
Date: 2007-01-10 10:47:37 -0500 (Wed, 10 Jan 2007)
New Revision: 5978
Modified:
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml
trunk/identity/src/main/org/jboss/portal/identity/IdentityContext.java
trunk/identity/src/main/org/jboss/portal/identity/IdentityContextImpl.java
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceController.java
Log:
- make JCRCMS not use JNDI to lookup user module, instead inject identity service
controller and retrieve user module from it. It was causing test case to fail in CMS
- use copy on write hashmap in identity service controller
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2007-01-10 15:18:22 UTC
(rev 5977)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2007-01-10 15:47:37 UTC
(rev 5978)
@@ -49,6 +49,9 @@
import org.jboss.portal.common.util.XML;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.IdentityServiceController;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.workflow.cms.ApprovePublish;
@@ -63,8 +66,6 @@
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
import javax.naming.CompositeName;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.URL;
@@ -99,13 +100,12 @@
private Element config;
- private UserModule userModule = null;
+ private IdentityServiceController identityServiceController;
- private ApprovePublish approvePublishWorkflow = null;
+ private ApprovePublish approvePublishWorkflow;
- private String jndiName = null;
+ private String jndiName;
-
private InvocationHandler handler = new InvocationHandler()
{
public Object invoke(Invocation invocation) throws Exception, InvocationException
@@ -226,24 +226,28 @@
this.approvePublishWorkflow = approvePublishWorkflow;
}
- /**
- *
- * @return
- */
public UserModule getUserModule()
{
- return this.userModule;
+ try
+ {
+ return
(UserModule)identityServiceController.getIdentityContext().getObject(IdentityContext.TYPE_USER_MODULE);
+ }
+ catch (IdentityException e)
+ {
+ return null;
+ }
}
-
- /**
- *
- * @param userModule
- */
- public void setUserModule(UserModule userModule)
+
+ public IdentityServiceController getIdentityServiceController()
{
- this.userModule = userModule;
+ return identityServiceController;
}
-
+
+ public void setIdentityServiceController(IdentityServiceController
identityServiceController)
+ {
+ this.identityServiceController = identityServiceController;
+ }
+
/**
*
* @return
@@ -265,16 +269,6 @@
/** CMS Start */
public void startService() throws Exception
{
- try
- {
- this.userModule = (UserModule)new
InitialContext().lookup("java:portal/UserModule");
- }
- catch (NamingException e)
- {
- log.error("Cannot obtain UserModule from JNDI: ", e);
- throw e;
- }
-
if (this.jndiName != null)
{
NonSerializableFactory.rebind(new CompositeName(this.jndiName), this, true);
@@ -390,12 +384,13 @@
URL root =
Thread.currentThread().getContextClassLoader().getResource(defaultContentLocation);
//make the user executing these to create the default content, an 'Admin'
user
- //without this, the fine grained security won't allow the creation
- if(this.userModule != null)
+ //without this, the fine grained security won't allow the creation
+ UserModule userModule = getUserModule();
+ if(userModule != null)
{
org.hibernate.Session session =
org.jboss.portal.cms.hibernate.state.Tools.getOpenSession();
org.hibernate.Transaction tx = session.beginTransaction();
- User user = this.userModule.findUserByUserName("admin");
+ User user = userModule.findUserByUserName("admin");
if(user!=null)
{
JCRCMS.getUserInfo().set(user);
Modified: trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-01-10 15:18:22
UTC (rev 5977)
+++ trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-01-10 15:47:37
UTC (rev 5978)
@@ -57,10 +57,11 @@
<depends>jboss.jca:service=DataSourceBinding,name=@portal.datasource.name@</depends>
<depends>portal:service=JAASLoginModule</depends>
<depends>portal:service=Hibernate,type=CMS</depends>
-
<depends>portal:service=Module,type=IdentityServiceController</depends>
- <!--depends optional-attribute-name="UserModule"
proxy-type="attribute">portal:service=Module,type=User</depends-->
- <!-- add this to activate publish/approval workflow integration -->
- <!--depends optional-attribute-name="ApprovePublishWorkflow"
proxy-type="attribute">portal:service=ApprovePublish,type=Workflow</depends-->
+ <depends optional-attribute-name="IdentityServiceController"
proxy-type="attribute">portal:service=Module,type=IdentityServiceController</depends>
+ <!-- Add this to activate publish/approval workflow integration -->
+ <!--
+ <depends optional-attribute-name="ApprovePublishWorkflow"
proxy-type="attribute">portal:service=ApprovePublish,type=Workflow</depends>
+ -->
<depends optional-attribute-name="StackFactory"
proxy-type="attribute">portal:service=InterceptorStackFactory,type=Cms</depends>
<attribute name="DoChecking">true</attribute>
<attribute
name="DefaultContentLocation">portal/cms/conf/default-content/default/</attribute>
Modified: trunk/identity/src/main/org/jboss/portal/identity/IdentityContext.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/IdentityContext.java 2007-01-10
15:18:22 UTC (rev 5977)
+++ trunk/identity/src/main/org/jboss/portal/identity/IdentityContext.java 2007-01-10
15:47:37 UTC (rev 5978)
@@ -21,8 +21,6 @@
*/
package org.jboss.portal.identity;
-import org.jboss.portal.identity.IdentityException;
-
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw
Dawidowicz</a>
* @version $Revision: 1.1 $
Modified: trunk/identity/src/main/org/jboss/portal/identity/IdentityContextImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/IdentityContextImpl.java 2007-01-10
15:18:22 UTC (rev 5977)
+++ trunk/identity/src/main/org/jboss/portal/identity/IdentityContextImpl.java 2007-01-10
15:47:37 UTC (rev 5978)
@@ -37,7 +37,7 @@
public class IdentityContextImpl extends AbstractJBossService implements IdentityContext
{
//private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(IdentityContextImpl.class);
- private Map registry;
+ private volatile Map registry;
public IdentityContextImpl()
{
@@ -62,7 +62,9 @@
throw new IdentityException("Name: " + name + " already
registered.");
}
if (log.isDebugEnabled()) log.debug("registering object: " + name +
" ; " + object.getClass());
- registry.put(name, object);
+ Map tmp = new HashMap(registry);
+ tmp.put(name, object);
+ registry = tmp;
}
}
@@ -77,8 +79,9 @@
if(registry.containsKey(name))
{
if (log.isDebugEnabled()) log.debug("unregistering object: " +
name);
-
- registry.remove(name);
+ Map tmp = new HashMap(registry);
+ tmp.remove(name);
+ registry = tmp;
}
}
}
@@ -89,18 +92,11 @@
{
throw new IllegalArgumentException("Name cannot be null");
}
-
- //TODO:
- synchronized(this)
+ Object o = registry.get(name);
+ if (o == null)
{
- if (registry.containsKey(name))
- {
- return registry.get(name);
- }
- else
- {
- throw new IdentityException("No such mapping in IdentityContext: "
+ name);
- }
+ throw new IdentityException("No such mapping in IdentityContext: " +
name);
}
+ return o;
}
}
Modified:
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceController.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceController.java 2007-01-10
15:18:22 UTC (rev 5977)
+++
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceController.java 2007-01-10
15:47:37 UTC (rev 5978)
@@ -21,8 +21,6 @@
*/
package org.jboss.portal.identity;
-import org.jboss.portal.identity.IdentityContext;
-
/**
*
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw
Dawidowicz</a>