Author: julien(a)jboss.com
Date: 2007-05-10 05:11:17 -0400 (Thu, 10 May 2007)
New Revision: 7234
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceCustomization.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceDefinition.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContext.java
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/persistent-jboss-beans.xml
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/transient-jboss-beans.xml
Removed:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceCustomizationImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceDefinitionImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.java
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/jboss-beans.xml
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/jboss-beans.xml
Modified:
trunk/common/src/main/org/jboss/portal/common/util/CollectionBuilder.java
trunk/core/build.xml
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/ContainerContext.java
trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-core-sar/conf/hibernate/instance/domain.hbm.xml
trunk/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
trunk/core/src/resources/portal-core-sar/portal-aop.xml
trunk/security/src/main/org/jboss/portal/security/RoleSecurityBinding.java
Log:
- improved instance container implementation with a cleaner separation between the logic
and the hibernate persistence
- improved instance container test cases
Modified: trunk/common/src/main/org/jboss/portal/common/util/CollectionBuilder.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/CollectionBuilder.java 2007-05-10
03:10:55 UTC (rev 7233)
+++ trunk/common/src/main/org/jboss/portal/common/util/CollectionBuilder.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -45,6 +45,19 @@
}
/**
+ * Factory method to create a collection builder using a singleton.
+ *
+ * @param o the object to add
+ * @return the builder created
+ */
+ public static CollectionBuilder singleton(Object o)
+ {
+ CollectionBuilder builder = new CollectionBuilder();
+ builder.collection.add(o);
+ return builder;
+ }
+
+ /**
* Add the object to the collection.
*
* @param o the object to add
Modified: trunk/core/build.xml
===================================================================
--- trunk/core/build.xml 2007-05-10 03:10:55 UTC (rev 7233)
+++ trunk/core/build.xml 2007-05-10 09:11:17 UTC (rev 7234)
@@ -252,7 +252,7 @@
<include
name="org/jboss/portal/core/aspects/portlet/TransactionInterceptor.class"/>
<include
name="org/jboss/portal/core/deployment/jboss/ObjectDeployment.class"/>
<include
name="org/jboss/portal/core/deployment/jboss/PortletAppDeployment.class"/>
- <include
name="org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.class"/>
+ <include
name="org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.class"/>
<include
name="org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.class"/>
<include
name="org/jboss/portal/core/impl/portlet/state/ProducerPortletInvoker.class"/>
<include
name="org/jboss/portal/core/hibernate/SessionFactoryBinder.class"/>
@@ -555,43 +555,53 @@
</x-sysproperty>
<x-test>
-<!--
<zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase"
outfile="TEST-PortalObjectContainerTestCase">
<parameter name="CacheNaturalId" value="true"/>
- <parameter name="ConfigLocation"
value="org/jboss/portal/test/core/model/portal/persistent-jboss-beans.xml"/>
+ <parameter name="Config"
value="persistent-jboss-beans.xml"/>
</zest>
--->
<zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase"
outfile="TEST-PortalObjectContainerTestCase">
<parameter name="CacheNaturalId" value="true"/>
- <parameter name="ConfigLocation"
value="org/jboss/portal/test/core/model/portal/transient-jboss-beans.xml"/>
+ <parameter name="Config"
value="transient-jboss-beans.xml"/>
</zest>
-<!--
<zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
outfile="TEST-PersistedLocally-ClonedOnCreate-InstanceContainerTestCase">
<parameter name="PersistLocally" value="true"/>
<parameter name="CloneOnCreate" value="true"/>
<parameter name="CacheNaturalId" value="true"/>
+ <parameter name="Config"
value="persistent-jboss-beans.xml"/>
</zest>
<zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
outfile="TEST-NotPersistedLocally-ClonedOnCreate-InstanceContainerTestCase">
<parameter name="PersistLocally"
value="false"/>
<parameter name="CloneOnCreate" value="true"/>
<parameter name="CacheNaturalId" value="true"/>
+ <parameter name="Config"
value="persistent-jboss-beans.xml"/>
</zest>
<zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
outfile="TEST-PersistedLocally-NotClonedOnCreate-InstanceContainerTestCase">
<parameter name="PersistLocally" value="true"/>
<parameter name="CloneOnCreate" value="false"/>
<parameter name="CacheNaturalId" value="true"/>
+ <parameter name="Config"
value="persistent-jboss-beans.xml"/>
</zest>
<zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
outfile="TEST-NotPersistedLocally-NotClonedOnCreate-InstanceContainerTestCase">
<parameter name="PersistLocally"
value="false"/>
<parameter name="CloneOnCreate" value="false"/>
<parameter name="CacheNaturalId" value="true"/>
+ <parameter name="Config"
value="persistent-jboss-beans.xml"/>
</zest>
+<!--
+ <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
+
outfile="TEST-PersistedLocally-ClonedOnCreate-InstanceContainerTestCase">
+ <parameter name="PersistLocally" value="true"/>
+ <parameter name="CloneOnCreate" value="true"/>
+ <parameter name="CacheNaturalId" value="true"/>
+ <parameter name="Config"
value="transient-jboss-beans.xml"/>
+ </zest>
+-->
<zest todir="${test.reports}"
name="org.jboss.portal.test.core.state.ProducerTestCase"
outfile="TEST-ProducerTestCase-WithoutRegistration">
<parameter name="UseRegistration"
value="false"/>
@@ -609,7 +619,6 @@
name="org.jboss.portal.test.core.model.portal.PortalObjectPermissionTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectIdTestCase"/>
--->
</x-test>
<x-classpath>
<pathelement location="${build.lib}/portal-core-lib.jar"/>
Copied:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java (from
rev 7225,
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceImpl.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -0,0 +1,340 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.instance;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.instance.InstanceCustomization;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.InstanceDefinition;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.state.AccessMode;
+import org.jboss.portal.portlet.state.PropertyChange;
+import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.portlet.state.DestroyCloneFailure;
+
+import java.util.Arrays;
+import java.util.Set;
+import java.util.List;
+import java.util.Collections;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractInstance implements Instance
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(AbstractInstance.class);
+
+ /** . */
+ protected String portletRef;
+
+ /** . */
+ protected byte[] state;
+
+ /** Composite representation of portletRef + state. */
+ protected PortletContext portletContext;
+
+ protected AbstractInstance()
+ {
+ }
+
+ public String getPortletRef()
+ {
+ return portletRef;
+ }
+
+ public void setPortletRef(String portletRef)
+ {
+ this.portletRef = portletRef;
+
+ // Invalidate
+ this.portletContext = null;
+ }
+
+ public byte[] getState()
+ {
+ return state;
+ }
+
+ public void setState(byte[] state)
+ {
+ this.state = state;
+
+ // Invalidate
+ this.portletContext = null;
+ }
+
+ public final PortletContext getPortletContext()
+ {
+ if (portletContext == null)
+ {
+ portletContext = PortletContext.createPortletContext(portletRef, state);
+ }
+ return portletContext;
+ }
+
+ public final void setPortletContext(PortletContext portletContext)
+ {
+ this.portletRef = portletContext.getId();
+ this.state = portletContext.getState();
+ this.portletContext = portletContext;
+ }
+
+ public final boolean isModifiable()
+ {
+ return isMutable();
+ }
+
+ protected abstract boolean isMutable();
+
+ protected abstract void setMutable(boolean modifiable);
+
+ protected abstract Logger getLogger();
+
+ protected abstract String getInstanceId();
+
+ protected abstract AccessMode getAccessMode();
+
+ protected abstract void cloned(PortletContext portletContext);
+
+ protected abstract void modified(PortletContext portletContext);
+
+ protected abstract AbstractInstanceDefinition getOwner();
+
+ protected abstract ContainerContext getContainerContext();
+
+ public final InstanceDefinition getDefinition()
+ {
+ return getOwner();
+ }
+
+ public final Portlet getPortlet() throws PortletInvokerException
+ {
+ PortletInvoker invoker = getContainer().getPortletInvoker();
+ PortletContext ctx = getOwner().getPortletContext();
+ return invoker.getPortlet(ctx);
+ }
+
+ public final InstanceContainer getContainer()
+ {
+ return getContainerContext().getContainer();
+ }
+
+ public final void setProperties(PropertyChange[] changes) throws
PortletInvokerException
+ {
+ if (changes == null)
+ {
+ throw new IllegalArgumentException("No null changes accepted");
+ }
+ boolean debug = getLogger().isDebugEnabled();
+
+ // Get the invoker
+ PortletInvoker portletInvoker = getContainer().getPortletInvoker();
+
+ //
+ PortletContext portletContext = getPortletContext();
+
+ //
+ if (isModifiable() == false)
+ {
+ // Clone the portlet
+ if (debug)
+ {
+ getLogger().debug("Need to clone non modifiable instance before setting
properties " /*+ instanceId + "/"*/ + portletContext);
+ }
+ portletContext = portletInvoker.createClone(portletContext);
+ if (debug)
+ {
+ getLogger().debug("Received updated portlet context " +
portletContext + " for instance " /*+ instanceId*/ + " after explicit
clone");
+ }
+
+ // Update the state
+ setPortletContext(portletContext);
+ setMutable(true);
+
+ //
+ getContainerContext().updateInstance(this);
+ }
+
+ //
+ if (debug)
+ {
+ getLogger().debug("Setting properties on " + /*instanceId +
"/" +*/ portletContext + " : " + Arrays.asList(changes));
+ }
+ portletContext = portletInvoker.setProperties(portletContext, changes);
+ if (debug)
+ {
+ getLogger().debug("Received updated portlet context " + portletContext
+ " for instance " + /*instanceId +*/ " after setting properties");
+ }
+ setPortletContext(portletContext);
+
+ //
+ getContainerContext().updateInstance(this);
+ }
+
+ public final PropertyMap getProperties() throws PortletInvokerException
+ {
+ PortletInvoker invoker = getContainer().getPortletInvoker();
+ PortletContext portletContext = getPortletContext();
+ return invoker.getProperties(portletContext);
+ }
+
+ public final PropertyMap getProperties(Set keys) throws PortletInvokerException
+ {
+ PortletInvoker invoker = getContainer().getPortletInvoker();
+ PortletContext portletContext = getPortletContext();
+ return invoker.getProperties(portletContext, keys);
+ }
+
+ public final PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException
+ {
+ boolean debug = getLogger().isDebugEnabled();
+ InstanceContainerImpl container = getContainerContext().getContainer();
+
+ //
+ AbstractInstance instance = this;
+ AccessMode accessMode = getAccessMode();
+
+ //
+ PortletContext portletContext = instance.getPortletContext();
+
+ // The instance context for the invocation
+ InstanceContextImpl instanceContext = new InstanceContextImpl(this, accessMode);
+
+ try
+ {
+ invocation.setAttribute(PortletInvocation.INVOCATION_SCOPE,
INSTANCE_ID_ATTRIBUTE, getInstanceId());
+ invocation.setTarget(portletContext);
+ invocation.setInstanceContext(instanceContext);
+
+ // Perform invocation
+ PortletInvocationResponse response = container.invoke(invocation);
+
+ // Create user instance if a clone operation occured
+ if (instanceContext.accessMode == AccessMode.CLONE_BEFORE_WRITE)
+ {
+ if (instanceContext.clonedContext != null)
+ {
+ if (debug)
+ {
+// log.debug("About to reference clone of (" + instanceId +
"," + portletContext +
+// ") having id " + instanceContext.clonedContext
+ " for user " + userId);
+ }
+ cloned(instanceContext.clonedContext);
+ }
+ else
+ {
+ // Does not make sense
+ }
+ }
+ else if (instanceContext.accessMode == AccessMode.READ_WRITE)
+ {
+ if (instanceContext.modifiedContext != null)
+ {
+ if (debug)
+ {
+// log.debug("About to update portlet context (" + instanceId +
"," + portletContext +
+// ") having id " + instanceContext.clonedContext +
" for user " + userId);
+ }
+ modified(instanceContext.modifiedContext);
+ }
+ else
+ {
+ // Does not make sense
+ }
+ }
+
+ //
+ return response;
+ }
+ finally
+ {
+ // Reset state before invocation
+ invocation.removeAttribute(PortletInvocation.INVOCATION_SCOPE,
INSTANCE_ID_ATTRIBUTE);
+ invocation.setTarget(null);
+ invocation.setInstanceContext(null);
+ }
+ }
+
+ public final InstanceCustomization getCustomization(String customizationId)
+ {
+ if (customizationId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ // Check if we have an instance for this particular customized id
+ AbstractInstanceCustomization customization =
getContainerContext().getCustomization(getOwner(), customizationId);
+
+ //
+ if (customization == null)
+ {
+ AbstractInstanceDefinition def = getOwner();
+ customization = getContainerContext().newInstanceCustomization(def,
customizationId, getPortletContext());
+ }
+
+ //
+ return customization;
+ }
+
+ public final void destroyCustomization(String customizationId)
+ {
+ AbstractInstanceCustomization customization =
getContainerContext().getCustomization(getOwner(), customizationId);
+
+ //
+ if (customization != null)
+ {
+ try
+ {
+ PortletContext customizationPortletContext =
customization.getPortletContext();
+ List toDestroy = Collections.singletonList(customizationPortletContext);
+ PortletInvoker portletInvoker = getContainer().getPortletInvoker();
+
+ //
+ List failures = portletInvoker.destroyClones(toDestroy);
+ if (failures.size() > 0)
+ {
+ for (Iterator i = failures.iterator();i.hasNext();)
+ {
+ DestroyCloneFailure failure = (DestroyCloneFailure)i.next();
+ log.error("Was not able to destroy " + failure.getPortletId()
+ " for customization " +
+ customizationId + ", reason is : " +
failure.getMessage());
+ }
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ log.error("Could not destroy customization " + customizationId,
e);
+ }
+ }
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceCustomization.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceCustomization.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceCustomization.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.instance;
+
+import org.jboss.portal.core.model.instance.InstanceCustomization;
+import org.jboss.portal.portlet.state.AccessMode;
+import org.jboss.portal.portlet.PortletContext;
+import org.apache.log4j.Logger;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractInstanceCustomization extends AbstractInstance implements
InstanceCustomization
+{
+
+ /** The logger. */
+ private static final Logger log =
Logger.getLogger(AbstractInstanceCustomization.class);
+
+ protected abstract boolean isPersistent();
+
+ protected AccessMode getAccessMode()
+ {
+ return isPersistent() ? AccessMode.READ_WRITE : AccessMode.CLONE_BEFORE_WRITE;
+ }
+
+ protected boolean isMutable()
+ {
+ return false;
+ }
+
+ protected void setMutable(boolean modifiable)
+ {
+ throw new IllegalStateException("Modifiable field is immutable");
+ }
+
+ protected final Logger getLogger()
+ {
+ return log;
+ }
+
+ protected final void cloned(PortletContext portletContext)
+ {
+ setPortletContext(portletContext);
+
+ //
+ getContainerContext().createInstanceCustomizaton(this);
+ }
+
+ protected final void modified(PortletContext portletContext)
+ {
+ setPortletContext(portletContext);
+
+ //
+ getContainerContext().updateInstance(this);
+ }
+
+ protected final String getInstanceId()
+ {
+ return getOwner().getInstanceId();
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceDefinition.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceDefinition.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceDefinition.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.instance;
+
+import org.jboss.portal.core.model.instance.InstanceDefinition;
+import org.jboss.portal.portlet.state.AccessMode;
+import org.jboss.portal.portlet.PortletContext;
+import org.apache.log4j.Logger;
+
+import java.util.Map;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6736 $
+ */
+public abstract class AbstractInstanceDefinition extends AbstractInstance implements
InstanceDefinition
+{
+
+ /** The logger. */
+ protected static final Logger log =
Logger.getLogger(AbstractInstanceDefinition.class);
+
+ // AbstractInstance implementation
**********************************************************************************
+
+ protected AccessMode getAccessMode()
+ {
+/*
+ if (Mode.EDIT_DEFAULTS.equals(ctxabc.getMode()))
+ {
+ // Implement it by using the shared portlet id, but a security check should be
made on using this
+ // mode first
+ // Another idea is to shove that in the security interceptor
+ throw new UnsupportedOperationException("Implement me");
+ }
+*/
+ return AccessMode.READ_ONLY;
+ }
+
+ protected Logger getLogger()
+ {
+ return log;
+ }
+
+ protected void cloned(PortletContext portletContext)
+ {
+ throw new IllegalStateException();
+ }
+
+ protected void modified(PortletContext portletContext)
+ {
+ getContainerContext().updateInstance(this);
+ }
+
+ protected AbstractInstanceDefinition getOwner()
+ {
+ return this;
+ }
+
+ protected abstract Collection getCustomizations();
+
+ public abstract Map getSecurityBindings();
+}
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/ContainerContext.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/ContainerContext.java 2007-05-10
03:10:55 UTC (rev 7233)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/ContainerContext.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -22,36 +22,46 @@
******************************************************************************/
package org.jboss.portal.core.impl.model.instance;
-import org.hibernate.Session;
-import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.core.model.instance.DuplicateInstanceException;
+import org.jboss.portal.portlet.PortletContext;
+import java.util.Collection;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class ContainerContext
+public abstract class ContainerContext
{
/** . */
- final PersistentInstanceContainer container;
+ private InstanceContainerImpl container;
- public ContainerContext(PersistentInstanceContainer container)
+ public InstanceContainerImpl getContainer()
{
- if (container == null)
- {
- throw new IllegalArgumentException();
- }
- this.container = container;
+ return container;
}
- protected Session getCurrentSession()
+ public void setContainer(InstanceContainerImpl container)
{
- return container.sessionFactory.getCurrentSession();
+ this.container = container;
}
- public PortletInvoker getPortletInvoker()
- {
- return container.getPortletInvoker();
- }
+ public abstract Collection getInstanceDefinitions();
+ public abstract AbstractInstanceDefinition getInstanceDefinition(String id);
+
+ public abstract AbstractInstanceDefinition newInstanceDefinition(String id, String
portletRef);
+
+ public abstract void createInstanceDefinition(AbstractInstanceDefinition instanceDef)
throws DuplicateInstanceException;
+
+ public abstract void destroyInstanceDefinition(AbstractInstanceDefinition
instanceDef);
+
+ public abstract AbstractInstanceCustomization
getCustomization(AbstractInstanceDefinition instanceDef, String customizationId);
+
+ public abstract AbstractInstanceCustomization
newInstanceCustomization(AbstractInstanceDefinition def, String id, PortletContext
portletContext);
+
+ public abstract void createInstanceCustomizaton(AbstractInstanceCustomization
customization);
+
+ public abstract void updateInstance(AbstractInstance instanceDef);
}
Copied:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.java
(from rev 7225,
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.java)
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -0,0 +1,517 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.instance;
+
+import org.jboss.portal.common.invocation.InvocationHandler;
+import org.jboss.portal.common.invocation.InterceptorStackFactory;
+import org.jboss.portal.common.invocation.Invocation;
+import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.core.model.instance.DuplicateInstanceException;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.InstanceDefinition;
+import org.jboss.portal.core.model.instance.InstancePermission;
+import org.jboss.portal.core.model.instance.NoSuchInstanceException;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.impl.model.instance.persistent.InstanceCustomizationImpl;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.state.DestroyCloneFailure;
+import org.jboss.portal.security.PortalPermission;
+import org.jboss.portal.security.PortalSecurityException;
+import org.jboss.portal.security.RoleSecurityBinding;
+import org.jboss.portal.security.SecurityConstants;
+import org.jboss.portal.security.PortalPermissionCollection;
+import org.jboss.portal.security.impl.JBossAuthorizationDomainRegistry;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
+import org.jboss.portal.security.spi.provider.AuthorizationDomain;
+import org.jboss.portal.security.spi.provider.DomainConfigurator;
+import org.jboss.portal.security.spi.provider.PermissionFactory;
+import org.jboss.portal.security.spi.provider.PermissionRepository;
+import org.jboss.portal.security.spi.provider.SecurityConfigurationException;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.Collections;
+
+/**
+ * Instance Container that is persistent
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author Anil.Saldhana(a)jboss.org
+ * @version $Revision$
+ */
+public class InstanceContainerImpl extends AbstractJBossService
+ implements InstanceContainer, AuthorizationDomain, DomainConfigurator,
+ PermissionRepository, PermissionFactory
+{
+
+
+ /** . */
+ protected InterceptorStackFactory stackFactory;
+
+ /** . */
+ protected PortletInvoker portletInvoker;
+
+ /** . */
+ protected PortalAuthorizationManagerFactory portalAuthorizationManagerFactory;
+
+ /** . */
+ protected JBossAuthorizationDomainRegistry authorizationDomainRegistry;
+
+ /** . */
+ protected InvocationHandler handler = new InvocationHandler()
+ {
+ public Object invoke(Invocation invocation) throws Exception, InvocationException
+ {
+ PortletInvocation portletInvocation = (PortletInvocation)invocation;
+ try
+ {
+ portletInvocation.setHandler(null);
+ return portletInvoker.invoke(portletInvocation);
+ }
+ finally
+ {
+ portletInvocation.setHandler(this);
+ }
+ }
+ };
+
+ /** If true clone the portlet on an instance creation. */
+ protected boolean cloneOnCreate;
+
+ /** The container context. */
+ protected ContainerContext containerContext;
+
+ public InterceptorStackFactory getStackFactory()
+ {
+ return stackFactory;
+ }
+
+ public void setStackFactory(InterceptorStackFactory stackFactory)
+ {
+ this.stackFactory = stackFactory;
+ }
+
+ public PortletInvoker getPortletInvoker()
+ {
+ return portletInvoker;
+ }
+
+ public void setPortletInvoker(PortletInvoker portletInvoker)
+ {
+ this.portletInvoker = portletInvoker;
+ }
+
+ public JBossAuthorizationDomainRegistry getAuthorizationDomainRegistry()
+ {
+ return authorizationDomainRegistry;
+ }
+
+ public void setAuthorizationDomainRegistry(JBossAuthorizationDomainRegistry
authorizationDomainRegistry)
+ {
+ this.authorizationDomainRegistry = authorizationDomainRegistry;
+ }
+
+ public PortalAuthorizationManagerFactory getPortalAuthorizationManagerFactory()
+ {
+ return portalAuthorizationManagerFactory;
+ }
+
+ public void setPortalAuthorizationManagerFactory(PortalAuthorizationManagerFactory
portalAuthorizationManagerFactory)
+ {
+ this.portalAuthorizationManagerFactory = portalAuthorizationManagerFactory;
+ }
+
+ protected void startService() throws Exception
+ {
+ // Add ourself as the authorization domain
+ if (authorizationDomainRegistry != null)
+ {
+ authorizationDomainRegistry.addDomain(this);
+ }
+
+ //
+ containerContext.setContainer(this);
+ }
+
+ protected void stopService() throws Exception
+ {
+ //
+ containerContext.setContainer(null);
+
+ //
+ if (authorizationDomainRegistry != null)
+ {
+ authorizationDomainRegistry.removeDomain(this);
+ }
+ }
+
+ public PortalPermission createPermissionContainer(PortalPermissionCollection
collection) throws PortalSecurityException
+ {
+ return new InstancePermission(collection);
+ }
+
+ public PortalPermission createPermission(String uri, String action) throws
PortalSecurityException
+ {
+ return new InstancePermission(uri, action);
+ }
+
+ public PortalPermission createPermission(String uri, Collection actions) throws
PortalSecurityException
+ {
+ return new InstancePermission(uri, actions);
+ }
+
+ public AuthorizationDomain getAuthorizationDomain()
+ {
+ return this;
+ }
+
+ public boolean getCloneOnCreate()
+ {
+ return cloneOnCreate;
+ }
+
+ public void setCloneOnCreate(boolean cloneOnCreate)
+ {
+ this.cloneOnCreate = cloneOnCreate;
+ }
+
+ public ContainerContext getContainerContext()
+ {
+ return containerContext;
+ }
+
+ public void setContainerContext(ContainerContext containerContext)
+ {
+ this.containerContext = containerContext;
+ }
+
+ public InstanceDefinition getDefinition(String id)
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("id cannot be null");
+ }
+ return containerContext.getInstanceDefinition(id);
+ }
+
+ public InstanceDefinition createDefinition(String id, String portletId) throws
DuplicateInstanceException, IllegalArgumentException, PortletInvokerException
+ {
+ return internalCreateDefinition(id, portletId, cloneOnCreate);
+ }
+
+ public InstanceDefinition createDefinition(String id, String portletId, boolean clone)
throws DuplicateInstanceException, PortletInvokerException
+ {
+ return internalCreateDefinition(id, portletId, clone);
+ }
+
+ private InstanceDefinition internalCreateDefinition(String id, String portletId,
boolean clone) throws DuplicateInstanceException, PortletInvokerException
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("id cannot be null");
+ }
+ boolean debug = log.isDebugEnabled();
+
+ //
+ if (debug)
+ {
+ log.debug("Creating instance " + id + " of portlet " +
portletId);
+ }
+
+ // Create the portlet context we'll use
+ PortletContext portletContext = PortletContext.createPortletContext(portletId);
+
+ // Check that the portlet exist before creating an instance of it
+ portletInvoker.getPortlet(portletContext);
+
+ //
+ AbstractInstanceDefinition instance = containerContext.newInstanceDefinition(id,
portletId);
+
+ //
+ containerContext.createInstanceDefinition(instance);
+
+ // Clone the portlet if required
+ if (clone)
+ {
+ // Clone the portlet state now and update the instance
+ if (debug)
+ {
+ log.debug("Cloning instance " + instance.getId() + "/" +
portletContext);
+ }
+ portletContext = portletInvoker.createClone(portletContext);
+ if (debug)
+ {
+ log.debug("Instance " + instance.getId() + " succesfully
cloned " + portletContext);
+ }
+
+ //
+ instance.setPortletContext(portletContext);
+ instance.setMutable(true);
+
+ //
+ containerContext.updateInstance(instance);
+ }
+
+ //
+ return instance;
+ }
+
+ public void destroyDefinition(String id) throws PortletInvokerException,
NoSuchInstanceException
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("id cannot be null");
+ }
+
+ // Lookup instance
+ AbstractInstanceDefinition definition =
containerContext.getInstanceDefinition(id);
+ if (definition == null)
+ {
+ throw new NoSuchInstanceException(id);
+ }
+
+ // Get customizations
+ Collection customizations = definition.getCustomizations();
+
+ // Collect portlet info to destroy for logging purpose
+ StringBuffer destroyLog = new StringBuffer("About to destroy portlets for
instance=").
+ append(definition.getInstanceId()).
+ append(" [");
+
+ //
+ List toDestroy = new ArrayList(customizations.size());
+ for (Iterator i = customizations.iterator(); i.hasNext();)
+ {
+ InstanceCustomizationImpl customization = (InstanceCustomizationImpl)i.next();
+
+ // Get the user portlet context
+ PortletContext customizationPortletContext = customization.getPortletContext();
+
+ // Add the portlet context
+ toDestroy.add(customizationPortletContext);
+
+ //
+ destroyLog.append(customizationPortletContext);
+ if (i.hasNext())
+ {
+ destroyLog.append(',');
+ }
+ }
+
+ //
+ if (definition.isModifiable())
+ {
+ // Destroy the state only if it is not a producer offered portlet
+ PortletContext sharedPortletContext = definition.getPortletContext();
+ toDestroy.add(sharedPortletContext);
+ destroyLog.append(sharedPortletContext);
+ }
+ destroyLog.append(']');
+ log.debug(destroyLog);
+
+ // Perform destruction
+ List failures = portletInvoker.destroyClones(toDestroy);
+
+ // Log failures if any
+ if (failures.size() > 0)
+ {
+ StringBuffer failureLog = new StringBuffer("Some portlet were not properly
destroyed for instance=").
+ append(definition.getInstanceId()).
+ append(" [");
+ for (Iterator i = failures.iterator(); i.hasNext();)
+ {
+ DestroyCloneFailure failure = (DestroyCloneFailure)i.next();
+ failureLog.append(failure.getPortletId());
+ if (i.hasNext())
+ {
+ failureLog.append(',');
+ }
+ }
+ failureLog.append(']');
+ log.debug(failureLog);
+ }
+
+ //
+ containerContext.destroyInstanceDefinition(definition);
+ }
+
+ public Collection getDefinitions()
+ {
+ //
+// PortalAuthorizationManager mgr = portalAuthorizationManagerFactory.getManager();
+
+ //
+ Collection list = containerContext.getInstanceDefinitions();
+
+ // Filter the list
+ for (Iterator i = list.iterator();i.hasNext();)
+ {
+ Instance instance = (Instance)i.next();
+ InstancePermission perm = new InstancePermission(instance.getId(),
InstancePermission.VIEW_ACTION);
+// if (mgr.checkPermission(perm) == false)
+// {
+// i.remove();
+// }
+ }
+
+ //
+ return list;
+ }
+
+ PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException
+ {
+ InvocationHandler prevHandler = invocation.getHandler();
+ try
+ {
+ invocation.setHandler(handler);
+ return
(PortletInvocationResponse)invocation.invoke(stackFactory.getInterceptorStack());
+ }
+ catch (Exception e)
+ {
+ if (e instanceof PortletInvokerException)
+ {
+ throw (PortletInvokerException)e;
+ }
+ else if (e instanceof RuntimeException)
+ {
+ throw (RuntimeException)e;
+ }
+ else
+ {
+ throw new PortletInvokerException(e);
+ }
+ }
+ finally
+ {
+ invocation.setHandler(prevHandler);
+ }
+ }
+
+ //**********************************************************************
+ // AuthorizationDomain Interface
+ //**********************************************************************
+
+ public String getType()
+ {
+ return InstancePermission.PERMISSION_TYPE;
+ }
+
+ public DomainConfigurator getConfigurator()
+ {
+ return this;
+ }
+
+ public PermissionRepository getPermissionRepository()
+ {
+ return this;
+ }
+
+ public PermissionFactory getPermissionFactory()
+ {
+ return this;
+ }
+
+ public Set getSecurityBindings(String uri)
+ {
+ Set constraints = null;
+ AbstractInstanceDefinition instance = containerContext.getInstanceDefinition(uri);
+ if (instance != null)
+ {
+ constraints = new HashSet();
+ Collection onscs = instance.getSecurityBindings().values();
+ for (Iterator i = onscs.iterator(); i.hasNext();)
+ {
+ InstanceSecurityBinding isc = (InstanceSecurityBinding)i.next();
+ RoleSecurityBinding sc = new RoleSecurityBinding(isc.getActions(),
isc.getRole());
+ constraints.add(sc);
+ }
+ }
+ return constraints;
+ }
+
+ public void setSecurityBindings(String uri, Set securityBindings) throws
SecurityConfigurationException
+ {
+ AbstractInstanceDefinition instanceDef =
containerContext.getInstanceDefinition(uri);
+
+ //
+ if (instanceDef == null)
+ {
+ throw new SecurityConfigurationException("The object should exist prior its
security is configured : fixme");
+ }
+
+ //
+ instanceDef.getSecurityBindings().clear();
+
+ //
+ HashMap map = new HashMap();
+ for (Iterator i = securityBindings.iterator(); i.hasNext();)
+ {
+ RoleSecurityBinding sc = (RoleSecurityBinding)i.next();
+
+ // Optimize
+ if (sc.getActions().size() > 0)
+ {
+ InstanceSecurityBinding isc = new InstanceSecurityBinding(sc.getActions(),
sc.getRoleName());
+ isc.setInstance(instanceDef);
+ map.put(sc.getRoleName(), isc);
+ }
+ }
+ instanceDef.getSecurityBindings().putAll(map);
+
+ //
+ containerContext.updateInstance(instanceDef);
+ }
+
+ public void removeSecurityBindings(String uri) throws SecurityConfigurationException
+ {
+ setSecurityBindings(uri, Collections.EMPTY_SET);
+ }
+
+ public PortalPermission getPermission(String roleName, String uri) throws
PortalSecurityException
+ {
+ Set set = getSecurityBindings(uri);
+ if (set != null && !set.isEmpty())
+ {
+ for (Iterator i = set.iterator(); i.hasNext();)
+ {
+ RoleSecurityBinding sc = (RoleSecurityBinding)i.next();
+ String constraintRoleName = sc.getRoleName();
+ if (constraintRoleName.equals(roleName) ||
SecurityConstants.UNCHECKED_ROLE_NAME.equals(constraintRoleName))
+ {
+ return createPermission(uri, sc.getActions());
+ }
+ }
+ }
+ return null;
+ }
+}
Property changes on:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceCustomizationImpl.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceCustomizationImpl.java 2007-05-10
03:10:55 UTC (rev 7233)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceCustomizationImpl.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -1,171 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.model.instance;
-
-import org.apache.log4j.Logger;
-import org.hibernate.Session;
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.instance.InstanceCustomization;
-import org.jboss.portal.core.model.instance.InstanceDefinition;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.state.AccessMode;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class InstanceCustomizationImpl extends InstanceImpl implements
InstanceCustomization
-{
-
- /** The logger. */
- private static final Logger log = Logger.getLogger(InstanceCustomizationImpl.class);
-
- // Persistent fields
-
- protected InstanceDefinitionImpl def;
- protected String customizationId;
-
- // Runtime fields
-
- protected boolean persistent;
-
- /** Used to build transient instances. */
- public InstanceCustomizationImpl(InstanceDefinitionImpl def, String customizationId,
ContainerContext containerContext, PortletContext portletContext)
- {
- super(containerContext);
-
- //
- if (def == null)
- {
- throw new IllegalArgumentException();
- }
- if (customizationId == null)
- {
- throw new IllegalArgumentException();
- }
- if (portletContext == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- this.def = def;
- this.customizationId = customizationId;
- this.persistent = false;
-
- //
- setPortletContext(portletContext);
- }
-
- /** Used by hibernate. */
- public InstanceCustomizationImpl()
- {
- this.customizationId = null;
- this.persistent = true;
- }
-
- public String getId()
- {
- return customizationId;
- }
-
- public Portlet getPortlet() throws PortletInvokerException
- {
- return def.getPortlet(getPortletContext());
- }
-
- public InstanceContainer getContainer()
- {
- return containerContext.container;
- }
-
- public InstanceDefinition getDefinition()
- {
- return def;
- }
-
- public String getCustomizationId()
- {
- return customizationId;
- }
-
- public void setCustomizationId(String customizationId)
- {
- this.customizationId = customizationId;
- }
-
- public InstanceDefinitionImpl getDef()
- {
- return def;
- }
-
- public void setDef(InstanceDefinitionImpl def)
- {
- this.def = def;
- }
-
- // AbstractInstance implementation
**********************************************************************************
-
- protected String getInstanceId()
- {
- return def.getInstanceId();
- }
-
- protected void cloned(PortletContext portletContext)
- {
- Session session = containerContext.getCurrentSession();
- setPortletContext(portletContext);
- session.persist(this);
- def.customizations.add(this);
- session.update(def);
- }
-
- protected void modified(PortletContext portletContext)
- {
- Session session = containerContext.getCurrentSession();
- setPortletContext(portletContext);
- session.update(this);
- }
-
- protected AccessMode getAccessMode()
- {
- return persistent ? AccessMode.READ_WRITE : AccessMode.CLONE_BEFORE_WRITE;
- }
-
- protected boolean isModifiable()
- {
- return true;
- }
-
- protected void setModifiable(boolean modifiable)
- {
- throw new IllegalStateException("Unmodifiable");
- }
-
- protected Logger getLogger()
- {
- return log;
- }
-}
Deleted:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceDefinitionImpl.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceDefinitionImpl.java 2007-05-10
03:10:55 UTC (rev 7233)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceDefinitionImpl.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -1,183 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.model.instance;
-
-import org.apache.log4j.Logger;
-import org.hibernate.Session;
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.instance.InstanceDefinition;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.state.AccessMode;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class InstanceDefinitionImpl extends InstanceImpl implements InstanceDefinition
-{
-
- /** The logger. */
- private static final Logger log = Logger.getLogger(InstanceDefinitionImpl.class);
-
- // Persistent fields
-
- protected String instanceId;
- protected boolean modifiable;
- protected Map securityBindings;
- protected Set customizations;
-
- public InstanceDefinitionImpl()
- {
- this.modifiable = false;
- this.portletRef = null;
- this.instanceId = null;
- this.securityBindings = null;
- this.customizations = null;
- this.state = null;
- }
-
- public InstanceDefinitionImpl(ContainerContext ctx, String id, String portletRef)
- {
- super(ctx);
- this.modifiable = false;
- this.portletRef = portletRef;
- this.instanceId = id;
- this.securityBindings = new HashMap();
- this.customizations = new HashSet();
- this.state = null;
- }
-
- // Hibernate
********************************************************************************************************
-
- public String getInstanceId()
- {
- return instanceId;
- }
-
- public void setInstanceId(String instanceId)
- {
- this.instanceId = instanceId;
- }
-
- public Map getSecurityBindings()
- {
- return securityBindings;
- }
-
- public void setSecurityBindings(Map securityBindings)
- {
- this.securityBindings = securityBindings;
- }
-
- public Set getCustomizations()
- {
- return customizations;
- }
-
- public void setCustomizations(Set customizations)
- {
- this.customizations = customizations;
- }
-
- public void setModifiable(boolean modifiable)
- {
- this.modifiable = modifiable;
- }
-
- // AbstractInstance implementation
**********************************************************************************
-
-
- protected AccessMode getAccessMode()
- {
-/*
- if (Mode.EDIT_DEFAULTS.equals(ctxabc.getMode()))
- {
- // Implement it by using the shared portlet id, but a security check should be
made on using this
- // mode first
- // Another idea is to shove that in the security interceptor
- throw new UnsupportedOperationException("Implement me");
- }
-*/
- return AccessMode.READ_ONLY;
- }
-
- protected Logger getLogger()
- {
- return log;
- }
-
- // Instance implementation
******************************************************************************************
-
- public String getId()
- {
- return instanceId;
- }
-
- public InstanceContainer getContainer()
- {
- return containerContext.container;
- }
-
- public boolean isModifiable()
- {
- return modifiable;
- }
-
- public Portlet getPortlet() throws PortletInvokerException
- {
- return getPortlet(getPortletContext());
- }
-
- Portlet getPortlet(PortletContext portletContext) throws PortletInvokerException
- {
- PersistentInstanceContainer container = containerContext.container;
- PortletInvoker invoker = container.getPortletInvoker();
- return invoker.getPortlet(portletContext);
- }
-
-
- protected void cloned(PortletContext portletContext)
- {
- throw new IllegalStateException();
- }
-
- protected void modified(PortletContext portletContext)
- {
- Session session = containerContext.getCurrentSession();
- setPortletContext(portletContext);
- session.update(this);
- }
-
- protected InstanceDefinitionImpl getDef()
- {
- return this;
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceImpl.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceImpl.java 2007-05-10
03:10:55 UTC (rev 7233)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceImpl.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -1,351 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.model.instance;
-
-import org.apache.log4j.Logger;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.core.model.instance.InstanceCustomization;
-import org.jboss.portal.jems.hibernate.ContextObject;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.state.AccessMode;
-import org.jboss.portal.portlet.state.PropertyChange;
-import org.jboss.portal.portlet.state.PropertyMap;
-import org.jboss.portal.portlet.state.DestroyCloneFailure;
-
-import java.util.Arrays;
-import java.util.Set;
-import java.util.List;
-import java.util.Collections;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public abstract class InstanceImpl implements ContextObject, Instance
-{
-
- /** . */
- private static final Logger log = Logger.getLogger(InstanceImpl.class);
-
- /** . */
- protected Long key;
-
- /** . */
- protected String portletRef;
-
- /** . */
- protected byte[] state;
-
- // Runtime fields
-
- /** . */
- protected ContainerContext containerContext;
-
- protected InstanceImpl(ContainerContext context)
- {
- if (context == null)
- {
- throw new IllegalArgumentException();
- }
- this.containerContext = context;
- }
-
- protected InstanceImpl()
- {
- }
-
- public Long getKey()
- {
- return key;
- }
-
- public void setKey(Long key)
- {
- this.key = key;
- }
-
- public String getPortletRef()
- {
- return portletRef;
- }
-
- public void setPortletRef(String portletRef)
- {
- this.portletRef = portletRef;
- }
-
- public byte[] getState()
- {
- return state;
- }
-
- public void setState(byte[] state)
- {
- this.state = state;
- }
-
- public PortletContext getPortletContext()
- {
- return PortletContext.createPortletContext(portletRef, state);
- }
-
- public void setPortletContext(PortletContext portletContext)
- {
- portletRef = portletContext.getId();
- state = portletContext.getState();
- }
-
- protected abstract boolean isModifiable();
-
- protected abstract void setModifiable(boolean modifiable);
-
- protected abstract Logger getLogger();
-
- protected abstract String getInstanceId();
-
- protected abstract AccessMode getAccessMode();
-
- protected abstract void cloned(PortletContext portletContext);
-
- protected abstract void modified(PortletContext portletContext);
-
- protected abstract InstanceDefinitionImpl getDef();
-
- public void setProperties(PropertyChange[] changes) throws PortletInvokerException
- {
- if (changes == null)
- {
- throw new IllegalArgumentException("No null changes accepted");
- }
- boolean debug = getLogger().isDebugEnabled();
-
- // Get the invoker
- PortletInvoker portletInvoker = containerContext.getPortletInvoker();
-
- //
- PortletContext portletContext = getPortletContext();
-
- //
- if (isModifiable() == false)
- {
- // Clone the portlet
- if (debug)
- {
- getLogger().debug("Need to clone non modifiable instance before setting
properties " /*+ instanceId + "/"*/ + portletContext);
- }
- portletContext = portletInvoker.createClone(portletContext);
- if (debug)
- {
- getLogger().debug("Received updated portlet context " +
portletContext + " for instance " /*+ instanceId*/ + " after explicit
clone");
- }
-
- // Update the state
- setPortletContext(portletContext);
- setModifiable(true);
-
- //
- Session session = containerContext.getCurrentSession();
- session.update(this);
- }
-
- //
- if (debug)
- {
- getLogger().debug("Setting properties on " + /*instanceId +
"/" +*/ portletContext + " : " + Arrays.asList(changes));
- }
- portletContext = portletInvoker.setProperties(portletContext, changes);
- if (debug)
- {
- getLogger().debug("Received updated portlet context " + portletContext
+ " for instance " + /*instanceId +*/ " after setting properties");
- }
- setPortletContext(portletContext);
-
- //
- Session session = containerContext.getCurrentSession();
- session.update(this);
- }
-
- public PropertyMap getProperties() throws PortletInvokerException
- {
- PersistentInstanceContainer container = containerContext.container;
- PortletInvoker invoker = container.getPortletInvoker();
- PortletContext portletContext = getPortletContext();
- return invoker.getProperties(portletContext);
- }
-
- public PropertyMap getProperties(Set keys) throws PortletInvokerException
- {
- PersistentInstanceContainer container = containerContext.container;
- PortletInvoker invoker = container.getPortletInvoker();
- PortletContext portletContext = getPortletContext();
- return invoker.getProperties(portletContext, keys);
- }
-
- public PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException
- {
- boolean debug = getLogger().isDebugEnabled();
- PersistentInstanceContainer container = this.containerContext.container;
-
- //
- InstanceImpl instance = this;
- AccessMode accessMode = getAccessMode();
-
- //
- PortletContext portletContext = instance.getPortletContext();
-
- // The instance context for the invocation
- InstanceContextImpl instanceContext = new InstanceContextImpl(this, accessMode);
-
- try
- {
- invocation.setAttribute(PortletInvocation.INVOCATION_SCOPE,
INSTANCE_ID_ATTRIBUTE, getInstanceId());
- invocation.setTarget(portletContext);
- invocation.setInstanceContext(instanceContext);
-
- // Perform invocation
- PortletInvocationResponse response = container.invoke(invocation);
-
- // Create user instance if a clone operation occured
- if (instanceContext.accessMode == AccessMode.CLONE_BEFORE_WRITE)
- {
- if (instanceContext.clonedContext != null)
- {
- if (debug)
- {
-// log.debug("About to reference clone of (" + instanceId +
"," + portletContext +
-// ") having id " + instanceContext.clonedContext
+ " for user " + userId);
- }
- cloned(instanceContext.clonedContext);
- }
- else
- {
- // Does not make sense
- }
- }
- else if (instanceContext.accessMode == AccessMode.READ_WRITE)
- {
- if (instanceContext.modifiedContext != null)
- {
- if (debug)
- {
-// log.debug("About to update portlet context (" + instanceId +
"," + portletContext +
-// ") having id " + instanceContext.clonedContext +
" for user " + userId);
- }
- modified(instanceContext.modifiedContext);
- }
- else
- {
- // Does not make sense
- }
- }
-
- //
- return response;
- }
- finally
- {
- // Reset state before invocation
- invocation.removeAttribute(PortletInvocation.INVOCATION_SCOPE,
INSTANCE_ID_ATTRIBUTE);
- invocation.setTarget(null);
- invocation.setInstanceContext(null);
- }
- }
-
- public InstanceCustomization getCustomization(String customizationId)
- {
- if (customizationId == null)
- {
- throw new IllegalArgumentException();
- }
-
- // Check if we have an instance for this particular customized id
- InstanceCustomizationImpl customization = loadCustomization(customizationId);
-
- //
- if (customization == null)
- {
- InstanceDefinitionImpl def = getDef();
- customization = new InstanceCustomizationImpl(def, customizationId,
containerContext, getPortletContext());
- }
-
- //
- return customization;
- }
-
- public void destroyCustomization(String customizationId)
- {
- InstanceCustomizationImpl customization = loadCustomization(customizationId);
-
- //
- if (customization != null)
- {
- try
- {
- PortletContext customizationPortletContext =
customization.getPortletContext();
- List toDestroy = Collections.singletonList(customizationPortletContext);
- PortletInvoker portletInvoker = containerContext.getPortletInvoker();
-
- //
- List failures = portletInvoker.destroyClones(toDestroy);
- if (failures.size() > 0)
- {
- for (Iterator i = failures.iterator();i.hasNext();)
- {
- DestroyCloneFailure failure = (DestroyCloneFailure)i.next();
- log.error("Was not able to destroy " + failure.getPortletId()
+ " for customization " +
- customizationId + ", reason is : " +
failure.getMessage());
- }
- }
- }
- catch (PortletInvokerException e)
- {
- log.error("Could not destroy customization " + customizationId,
e);
- }
- }
- }
-
- private InstanceCustomizationImpl loadCustomization(String customizationId)
- {
- // Check if we have an instance for this particular customized id
- Session session = containerContext.getCurrentSession();
- Query query = session.createQuery("from InstanceCustomizationImpl where
def.key=:defKey and customizationId=:customizationId");
- query.setParameter("defKey", key);
- query.setParameter("customizationId", customizationId);
- query.setCacheable(true);
- return (InstanceCustomizationImpl)query.uniqueResult();
- }
-
- // ContextObject implementation
*************************************************************************************
-
- public void setContext(Object context)
- {
- this.containerContext = (ContainerContext)context;
- }
-}
Deleted:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.java 2007-05-10
03:10:55 UTC (rev 7233)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -1,689 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.impl.model.instance;
-
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Query;
-import org.hibernate.exception.ConstraintViolationException;
-import org.jboss.portal.common.invocation.InterceptorStackFactory;
-import org.jboss.portal.common.invocation.Invocation;
-import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.common.invocation.InvocationHandler;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.core.model.instance.DuplicateInstanceException;
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.instance.InstanceDefinition;
-import org.jboss.portal.core.model.instance.InstancePermission;
-import org.jboss.portal.core.model.instance.NoSuchInstanceException;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.jems.hibernate.ObjectContextualizer;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.state.DestroyCloneFailure;
-import org.jboss.portal.security.PortalPermission;
-import org.jboss.portal.security.PortalPermissionCollection;
-import org.jboss.portal.security.PortalSecurityException;
-import org.jboss.portal.security.RoleSecurityBinding;
-import org.jboss.portal.security.SecurityConstants;
-import org.jboss.portal.security.impl.JBossAuthorizationDomainRegistry;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
-import org.jboss.portal.security.spi.provider.AuthorizationDomain;
-import org.jboss.portal.security.spi.provider.DomainConfigurator;
-import org.jboss.portal.security.spi.provider.PermissionFactory;
-import org.jboss.portal.security.spi.provider.PermissionRepository;
-import org.jboss.portal.security.spi.provider.SecurityConfigurationException;
-
-import javax.naming.InitialContext;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Instance Container that is persistent
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author Anil.Saldhana(a)jboss.org
- * @version $Revision$
- */
-public class PersistentInstanceContainer extends AbstractJBossService
- implements InstanceContainer, AuthorizationDomain, DomainConfigurator,
- PermissionRepository, PermissionFactory
-{
-
- /** . */
- private static final String BY_INSTANCE_ID_QUERY = "from " +
Tools.getShortNameOf(InstanceDefinitionImpl.class) + " where
instanceId=:instanceId";
-
- /** . */
- protected InterceptorStackFactory stackFactory;
-
- /** . */
- protected SessionFactory sessionFactory;
-
- /** If true clone the portlet on an instance creation. */
- protected boolean cloneOnCreate;
-
- /** . */
- protected PortletInvoker portletInvoker;
-
- /** . */
- protected ContainerContext ctx;
-
- /** . */
- protected PortalAuthorizationManagerFactory portalAuthorizationManagerFactory;
-
- /** . */
- protected JBossAuthorizationDomainRegistry authorizationDomainRegistry;
-
- /** . */
- protected String sessionFactoryJNDIName;
-
- /** . */
- protected ObjectContextualizer contextualizer;
-
- /** . */
- protected InvocationHandler handler = new InvocationHandler()
- {
- public Object invoke(Invocation invocation) throws Exception, InvocationException
- {
- PortletInvocation portletInvocation = (PortletInvocation)invocation;
- try
- {
- portletInvocation.setHandler(null);
- return portletInvoker.invoke(portletInvocation);
- }
- finally
- {
- portletInvocation.setHandler(this);
- }
- }
- };
-
- /** . */
- protected ConcurrentReaderHashMap cache;
-
- /** . */
- protected boolean cacheNaturalId;
-
- public PersistentInstanceContainer()
- {
- ctx = new ContainerContext(this);
-
- //
- contextualizer = new ObjectContextualizer(ctx);
- cache = new ConcurrentReaderHashMap();
- }
-
- public void flushNaturalIdCache()
- {
- cache.clear();
- }
-
- public int getNaturalIdCacheSize()
- {
- return cache.size();
- }
-
- public boolean getCacheNaturalId()
- {
- return cacheNaturalId;
- }
-
- public void setCacheNaturalId(boolean cacheNaturalId)
- {
- this.cacheNaturalId = cacheNaturalId;
- }
-
- public boolean getCloneOnCreate()
- {
- return cloneOnCreate;
- }
-
- public void setCloneOnCreate(boolean cloneOnCreate)
- {
- this.cloneOnCreate = cloneOnCreate;
- }
-
- public InterceptorStackFactory getStackFactory()
- {
- return stackFactory;
- }
-
- public void setStackFactory(InterceptorStackFactory stackFactory)
- {
- this.stackFactory = stackFactory;
- }
-
- public PortletInvoker getPortletInvoker()
- {
- return portletInvoker;
- }
-
- public void setPortletInvoker(PortletInvoker portletInvoker)
- {
- this.portletInvoker = portletInvoker;
- }
-
- public String getSessionFactoryJNDIName()
- {
- return sessionFactoryJNDIName;
- }
-
- public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
- {
- this.sessionFactoryJNDIName = sessionFactoryJNDIName;
- }
-
- public ContainerContext getContainerContext()
- {
- return ctx;
- }
-
- public void startService() throws Exception
- {
- sessionFactory = (SessionFactory)new
InitialContext().lookup(sessionFactoryJNDIName);
-
- //
- contextualizer.attach(sessionFactory);
-
- // Add ourself as the authorization domain
- if (authorizationDomainRegistry != null)
- {
- authorizationDomainRegistry.addDomain(this);
- }
-
- //
- super.startService();
- }
-
- protected void stopService() throws Exception
- {
- super.stopService();
-
- //
- if (authorizationDomainRegistry != null)
- {
- authorizationDomainRegistry.removeDomain(this);
- }
-
- //
- sessionFactory = null;
- }
-
- public InstanceDefinition getDefinition(String id)
- {
- if (id == null)
- {
- throw new IllegalArgumentException("id cannot be null");
- }
- Session session = ctx.getCurrentSession();
- return lookup(session, id);
- }
-
- public InstanceDefinition createDefinition(String id, String portletId) throws
DuplicateInstanceException, IllegalArgumentException, PortletInvokerException
- {
- return internalCreateDefinition(id, portletId, cloneOnCreate);
- }
-
- public InstanceDefinition createDefinition(String id, String portletId, boolean clone)
throws DuplicateInstanceException, PortletInvokerException
- {
- return internalCreateDefinition(id, portletId, clone);
- }
-
- private InstanceDefinition internalCreateDefinition(String id, String portletId,
boolean clone) throws DuplicateInstanceException, PortletInvokerException
- {
- if (id == null)
- {
- throw new IllegalArgumentException("id cannot be null");
- }
- boolean debug = log.isDebugEnabled();
-
- //
- if (debug)
- {
- log.debug("Creating instance " + id + " of portlet " +
portletId);
- }
-
- // Create the portlet context we'll use
- PortletContext portletContext = PortletContext.createPortletContext(portletId);
-
- // Check that the portlet exist before creating an instance of it
- portletInvoker.getPortlet(portletContext);
-
- // Prevent duplicate
- Session session = ctx.getCurrentSession();
- if (lookup(session, id) != null)
- {
- throw new DuplicateInstanceException("An instance with id " + id +
" already exist");
- }
-
- //
- InstanceDefinitionImpl instance;
- try
- {
- instance = new InstanceDefinitionImpl(ctx, id, portletId);
- session.persist(instance);
- }
- catch (ConstraintViolationException e)
- {
- // May raise a constraint violation exception if it is has been inserted between
the lookup
- // and the insert and the isolation level is not serializable
- throw new DuplicateInstanceException("An instance with id " + id +
" already exist");
- }
-
- // Clone the portlet if required
- if (clone)
- {
- // Clone the portlet state now and update the instance
- if (debug)
- {
- log.debug("Cloning instance " + instance.instanceId + "/"
+ portletContext);
- }
- portletContext = portletInvoker.createClone(portletContext);
- if (debug)
- {
- log.debug("Instance " + instance.instanceId + " succesfully
cloned " + portletContext);
- }
-
- //
- instance.setPortletContext(portletContext);
- instance.setModifiable(true);
-
- //
- session.update(instance);
- }
-
- //
- return instance;
- }
-
- public void destroyDefinition(String id) throws PortletInvokerException,
NoSuchInstanceException
- {
- if (id == null)
- {
- throw new IllegalArgumentException("id cannot be null");
- }
-
- // Get an hibernate session
- Session session = ctx.getCurrentSession();
-
- // Lookup instance
- InstanceDefinitionImpl definition = lookup(session, id);
- if (definition == null)
- {
- throw new NoSuchInstanceException(id);
- }
- Set customizations = definition.getCustomizations();
-
- // Collect portlet info to destroy for logging purpose
- StringBuffer destroyLog = new StringBuffer("About to destroy portlets for
instance=").
- append(definition.getInstanceId()).
- append(" [");
-
- //
- List toDestroy = new ArrayList(customizations.size());
- for (Iterator i = customizations.iterator(); i.hasNext();)
- {
- InstanceCustomizationImpl customization = (InstanceCustomizationImpl)i.next();
-
- // Get the user portlet context
- PortletContext customizationPortletContext = customization.getPortletContext();
-
- // Add the portlet context
- toDestroy.add(customizationPortletContext);
-
- //
- destroyLog.append(customizationPortletContext);
- if (i.hasNext())
- {
- destroyLog.append(',');
- }
- }
-
- //
- if (definition.isModifiable())
- {
- // Destroy the state only if it is not a producer offered portlet
- PortletContext sharedPortletContext = definition.getPortletContext();
- toDestroy.add(sharedPortletContext);
- destroyLog.append(sharedPortletContext);
- }
- destroyLog.append(']');
- log.debug(destroyLog);
-
- // Perform destruction
- List failures = portletInvoker.destroyClones(toDestroy);
-
- // Log failures if any
- if (failures.size() > 0)
- {
- StringBuffer failureLog = new StringBuffer("Some portlet were not properly
destroyed for instance=").
- append(definition.getInstanceId()).
- append(" [");
- for (Iterator i = failures.iterator(); i.hasNext();)
- {
- DestroyCloneFailure failure = (DestroyCloneFailure)i.next();
- failureLog.append(failure.getPortletId());
- if (i.hasNext())
- {
- failureLog.append(',');
- }
- }
- failureLog.append(']');
- log.debug(failureLog);
- }
-
- // Destroy the user instances
- for (Iterator i = customizations.iterator(); i.hasNext();)
- {
- InstanceCustomizationImpl userInstance = (InstanceCustomizationImpl)i.next();
- i.remove();
- userInstance.def = null;
- session.delete(userInstance);
- }
-
- // Delete instance
- removeBindings(session, definition);
- session.delete(definition);
-
- //
- session.flush();
- }
-
- public Collection getDefinitions()
- {
- //
- PortalAuthorizationManager mgr = portalAuthorizationManagerFactory.getManager();
-
- //
- Session session = ctx.getCurrentSession();
- List list = session.createQuery("from InstanceDefinitionImpl").list();
-
- // Filter the list
- for (Iterator i = list.iterator();i.hasNext();)
- {
- Instance instance = (Instance)i.next();
- InstancePermission perm = new InstancePermission(instance.getId(),
InstancePermission.VIEW_ACTION);
- if (mgr.checkPermission(perm) == false)
- {
- i.remove();
- }
- }
-
- //
- return list;
- }
-
- PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException
- {
- InvocationHandler prevHandler = invocation.getHandler();
- try
- {
- invocation.setHandler(handler);
- return
(PortletInvocationResponse)invocation.invoke(stackFactory.getInterceptorStack());
- }
- catch (Exception e)
- {
- if (e instanceof PortletInvokerException)
- {
- throw (PortletInvokerException)e;
- }
- else if (e instanceof RuntimeException)
- {
- throw (RuntimeException)e;
- }
- else
- {
- throw new PortletInvokerException(e);
- }
- }
- finally
- {
- invocation.setHandler(prevHandler);
- }
- }
-
- public JBossAuthorizationDomainRegistry getAuthorizationDomainRegistry()
- {
- return authorizationDomainRegistry;
- }
-
- public void setAuthorizationDomainRegistry(JBossAuthorizationDomainRegistry
authorizationDomainRegistry)
- {
- this.authorizationDomainRegistry = authorizationDomainRegistry;
- }
-
- public PortalAuthorizationManagerFactory getPortalAuthorizationManagerFactory()
- {
- return portalAuthorizationManagerFactory;
- }
-
- public void setPortalAuthorizationManagerFactory(PortalAuthorizationManagerFactory
portalAuthorizationManagerFactory)
- {
- this.portalAuthorizationManagerFactory = portalAuthorizationManagerFactory;
- }
-
- private InstanceDefinitionImpl lookup(Session session, String id)
- {
- // Get cached pk from natural id
- Long pk = cacheNaturalId ? (Long)cache.get(id) : null;
-
- //
- InstanceDefinitionImpl instance;
-
- //
- if (pk == null)
- {
- // No pk
- instance = lookupNoCache(session, id);
- }
- else
- {
- // Try lookup using the cached pk
- instance = (InstanceDefinitionImpl)session.get(InstanceDefinitionImpl.class,
pk);
-
- // The pk may be invalid if the instance has been recreted under the same path
with a different pk
- if (instance == null)
- {
- // In that case we try a no cache
- instance = lookupNoCache(session, id);
- }
- }
-
- //
- if (cacheNaturalId)
- {
- if (instance != null)
- {
- cache.put(id, instance.getKey());
- }
- else
- {
- cache.remove(id);
- }
- }
-
- //
- return instance;
- }
-
- private InstanceDefinitionImpl lookupNoCache(Session session, String id)
- {
- Query q = session.createQuery(BY_INSTANCE_ID_QUERY);
- q.setString("instanceId", id);
- return (InstanceDefinitionImpl)q.uniqueResult();
- }
-
- //**********************************************************************
- // AuthorizationDomain Interface
- //**********************************************************************
-
- public String getType()
- {
- return InstancePermission.PERMISSION_TYPE;
- }
-
- public DomainConfigurator getConfigurator()
- {
- return this;
- }
-
- public PermissionRepository getPermissionRepository()
- {
- return this;
- }
-
- public PermissionFactory getPermissionFactory()
- {
- return this;
- }
-
- public Set getSecurityBindings(String uri)
- {
- Set constraints = null;
- InstanceDefinitionImpl instance = lookup(sessionFactory.getCurrentSession(), uri);
- if (instance != null)
- {
- constraints = new HashSet();
- Collection onscs = instance.getSecurityBindings().values();
- for (Iterator i = onscs.iterator(); i.hasNext();)
- {
- InstanceSecurityBinding isc = (InstanceSecurityBinding)i.next();
- RoleSecurityBinding sc = new RoleSecurityBinding(isc.getActions(),
isc.getRole());
- constraints.add(sc);
- }
- }
- return constraints;
- }
-
- public void setSecurityBindings(String uri, Set securityBindings) throws
SecurityConfigurationException
- {
- Session session = sessionFactory.getCurrentSession();
- InstanceDefinitionImpl instance = lookup(session, uri);
-
- //
- if (instance == null)
- {
- throw new SecurityConfigurationException("The object should exist prior its
security is configured : fixme");
- }
-
- //
- removeBindings(session, instance);
-
- //
- HashMap map = new HashMap();
- for (Iterator i = securityBindings.iterator(); i.hasNext();)
- {
- RoleSecurityBinding sc = (RoleSecurityBinding)i.next();
-
- // Optimize
- if (sc.getActions().size() > 0)
- {
- InstanceSecurityBinding isc = new InstanceSecurityBinding(sc.getActions(),
sc.getRoleName());
- isc.setInstance(instance);
- map.put(sc.getRoleName(), isc);
- session.save(isc);
- }
- }
- instance.setSecurityBindings(map);
-
- //
- session.flush();
- }
-
- public void removeSecurityBindings(String uri) throws SecurityConfigurationException
- {
- Session session = sessionFactory.getCurrentSession();
- InstanceDefinitionImpl instance = lookup(session, uri);
-
- //
- if (instance == null)
- {
- throw new SecurityConfigurationException("The object should exist prior its
security is configured : fixme");
- }
-
- removeBindings(session, instance);
- session.flush();
- }
-
- public PortalPermission getPermission(String roleName, String uri) throws
PortalSecurityException
- {
- Set set = getSecurityBindings(uri);
- if (set != null && !set.isEmpty())
- {
- for (Iterator i = set.iterator(); i.hasNext();)
- {
- RoleSecurityBinding sc = (RoleSecurityBinding)i.next();
- String constraintRoleName = sc.getRoleName();
- if (constraintRoleName.equals(roleName) ||
SecurityConstants.UNCHECKED_ROLE_NAME.equals(constraintRoleName))
- {
- return createPermission(uri, sc.getActions());
- }
- }
- }
- return null;
- }
-
- public PortalPermission createPermissionContainer(PortalPermissionCollection
collection) throws PortalSecurityException
- {
- return new InstancePermission(collection);
- }
-
- public PortalPermission createPermission(String uri, String action) throws
PortalSecurityException
- {
- return new InstancePermission(uri, action);
- }
-
- public PortalPermission createPermission(String uri, Collection actions) throws
PortalSecurityException
- {
- return new InstancePermission(uri, actions);
- }
-
- public AuthorizationDomain getAuthorizationDomain()
- {
- return this;
- }
-
- private void removeBindings(Session session, InstanceDefinitionImpl instance)
- {
- if (instance.getSecurityBindings() != null)
- {
- for (Iterator i = instance.getSecurityBindings().values().iterator();
i.hasNext();)
- {
- InstanceSecurityBinding insc = (InstanceSecurityBinding)i.next();
- session.delete(insc);
- }
- instance.getSecurityBindings().clear();
- }
- }
-}
Copied:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java
(from rev 7225,
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceCustomizationImpl.java)
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -0,0 +1,130 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.instance.persistent;
+
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceCustomization;
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceDefinition;
+import org.jboss.portal.core.impl.model.instance.ContainerContext;
+import org.jboss.portal.portlet.PortletContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class InstanceCustomizationImpl extends AbstractInstanceCustomization
+{
+
+ // Persistent fields
+
+ protected Long key;
+ protected InstanceDefinitionImpl relatedDefinition;
+ protected String customizationId;
+
+ // Runtime fields
+
+ protected InstanceDefinitionImpl owner;
+ protected boolean persistent;
+
+ /** Used to build transient instances. */
+ public InstanceCustomizationImpl(InstanceDefinitionImpl owner, String customizationId,
PortletContext portletContext)
+ {
+ if (owner == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (customizationId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (portletContext == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.owner = owner;
+ this.persistent = false;
+
+ //
+ setCustomizationId(customizationId);
+ setPortletContext(portletContext);
+ }
+
+ /** Used by hibernate. */
+ public InstanceCustomizationImpl()
+ {
+ this.owner = null;
+ this.persistent = true;
+ }
+
+ public Long getKey()
+ {
+ return key;
+ }
+
+ public void setKey(Long key)
+ {
+ this.key = key;
+ }
+
+ public String getId()
+ {
+ return customizationId;
+ }
+
+ public String getCustomizationId()
+ {
+ return customizationId;
+ }
+
+ public void setCustomizationId(String customizationId)
+ {
+ this.customizationId = customizationId;
+ }
+
+ public AbstractInstanceDefinition getOwner()
+ {
+ return owner;
+ }
+
+ public InstanceDefinitionImpl getRelatedDefinition()
+ {
+ return relatedDefinition;
+ }
+
+ public void setRelatedDefinition(InstanceDefinitionImpl relatedDefinition)
+ {
+ this.relatedDefinition = relatedDefinition;
+ this.owner = relatedDefinition;
+ }
+
+ protected boolean isPersistent()
+ {
+ return persistent;
+ }
+
+ protected ContainerContext getContainerContext()
+ {
+ return owner.containerContext;
+ }
+}
Property changes on:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java
(from rev 7225,
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceDefinitionImpl.java)
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -0,0 +1,150 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.instance.persistent;
+
+import org.jboss.portal.core.impl.model.instance.ContainerContext;
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceDefinition;
+import org.jboss.portal.jems.hibernate.ContextObject;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class InstanceDefinitionImpl extends AbstractInstanceDefinition implements
ContextObject
+{
+
+ // Persistent fields
+
+ protected Long key;
+ protected String instanceId;
+ protected boolean mutable;
+ protected Map securityBindings;
+ protected Map customizationMap;
+
+ // Runtime fields
+
+ /** . */
+ protected ContainerContext containerContext;
+
+ public InstanceDefinitionImpl()
+ {
+ this.mutable = false;
+ this.portletRef = null;
+ this.instanceId = null;
+ this.securityBindings = null;
+ this.customizationMap = null;
+ this.state = null;
+ }
+
+ public InstanceDefinitionImpl(String id, String portletRef)
+ {
+ this.mutable = false;
+ this.portletRef = portletRef;
+ this.instanceId = id;
+ this.securityBindings = new HashMap();
+ this.customizationMap = new HashMap();
+ this.state = null;
+ }
+
+ // Hibernate
********************************************************************************************************
+
+ public Long getKey()
+ {
+ return key;
+ }
+
+ public void setKey(Long key)
+ {
+ this.key = key;
+ }
+
+ public String getInstanceId()
+ {
+ return instanceId;
+ }
+
+ public void setInstanceId(String instanceId)
+ {
+ this.instanceId = instanceId;
+ }
+
+ public Map getSecurityBindings()
+ {
+ return securityBindings;
+ }
+
+ public void setSecurityBindings(Map securityBindings)
+ {
+ this.securityBindings = securityBindings;
+ }
+
+ public Map getCustomizationMap()
+ {
+ return customizationMap;
+ }
+
+ public void setCustomizationMap(Map customizationMap)
+ {
+ this.customizationMap = customizationMap;
+ }
+
+ public boolean isMutable()
+ {
+ return mutable;
+ }
+
+ public void setMutable(boolean mutable)
+ {
+ this.mutable = mutable;
+ }
+
+ // Instance implementation
******************************************************************************************
+
+ public String getId()
+ {
+ return instanceId;
+ }
+
+ // AbstractInstanceDefinition implementation
************************************************************************
+
+ protected Collection getCustomizations()
+ {
+ return customizationMap.values();
+ }
+
+ // ContextObject implementation
*************************************************************************************
+
+ public void setContext(Object context)
+ {
+ this.containerContext = (ContainerContext)context;
+ }
+
+ protected ContainerContext getContainerContext()
+ {
+ return containerContext;
+ }
+}
Property changes on:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContext.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContext.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContext.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -0,0 +1,274 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.instance.persistent;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.exception.ConstraintViolationException;
+import org.jboss.portal.jems.hibernate.ObjectContextualizer;
+import org.jboss.portal.core.model.instance.DuplicateInstanceException;
+import org.jboss.portal.core.impl.model.instance.ContainerContext;
+import org.jboss.portal.core.impl.model.instance.AbstractInstance;
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceDefinition;
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceCustomization;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.portlet.PortletContext;
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
+
+import javax.naming.InitialContext;
+import java.util.Iterator;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PersistentInstanceContext extends ContainerContext
+{
+
+ /** . */
+ private static final String BY_INSTANCE_ID_QUERY = "from " +
Tools.getShortNameOf(InstanceDefinitionImpl.class) + " where
instanceId=:instanceId";
+
+ /** . */
+ protected SessionFactory sessionFactory;
+
+ /** . */
+ protected String sessionFactoryJNDIName;
+
+ /** . */
+ protected ObjectContextualizer contextualizer;
+
+ /** . */
+ protected ConcurrentReaderHashMap cache;
+
+ /** . */
+ protected boolean cacheNaturalId;
+
+ public PersistentInstanceContext()
+ {
+ this.contextualizer = new ObjectContextualizer(this);
+ this.cache = new ConcurrentReaderHashMap();
+ }
+
+ public void flushNaturalIdCache()
+ {
+ cache.clear();
+ }
+
+ public int getNaturalIdCacheSize()
+ {
+ return cache.size();
+ }
+
+ public boolean getCacheNaturalId()
+ {
+ return cacheNaturalId;
+ }
+
+ public void setCacheNaturalId(boolean cacheNaturalId)
+ {
+ this.cacheNaturalId = cacheNaturalId;
+ }
+
+ public String getSessionFactoryJNDIName()
+ {
+ return sessionFactoryJNDIName;
+ }
+
+ public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+ {
+ this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+ }
+
+ public void start() throws Exception
+ {
+ sessionFactory = (SessionFactory)new
InitialContext().lookup(sessionFactoryJNDIName);
+
+ //
+ contextualizer.attach(sessionFactory);
+ }
+
+ public void stop() throws Exception
+ {
+ sessionFactory = null;
+ }
+
+ public Collection getInstanceDefinitions()
+ {
+ Session session = sessionFactory.getCurrentSession();
+ return session.createQuery("from InstanceDefinitionImpl").list();
+ }
+
+ public AbstractInstanceCustomization
newInstanceCustomization(AbstractInstanceDefinition def, String id, PortletContext
portletContext)
+ {
+ return new InstanceCustomizationImpl((InstanceDefinitionImpl)def, id,
portletContext);
+ }
+
+ public AbstractInstanceDefinition newInstanceDefinition(String id, String portletRef)
+ {
+ return new InstanceDefinitionImpl(id, portletRef);
+ }
+
+ public AbstractInstanceDefinition getInstanceDefinition(String id)
+ {
+ // Get cached pk from natural id
+ Long pk = cacheNaturalId ? (Long)cache.get(id) : null;
+
+ //
+ InstanceDefinitionImpl instance;
+
+ //
+ Session session = sessionFactory.getCurrentSession();
+
+ //
+ if (pk == null)
+ {
+ // No pk
+ instance = lookupNoCache(session, id);
+ }
+ else
+ {
+ // Try lookup using the cached pk
+ instance = (InstanceDefinitionImpl)session.get(InstanceDefinitionImpl.class,
pk);
+
+ // The pk may be invalid if the instance has been recreted under the same path
with a different pk
+ if (instance == null)
+ {
+ // In that case we try a no cache
+ instance = lookupNoCache(session, id);
+ }
+ }
+
+ //
+ if (cacheNaturalId)
+ {
+ if (instance != null)
+ {
+ cache.put(id, instance.getKey());
+ }
+ else
+ {
+ cache.remove(id);
+ }
+ }
+
+ //
+ return instance;
+ }
+
+ public AbstractInstanceCustomization getCustomization(AbstractInstanceDefinition
instanceDef, String customizationId)
+ {
+ InstanceDefinitionImpl _instanceDef = (InstanceDefinitionImpl)instanceDef;
+ return
(InstanceCustomizationImpl)_instanceDef.customizationMap.get(customizationId);
+ }
+
+ private InstanceDefinitionImpl lookupNoCache(Session session, String id)
+ {
+ Query q = session.createQuery(BY_INSTANCE_ID_QUERY);
+ q.setString("instanceId", id);
+ return (InstanceDefinitionImpl)q.uniqueResult();
+ }
+
+ public void createInstanceDefinition(AbstractInstanceDefinition instanceDef) throws
DuplicateInstanceException
+ {
+ String id = instanceDef.getId();
+
+ //
+ if (getInstanceDefinition(id) != null)
+ {
+ throw new DuplicateInstanceException("An instance with id " + id +
" already exist");
+ }
+
+ //
+ try
+ {
+ Session session = sessionFactory.getCurrentSession();
+ session.persist(instanceDef);
+ }
+ catch (ConstraintViolationException e)
+ {
+ // May raise a constraint violation exception if it is has been inserted between
the lookup
+ // and the insert and the isolation level is not serializable
+ throw new DuplicateInstanceException("An instance with id " + id +
" already exist");
+ }
+ }
+
+ public void createInstanceCustomizaton(AbstractInstanceCustomization customization)
+ {
+ createInstanceCustomizaton((InstanceCustomizationImpl)customization);
+ }
+
+ private void createInstanceCustomizaton(InstanceCustomizationImpl customization)
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ // Persist in db
+ session.persist(customization);
+
+ // Get owner that will become the related definition
+ InstanceDefinitionImpl relatedDefinition = customization.owner;
+
+ // Create one to many assoication
+ relatedDefinition.customizationMap.put(customization.customizationId,
customization);
+ customization.relatedDefinition = relatedDefinition;
+
+ // Update state
+ session.update(customization.relatedDefinition);
+
+ // Mark state as persistent
+ customization.persistent = true;
+ }
+
+ public void updateInstance(AbstractInstance instanceDef)
+ {
+ Session session = sessionFactory.getCurrentSession();
+ session.update(instanceDef);
+ }
+
+ public void destroyInstanceDefinition(AbstractInstanceDefinition instanceDef)
+ {
+ destroyInstanceDefinition((InstanceDefinitionImpl)instanceDef);
+ }
+
+ private void destroyInstanceDefinition(InstanceDefinitionImpl instanceDef)
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ // Destroy the user instances
+ Collection customizations = instanceDef.getCustomizationMap().values();
+ for (Iterator i = customizations.iterator(); i.hasNext();)
+ {
+ InstanceCustomizationImpl userInstance = (InstanceCustomizationImpl)i.next();
+ i.remove();
+ userInstance.relatedDefinition = null;
+ session.delete(userInstance);
+ }
+
+ // Delete instance
+ session.delete(instanceDef);
+
+ //
+ session.flush();
+ }
+}
Modified:
trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java 2007-05-10
03:10:55 UTC (rev 7233)
+++
trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -38,15 +38,17 @@
import org.apache.log4j.SimpleLayout;
import org.hibernate.Session;
import org.jboss.portal.Mode;
+import org.jboss.portal.security.spi.provider.DomainConfigurator;
+import org.jboss.portal.security.RoleSecurityBinding;
import org.jboss.portal.common.junit.TransactionAssert;
import org.jboss.portal.common.util.CollectionBuilder;
import org.jboss.portal.common.value.StringValue;
import org.jboss.portal.common.test.junit.POJOJUnitTest;
import org.jboss.portal.common.test.junit.JUnitAdapter;
import org.jboss.portal.common.test.TestParametrization;
-import org.jboss.portal.core.impl.model.instance.InstanceCustomizationImpl;
-import org.jboss.portal.core.impl.model.instance.InstanceDefinitionImpl;
-import org.jboss.portal.core.impl.model.instance.PersistentInstanceContainer;
+import org.jboss.portal.core.impl.model.instance.persistent.InstanceCustomizationImpl;
+import org.jboss.portal.core.impl.model.instance.persistent.InstanceDefinitionImpl;
+import org.jboss.portal.core.impl.model.instance.InstanceContainerImpl;
import
org.jboss.portal.core.impl.portlet.state.PersistentPortletStatePersistenceManager;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.instance.InstanceDefinition;
@@ -76,8 +78,9 @@
import org.jboss.portal.test.framework.embedded.HibernateSupport;
import java.net.URL;
-import java.util.List;
import java.util.Set;
+import java.util.Collections;
+import java.util.Collection;
/**
* Test Case that tests the authorization for instances via the instance container
@@ -155,6 +158,9 @@
private boolean cloneOnCreate;
/** . */
+ private boolean cacheNaturalId;
+
+ /** . */
private DataSourceSupport.Config dataSourceConfigParameter;
/** . */
@@ -167,7 +173,7 @@
private HibernateSupport portletHibernateSupport;
/** . */
- private PersistentInstanceContainer instanceContainer;
+ private InstanceContainerImpl instanceContainer;
/** . */
private PersistentPortletStatePersistenceManager persistenceManager;
@@ -178,9 +184,12 @@
/** . */
private PortletInvokerSupport portletContainer;
+ /** . */
+ private String config;
+
public String getName()
{
- return super.getName() + ",persistLocally=" + persistLocally +
",cloneOnCreate=" + cloneOnCreate + ",ds=" +
dataSourceConfigParameter.getName();
+ return super.getName() + ",persistLocally=" + persistLocally +
",cacheNaturalId=" + cacheNaturalId + ",cloneOnCreate=" +
cloneOnCreate + ",ds=" + dataSourceConfigParameter.getName() +
",config=" + config;
}
public String getPersistLocallyParameter()
@@ -203,6 +212,16 @@
this.cloneOnCreate = Boolean.valueOf(cloneOnCreateParameter).booleanValue();
}
+ public String getCacheNaturalIdParameter()
+ {
+ return Boolean.toString(cacheNaturalId);
+ }
+
+ public void setCacheNaturalIdParameter(String cacheNaturalIdParameter)
+ {
+ this.cacheNaturalId = Boolean.valueOf(cacheNaturalIdParameter).booleanValue();
+ }
+
public DataSourceSupport.Config getDataSourceConfigParameter()
{
return dataSourceConfigParameter;
@@ -213,6 +232,16 @@
this.dataSourceConfigParameter = dataSourceConfigParameter;
}
+ public String getConfigParameter()
+ {
+ return config;
+ }
+
+ public void setConfigParameter(String configParameter)
+ {
+ this.config = configParameter;
+ }
+
public boolean isPersistLocally()
{
return persistLocally;
@@ -223,6 +252,11 @@
return cloneOnCreate;
}
+ public boolean isCacheNaturalId()
+ {
+ return cacheNaturalId;
+ }
+
public TestRuntimeContext getRuntimeContext()
{
return runtimeContext;
@@ -253,12 +287,12 @@
this.portletHibernateSupport = portletHibernateSupport;
}
- public PersistentInstanceContainer getInstanceContainer()
+ public InstanceContainerImpl getInstanceContainer()
{
return instanceContainer;
}
- public void setInstanceContainer(PersistentInstanceContainer instanceContainer)
+ public void setInstanceContainer(InstanceContainerImpl instanceContainer)
{
this.instanceContainer = instanceContainer;
}
@@ -295,8 +329,7 @@
public void setUp() throws Exception
{
- //
- runtimeContext = new
TestRuntimeContext("org/jboss/portal/test/core/model/instance/jboss-beans.xml");
+ runtimeContext = new
TestRuntimeContext("org/jboss/portal/test/core/model/instance/" + config);
runtimeContext.addBean("TestCaseConfig", this);
runtimeContext.addBean("TestBean", this);
runtimeContext.addBean("DataSourceConfig", dataSourceConfigParameter);
@@ -319,25 +352,33 @@
internalPortlet.addPreference("abc", new StringValue("def"));
//
+ TransactionAssert.beginTransaction();
Instance instance = instanceContainer.createDefinition("MyInstance",
"MyPortlet", true);
assertNotNull(instance);
+ TransactionAssert.commitTransaction();
//
TransactionAssert.beginTransaction();
- Session session = instanceHibernateSupport.getCurrentSession();
- List instances = session.createQuery("from
InstanceDefinitionImpl").list();
- assertEquals(1, instances.size());
- InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instances.get(0);
+// Session session = instanceHibernateSupport.getCurrentSession();
+// List instances = session.createQuery("from
InstanceDefinitionImpl").list();
+// assertEquals(1, instances.size());
+// InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instances.get(0);
+// assertEquals(true, instanceImpl.isModifiable());
+ assertEquals(1, instanceContainer.getDefinitions().size());
+ InstanceDefinitionImpl instanceImpl =
(InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
+ assertNotNull(instanceImpl);
assertEquals(true, instanceImpl.isModifiable());
TransactionAssert.commitTransaction();
//
TransactionAssert.beginTransaction();
+ instance = instanceContainer.getDefinition("MyInstance");
instance.setProperties(new
PropertyChange[]{PropertyChange.newUpdate("abc", new
StringValue("_def")), PropertyChange.newUpdate("ghi", new
StringValue("_jkl"))});
TransactionAssert.commitTransaction();
//
TransactionAssert.beginTransaction();
+ instance = instanceContainer.getDefinition("MyInstance");
PropertyMap props = instance.getProperties(new
CollectionBuilder().add("abc").add("ghi").toHashSet());
PropertyMap expectedProps = new SimplePropertyMap();
expectedProps.setProperty("abc", new StringValue("_def"));
@@ -347,10 +388,14 @@
//
TransactionAssert.beginTransaction();
- session = instanceHibernateSupport.getCurrentSession();
- instances = session.createQuery("from InstanceDefinitionImpl").list();
- assertEquals(1, instances.size());
- instanceImpl = (InstanceDefinitionImpl)instances.get(0);
+// session = instanceHibernateSupport.getCurrentSession();
+// instances = session.createQuery("from InstanceDefinitionImpl").list();
+// assertEquals(1, instances.size());
+// instanceImpl = (InstanceDefinitionImpl)instances.get(0);
+// assertEquals(true, instanceImpl.isModifiable());
+ assertEquals(1, instanceContainer.getDefinitions().size());
+ instanceImpl =
(InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
+ assertNotNull(instanceImpl);
assertEquals(true, instanceImpl.isModifiable());
TransactionAssert.commitTransaction();
}
@@ -490,7 +535,7 @@
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl =
(InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
assertNotNull(instanceImpl);
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -520,7 +565,7 @@
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl =
(InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
assertNotNull(instanceImpl);
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -543,7 +588,7 @@
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl =
(InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
assertNotNull(instanceImpl);
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(1, userInstances.size());
InstanceCustomizationImpl userInstance =
(InstanceCustomizationImpl)userInstances.iterator().next();
@@ -578,7 +623,7 @@
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl =
(InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
assertNotNull(instanceImpl);
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(1, userInstances.size());
InstanceCustomizationImpl userInstance =
(InstanceCustomizationImpl)userInstances.iterator().next();
@@ -614,7 +659,7 @@
// Check state
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl =
(InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -636,7 +681,7 @@
// Check state
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl =
(InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -658,7 +703,7 @@
// Check state
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl =
(InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -680,7 +725,7 @@
// Check state
TransactionAssert.beginTransaction();
InstanceDefinitionImpl instanceImpl =
(InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
- Set userInstances = instanceImpl.getCustomizations();
+ Collection userInstances = instanceImpl.getCustomizationMap().values();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -717,7 +762,7 @@
PortletContext sharedPortletContext = instanceImpl.getPortletContext();
assertNotNull(producer.getPortlet(sharedPortletContext));
assertNotNull(instance);
- Set children = instanceImpl.getCustomizations();
+ Collection children = instanceImpl.getCustomizationMap().values();
assertNotNull(children);
assertEquals(1, children.size());
InstanceCustomizationImpl userInstance =
(InstanceCustomizationImpl)children.iterator().next();
@@ -807,6 +852,86 @@
}
}
+ /** . */
+ private final Set securityBindings1 =
Collections.unmodifiableSet(CollectionBuilder.singleton(new
RoleSecurityBinding("a,b", "admin")).add(new
RoleSecurityBinding("a", "user")).toHashSet());
+
+ /** . */
+ private final Set securityBindings2 =
Collections.unmodifiableSet(CollectionBuilder.singleton(new
RoleSecurityBinding("a,b", "user")).toHashSet());
+
+ public void testSecurityConfiguration() throws Exception
+ {
+ portletContainer.addInternalPortlet("MyPortlet", new
TestPortletSupport());
+
+ //
+ TransactionAssert.beginTransaction();
+ String instanceId = instanceContainer.createDefinition("MyInstance",
"MyPortlet").getId();
+ TransactionAssert.commitTransaction();
+
+ //
+ DomainConfigurator configurator = instanceContainer.getConfigurator();
+ assertNotNull(configurator);
+
+ //
+ TransactionAssert.beginTransaction();
+ configurator.setSecurityBindings(instanceId, securityBindings1);
+ TransactionAssert.commitTransaction();
+
+ //
+ TransactionAssert.beginTransaction();
+ Set bindings = configurator.getSecurityBindings(instanceId);
+ assertNotNull(bindings);
+ assertEquals(securityBindings1, bindings);
+ TransactionAssert.commitTransaction();
+
+ //
+ TransactionAssert.beginTransaction();
+ configurator.setSecurityBindings(instanceId, securityBindings2);
+ TransactionAssert.commitTransaction();
+
+ //
+ TransactionAssert.beginTransaction();
+ bindings = configurator.getSecurityBindings(instanceId);
+ assertNotNull(bindings);
+ assertEquals(securityBindings2, bindings);
+ TransactionAssert.commitTransaction();
+
+ //
+ TransactionAssert.beginTransaction();
+ configurator.removeSecurityBindings(instanceId);
+ TransactionAssert.commitTransaction();
+
+ //
+ TransactionAssert.beginTransaction();
+ bindings = configurator.getSecurityBindings(instanceId);
+ assertNotNull(bindings);
+ assertEquals(0, bindings.size());
+ TransactionAssert.commitTransaction();
+ }
+
+ public void testDestroyInstanceWithSecurityConfiguration() throws Exception
+ {
+ portletContainer.addInternalPortlet("MyPortlet", new
TestPortletSupport());
+
+ //
+ TransactionAssert.beginTransaction();
+ String instanceId = instanceContainer.createDefinition("MyInstance",
"MyPortlet").getId();
+ TransactionAssert.commitTransaction();
+
+ //
+ DomainConfigurator configurator = instanceContainer.getConfigurator();
+ assertNotNull(configurator);
+
+ //
+ TransactionAssert.beginTransaction();
+ configurator.setSecurityBindings(instanceId, securityBindings1);
+ TransactionAssert.commitTransaction();
+
+ //
+ TransactionAssert.beginTransaction();
+ instanceContainer.destroyDefinition(instanceId);
+ TransactionAssert.commitTransaction();
+ }
+
//
//// /**Tests the authorization of portal objects */
//// public void testInstanceAuthorization() throws Exception
Modified:
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-05-10
03:10:55 UTC (rev 7233)
+++
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -75,11 +75,17 @@
return suite;
}
+ public String getName()
+ {
+ TestParametrization parametrization = JUnitAdapter.getParametrization();
+ return super.getName() + ",ds=" + dataSourceConfigParameter.getName() +
",Config=" + parametrization.getParameterValue("Config").get();
+ }
+
protected String getConfigLocation()
{
TestParametrization parametrization = JUnitAdapter.getParametrization();
- TestParameterValue paramValue =
parametrization.getParameterValue("ConfigLocation");
- return (String)paramValue.get();
+ TestParameterValue paramValue =
parametrization.getParameterValue("Config");
+ return "org/jboss/portal/test/core/model/portal/" + paramValue.get();
}
public PortalObjectContainer getPortalObjectContainer()
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-05-10
03:10:55 UTC (rev 7233)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-05-10
09:11:17 UTC (rev 7234)
@@ -561,7 +561,7 @@
<!-- The different containers -->
<mbean
-
code="org.jboss.portal.core.impl.model.instance.PersistentInstanceContainer"
+ code="org.jboss.portal.core.impl.model.instance.InstanceContainerImpl"
name="portal:container=Instance"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
Modified: trunk/core/src/resources/portal-core-sar/conf/hibernate/instance/domain.hbm.xml
===================================================================
---
trunk/core/src/resources/portal-core-sar/conf/hibernate/instance/domain.hbm.xml 2007-05-10
03:10:55 UTC (rev 7233)
+++
trunk/core/src/resources/portal-core-sar/conf/hibernate/instance/domain.hbm.xml 2007-05-10
09:11:17 UTC (rev 7234)
@@ -27,7 +27,7 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
- name="org.jboss.portal.core.impl.model.instance.InstanceDefinitionImpl"
+
name="org.jboss.portal.core.impl.model.instance.persistent.InstanceDefinitionImpl"
table="JBP_INSTANCE">
<cache usage="@portal.hibernate.cache.usage(a)"/>
<id
@@ -51,7 +51,7 @@
not-null="false"
unique="false"/>
<property
- name="modifiable"
+ name="mutable"
column="MODIFIABLE"
not-null="true"
unique="false"/>
@@ -65,27 +65,30 @@
name="securityBindings"
sort="unsorted"
inverse="true"
- cascade="none"
+ cascade="all-delete-orphan"
fetch="join">
<cache usage="@portal.hibernate.cache.usage(a)"/>
<key column="INSTANCE_PK"/>
<index column="ROLE" type="string"/>
<one-to-many
class="org.jboss.portal.core.impl.model.instance.InstanceSecurityBinding"/>
</map>
- <set
- name="customizations"
+ <map
+ name="customizationMap"
inverse="true"
cascade="save-update"
fetch="select"
lazy="extra">
<cache usage="@portal.hibernate.cache.usage(a)"/>
<key column="INSTANCE_PK"/>
- <one-to-many
class="org.jboss.portal.core.impl.model.instance.InstanceCustomizationImpl"/>
- </set>
+ <map-key
+ type="string"
+ column="USER_ID"/>
+ <one-to-many
class="org.jboss.portal.core.impl.model.instance.persistent.InstanceCustomizationImpl"/>
+ </map>
</class>
<class
-
name="org.jboss.portal.core.impl.model.instance.InstanceCustomizationImpl"
+
name="org.jboss.portal.core.impl.model.instance.persistent.InstanceCustomizationImpl"
table="JBP_INSTANCE_PER_USER">
<cache usage="@portal.hibernate.cache.usage(a)"/>
<id
@@ -97,9 +100,9 @@
</generator>
</id>
<many-to-one
- name="def"
+ name="relatedDefinition"
column="INSTANCE_PK"
-
class="org.jboss.portal.core.impl.model.instance.InstanceDefinitionImpl"
+
class="org.jboss.portal.core.impl.model.instance.persistent.InstanceDefinitionImpl"
cascade="none"
fetch="select"/>
<property
@@ -144,7 +147,7 @@
<set
name="actions"
table="JBP_INSTANCE_SECURITY_ACTIONS"
- cascade="none"
+ cascade="all-delete-orphan"
fetch="join">
<cache usage="@portal.hibernate.cache.usage(a)"/>
<key column="PK"/>
@@ -153,7 +156,7 @@
<many-to-one
name="instance"
column="INSTANCE_PK"
-
class="org.jboss.portal.core.impl.model.instance.InstanceDefinitionImpl"
+
class="org.jboss.portal.core.impl.model.instance.persistent.InstanceDefinitionImpl"
cascade="none"
fetch="select"/>
</class>
Modified: trunk/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
===================================================================
---
trunk/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml 2007-05-10
03:10:55 UTC (rev 7233)
+++
trunk/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml 2007-05-10
09:11:17 UTC (rev 7234)
@@ -54,7 +54,8 @@
name="children"
inverse="true"
cascade="none"
- fetch="select">
+ fetch="select"
+ lazy="extra">
<cache usage="@portal.hibernate.cache.usage(a)"/>
<key column="PARENT_KEY"/>
<map-key
Modified: trunk/core/src/resources/portal-core-sar/portal-aop.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/portal-aop.xml 2007-05-10 03:10:55 UTC (rev
7233)
+++ trunk/core/src/resources/portal-core-sar/portal-aop.xml 2007-05-10 09:11:17 UTC (rev
7234)
@@ -94,7 +94,7 @@
</metadata>
<metadata
tag="transaction"
-
class="org.jboss.portal.core.impl.model.instance.PersistentInstanceContainer">
+
class="org.jboss.portal.core.impl.model.instance.InstanceContainerImpl">
<method name="getDefinition">
<trans-attribute>Required</trans-attribute>
</method>
Deleted:
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/jboss-beans.xml
===================================================================
---
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/jboss-beans.xml 2007-05-10
03:10:55 UTC (rev 7233)
+++
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/jboss-beans.xml 2007-05-10
09:11:17 UTC (rev 7234)
@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ JBoss, a division of Red Hat ~
- ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
- ~ contributors as indicated by the @authors tag. See the ~
- ~ copyright.txt in the distribution for a full listing of ~
- ~ individual contributors. ~
- ~ ~
- ~ This is free software; you can redistribute it and/or modify it ~
- ~ under the terms of the GNU Lesser General Public License as ~
- ~ published by the Free Software Foundation; either version 2.1 of ~
- ~ the License, or (at your option) any later version. ~
- ~ ~
- ~ This software is distributed in the hope that it will be useful, ~
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
- ~ Lesser General Public License for more details. ~
- ~ ~
- ~ You should have received a copy of the GNU Lesser General Public ~
- ~ License along with this software; if not, write to the Free ~
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
- ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-
-<deployment
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
- xmlns="urn:jboss:bean-deployer">
-
- <bean name="TestCaseConfig"
class="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>TestCaseConfig</parameter>
- </constructor>
- </bean>
-
- <bean name="DataSourceConfig"
class="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>DataSourceConfig</parameter>
- </constructor>
- </bean>
-
- <bean name="HibernateConfig"
class="org.jboss.portal.test.framework.embedded.HibernateSupport$Config">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>HibernateConfig</parameter>
- </constructor>
- </bean>
-
- <bean name="JNDISupport"
class="org.jboss.portal.test.framework.embedded.JNDISupport">
- </bean>
-
- <bean name="TransactionManagerSupport"
class="org.jboss.portal.test.framework.embedded.TransactionManagerSupport">
- </bean>
-
- <bean name="ConnectionManagerSupport"
class="org.jboss.portal.test.framework.embedded.ConnectionManagerSupport">
- <property name="transactionManager"><inject
bean="TransactionManagerSupport"
property="transactionManager"/></property>
- </bean>
-
- <bean name="DataSourceSupport"
class="org.jboss.portal.test.framework.embedded.DataSourceSupport">
- <property name="transactionManager"><inject
bean="TransactionManagerSupport"
property="transactionManager"/></property>
- <property name="connectionManagerReference"><inject
bean="ConnectionManagerSupport"
property="connectionManagerReference"/></property>
- <property name="config"><inject
bean="DataSourceConfig"/></property>
- </bean>
-
- <bean name="InstanceHibernateSupport"
class="org.jboss.portal.test.framework.embedded.HibernateSupport">
- <property name="config"><inject
bean="HibernateConfig"/></property>
- <property name="mappings">
- <list elementClass="java.lang.String">
- <value>conf/hibernate/instance/domain.hbm.xml</value>
- </list>
- </property>
- <property
name="jNDIName">java:/InstanceSessionFactory</property>
- </bean>
-
- <bean name="PortletHibernateSupport"
class="org.jboss.portal.test.framework.embedded.HibernateSupport">
- <property name="config"><inject
bean="HibernateConfig"/></property>
- <property name="mappings">
- <list elementClass="java.lang.String">
- <value>conf/hibernate/portlet/domain.hbm.xml</value>
- </list>
- </property>
- <property
name="jNDIName">java:/PortletSessionFactory</property>
- </bean>
-
- <bean name="StateConverter"
class="org.jboss.portal.portlet.impl.state.StateConverterV0">
- </bean>
- <bean name="StateManagementPolicy"
class="org.jboss.portal.portlet.impl.state.StateManagementPolicyService">
- <property name="persistLocally"><inject
bean="TestCaseConfig" property="persistLocally"/></property>
- </bean>
- <bean name="PersistenceManager"
class="org.jboss.portal.core.impl.portlet.state.PersistentPortletStatePersistenceManager">
- <property
name="sessionFactoryJNDIName">java:/PortletSessionFactory</property>
- </bean>
- <bean name="PortletContainer"
class="org.jboss.portal.portlet.test.support.PortletInvokerSupport">
- </bean>
- <bean name="Producer"
class="org.jboss.portal.portlet.state.producer.ProducerPortletInvoker">
- <property name="persistenceManager"><inject
bean="PersistenceManager"/></property>
- <property name="portletInvoker"><inject
bean="PortletContainer"/></property>
- <property name="stateManagementPolicy"><inject
bean="StateManagementPolicy"/></property>
- <property name="stateConverter"><inject
bean="StateConverter"/></property>
- </bean>
-
- <bean name="StackFactory"
class="org.jboss.portal.common.invocation.EmptyInterceptorStackFactory">
- </bean>
- <bean name="InstanceContainer"
class="org.jboss.portal.core.impl.model.instance.PersistentInstanceContainer">
- <property name="cloneOnCreate"><inject
bean="TestCaseConfig" property="cloneOnCreate"/></property>
- <property name="portletInvoker"><inject
bean="Producer"/></property>
- <property
name="sessionFactoryJNDIName">java:/InstanceSessionFactory</property>
- <property name="stackFactory"><inject
bean="StackFactory"/></property>
- </bean>
-
- <bean name="TestBean"
class="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>TestBean</parameter>
- </constructor>
- <property name="instanceHibernateSupport"><inject
bean="InstanceHibernateSupport"/></property>
- <property name="portletHibernateSupport"><inject
bean="PortletHibernateSupport"/></property>
- <property name="instanceContainer"><inject
bean="InstanceContainer"/></property>
- <property name="persistenceManager"><inject
bean="PersistenceManager"/></property>
- <property name="producer"><inject
bean="Producer"/></property>
- <property name="portletContainer"><inject
bean="PortletContainer"/></property>
- </bean>
-</deployment>
Added:
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/persistent-jboss-beans.xml
===================================================================
---
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/persistent-jboss-beans.xml
(rev 0)
+++
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/persistent-jboss-beans.xml 2007-05-10
09:11:17 UTC (rev 7234)
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<deployment
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="TestCaseConfig"
class="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>TestCaseConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="DataSourceConfig"
class="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>DataSourceConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="HibernateConfig"
class="org.jboss.portal.test.framework.embedded.HibernateSupport$Config">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>HibernateConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="JNDISupport"
class="org.jboss.portal.test.framework.embedded.JNDISupport">
+ </bean>
+
+ <bean name="TransactionManagerSupport"
class="org.jboss.portal.test.framework.embedded.TransactionManagerSupport">
+ </bean>
+
+ <bean name="ConnectionManagerSupport"
class="org.jboss.portal.test.framework.embedded.ConnectionManagerSupport">
+ <property name="transactionManager"><inject
bean="TransactionManagerSupport"
property="transactionManager"/></property>
+ </bean>
+
+ <bean name="DataSourceSupport"
class="org.jboss.portal.test.framework.embedded.DataSourceSupport">
+ <property name="transactionManager"><inject
bean="TransactionManagerSupport"
property="transactionManager"/></property>
+ <property name="connectionManagerReference"><inject
bean="ConnectionManagerSupport"
property="connectionManagerReference"/></property>
+ <property name="config"><inject
bean="DataSourceConfig"/></property>
+ </bean>
+
+ <bean name="InstanceHibernateSupport"
class="org.jboss.portal.test.framework.embedded.HibernateSupport">
+ <property name="config"><inject
bean="HibernateConfig"/></property>
+ <property name="mappings">
+ <list elementClass="java.lang.String">
+ <value>conf/hibernate/instance/domain.hbm.xml</value>
+ </list>
+ </property>
+ <property
name="jNDIName">java:/InstanceSessionFactory</property>
+ </bean>
+
+ <bean name="PortletHibernateSupport"
class="org.jboss.portal.test.framework.embedded.HibernateSupport">
+ <property name="config"><inject
bean="HibernateConfig"/></property>
+ <property name="mappings">
+ <list elementClass="java.lang.String">
+ <value>conf/hibernate/portlet/domain.hbm.xml</value>
+ </list>
+ </property>
+ <property
name="jNDIName">java:/PortletSessionFactory</property>
+ </bean>
+
+ <bean name="StateConverter"
class="org.jboss.portal.portlet.impl.state.StateConverterV0">
+ </bean>
+ <bean name="StateManagementPolicy"
class="org.jboss.portal.portlet.impl.state.StateManagementPolicyService">
+ <property name="persistLocally"><inject
bean="TestCaseConfig" property="persistLocally"/></property>
+ </bean>
+ <bean name="PersistenceManager"
class="org.jboss.portal.core.impl.portlet.state.PersistentPortletStatePersistenceManager">
+ <property
name="sessionFactoryJNDIName">java:/PortletSessionFactory</property>
+ </bean>
+ <bean name="PortletContainer"
class="org.jboss.portal.portlet.test.support.PortletInvokerSupport">
+ </bean>
+ <bean name="Producer"
class="org.jboss.portal.portlet.state.producer.ProducerPortletInvoker">
+ <property name="persistenceManager"><inject
bean="PersistenceManager"/></property>
+ <property name="portletInvoker"><inject
bean="PortletContainer"/></property>
+ <property name="stateManagementPolicy"><inject
bean="StateManagementPolicy"/></property>
+ <property name="stateConverter"><inject
bean="StateConverter"/></property>
+ </bean>
+
+ <bean name="StackFactory"
class="org.jboss.portal.common.invocation.EmptyInterceptorStackFactory">
+ </bean>
+ <bean name="ContainerContext"
class="org.jboss.portal.core.impl.model.instance.persistent.PersistentInstanceContext">
+ <property
name="sessionFactoryJNDIName">java:/InstanceSessionFactory</property>
+ <property name="cacheNaturalId"><inject
bean="TestCaseConfig" property="cacheNaturalId"/></property>
+ </bean>
+ <bean name="InstanceContainer"
class="org.jboss.portal.core.impl.model.instance.InstanceContainerImpl">
+ <property name="cloneOnCreate"><inject
bean="TestCaseConfig" property="cloneOnCreate"/></property>
+ <property name="portletInvoker"><inject
bean="Producer"/></property>
+ <property name="containerContext"><inject
bean="ContainerContext"/></property>
+ <property name="stackFactory"><inject
bean="StackFactory"/></property>
+ </bean>
+
+ <bean name="TestBean"
class="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>TestBean</parameter>
+ </constructor>
+ <property name="instanceHibernateSupport"><inject
bean="InstanceHibernateSupport"/></property>
+ <property name="portletHibernateSupport"><inject
bean="PortletHibernateSupport"/></property>
+ <property name="instanceContainer"><inject
bean="InstanceContainer"/></property>
+ <property name="persistenceManager"><inject
bean="PersistenceManager"/></property>
+ <property name="producer"><inject
bean="Producer"/></property>
+ <property name="portletContainer"><inject
bean="PortletContainer"/></property>
+ </bean>
+</deployment>
Added:
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/transient-jboss-beans.xml
===================================================================
---
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/transient-jboss-beans.xml
(rev 0)
+++
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/transient-jboss-beans.xml 2007-05-10
09:11:17 UTC (rev 7234)
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<deployment
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="TestCaseConfig"
class="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>TestCaseConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="DataSourceConfig"
class="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>DataSourceConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="HibernateConfig"
class="org.jboss.portal.test.framework.embedded.HibernateSupport$Config">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>HibernateConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="JNDISupport"
class="org.jboss.portal.test.framework.embedded.JNDISupport">
+ </bean>
+
+ <bean name="TransactionManagerSupport"
class="org.jboss.portal.test.framework.embedded.TransactionManagerSupport">
+ </bean>
+
+ <bean name="ConnectionManagerSupport"
class="org.jboss.portal.test.framework.embedded.ConnectionManagerSupport">
+ <property name="transactionManager"><inject
bean="TransactionManagerSupport"
property="transactionManager"/></property>
+ </bean>
+
+ <bean name="DataSourceSupport"
class="org.jboss.portal.test.framework.embedded.DataSourceSupport">
+ <property name="transactionManager"><inject
bean="TransactionManagerSupport"
property="transactionManager"/></property>
+ <property name="connectionManagerReference"><inject
bean="ConnectionManagerSupport"
property="connectionManagerReference"/></property>
+ <property name="config"><inject
bean="DataSourceConfig"/></property>
+ </bean>
+
+ <bean name="InstanceHibernateSupport"
class="org.jboss.portal.test.framework.embedded.HibernateSupport">
+ <property name="config"><inject
bean="HibernateConfig"/></property>
+ <property name="mappings">
+ <list elementClass="java.lang.String">
+ <value>conf/hibernate/instance/domain.hbm.xml</value>
+ </list>
+ </property>
+ <property
name="jNDIName">java:/InstanceSessionFactory</property>
+ </bean>
+
+ <bean name="PortletHibernateSupport"
class="org.jboss.portal.test.framework.embedded.HibernateSupport">
+ <property name="config"><inject
bean="HibernateConfig"/></property>
+ <property name="mappings">
+ <list elementClass="java.lang.String">
+ <value>conf/hibernate/portlet/domain.hbm.xml</value>
+ </list>
+ </property>
+ <property
name="jNDIName">java:/PortletSessionFactory</property>
+ </bean>
+
+ <bean name="StateConverter"
class="org.jboss.portal.portlet.impl.state.StateConverterV0">
+ </bean>
+ <bean name="StateManagementPolicy"
class="org.jboss.portal.portlet.impl.state.StateManagementPolicyService">
+ <property name="persistLocally"><inject
bean="TestCaseConfig" property="persistLocally"/></property>
+ </bean>
+ <bean name="PersistenceManager"
class="org.jboss.portal.core.impl.portlet.state.PersistentPortletStatePersistenceManager">
+ <property
name="sessionFactoryJNDIName">java:/PortletSessionFactory</property>
+ </bean>
+ <bean name="PortletContainer"
class="org.jboss.portal.portlet.test.support.PortletInvokerSupport">
+ </bean>
+ <bean name="Producer"
class="org.jboss.portal.portlet.state.producer.ProducerPortletInvoker">
+ <property name="persistenceManager"><inject
bean="PersistenceManager"/></property>
+ <property name="portletInvoker"><inject
bean="PortletContainer"/></property>
+ <property name="stateManagementPolicy"><inject
bean="StateManagementPolicy"/></property>
+ <property name="stateConverter"><inject
bean="StateConverter"/></property>
+ </bean>
+
+ <bean name="StackFactory"
class="org.jboss.portal.common.invocation.EmptyInterceptorStackFactory">
+ </bean>
+ <bean name="ContainerContext"
class="org.jboss.portal.core.impl.model.instance.TransientContainerContext">
+ </bean>
+ <bean name="InstanceContainer"
class="org.jboss.portal.core.impl.model.instance.InstanceContainerImpl">
+ <property name="cloneOnCreate"><inject
bean="TestCaseConfig" property="cloneOnCreate"/></property>
+ <property name="portletInvoker"><inject
bean="Producer"/></property>
+ <property name="containerContext"><inject
bean="ContainerContext"/></property>
+ <property name="stackFactory"><inject
bean="StackFactory"/></property>
+ </bean>
+
+ <bean name="TestBean"
class="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>TestBean</parameter>
+ </constructor>
+ <property name="instanceHibernateSupport"><inject
bean="InstanceHibernateSupport"/></property>
+ <property name="portletHibernateSupport"><inject
bean="PortletHibernateSupport"/></property>
+ <property name="instanceContainer"><inject
bean="InstanceContainer"/></property>
+ <property name="persistenceManager"><inject
bean="PersistenceManager"/></property>
+ <property name="producer"><inject
bean="Producer"/></property>
+ <property name="portletContainer"><inject
bean="PortletContainer"/></property>
+ </bean>
+</deployment>
Deleted:
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/jboss-beans.xml
===================================================================
---
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/jboss-beans.xml 2007-05-10
03:10:55 UTC (rev 7233)
+++
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/jboss-beans.xml 2007-05-10
09:11:17 UTC (rev 7234)
@@ -1,102 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ JBoss, a division of Red Hat ~
- ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
- ~ contributors as indicated by the @authors tag. See the ~
- ~ copyright.txt in the distribution for a full listing of ~
- ~ individual contributors. ~
- ~ ~
- ~ This is free software; you can redistribute it and/or modify it ~
- ~ under the terms of the GNU Lesser General Public License as ~
- ~ published by the Free Software Foundation; either version 2.1 of ~
- ~ the License, or (at your option) any later version. ~
- ~ ~
- ~ This software is distributed in the hope that it will be useful, ~
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
- ~ Lesser General Public License for more details. ~
- ~ ~
- ~ You should have received a copy of the GNU Lesser General Public ~
- ~ License along with this software; if not, write to the Free ~
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
- ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-
-<deployment
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
- xmlns="urn:jboss:bean-deployer">
-
- <bean name="DataSourceConfig"
class="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>DataSourceConfig</parameter>
- </constructor>
- </bean>
-
- <bean name="HibernateConfig"
class="org.jboss.portal.test.framework.embedded.HibernateSupport$Config">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>HibernateConfig</parameter>
- </constructor>
- </bean>
-
- <bean name="JNDISupport"
class="org.jboss.portal.test.framework.embedded.JNDISupport">
- </bean>
-
- <bean name="TransactionManagerSupport"
class="org.jboss.portal.test.framework.embedded.TransactionManagerSupport">
- </bean>
-
- <bean name="ConnectionManagerSupport"
class="org.jboss.portal.test.framework.embedded.ConnectionManagerSupport">
- <property name="transactionManager"><inject
bean="TransactionManagerSupport"
property="transactionManager"/></property>
- </bean>
-
- <bean name="DataSourceSupport"
class="org.jboss.portal.test.framework.embedded.DataSourceSupport">
- <property name="transactionManager"><inject
bean="TransactionManagerSupport"
property="transactionManager"/></property>
- <property name="connectionManagerReference"><inject
bean="ConnectionManagerSupport"
property="connectionManagerReference"/></property>
- <property name="config"><inject
bean="DataSourceConfig"/></property>
- </bean>
-
- <bean name="HibernateSupport"
class="org.jboss.portal.test.framework.embedded.HibernateSupport">
- <property name="config"><inject
bean="HibernateConfig"/></property>
- <property name="mappings">
- <list elementClass="java.lang.String">
- <value>conf/hibernate/portal/domain.hbm.xml</value>
- </list>
- </property>
- <property name="jNDIName">java:/SessionFactory</property>
- </bean>
-
- <bean name="AuthorizationDomainRegistry"
class="org.jboss.portal.security.impl.JBossAuthorizationDomainRegistryImpl">
- </bean>
-
- <bean name="AuthorizationManagerFactory"
class="org.jboss.portal.security.impl.jacc.JACCPortalAuthorizationManagerFactory">
- <property name="authorizationDomainRegistry"><inject
bean="AuthorizationDomainRegistry"/></property>
- </bean>
-
- <bean name="ContentProviderRegistry"
class="org.jboss.portal.test.core.model.content.SimpleContentProviderRegistry">
- </bean>
-
- <bean name="PortletContentProvider"
class="org.jboss.portal.test.core.model.content.SimpleContentProvider">
- <constructor>
- <parameter>portlet</parameter>
- </constructor>
- <property name="registry"><inject
bean="ContentProviderRegistry"/></property>
- </bean>
-
- <bean name="PortalObjectContainer"
class="org.jboss.portal.core.impl.model.portal.PersistentPortalObjectContainer">
- <property
name="sessionFactoryJNDIName">java:/SessionFactory</property>
- <property name="authorizationDomainRegistry"><inject
bean="AuthorizationDomainRegistry"/></property>
- <property name="portalAuthorizationManagerFactory"><inject
bean="AuthorizationManagerFactory"/></property>
- <property name="contentProviderRegistry"><inject
bean="ContentProviderRegistry"/></property>
- </bean>
-
- <bean name="TestBean"
class="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>TestBean</parameter>
- </constructor>
- <property name="hibernate"><inject
bean="HibernateSupport"/></property>
- <property name="portalObjectContainer"><inject
bean="PortalObjectContainer"/></property>
- </bean>
-</deployment>
Modified: trunk/security/src/main/org/jboss/portal/security/RoleSecurityBinding.java
===================================================================
--- trunk/security/src/main/org/jboss/portal/security/RoleSecurityBinding.java 2007-05-10
03:10:55 UTC (rev 7233)
+++ trunk/security/src/main/org/jboss/portal/security/RoleSecurityBinding.java 2007-05-10
09:11:17 UTC (rev 7234)
@@ -174,14 +174,18 @@
if (toString == null)
{
StringBuffer tmp = new StringBuffer("SecurityConstraint: actions [");
- for (Iterator i = actions.iterator(); i.hasNext();)
+ for (Iterator i = actions.iterator();;)
{
String action = (String)i.next();
+ tmp.append(action);
if (i.hasNext())
{
tmp.append(", ");
}
- tmp.append(action);
+ else
+ {
+ break;
+ }
}
tmp.append("] role [").append(roleName).append("]");
toString = tmp.toString();