Author: bdaw
Date: 2008-06-29 07:22:39 -0400 (Sun, 29 Jun 2008)
New Revision: 11189
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/coordination/
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/coordination/CoordinationService.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/coordination/SimpleEventConverter.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/CoordinationConfigurator.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/EventConverter.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/ImplicitStrategy.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/model/portal/coordination/
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/model/portal/coordination/CoordinationServiceTestCase.java
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/coordination/
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/coordination/persistent-jboss-beans.xml
Modified:
branches/JBoss_Portal_Branch_2_7/core/build.xml
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/CoordinationManager.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/IllegalCoordinationException.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/ParameterBindingInfo.java
Log:
initial simple coordination implementation with minimal testing (for now). Not plugged
in.
Modified: branches/JBoss_Portal_Branch_2_7/core/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/build.xml 2008-06-28 12:14:22 UTC (rev 11188)
+++ branches/JBoss_Portal_Branch_2_7/core/build.xml 2008-06-29 11:22:39 UTC (rev 11189)
@@ -549,10 +549,8 @@
<execute-tests>
<x-sysproperty>
- <!--
- <jvmarg value="-Xdebug"/>
- <jvmarg
value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"/>
- -->
+ <!--<jvmarg value="-Xdebug"/>-->
+ <!--<jvmarg
value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"/>-->
<sysproperty
key="jboss.aop.path"
@@ -580,6 +578,11 @@
<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.portal.coordination.CoordinationServiceTestCase"
+ outfile="TEST-CoordinationServiceTestCase">
+ <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.portal.PortalObjectContainerTestCase"
outfile="TEST-PortalObjectContainerTestCase">
@@ -692,7 +695,7 @@
<mkdir dir="${build.reports}"/>
<mkdir dir="${build.testlog}"/>
-
+
<junit printsummary="yes" showoutput="yes"
dir="${module.output}">
<!--jvmarg line="-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006" /-->
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/coordination/CoordinationService.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/coordination/CoordinationService.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/coordination/CoordinationService.java 2008-06-29
11:22:39 UTC (rev 11189)
@@ -0,0 +1,1043 @@
+/*
+* 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.portal.coordination;
+
+import org.jboss.portal.core.model.portal.coordination.CoordinationManager;
+import org.jboss.portal.core.model.portal.coordination.IllegalCoordinationException;
+import org.jboss.portal.core.model.portal.coordination.EventWiringInfo;
+import org.jboss.portal.core.model.portal.coordination.ParameterBindingInfo;
+import org.jboss.portal.core.model.portal.coordination.ImplicitStrategy;
+import org.jboss.portal.core.model.portal.coordination.CoordinationConfigurator;
+import org.jboss.portal.core.model.portal.coordination.EventConverter;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.PageContainer;
+import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.controller.portlet.ControllerPortletControllerContext;
+import org.jboss.portal.portlet.controller.event.PortletWindowEvent;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.info.EventInfo;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import javax.xml.namespace.QName;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.HashMap;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class CoordinationService extends AbstractJBossService
+ implements CoordinationManager, CoordinationConfigurator
+{
+ public static final String SOURCE = "source";
+
+ public static final String DESTINATION = "destination";
+
+ public static final String BINDING = "binding";
+
+ public static final String ALIAS = "alias";
+
+ public static final String PREFIX =
"org.jboss.portal.core.model.portal.coordination";
+
+ public static final String PREFIX_EVENT = PREFIX + ".event";
+
+ public static final String PREFIX_PARAMETER = PREFIX + ".binding";
+
+ public static final String PREFIX_EVENT_NAME = PREFIX_EVENT + ".name";
+
+ public static final String PREFIX_EVENT_WIRING = PREFIX_EVENT + ".wiring";
+
+ public static final String PREFIX_PARAMETER_NAME = PREFIX_PARAMETER +
".name";
+
+ public static final String PREFIX_PARAMETER_BINDING = PREFIX_PARAMETER +
".binding";
+
+ public static final String PREFIX_PARAMETER_ALIAS = PREFIX_PARAMETER +
".alias";
+
+ public static final String PREFIX_EVENT_IMPLICIT_STRATEGY = PREFIX_EVENT +
".implicit_strategy";
+
+ public static final String PREFIX_PARAMETER_IMPLICIT_STRATEGY = PREFIX_PARAMETER +
".implicit_strategy";
+
+ public static final String STRATEGY_FALLBACK = ImplicitStrategy.FALLBACK.name();
+
+ public static final String STRATEGY_EXCLUSIVE = ImplicitStrategy.EXCLUSIVE.name();
+
+ public static final String STRATEGY_DISABLED = ImplicitStrategy.DISABLED.name();
+
+ public static final String STRATEGY_RECURSIVE_DISABLED =
ImplicitStrategy.RECURSIVE_DISABLED.name();
+
+ public static final String STRATEGY_RECURSIVE_EXCLUSIVE =
ImplicitStrategy.RECURSIVE_EXCLUSIVE.name();
+
+ public static final String STRATEGY_RECURSIVE_FALLBACK =
ImplicitStrategy.RECURSIVE_FALLBACK.name();
+
+ public static final ImplicitStrategy DEFAULT_STRATEGY = ImplicitStrategy.FALLBACK;
+
+
+ protected EventConverter eventConverter = new SimpleEventConverter();
+
+ protected PortalObjectContainer container;
+
+ protected void startService() throws Exception
+ {
+ super.startService();
+
+ if (container == null)
+ {
+ throw new IllegalStateException("Cannot instantiate CoordinationManager: no
PortalObjectContainer present");
+ }
+ }
+
+
+ public Map<Window, PortletWindowEvent> getEventWindows(PortletWindowEvent event,
ControllerPortletControllerContext context) throws IllegalCoordinationException
+ {
+
+ if (event == null)
+ {
+ throw new IllegalArgumentException("event is null");
+ }
+
+ if (context == null)
+ {
+ throw new IllegalArgumentException("context is null");
+ }
+
+ // Obtain page for which we scope this event
+
+ Page page = context.getWindow(event.getWindowId()).getPage();
+
+ ImplicitStrategy strategy = resolveImplicitEventWiringStrategy(page);
+
+ Map<Window, PortletWindowEvent> windows = new HashMap<Window,
PortletWindowEvent>();
+
+ // Only implicit wirings
+
+ if (strategy.equals(ImplicitStrategy.EXCLUSIVE))
+ {
+ windows = getEventWindowsImplicit(page, event, context);
+ }
+
+ // Only explicit wirings
+
+ else if(strategy.equals(ImplicitStrategy.DISABLED))
+ {
+ windows = getEventWindowsExplicit(page, event, context);
+ }
+
+ // If no explicit wirings for this event fallback to implicit
+
+ else if(strategy.equals(ImplicitStrategy.FALLBACK))
+ {
+ windows = getEventWindowsExplicit(page, event, context);
+
+ if (windows.size() == 0)
+ {
+ windows = getEventWindowsImplicit(page, event, context);
+ }
+ }
+
+ return windows;
+ }
+
+ private Map<Window, PortletWindowEvent> getEventWindowsExplicit(Page page,
PortletWindowEvent event, ControllerPortletControllerContext context)
+ {
+ Map<Window, PortletWindowEvent> windows = new HashMap<Window,
PortletWindowEvent>();
+
+ Collection<EventWiringInfo> infos = getEventWirings(page);
+
+ for (EventWiringInfo info : infos)
+ {
+ if (info.getSources().containsValue(event.getName()))
+ {
+ for (Window window : info.getDestinations().keySet())
+ {
+ PortletInfo portletInfo = context.getPortletInfo(window.getName());
+ QName destEventName = info.getDestinations().get(window);
+ EventInfo destEventInfo =
portletInfo.getEventing().getConsumedEvents().get(destEventName);
+ if (destEventInfo != null)
+ {
+ windows.put(window, getEventConverter().resolveEvent(event,
destEventInfo));
+ }
+
+ }
+ }
+ }
+
+ return windows;
+ }
+
+ private Map<Window, PortletWindowEvent> getEventWindowsImplicit(Page page,
PortletWindowEvent event, ControllerPortletControllerContext context)
+ {
+ Map<Window, PortletWindowEvent> windows = new HashMap<Window,
PortletWindowEvent>();
+
+ for (String windowName : context.getWindowNames())
+ {
+ PortletInfo info = context.getPortletInfo(windowName);
+
+ //
+ if (info.getEventing().getConsumedEvents().containsKey(event.getName()))
+ {
+ PortletWindowEvent distributedEvent = new
PortletWindowEvent(event.getName(), event.getPayload(), windowName);
+ windows.put(context.getWindow(windowName), distributedEvent);
+ }
+ }
+
+ return windows;
+ }
+
+ public void setEventWiring(Map<Window, QName> sources, Map<Window, QName>
destinations, String eventName) throws IllegalCoordinationException
+ {
+
+ if (sources == null)
+ {
+ throw new IllegalArgumentException("sources are null");
+ }
+
+ if (destinations == null)
+ {
+ throw new IllegalArgumentException("destinations are null");
+ }
+
+ if (eventName == null)
+ {
+ throw new IllegalArgumentException("eventName is null");
+ }
+
+ if (sources.isEmpty())
+ {
+ throw new IllegalArgumentException("empty sources map");
+ }
+
+ if (destinations.isEmpty())
+ {
+ throw new IllegalArgumentException("empty destinations map");
+ }
+
+ // Obtain parent page and check that all windows are in one branch...
+
+ Page parentPage = null;
+
+ Set<Window> sw = sources.keySet();
+ Set<Window> dw = destinations.keySet();
+
+ Set<Window> all = new HashSet<Window>();
+ all.addAll(sw);
+ all.addAll(dw);
+
+
+ for (Window window : all)
+ {
+ if (parentPage == null)
+ {
+ parentPage = window.getPage();
+ }
+
+ if (!window.getPage().equals(parentPage))
+ {
+ throw new IllegalCoordinationException("Parent page is not the same for
all windows");
+ }
+ }
+
+ // Check if the same window is not both in sources and destinations map
+
+ for (Window window : sw)
+ {
+ if (dw.contains(window))
+ {
+ throw new IllegalCoordinationException("The same window cannot be source
and destination of the same explicit wiring");
+ }
+ }
+
+ // Set the sources
+
+ String prop_name = PREFIX_EVENT_NAME + "." + eventName;
+ String prop_wiring = PREFIX_EVENT_WIRING + "." + eventName;
+
+ for (Window window : sw)
+ {
+ window.setDeclaredProperty(prop_name, SOURCE);
+ window.setDeclaredProperty(prop_wiring, sources.get(window).toString());
+ }
+
+ // Set the sources
+
+ for (Window window : dw)
+ {
+ window.setDeclaredProperty(prop_name, DESTINATION);
+ window.setDeclaredProperty(prop_wiring, destinations.get(window).toString());
+ }
+
+ }
+
+ public void removeEventWiring(EventWiringInfo info) throws
IllegalCoordinationException
+ {
+ if (info == null)
+ {
+ throw new IllegalArgumentException("EventWiringInfo is null");
+ }
+
+ // Remove all entries
+
+ String prop_name = PREFIX_EVENT_NAME + "." + info.getName();
+ String prop_wiring = PREFIX_EVENT_WIRING + "." + info.getName();
+
+ Set<Window> all = new HashSet<Window>();
+ all.addAll(info.getSources().keySet());
+ all.addAll(info.getDestinations().keySet());
+
+ for (Window window : all)
+ {
+ window.setDeclaredProperty(prop_name, null);
+ window.setDeclaredProperty(prop_wiring, null);
+ }
+ }
+
+ public void setImplicitEventWiringStrategy(PageContainer pageContainer,
ImplicitStrategy strategy) throws IllegalCoordinationException
+ {
+ if (pageContainer == null)
+ {
+ throw new IllegalArgumentException("pageContainer is null");
+ }
+
+
+ setStrategy(pageContainer, strategy, PREFIX_EVENT_IMPLICIT_STRATEGY);
+
+ }
+
+ public ImplicitStrategy getImplicitEventWiringStrategy(PageContainer page) throws
IllegalCoordinationException
+ {
+ if (page == null)
+ {
+ throw new IllegalArgumentException("page is null");
+ }
+
+ return decodeStrategy(page, PREFIX_EVENT_IMPLICIT_STRATEGY);
+
+ }
+
+ public ImplicitStrategy resolveImplicitEventWiringStrategy(PageContainer page)
+ {
+
+ if (page == null)
+ {
+ throw new IllegalArgumentException("page is null");
+ }
+
+ return resolveStrategy(page, PREFIX_EVENT_IMPLICIT_STRATEGY);
+ }
+
+ public Collection<EventWiringInfo> getEventWirings(Page page, QName eventQName)
+ {
+
+ if (page == null)
+ {
+ throw new IllegalArgumentException("page is null");
+ }
+
+ if (eventQName == null)
+ {
+ throw new IllegalArgumentException("eventQName is null");
+ }
+
+ Collection<EventWiringInfo> pageEvents = getEventWirings(page);
+
+ Set<EventWiringInfo> events = new HashSet<EventWiringInfo>();
+
+ for (EventWiringInfo event : pageEvents)
+ {
+ if (event.getSources().containsValue(eventQName) ||
event.getDestinations().containsValue(eventQName))
+ {
+ pageEvents.add(event);
+ }
+ }
+
+ return events;
+ }
+
+ public Collection<EventWiringInfo> getEventWirings(Page page)
+ {
+ if (page == null)
+ {
+ throw new IllegalArgumentException("page is null");
+ }
+
+ // Examine window properties and create page events
+
+ Collection<Window> windows = getWindows(page);
+
+ Map<String, EventInfoPOJO> events = new HashMap<String,
EventInfoPOJO>();
+
+
+
+ for (Window window : windows)
+ {
+ Set<String> propNames = window.getProperties().keySet();
+
+ for (String propName : propNames)
+ {
+ if(propName.startsWith(PREFIX_EVENT_NAME))
+ {
+ String en = propName.substring(PREFIX_EVENT_NAME.length() + 1);
+ EventInfoPOJO info = null;
+
+ if (!events.keySet().contains(en))
+ {
+ info = new EventInfoPOJO(en);
+ events.put(en, info);
+ }
+ else
+ {
+ info = events.get(en);
+ }
+
+ String prop_wiring = PREFIX_EVENT_WIRING + "." + en;
+
+ String name = window.getProperty(prop_wiring);
+ String role = window.getProperty(propName);
+
+
+ //TODO: if the imformation from properties is not consistent should we
throw exception?
+
+ if (name != null)
+ {
+ QName qname = decodeQName(name);
+
+
+ if (qname != null && role != null &&
role.equalsIgnoreCase("source"))
+ {
+ info.getSources().put(window, qname);
+ }
+ else if (qname != null && role != null &&
role.equalsIgnoreCase("destination"))
+ {
+ info.getDestinations().put(window, qname);
+ }
+ }
+
+ break;
+ }
+ }
+ }
+
+ // Make immutable copy
+ Collection<EventWiringInfo> immutableEvents = new
HashSet<EventWiringInfo>();
+
+ for (EventInfoPOJO info : events.values())
+ {
+ immutableEvents.add(info.getImmutableWiringInfo());
+ }
+
+ return immutableEvents;
+ }
+
+ public Collection<EventWiringInfo> getEventSourceWirings(Window window)
+ {
+
+ Collection<EventWiringInfo> pageEvents = getEventWirings(window.getPage());
+
+ Set<EventWiringInfo> events = new HashSet<EventWiringInfo>();
+
+ for (EventWiringInfo pageEvent : pageEvents)
+ {
+ if (pageEvent.getSources().keySet().contains(window))
+ {
+ events.add(pageEvent);
+ }
+ }
+
+ return events;
+ }
+
+ public Collection<EventWiringInfo> getEventDestinationWirings(Window window)
+ {
+ Collection<EventWiringInfo> pageEvents = getEventWirings(window.getPage());
+
+ Set<EventWiringInfo> events = new HashSet<EventWiringInfo>();
+
+ for (EventWiringInfo pageEvent : pageEvents)
+ {
+ if (pageEvent.getDestinations().keySet().contains(window))
+ {
+ events.add(pageEvent);
+ }
+ }
+
+ return events;
+ }
+
+ public void setParameterBinding(String name, Map<Window, QName> windows) throws
IllegalCoordinationException
+ {
+ if (windows == null)
+ {
+ throw new IllegalArgumentException("windows are null");
+ }
+
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name is null");
+ }
+
+ if (windows.isEmpty())
+ {
+ throw new IllegalArgumentException("empty windows map");
+ }
+
+
+ // Obtain parent page and check that all windows are in one branch...
+
+ Page parentPage = null;
+
+ Set<Window> dw = windows.keySet();
+
+
+ for (Window window : dw)
+ {
+ if (parentPage == null)
+ {
+ parentPage = window.getPage();
+ }
+
+ if (!window.getPage().equals(parentPage))
+ {
+ throw new IllegalCoordinationException("Parent page is not the same for
all windows");
+ }
+ }
+
+
+ // Set window properties
+
+ String prop_wiring = PREFIX_PARAMETER_BINDING + "." + name;
+
+ for (Window window : dw)
+ {
+ window.setDeclaredProperty(prop_wiring, windows.get(window).toString());
+ }
+
+ }
+
+ public void removeParameterBinding(ParameterBindingInfo info) throws
IllegalCoordinationException
+ {
+ if (info == null)
+ {
+ throw new IllegalArgumentException("ParameterBindingInfo is null");
+ }
+
+ // Remove all entries
+
+ String prop_wiring = PREFIX_PARAMETER_BINDING + "." + info.getName();
+
+ for (Window window : info.getWindows().keySet())
+ {
+ window.setDeclaredProperty(prop_wiring, null);
+ }
+ }
+
+ public void setParameterAlias(Page page, String name)
+ {
+ if (page == null)
+ {
+ throw new IllegalArgumentException("page is null");
+ }
+
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name is null");
+ }
+
+ page.setDeclaredProperty(PREFIX_PARAMETER_ALIAS + "." + name, ALIAS);
+ }
+
+ public Collection<String> getParameterAliases(Page page)
+ {
+ if (page == null)
+ {
+ throw new IllegalArgumentException("page is null");
+ }
+
+ Collection<String> aliases = new HashSet<String>();
+
+ for (String propName : page.getProperties().keySet())
+ {
+ if (propName.startsWith(PREFIX_PARAMETER_ALIAS))
+ {
+ String value = page.getProperty(propName);
+ if (value.equalsIgnoreCase(ALIAS))
+ {
+ String aliasName = propName.substring(PREFIX_PARAMETER_ALIAS.length() +
1);
+ aliases.add(aliasName);
+ }
+ }
+ }
+
+ return aliases;
+
+ }
+
+ public void removeParameterAlias(Page page, String name) throws
IllegalCoordinationException
+ {
+
+ if (page == null)
+ {
+ throw new IllegalArgumentException("page is null");
+ }
+
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name is null");
+ }
+
+ page.setDeclaredProperty(PREFIX_PARAMETER_ALIAS + "." + name, null);
+
+ }
+
+ public void setImplicitParameterBindingStrategy(PageContainer pageContainer,
ImplicitStrategy strategy) throws IllegalCoordinationException
+ {
+ if (pageContainer == null)
+ {
+ throw new IllegalArgumentException("pageContainer is null");
+ }
+
+
+ setStrategy(pageContainer, strategy, PREFIX_PARAMETER_IMPLICIT_STRATEGY);
+ }
+
+ public ImplicitStrategy getImplicitParameterBindingStrategy(PageContainer
pageContainer) throws IllegalCoordinationException
+ {
+
+ if (pageContainer == null)
+ {
+ throw new IllegalArgumentException("page is null");
+ }
+
+ return decodeStrategy(pageContainer, PREFIX_PARAMETER_IMPLICIT_STRATEGY);
+
+ }
+
+ public ImplicitStrategy resolveImplicitBindingStrategy(PageContainer page)
+ {
+ if (page == null)
+ {
+ throw new IllegalArgumentException("page is null");
+ }
+
+ return resolveStrategy(page, PREFIX_PARAMETER_IMPLICIT_STRATEGY);
+ }
+
+ public Collection<ParameterBindingInfo> getParameterBindings(Page page, QName
parameterQName)
+ {
+
+ if (page == null)
+ {
+ throw new IllegalArgumentException("page is null");
+ }
+
+ if (parameterQName == null)
+ {
+ throw new IllegalArgumentException("QName is null");
+ }
+
+ Collection<ParameterBindingInfo> pageParams = getParameterBindings(page);
+
+ Collection<ParameterBindingInfo> infos = new
HashSet<ParameterBindingInfo>();
+
+ for (ParameterBindingInfo pageParam : pageParams)
+ {
+ if (pageParam.getWindows().containsValue(parameterQName))
+ {
+ infos.add(pageParam);
+ }
+ }
+
+ return infos;
+ }
+
+ public Collection<ParameterBindingInfo> getParameterBindings(Page page)
+ {
+ if (page == null)
+ {
+ throw new IllegalArgumentException("page is null");
+ }
+
+ // Examine window properties and create page parameters
+
+ Collection<Window> windows = getWindows(page);
+
+ Map<String, ParameterInfoPOJO> params = new HashMap<String,
ParameterInfoPOJO>();
+
+
+
+ for (Window window : windows)
+ {
+ Set<String> propNames = window.getProperties().keySet();
+
+ for (String propName : propNames)
+ {
+ if(propName.startsWith(PREFIX_PARAMETER_BINDING))
+ {
+ String pn = propName.substring(PREFIX_PARAMETER_BINDING.length() + 1);
+ ParameterInfoPOJO info = null;
+
+ if (!params.keySet().contains(pn))
+ {
+ info = new ParameterInfoPOJO(pn);
+ params.put(pn, info);
+ }
+ else
+ {
+ info = params.get(pn);
+ }
+
+ String binding = window.getProperty(propName);
+
+
+ //TODO: if the imformation from properties is not consistent should we
throw exception?
+
+ if (binding != null)
+ {
+ QName qname = decodeQName(binding);
+
+
+ if (qname != null)
+ {
+ info.getWindows().put(window, qname);
+ }
+
+ }
+
+ break;
+ }
+ }
+ }
+
+ // Make immutable copy
+ Collection<ParameterBindingInfo> immutableParams = new
HashSet<ParameterBindingInfo>();
+
+ for (ParameterInfoPOJO info : params.values())
+ {
+ immutableParams.add(info.getImmutableInfo());
+ }
+
+ return immutableParams;
+ }
+
+ public Collection<ParameterBindingInfo> getParameterBindings(Window window)
+ {
+ Collection<ParameterBindingInfo> pageParams =
getParameterBindings(window.getPage());
+
+ Collection<ParameterBindingInfo> infos = new
HashSet<ParameterBindingInfo>();
+
+ for (ParameterBindingInfo pageParam : pageParams)
+ {
+ if (pageParam.getWindows().keySet().contains(window))
+ {
+ infos.add(pageParam);
+ }
+ }
+
+ return infos;
+ }
+
+ // SETTERS & GETTERS
+
+ public PortalObjectContainer getContainer()
+ {
+ return container;
+ }
+
+ public void setContainer(PortalObjectContainer container)
+ {
+ this.container = container;
+ }
+
+ public EventConverter getEventConverter()
+ {
+ return eventConverter;
+ }
+
+ public void setEventConverter(EventConverter eventConverter)
+ {
+ this.eventConverter = eventConverter;
+ }
+
+ // HELPER METHODS
+
+ private void setStrategy(PageContainer pageContainer, ImplicitStrategy strategy,
String prefix)
+ {
+ if (strategy == null)
+ {
+ pageContainer.setDeclaredProperty(prefix, null);
+ }
+ else if (strategy.equals(ImplicitStrategy.DISABLED))
+ {
+ pageContainer.setDeclaredProperty(prefix, STRATEGY_DISABLED);
+ }
+ else if (strategy.equals(ImplicitStrategy.EXCLUSIVE))
+ {
+ pageContainer.setDeclaredProperty(prefix, STRATEGY_EXCLUSIVE);
+ }
+ else if (strategy.equals(ImplicitStrategy.FALLBACK))
+ {
+ pageContainer.setDeclaredProperty(prefix,STRATEGY_FALLBACK);
+ }
+ else if (strategy.equals(ImplicitStrategy.RECURSIVE_DISABLED))
+ {
+ pageContainer.setDeclaredProperty(prefix,STRATEGY_RECURSIVE_DISABLED);
+ }
+ else if (strategy.equals(ImplicitStrategy.RECURSIVE_EXCLUSIVE))
+ {
+ pageContainer.setDeclaredProperty(prefix,STRATEGY_RECURSIVE_EXCLUSIVE);
+ }
+ else if (strategy.equals(ImplicitStrategy.RECURSIVE_FALLBACK))
+ {
+ pageContainer.setDeclaredProperty(prefix,STRATEGY_RECURSIVE_FALLBACK);
+ }
+ }
+
+ private ImplicitStrategy decodeStrategy(PageContainer pageContainer, String prefix)
+ {
+ String value = pageContainer.getDeclaredProperty(prefix);
+
+ return decodeStrategy(value);
+ }
+
+ private ImplicitStrategy decodeStrategy(String value)
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ else if (value.equals(STRATEGY_DISABLED))
+ {
+ return ImplicitStrategy.DISABLED;
+ }
+ else if (value.equals(STRATEGY_EXCLUSIVE))
+ {
+ return ImplicitStrategy.EXCLUSIVE;
+ }
+ else if (value.equals(STRATEGY_FALLBACK))
+ {
+ return ImplicitStrategy.FALLBACK;
+ }
+ else if (value.equals(STRATEGY_RECURSIVE_DISABLED))
+ {
+ return ImplicitStrategy.RECURSIVE_DISABLED;
+ }
+ else if (value.equals(STRATEGY_RECURSIVE_EXCLUSIVE))
+ {
+ return ImplicitStrategy.RECURSIVE_EXCLUSIVE;
+ }
+ else if (value.equals(STRATEGY_RECURSIVE_FALLBACK))
+ {
+ return ImplicitStrategy.RECURSIVE_FALLBACK;
+ }
+
+ // Strategy unknown
+ return null;
+ }
+
+ private ImplicitStrategy resolveStrategy(PageContainer pageContainer, String prefix)
+ {
+ String value = pageContainer.getDeclaredProperty(prefix);
+
+ ImplicitStrategy strategy = null;
+
+
+ // Try to obtain recursive strategy from parents
+
+ if (value == null)
+ {
+ strategy = resolveRecursiveStrategy(pageContainer, prefix);
+ }
+ else
+ {
+ strategy = decodeStrategy(value);
+ }
+
+ if (strategy != null)
+ {
+ if (strategy.equals(ImplicitStrategy.RECURSIVE_DISABLED))
+ {
+ return ImplicitStrategy.DISABLED;
+ }
+ else if (strategy.equals(ImplicitStrategy.RECURSIVE_EXCLUSIVE))
+ {
+ return ImplicitStrategy.EXCLUSIVE;
+ }
+ else if (strategy.equals(ImplicitStrategy.RECURSIVE_FALLBACK))
+ {
+ return ImplicitStrategy.FALLBACK;
+ }
+
+ return strategy;
+ }
+ else
+ {
+ return DEFAULT_STRATEGY;
+ }
+
+ }
+
+ // Search for the RECURSIVE_ type of strategy
+ private ImplicitStrategy resolveRecursiveStrategy(PortalObject po, String prefix)
+ {
+ String value = po.getDeclaredProperty(prefix);
+ ImplicitStrategy strategy = null;
+
+ if (value != null)
+ {
+ strategy = decodeStrategy(value);
+ }
+
+ if (strategy != null &&
+ (strategy.equals(ImplicitStrategy.RECURSIVE_DISABLED) ||
+ strategy.equals(ImplicitStrategy.RECURSIVE_EXCLUSIVE) ||
+ strategy.equals(ImplicitStrategy.RECURSIVE_FALLBACK)))
+ {
+ return strategy;
+ }
+ else if (!(po instanceof Portal))
+ {
+ return resolveRecursiveStrategy(po.getParent(), prefix);
+ }
+
+ return null;
+ }
+
+
+ Collection<Window> getWindows(Page page)
+ {
+ Set<Window> windows = new HashSet<Window>();
+ for (PortalObject portalObject : page.getChildren())
+ {
+
+ if (portalObject instanceof Window)
+ {
+ windows.add((Window)portalObject);
+ }
+ }
+ return windows;
+ }
+
+ private QName decodeQName(String fullString)
+ {
+ if (fullString.startsWith("{"))
+ {
+ String[] parts = fullString.split("}");
+
+ if (parts.length == 2)
+ {
+ return new QName(parts[0].substring(1), parts[1]);
+ }
+ }
+ else
+ {
+ return new QName(fullString);
+ }
+
+ return null;
+
+ }
+
+
+ private class EventInfoPOJO implements EventWiringInfo
+ {
+ private final String name;
+ private final Map<Window,QName> sources;
+ private final Map<Window,QName> destinations;
+
+ private EventInfoPOJO(String name, Map<Window, QName> sources, Map<Window,
QName> destinations)
+ {
+ this.name = name;
+ this.sources = sources;
+ this.destinations = destinations;
+ }
+
+ private EventInfoPOJO(String name)
+ {
+ this.name = name;
+ this.sources = new HashMap<Window,QName>();
+ this.destinations = new HashMap<Window,QName>();
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Map<Window, QName> getSources()
+ {
+ return sources;
+ }
+
+ public Map<Window, QName> getDestinations()
+ {
+ return destinations;
+ }
+
+ EventWiringInfo getImmutableWiringInfo()
+ {
+ return new EventInfoPOJO(name, Collections.unmodifiableMap(sources),
Collections.unmodifiableMap(destinations));
+ }
+
+ }
+
+ private class ParameterInfoPOJO implements ParameterBindingInfo
+ {
+
+ private final String name;
+ private final Map<Window, QName> windows;
+
+ private ParameterInfoPOJO(String name, Map<Window, QName> windows)
+ {
+ this.name = name;
+ this.windows = windows;
+ }
+
+ private ParameterInfoPOJO(String name)
+ {
+ this.name = name;
+ this.windows = new HashMap<Window,QName>();
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Map<Window, QName> getWindows()
+ {
+ return windows;
+ }
+
+ ParameterBindingInfo getImmutableInfo()
+ {
+ return new ParameterInfoPOJO(name, Collections.unmodifiableMap(windows));
+ }
+
+ }
+
+}
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/coordination/SimpleEventConverter.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/coordination/SimpleEventConverter.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/coordination/SimpleEventConverter.java 2008-06-29
11:22:39 UTC (rev 11189)
@@ -0,0 +1,84 @@
+/*
+* 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.portal.coordination;
+
+import org.jboss.portal.core.model.portal.coordination.EventConverter;
+import org.jboss.portal.portlet.controller.event.PortletWindowEvent;
+import org.jboss.portal.portlet.info.EventInfo;
+
+import javax.xml.namespace.QName;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class SimpleEventConverter implements EventConverter
+{
+
+ public PortletWindowEvent resolveEvent(PortletWindowEvent sourceEvent, EventInfo
destEventInfo)
+ {
+
+ QName destName = destEventInfo.getName();
+ String windowId = sourceEvent.getWindowId();
+ Serializable payload = sourceEvent.getPayload();
+
+
+ // Source and destination payload types
+
+ String sourcePayloadType = sourceEvent.getPayload().getClass().getName();
+ String destPayloadType = destEventInfo.getType().getName();
+
+
+ // NOTE: rules below can be merged but I leave it like this to have more clear
logic to follow
+
+ // Same payload types
+
+ if (destPayloadType != null && sourcePayloadType.equals(destPayloadType))
+ {
+ return new PortletWindowEvent(destName, payload, windowId);
+ }
+
+ // source payload == null -> null
+
+ else if (sourceEvent.getPayload() == null)
+ {
+ return new PortletWindowEvent(destName, null, windowId);
+ }
+
+ // destination have no type
+
+ else if (destPayloadType == null || destPayloadType.equals(""))
+ {
+ return new PortletWindowEvent(destName, null, windowId);
+ }
+
+ // DEFAULT - just pass null value
+ return new PortletWindowEvent(destName, null, windowId);
+
+
+ }
+
+
+
+}
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/CoordinationConfigurator.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/CoordinationConfigurator.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/CoordinationConfigurator.java 2008-06-29
11:22:39 UTC (rev 11189)
@@ -0,0 +1,177 @@
+/*
+* 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.model.portal.coordination;
+
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.PageContainer;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface CoordinationConfigurator
+{
+ // Management
+
+ /**
+ * Defines a wiring for a given even QName between multiply source and destination
windows
+ *
+ * @param sources
+ * @param targets
+ * @param eventName
+ * @throws IllegalCoordinationException
+ */
+ void setEventWiring(Map<Window, QName> sources, Map<Window, QName>
targets, String eventName) throws IllegalCoordinationException;
+
+ /**
+ * Remove wiring
+ *
+ * @param eventWiringInfo
+ * @throws IllegalCoordinationException
+ */
+ void removeEventWiring(EventWiringInfo eventWiringInfo) throws
IllegalCoordinationException;
+
+ /**
+ * Sets implicit wiring strategy for a given page
+ *
+ * @param pageContainer
+ * @param strategy
+ * @throws IllegalCoordinationException
+ */
+ void setImplicitEventWiringStrategy(PageContainer pageContainer, ImplicitStrategy
strategy) throws IllegalCoordinationException;
+
+ /**
+ * @param page
+ * @return implicit wiring strategy for a given page. Can return null if no strategy
is set
+ */
+ ImplicitStrategy getImplicitEventWiringStrategy(PageContainer page) throws
IllegalCoordinationException;
+
+ /**
+ * @param page
+ * @param eventQName
+ * @return all wirings defined for a given qname
+ */
+ Collection<EventWiringInfo> getEventWirings(Page page, QName eventQName);
+
+ /**
+ * @param page
+ * @return all wirings defined in the scope of a given page
+ */
+ Collection<EventWiringInfo> getEventWirings(Page page);
+
+ /**
+ * @param window
+ * @return all wirings where given window is a source
+ */
+ Collection<EventWiringInfo> getEventSourceWirings(Window window);
+
+ /**
+ * @param window
+ * @return all wirings where given window is a destination
+ */
+ Collection<EventWiringInfo> getEventDestinationWirings(Window window);
+
+ /**
+ * Defines shared parameter binding for a given collection of windows.
+ *
+ * @param name
+ * @param windows
+ * @throws IllegalCoordinationException
+ */
+ void setParameterBinding(String name, Map<Window, QName> windows) throws
IllegalCoordinationException;
+
+ /**
+ * Removes given parameter binding
+ *
+ * @param parameterBinding
+ * @throws IllegalCoordinationException
+ */
+ void removeParameterBinding(ParameterBindingInfo parameterBinding) throws
IllegalCoordinationException;
+
+ /**
+ * Defines page scoped alias for shared parameter. All parameters with a local part
equal to given name will
+ * share request value
+ *
+ * @param page
+ * @param name
+ */
+ void setParameterAlias(Page page, String name);
+
+ /**
+ * Get a collection of aliases defined for a given page
+ *
+ * @param page
+ * @return
+ */
+ Collection<String> getParameterAliases(Page page);
+
+ /**
+ * Remove alias
+ *
+ * @param page
+ * @param name
+ * @throws IllegalCoordinationException
+ */
+ void removeParameterAlias(Page page, String name) throws
IllegalCoordinationException;
+
+ /**
+ * Set implicit strategy for a given page container
+ *
+ * @param pageContainer
+ * @param implicitStrategy
+ * @throws IllegalCoordinationException
+ */
+ void setImplicitParameterBindingStrategy(PageContainer pageContainer, ImplicitStrategy
implicitStrategy) throws IllegalCoordinationException;
+
+ /**
+ * @param pageContainer
+ * @return implicit strategy for a given page container. Can return null if no
strategy is defined
+ */
+ ImplicitStrategy getImplicitParameterBindingStrategy(PageContainer pageContainer)
throws IllegalCoordinationException;
+
+
+
+ /**
+ * @param page
+ * @param parameterQName
+ * @return parameter bindings for a given parameter qname
+ */
+ Collection<ParameterBindingInfo> getParameterBindings(Page page, QName
parameterQName);
+
+ /**
+ * @param page
+ * @return parameter bindings define in the scope of a given page
+ */
+ Collection<ParameterBindingInfo> getParameterBindings(Page page);
+
+ /**
+ * @param window
+ * @return parameter bindings where given window is involved
+ */
+ Collection<ParameterBindingInfo> getParameterBindings(Window window);
+}
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/CoordinationManager.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/CoordinationManager.java 2008-06-28
12:14:22 UTC (rev 11188)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/CoordinationManager.java 2008-06-29
11:22:39 UTC (rev 11189)
@@ -25,11 +25,11 @@
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.PageContainer;
import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.controller.portlet.ControllerPortletControllerContext;
import org.jboss.portal.portlet.controller.event.PortletWindowEvent;
import javax.xml.namespace.QName;
import java.util.Collection;
-import java.util.Set;
import java.util.Map;
/**
@@ -41,194 +41,34 @@
public interface CoordinationManager
{
- enum ImplicitStrategy
- {
- // Explicit wiring takes precedence
- FALLBACK,
-
- // Only implicit wiring enabled
- EXCLUSIVE,
-
- // Implicit wiring disabled
- DISABLED,
-
- // Inherited by children nodes in the tree
- RECURSIVE_FALLBACK,
-
- // .
- RECURSIVE_EXCLUSIVE,
-
- // .
- RECURSIVE_DISABLED
-
- }
-
-
// Event Discovery
/**
* @param event
+ * @param context
* @return all windows that given event should be delivered to with current wirings
and configuration
*/
- Collection<Window> getEventWindows(PortletWindowEvent event);
+ Map<Window, PortletWindowEvent> getEventWindows(PortletWindowEvent event,
ControllerPortletControllerContext context) throws IllegalCoordinationException;
- // Management
- /**
- * Defines a wiring for a given even QName between multiply source and destination
windows
+ /**
+ * Resolves implicit strategy. If there is no strategy defined for this page container
method will browse
+ * parent object to resolve inherited recursive strategies. If no strategy is set this
method will return default one
*
- * @param sources
- * @param targets
- * @param eventName
- * @throws IllegalCoordinationException
- */
- void setEventWiring(Map<Window, QName> sources, Map<Window, QName>
targets, String eventName) throws IllegalCoordinationException;
-
- /**
- * Remove wiring
- *
- * @param eventWiringInfo
- * @throws IllegalCoordinationException
- */
- void removeEventWiring(EventWiringInfo eventWiringInfo) throws
IllegalCoordinationException;
-
- /**
- * Defines a wiring between qnames at the page level. Event with given qname will be
delivered
- * to all windows being destination of destination qnames. All qnames need to be
compatible - have no or the same
- * payload - otherwise IllegalCoordinationException will be thrown.
- * This method overrites any previous wiring for this qname in the page. Empty
destinations collection removes the
- * wiring.
- *
- * @param source
- * @param destinations
* @param page
+ * @return
* @throws IllegalCoordinationException
*/
- void setNameEventWiring(QName source, Collection<QName> destinations, Page page)
throws IllegalCoordinationException;
+ ImplicitStrategy resolveImplicitBindingStrategy(PageContainer page);
-
- /**
- * Sets implicit wiring strategy for a given page
- *
- * @param pageContainer
- * @param strategy
- * @throws IllegalCoordinationException
- */
- void setImplicitEventWiringStrategy(PageContainer pageContainer, ImplicitStrategy
strategy) throws IllegalCoordinationException;
-
- /**
- * @param page
- * @return implicit wiring strategy for a given page
- */
- ImplicitStrategy getImplicitEventWiringStrategy(Page page);
-
- /**
- * @param page
- * @param source
- * @return a collection of qnames that are wired with a given gname in scope of given
page
- * @throws IllegalCoordinationException
- */
- Collection<QName> getNameEventWiring(Page page, QName source) throws
IllegalCoordinationException;
-
-
- /**
- * @param eventQName
- * @return all wirings defined for a given qname
- */
- Collection<EventWiringInfo> getEventWirings(QName eventQName);
-
- /**
- * @param page
- * @return all wirings defined in the scope of a given page
- */
- Collection<EventWiringInfo> getEventWirings(Page page);
-
- /**
- * @param window
- * @return all wirings where given window is a source
- */
- Collection<EventWiringInfo> getEventSourceWirings(Window window);
-
- /**
- * @param window
- * @return all wirings where given window is a destination
- */
- Collection<EventWiringInfo> getEventDestinationWirings(Window window);
-
- /**
- * Defines shared parameter binding for a given collection of windows.
+ /**
+ * Resolves implicit wiring strategy. If there is no strategy defined for this page
container method will browse
+ * parent object to resolve inherited recursive strategies. If no strategy is set this
method will return default one
*
- * @param qname
- * @param windows
- * @throws IllegalCoordinationException
- */
- void setParameterBinding(QName qname, Collection<Window> windows) throws
IllegalCoordinationException;
-
- /**
- * Removes given parameter binding
- *
- * @param parameterBinding
- * @throws IllegalCoordinationException
- */
- void removeParameterBinding(ParameterBindingInfo parameterBinding) throws
IllegalCoordinationException;
-
- /**
- * Defines page scoped alias for shared parameter. All parameters with a local part
equal to given name will
- * share request value
- *
* @param page
- * @param name
- */
- void setParameterAlias(Page page, String name);
-
- /**
- * Get a collection of aliases defined for a given page
- *
- * @param page
* @return
- */
- Collection<String> getParameterAliases(Page page);
-
- /**
- * Remove alias
- *
- * @param page
- * @param name
* @throws IllegalCoordinationException
*/
- void removeParameterAlias(Page page, String name) throws
IllegalCoordinationException;
+ ImplicitStrategy resolveImplicitEventWiringStrategy(PageContainer page);
- /**
- * Set implicit strategy for a given page container
- *
- * @param pageContainer
- * @param implicitStrategy
- * @throws IllegalCoordinationException
- */
- void setImplicitParameterBindingStrategy(PageContainer pageContainer, ImplicitStrategy
implicitStrategy) throws IllegalCoordinationException;
-
- /**
- * @param pageContainer
- * @return implicit strategy for a given page container
- */
- ImplicitStrategy getImplicitParameterBindingStrategy(PageContainer pageContainer);
-
- /**
- * @param parameterQName
- * @return parameter bindings for a given parameter qname
- */
- Collection<ParameterBindingInfo> getParameterBindings(QName parameterQName);
-
- /**
- * @param page
- * @return parameter bindings define in the scope of a given page
- */
- Collection<ParameterBindingInfo> getParameterBindings(Page page);
-
- /**
- * @param window
- * @return parameter bindings where given window is involved
- */
- Collection<ParameterBindingInfo> getParameterBindings(Window window);
-
}
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/EventConverter.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/EventConverter.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/EventConverter.java 2008-06-29
11:22:39 UTC (rev 11189)
@@ -0,0 +1,44 @@
+/*
+* 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.model.portal.coordination;
+
+import org.jboss.portal.portlet.controller.event.PortletWindowEvent;
+import org.jboss.portal.portlet.info.EventInfo;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface EventConverter
+{
+
+ /**
+ * Converts source event using information about destination event mapping. Return
event will have
+ * destination event QName, source event windowId and negotiated payload value.
+ *
+ * @param sourceEvent
+ * @param destEventInfo
+ * @return
+ */
+ PortletWindowEvent resolveEvent(PortletWindowEvent sourceEvent, EventInfo
destEventInfo);
+}
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/IllegalCoordinationException.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/IllegalCoordinationException.java 2008-06-28
12:14:22 UTC (rev 11188)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/IllegalCoordinationException.java 2008-06-29
11:22:39 UTC (rev 11189)
@@ -28,4 +28,8 @@
*/
public class IllegalCoordinationException extends Exception
{
+ public IllegalCoordinationException(String message)
+ {
+ super(message);
+ }
}
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/ImplicitStrategy.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/ImplicitStrategy.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/ImplicitStrategy.java 2008-06-29
11:22:39 UTC (rev 11189)
@@ -0,0 +1,50 @@
+/*
+* 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.model.portal.coordination;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+* @version : 0.1 $
+*/
+public enum ImplicitStrategy
+{
+
+ // Explicit wiring takes precedence and if none exist for a given event it will be
processed with implicit wiring
+ FALLBACK,
+
+ // Only implicit wiring enabled
+ EXCLUSIVE,
+
+ // Implicit wiring disabled
+ DISABLED,
+
+ // All children nodes in the tree will inherit FALLBACK strategy
+ RECURSIVE_FALLBACK,
+
+ // All children nodes in the tree will inherit EXCLUSIVE strategy
+ RECURSIVE_EXCLUSIVE,
+
+ // All children nodes in the tree will inherit DISABLED strategy
+ RECURSIVE_DISABLED;
+
+}
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/ParameterBindingInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/ParameterBindingInfo.java 2008-06-28
12:14:22 UTC (rev 11188)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/coordination/ParameterBindingInfo.java 2008-06-29
11:22:39 UTC (rev 11189)
@@ -26,6 +26,7 @@
import javax.xml.namespace.QName;
import java.util.Collection;
+import java.util.Map;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
@@ -33,8 +34,8 @@
*/
public interface ParameterBindingInfo
{
- QName getName();
+ String getName();
- Collection<Window> getWindows();
+ Map<Window, QName> getWindows();
}
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/model/portal/coordination/CoordinationServiceTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/model/portal/coordination/CoordinationServiceTestCase.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/model/portal/coordination/CoordinationServiceTestCase.java 2008-06-29
11:22:39 UTC (rev 11189)
@@ -0,0 +1,294 @@
+/*
+* 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.test.core.model.portal.coordination;
+
+import org.jboss.portal.test.core.model.portal.AbstractPortalObjectContainerTestCase;
+import org.jboss.portal.common.junit.TransactionAssert;
+import org.jboss.portal.core.model.portal.Context;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.coordination.CoordinationManager;
+import org.jboss.portal.core.model.portal.coordination.CoordinationConfigurator;
+import org.jboss.portal.core.model.portal.coordination.ImplicitStrategy;
+import org.jboss.portal.core.model.portal.coordination.EventWiringInfo;
+import org.jboss.portal.core.model.portal.coordination.ParameterBindingInfo;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.impl.model.portal.coordination.CoordinationService;
+import org.apache.log4j.Appender;
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.SimpleLayout;
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+import junit.framework.TestSuite;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class CoordinationServiceTestCase extends AbstractPortalObjectContainerTestCase
+{
+
+ static
+ {
+ Appender appender = new ConsoleAppender(new SimpleLayout());
+ Logger.getRoot().addAppender(appender);
+ Logger.getRoot().setLevel(Level.ERROR);
+ Logger.getLogger("org.hibernate").setLevel(Level.ERROR);
+ }
+
+ protected CoordinationService cos;
+
+ protected String getConfigLocationPrefix()
+ {
+ return "org/jboss/portal/test/core/model/portal/coordination/";
+ }
+
+ public static TestSuite suite() throws Exception
+ {
+ return
AbstractPortalObjectContainerTestCase.suite(CoordinationServiceTestCase.class);
+ }
+
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ //
+ TransactionAssert.beginTransaction();
+ Context root = container.getContext("");
+ Portal p_1 = root.createPortal("Portal_1");
+ Page p_1_1 = p_1.createPage("Page_1");
+ Page p_1_2 = p_1.createPage("Page_2");
+
+ Page p_1_1_1 = p_1_1.createPage("Page_1");
+
+ Window w_1_1 = p_1_1.createWindow("Window_1", ContentType.PORTLET,
"");
+ Window w_1_2 = p_1_1.createWindow("Window_2", ContentType.PORTLET,
"");
+ Window w_1_3 = p_1_1.createWindow("Window_3", ContentType.PORTLET,
"");
+ Window w_1_4 = p_1_1.createWindow("Window_4", ContentType.PORTLET,
"");
+
+
+ Window w_2_1 = p_1_2.createWindow("Window_1", ContentType.PORTLET,
"");
+ Window w_2_2 = p_1_2.createWindow("Window_2", ContentType.PORTLET,
"");
+ Window w_2_3 = p_1_2.createWindow("Window_3", ContentType.PORTLET,
"");
+ Window w_2_4 = p_1_2.createWindow("Window_4", ContentType.PORTLET,
"");
+
+
+ TransactionAssert.commitTransaction();
+ }
+
+ public void testImplicitStrategy() throws Exception
+ {
+ TransactionAssert.beginTransaction();
+
+ Portal portal_1 =
container.getContext("").getPortal("Portal_1");
+ Page page_1 = portal_1.getPage("Page_1");
+
+
+ assertNull(cos.getImplicitEventWiringStrategy(page_1));
+ assertNull(cos.getImplicitParameterBindingStrategy(page_1));
+
+ cos.setImplicitEventWiringStrategy(page_1, ImplicitStrategy.EXCLUSIVE);
+
+ assertEquals(ImplicitStrategy.EXCLUSIVE,
cos.getImplicitEventWiringStrategy(page_1));
+ assertNull(cos.getImplicitParameterBindingStrategy(page_1));
+
+ cos.setImplicitParameterBindingStrategy(page_1, ImplicitStrategy.DISABLED);
+
+ assertEquals(ImplicitStrategy.EXCLUSIVE,
cos.getImplicitEventWiringStrategy(page_1));
+ assertEquals(ImplicitStrategy.DISABLED,
cos.getImplicitParameterBindingStrategy(page_1));
+
+ cos.setImplicitEventWiringStrategy(page_1, null);
+ cos.setImplicitParameterBindingStrategy(page_1, null);
+ cos.setImplicitEventWiringStrategy(portal_1,
ImplicitStrategy.RECURSIVE_EXCLUSIVE);
+ cos.setImplicitParameterBindingStrategy(portal_1,
ImplicitStrategy.RECURSIVE_FALLBACK);
+
+ assertEquals(null, cos.getImplicitEventWiringStrategy(page_1));
+ assertEquals(null, cos.getImplicitParameterBindingStrategy(page_1));
+ assertEquals(ImplicitStrategy.RECURSIVE_EXCLUSIVE,
cos.getImplicitEventWiringStrategy(portal_1));
+ assertEquals(ImplicitStrategy.RECURSIVE_FALLBACK,
cos.getImplicitParameterBindingStrategy(portal_1));
+
+ // Resolve
+
+ assertEquals(ImplicitStrategy.EXCLUSIVE,
cos.resolveImplicitEventWiringStrategy(page_1));
+ assertEquals(ImplicitStrategy.EXCLUSIVE,
cos.resolveImplicitEventWiringStrategy(portal_1));
+ assertEquals(ImplicitStrategy.FALLBACK,
cos.resolveImplicitBindingStrategy(page_1));
+ assertEquals(ImplicitStrategy.FALLBACK,
cos.resolveImplicitBindingStrategy(portal_1));
+
+ // Inheritance and overriding value in the middle of the tree
+
+ Page page_1_1 = page_1.getPage("Page_1");
+
+ cos.setImplicitEventWiringStrategy(portal_1,
ImplicitStrategy.RECURSIVE_EXCLUSIVE);
+ cos.setImplicitEventWiringStrategy(page_1, ImplicitStrategy.DISABLED);
+ cos.setImplicitEventWiringStrategy(page_1_1, null);
+
+ cos.setImplicitParameterBindingStrategy(portal_1,
ImplicitStrategy.RECURSIVE_FALLBACK);
+ cos.setImplicitParameterBindingStrategy(page_1, ImplicitStrategy.EXCLUSIVE);
+ cos.setImplicitParameterBindingStrategy(page_1_1, null);
+
+ assertEquals(ImplicitStrategy.EXCLUSIVE,
cos.resolveImplicitEventWiringStrategy(page_1_1));
+ assertEquals(ImplicitStrategy.DISABLED,
cos.resolveImplicitEventWiringStrategy(page_1));
+ assertEquals(ImplicitStrategy.EXCLUSIVE,
cos.resolveImplicitEventWiringStrategy(portal_1));
+
+ assertEquals(ImplicitStrategy.FALLBACK,
cos.resolveImplicitBindingStrategy(page_1_1));
+ assertEquals(ImplicitStrategy.EXCLUSIVE,
cos.resolveImplicitBindingStrategy(page_1));
+ assertEquals(ImplicitStrategy.FALLBACK,
cos.resolveImplicitBindingStrategy(portal_1));
+
+
+ TransactionAssert.commitTransaction();
+ }
+
+ public void testEventWiring() throws Exception
+ {
+ TransactionAssert.beginTransaction();
+
+ Portal portal1 =
container.getContext("").getPortal("Portal_1");
+ Page page1 = portal1.getPage("Page_1");
+ Page page2 = portal1.getPage("Page_2");
+
+
+ Window w1 = page1.getWindow("Window_1");
+ Window w2 = page1.getWindow("Window_2");
+ Window w3 = page1.getWindow("Window_3");
+ Window w4 = page1.getWindow("Window_4");
+
+ Window w2_1 = page1.getWindow("Window_2");
+
+
+ Map<Window, QName> s1 = new HashMap<Window, QName>();
+ Map<Window, QName> d1 = new HashMap<Window, QName>();
+ s1.put(w1, new QName("juju", "foo"));
+ s1.put(w2, new QName("juju", "foo1"));
+ s1.put(w3, new QName("juju", "foo3"));
+
+ d1.put(w4, new QName("bobo", "bar"));
+
+
+ cos.setEventWiring(s1, d1, "event1");
+
+
+ Collection<EventWiringInfo> events = cos.getEventWirings(page1);
+
+ assertEquals(1, events.size());
+
+ EventWiringInfo info = events.iterator().next();
+ assertEquals("event1", info.getName());
+
+ events = cos.getEventSourceWirings(w1);
+
+ assertNotNull(events);
+ assertEquals(1, events.size());
+
+ info = events.iterator().next();
+
+ assertTrue(info.getSources().keySet().size() == 3);
+ assertTrue(info.getSources().keySet().contains(w1));
+ assertTrue(info.getSources().keySet().contains(w2));
+ assertTrue(info.getSources().keySet().contains(w3));
+
+ events = cos.getEventDestinationWirings(w4);
+
+ assertNotNull(events);
+ assertTrue(events.size() == 1);
+
+ info = events.iterator().next();
+
+ assertTrue(info.getDestinations().keySet().size() == 1);
+ assertTrue(info.getDestinations().keySet().contains(w4));
+
+
+ // remove
+ cos.removeEventWiring(info);
+ events = cos.getEventDestinationWirings(w4);
+
+ assertNotNull(events);
+ assertTrue(events.size() == 0);
+
+
+
+
+ TransactionAssert.commitTransaction();
+ }
+
+ public void testParameterBinding() throws Exception
+ {
+ TransactionAssert.beginTransaction();
+
+ Portal portal1 =
container.getContext("").getPortal("Portal_1");
+ Page page1 = portal1.getPage("Page_1");
+ Page page2 = portal1.getPage("Page_2");
+
+ Window w1 = page1.getWindow("Window_1");
+ Window w2 = page1.getWindow("Window_2");
+ Window w3 = page1.getWindow("Window_3");
+ Window w4 = page1.getWindow("Window_4");
+
+ Window w2_1 = page1.getWindow("Window_2");
+
+
+ Map<Window, QName> ws = new HashMap<Window, QName>();
+ ws.put(w1, new QName("juju", "foo"));
+ ws.put(w2, new QName("juju", "foo1"));
+ ws.put(w4, new QName("juju", "foo3"));
+
+ cos.setParameterBinding("binding1", ws);
+
+ Collection<ParameterBindingInfo> bindings = cos.getParameterBindings(page1);
+
+ assertEquals(1, bindings.size());
+
+ Map<Window, QName> windows = bindings.iterator().next().getWindows();
+
+ assertEquals(3, windows.size());
+
+ assertTrue(windows.containsKey(w1));
+ assertTrue(windows.containsKey(w2));
+ assertTrue(windows.containsKey(w4));
+
+ cos.removeParameterBinding(bindings.iterator().next());
+
+ bindings = cos.getParameterBindings(w1);
+
+ assertEquals(0, bindings.size());
+
+
+ TransactionAssert.commitTransaction();
+ }
+
+ public CoordinationService getCos()
+ {
+ return cos;
+ }
+
+ public void setCos(CoordinationService cos)
+ {
+ this.cos = cos;
+ }
+}
Copied:
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/coordination/persistent-jboss-beans.xml
(from rev 11138,
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/persistent-jboss-beans.xml)
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/coordination/persistent-jboss-beans.xml
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/portal/coordination/persistent-jboss-beans.xml 2008-06-29
11:22:39 UTC (rev 11189)
@@ -0,0 +1,110 @@
+<?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 class="java.lang.String">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="CoordinationService"
class="org.jboss.portal.core.impl.model.portal.coordination.CoordinationService">
+ <property name="container"><inject
bean="PortalObjectContainer"/></property>
+ </bean>
+
+ <bean name="TestBean"
class="org.jboss.portal.test.core.model.portal.coordination.CoordinationServiceTestCase">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>TestBean</parameter>
+ </constructor>
+ <property name="hibernate"><inject
bean="HibernateSupport"/></property>
+ <property name="portalObjectContainer"><inject
bean="PortalObjectContainer"/></property>
+ <property name="authorizationManagerFactory"><inject
bean="AuthorizationManagerFactory"/></property>
+ <property name="cos"><inject
bean="CoordinationService"/></property>
+ </bean>
+</deployment>