Author: julien(a)jboss.com
Date: 2007-01-29 21:06:15 -0500 (Mon, 29 Jan 2007)
New Revision: 6118
Added:
trunk/federation/src/main/org/jboss/portal/portlet/federation/
trunk/federation/src/main/org/jboss/portal/portlet/federation/FederatedPortletInvoker.java
trunk/federation/src/main/org/jboss/portal/portlet/federation/FederatingPortletInvoker.java
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatedPortlet.java
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatedPortletInvokerService.java
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatingPortletInvokerService.java
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/PortletInvokerRegistrationService.java
trunk/federation/src/main/org/jboss/portal/portlet/federation/spi/
trunk/federation/src/main/org/jboss/portal/portlet/federation/spi/PortletInvokerRegistration.java
Log:
fix svn fuckup
Added:
trunk/federation/src/main/org/jboss/portal/portlet/federation/FederatedPortletInvoker.java
===================================================================
---
trunk/federation/src/main/org/jboss/portal/portlet/federation/FederatedPortletInvoker.java
(rev 0)
+++
trunk/federation/src/main/org/jboss/portal/portlet/federation/FederatedPortletInvoker.java 2007-01-30
02:06:15 UTC (rev 6118)
@@ -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.portlet.federation;
+
+import org.jboss.portal.portlet.PortletInvoker;
+
+/**
+ * Provide access to a federated invoker.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ * @since 2.4
+ */
+public interface FederatedPortletInvoker extends PortletInvoker
+{
+ /**
+ * Return the invoker id.
+ *
+ * @return the invoker id
+ */
+ String getId();
+
+ /**
+ * Return the underlying portlet invoker.
+ *
+ * @return the underlying portlet invoker
+ * @since 2.6
+ */
+ PortletInvoker getPortletInvoker();
+}
Property changes on:
trunk/federation/src/main/org/jboss/portal/portlet/federation/FederatedPortletInvoker.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/federation/src/main/org/jboss/portal/portlet/federation/FederatingPortletInvoker.java
===================================================================
---
trunk/federation/src/main/org/jboss/portal/portlet/federation/FederatingPortletInvoker.java
(rev 0)
+++
trunk/federation/src/main/org/jboss/portal/portlet/federation/FederatingPortletInvoker.java 2007-01-30
02:06:15 UTC (rev 6118)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * 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.portlet.federation;
+
+import org.jboss.portal.portlet.federation.spi.PortletInvokerRegistration;
+import org.jboss.portal.portlet.PortletInvoker;
+
+import java.util.Collection;
+
+/**
+ * A portlet invoker that federates other invokers.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5687 $
+ * @since 2.4
+ */
+public interface FederatingPortletInvoker extends PortletInvoker
+{
+ /**
+ * Register an invoker.
+ *
+ * @param registration the invoker to register
+ * @throws IllegalArgumentException if the invoker is null or already registered
+ */
+ FederatedPortletInvoker registerInvoker(PortletInvokerRegistration registration)
throws IllegalArgumentException;
+
+ /**
+ * Unregister an invoker.
+ *
+ * @param registration the invoker to register
+ * @throws IllegalArgumentException if the invoker is null or already registered
+ */
+ void unregisterInvoker(PortletInvokerRegistration registration) throws
IllegalArgumentException;
+
+ /**
+ * Return a portlet invoker registered or null if not found
+ *
+ * @param id the id
+ * @return the invoker
+ * @throws IllegalArgumentException if the id is null
+ */
+ FederatedPortletInvoker getFederatedInvoker(String id) throws
IllegalArgumentException;
+
+ /**
+ * Return the registered portlet invokers.
+ *
+ * @return a collection that contains the portlet invokers
+ */
+ Collection getFederatedInvokers();
+}
Property changes on:
trunk/federation/src/main/org/jboss/portal/portlet/federation/FederatingPortletInvoker.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatedPortlet.java
===================================================================
---
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatedPortlet.java
(rev 0)
+++
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatedPortlet.java 2007-01-30
02:06:15 UTC (rev 6118)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * 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.portlet.federation.impl;
+
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.info.PortletInfo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class FederatedPortlet implements Portlet
+{
+
+ /** . */
+ final PortletContext compoundContext;
+
+ /** . */
+ final Portlet portlet;
+
+ public FederatedPortlet(PortletContext compoundContext, Portlet portlet)
+ {
+ if (compoundContext == null)
+ {
+ throw new IllegalArgumentException("No null id accepted");
+ }
+ if (portlet == null)
+ {
+ throw new IllegalArgumentException("No null portlet accepted");
+ }
+ this.compoundContext = compoundContext;
+ this.portlet = portlet;
+ }
+
+ public PortletContext getContext()
+ {
+ return compoundContext;
+ }
+
+ public PortletInfo getInfo()
+ {
+ return portlet.getInfo();
+ }
+
+ public boolean isRemote()
+ {
+ return portlet.isRemote();
+ }
+}
Property changes on:
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatedPortlet.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatedPortletInvokerService.java
===================================================================
---
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatedPortletInvokerService.java
(rev 0)
+++
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatedPortletInvokerService.java 2007-01-30
02:06:15 UTC (rev 6118)
@@ -0,0 +1,235 @@
+/******************************************************************************
+ * 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.portlet.federation.impl;
+
+import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.portlet.federation.FederatedPortletInvoker;
+import org.jboss.portal.portlet.federation.FederatingPortletInvoker;
+import org.jboss.portal.portlet.federation.spi.PortletInvokerRegistration;
+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.StateEvent;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.spi.InstanceContext;
+import org.jboss.portal.portlet.state.AccessMode;
+import org.jboss.portal.portlet.state.DestroyCloneFailure;
+import org.jboss.portal.portlet.state.PropertyChange;
+import org.jboss.portal.portlet.state.PropertyMap;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5943 $
+ * @since 2.4
+ */
+public class FederatedPortletInvokerService implements FederatedPortletInvoker
+{
+
+ /** . */
+ private String id;
+
+ /** . */
+ private PortletInvoker portletInvoker;
+
+ /** . */
+ private FederatingPortletInvoker federatingPortletInvoker;
+
+ public FederatedPortletInvokerService(FederatingPortletInvoker
federatingPortletInvoker, PortletInvokerRegistration registration)
+ {
+ this.id = registration.getId();
+ this.portletInvoker = registration.getPortletInvoker();
+ this.federatingPortletInvoker = federatingPortletInvoker;
+ }
+
+ public PortletInvoker getPortletInvoker()
+ {
+ return portletInvoker;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public FederatingPortletInvoker getFederatingPortletInvoker()
+ {
+ return federatingPortletInvoker;
+ }
+
+ public Set getPortlets() throws PortletInvokerException
+ {
+ Set federatedPortlets = new LinkedHashSet();
+ for (Iterator i = portletInvoker.getPortlets().iterator(); i.hasNext();)
+ {
+ Portlet portlet = (Portlet)i.next();
+ Portlet federatedPortlet = new FederatedPortlet(reference(portlet.getContext()),
portlet);
+ federatedPortlets.add(federatedPortlet);
+ }
+ return federatedPortlets;
+ }
+
+ public Portlet getPortlet(PortletContext compoundPortletContext) throws
IllegalArgumentException, PortletInvokerException
+ {
+ // Get portlet context
+ PortletContext portletContext = dereference(compoundPortletContext);
+
+ // Retrieve wrapped portlet
+ Portlet portlet = portletInvoker.getPortlet(portletContext);
+
+ // Return correct result
+ return new FederatedPortlet(compoundPortletContext, portlet);
+ }
+
+ private class FederatedInstanceContext implements InstanceContext
+ {
+
+ /** . */
+ private InstanceContext ctx;
+
+ public FederatedInstanceContext(InstanceContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public String getId()
+ {
+ return ctx.getId();
+ }
+
+ public AccessMode getAccessMode()
+ {
+ return ctx.getAccessMode();
+ }
+
+ public void onStateEvent(StateEvent event)
+ {
+ ctx.onStateEvent(new StateEvent(reference(event.getPortletContext()),
event.getType()));
+ }
+ }
+
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws
InvocationException, PortletInvokerException
+ {
+ PortletContext compoundPortletContext =
(PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE,
PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
+ PortletContext portletContext = dereference(compoundPortletContext);
+ InstanceContext instanceContext = invocation.getInstanceContext();
+ try
+ {
+ invocation.setAttribute(PortletInvocation.REQUEST_SCOPE,
PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portletContext);
+ invocation.setInstanceContext(new FederatedInstanceContext(instanceContext));
+ return portletInvoker.invoke(invocation);
+ }
+ finally
+ {
+ invocation.setAttribute(PortletInvocation.REQUEST_SCOPE,
PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, compoundPortletContext);
+ invocation.setInstanceContext(instanceContext);
+ }
+ }
+
+ public PortletContext createClone(PortletContext compoundPortletContext) throws
PortletInvokerException
+ {
+ PortletContext portletContext = dereference(compoundPortletContext);
+ PortletContext cloneContext = portletInvoker.createClone(portletContext);
+ return reference(cloneContext);
+ }
+
+ public List destroyClones(List portletContexts) throws IllegalArgumentException,
PortletInvokerException, UnsupportedOperationException
+ {
+ if (portletContexts == null)
+ {
+ throw new IllegalArgumentException("Null portlet id list not
accepted");
+ }
+ if (portletContexts.size() == 0)
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ //
+ List dereferencedList = new ArrayList(portletContexts);
+ for (int i = 0; i < dereferencedList.size(); i++)
+ {
+ PortletContext compoundPortletContext =
(PortletContext)dereferencedList.get(i);
+ PortletContext portletContext = dereference(compoundPortletContext);
+ dereferencedList.set(i, portletContext);
+ }
+
+ //
+ List failures = portletInvoker.destroyClones(dereferencedList);
+ for (int i = 0; i < failures.size(); i++)
+ {
+ DestroyCloneFailure failure = (DestroyCloneFailure)failures.get(i);
+ String cloneId = failure.getPortletId();
+ failure = new DestroyCloneFailure(reference(cloneId));
+ failures.set(i, failure);
+ }
+
+ //
+ return failures;
+ }
+
+ public PropertyMap getProperties(PortletContext compoundPortletContext) throws
PortletInvokerException
+ {
+ PortletContext portletId = dereference(compoundPortletContext);
+ return portletInvoker.getProperties(portletId);
+ }
+
+ public PropertyMap getProperties(PortletContext compoundPortletContext, Set keys)
throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ PortletContext portletId = dereference(compoundPortletContext);
+ return portletInvoker.getProperties(portletId, keys);
+ }
+
+ public PortletContext setProperties(PortletContext compoundPortletContext,
PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ PortletContext portletContext = dereference(compoundPortletContext);
+ portletContext = portletInvoker.setProperties(portletContext, changes);
+ return reference(portletContext);
+ }
+
+
+ private PortletContext dereference(PortletContext compoundPortletContext)
+ {
+ String portletId = compoundPortletContext.getId().substring(id.length() + 1);
+ return PortletContext.createPortletContext(portletId,
compoundPortletContext.getState());
+ }
+
+ private PortletContext reference(PortletContext portletContext)
+ {
+ String compoundPortletId = reference(portletContext.getId());
+ return PortletContext.createPortletContext(compoundPortletId,
portletContext.getState());
+ }
+
+ private String reference(String portletId)
+ {
+ return id + FederatingPortletInvokerService.SEPARATOR + portletId;
+ }
+}
+
\ No newline at end of file
Property changes on:
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatedPortletInvokerService.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatingPortletInvokerService.java
===================================================================
---
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatingPortletInvokerService.java
(rev 0)
+++
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatingPortletInvokerService.java 2007-01-30
02:06:15 UTC (rev 6118)
@@ -0,0 +1,258 @@
+/******************************************************************************
+ * 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.portlet.federation.impl;
+
+import org.jboss.portal.portlet.federation.FederatedPortletInvoker;
+import org.jboss.portal.portlet.federation.FederatingPortletInvoker;
+import org.jboss.portal.portlet.federation.spi.PortletInvokerRegistration;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.portlet.InvokerUnavailableException;
+import org.jboss.portal.portlet.NoSuchPortletException;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+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.PropertyChange;
+import org.jboss.portal.portlet.state.PropertyMap;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 5918 $
+ * @since 2.4
+ */
+public class FederatingPortletInvokerService extends AbstractJBossService implements
FederatingPortletInvoker
+{
+
+ /** The separator used in the id to route to the correct invoker. */
+ static final String SEPARATOR = ".";
+
+ /** The registred FederatedPortletInvokers. */
+ private Map registry = new HashMap();
+
+ public synchronized FederatedPortletInvoker registerInvoker(PortletInvokerRegistration
registration)
+ {
+ if (registration == null)
+ {
+ throw new IllegalArgumentException("No null invoker");
+ }
+ String id = registration.getId();
+ if (registry.containsKey(id))
+ {
+ throw new IllegalArgumentException("Attempting dual registration of "
+ id);
+ }
+ Map copy = new HashMap(registry);
+ FederatedPortletInvokerService invoker = new FederatedPortletInvokerService(this,
registration);
+ copy.put(id, invoker);
+ registry = copy;
+ return invoker;
+ }
+
+ public synchronized void unregisterInvoker(PortletInvokerRegistration registration)
+ {
+ if (registration == null)
+ {
+ throw new IllegalArgumentException("No null invoker");
+ }
+ String id = registration.getId();
+ if (id == null)
+ {
+ throw new IllegalArgumentException("No null id accepted");
+ }
+ if (!registry.containsKey(id))
+ {
+ throw new IllegalArgumentException("Attempting to unregister unknown
invoker " + id);
+ }
+ Map copy = new HashMap(registry);
+ copy.remove(id);
+ registry = copy;
+ }
+
+ public FederatedPortletInvoker getFederatedInvoker(String id) throws
IllegalArgumentException
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("No null id provided");
+ }
+ return (FederatedPortletInvoker)registry.get(id);
+ }
+
+ public Collection getFederatedInvokers()
+ {
+ return registry.values();
+ }
+
+ // PortletInvoker implementation
************************************************************************************
+
+ public Set getPortlets() throws PortletInvokerException
+ {
+ LinkedHashSet portlets = new LinkedHashSet();
+ for (Iterator iterator = registry.values().iterator(); iterator.hasNext();)
+ {
+ FederatedPortletInvoker federated = (FederatedPortletInvoker)iterator.next();
+ try
+ {
+ Set offeredPortlets = federated.getPortlets();
+ portlets.addAll(offeredPortlets);
+ }
+ catch (InvokerUnavailableException e)
+ {
+ Throwable cause = e.getCause();
+ log.debug(e.fillInStackTrace());
+ log.warn("PortletInvoker with id: " + federated.getId() + " is
not available.\nReason: " + e.getMessage()
+ + "\nCaused by:\n" + (cause == null ? e : cause));
+ }
+ }
+ return portlets;
+ }
+
+ public Portlet getPortlet(PortletContext compoundPortletContext) throws
IllegalArgumentException, PortletInvokerException
+ {
+ FederatedPortletInvoker federated;
+ try
+ {
+ federated = getFederatedPortletInvokerFor(compoundPortletContext);
+ }
+ catch (NoSuchPortletException e)
+ {
+ log.warn(e);
+ return null;
+ }
+
+ //
+ Portlet portlet = federated.getPortlet(compoundPortletContext);
+
+ //
+ return new FederatedPortlet(compoundPortletContext, portlet);
+ }
+
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException
+ {
+ PortletContext compoundPortletContext =
(PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE,
PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
+ FederatedPortletInvoker federated =
getFederatedPortletInvokerFor(compoundPortletContext);
+ return federated.invoke(invocation);
+ }
+
+ public PortletContext createClone(PortletContext compoundPortletContext) throws
PortletInvokerException
+ {
+ FederatedPortletInvoker federated =
getFederatedPortletInvokerFor(compoundPortletContext);
+ return federated.createClone(compoundPortletContext);
+ }
+
+ public List destroyClones(List portletContexts) throws IllegalArgumentException,
PortletInvokerException, UnsupportedOperationException
+ {
+ if (portletContexts == null)
+ {
+ throw new IllegalArgumentException("No null list accepted");
+ }
+ if (portletContexts.size() == 0)
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ // Get the invoker and check that we address only one invoker (for now)
+ FederatedPortletInvoker invoker = null;
+ for (int i = 0; i < portletContexts.size(); i++)
+ {
+ PortletContext compoundPortletId = (PortletContext)portletContexts.get(i);
+ FederatedPortletInvoker federated =
getFederatedPortletInvokerFor(compoundPortletId);
+ if (invoker == null)
+ {
+ invoker = federated;
+ }
+ else if (invoker.equals(federated) == false)
+ {
+ throw new PortletInvokerException("Cannot destroy portlet lists that
requires more than one federated invoker");
+ }
+ }
+
+ //
+ return invoker.destroyClones(portletContexts);
+ }
+
+ public PropertyMap getProperties(PortletContext compoundPortletContext, Set keys)
throws PortletInvokerException
+ {
+ FederatedPortletInvoker federated =
getFederatedPortletInvokerFor(compoundPortletContext);
+ return federated.getProperties(compoundPortletContext, keys);
+ }
+
+ public PropertyMap getProperties(PortletContext compoundPortletContext) throws
PortletInvokerException
+ {
+ FederatedPortletInvoker federated =
getFederatedPortletInvokerFor(compoundPortletContext);
+ return federated.getProperties(compoundPortletContext);
+ }
+
+ public PortletContext setProperties(PortletContext compoundPortletContext,
PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ FederatedPortletInvoker federated =
getFederatedPortletInvokerFor(compoundPortletContext);
+ return federated.setProperties(compoundPortletContext, changes);
+ }
+
+ // Support methods
**************************************************************************************************
+
+ /**
+ * Retrieves the portlet invoker associated with the specified compound portlet id or
null if it is not found.
+ *
+ * @param compoundPortletContext the portlet context for which the invoker is to be
retrieved
+ * @return the portlet invoker associated with the specified compound portlet id
+ * @throws IllegalArgumentException if the compound portlet id is not well formed or
null
+ */
+ private FederatedPortletInvoker getFederatedPortletInvokerFor(PortletContext
compoundPortletContext) throws IllegalArgumentException, NoSuchPortletException
+ {
+ if (compoundPortletContext == null)
+ {
+ throw new IllegalArgumentException("No null portlet id accepted");
+ }
+
+ //
+ String compoundPortletId = compoundPortletContext.getId();
+
+ //
+ int pos = compoundPortletId.indexOf(SEPARATOR);
+ if (pos == -1)
+ {
+ throw new IllegalArgumentException("Bad portlet id format " +
compoundPortletId);
+ }
+
+ //
+ String invokerId = compoundPortletId.substring(0, pos);
+ FederatedPortletInvoker federated =
(FederatedPortletInvoker)registry.get(invokerId);
+ if (federated == null)
+ {
+ throw new NoSuchPortletException(compoundPortletId);
+ }
+
+ //
+ return federated;
+ }
+}
Property changes on:
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/FederatingPortletInvokerService.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/PortletInvokerRegistrationService.java
===================================================================
---
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/PortletInvokerRegistrationService.java
(rev 0)
+++
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/PortletInvokerRegistrationService.java 2007-01-30
02:06:15 UTC (rev 6118)
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * 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.portlet.federation.impl;
+
+import org.jboss.portal.portlet.federation.FederatingPortletInvoker;
+import org.jboss.portal.portlet.federation.spi.PortletInvokerRegistration;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.portlet.PortletInvoker;
+
+/**
+ * Register any portlet invoker into a federating portlet invoker.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ * @since 2.4
+ */
+public class PortletInvokerRegistrationService extends AbstractJBossService implements
PortletInvokerRegistration
+{
+
+ /** The registration id. */
+ private String id;
+
+ /** The portlet invoker to register. */
+ private PortletInvoker portletInvoker;
+
+ /** The federating portlet invoker. */
+ private FederatingPortletInvoker federatingPortletInvoker;
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public PortletInvoker getPortletInvoker()
+ {
+ return portletInvoker;
+ }
+
+ public void setPortletInvoker(PortletInvoker portletInvoker)
+ {
+ this.portletInvoker = portletInvoker;
+ }
+
+ public FederatingPortletInvoker getFederatingPortletInvoker()
+ {
+ return federatingPortletInvoker;
+ }
+
+ public void setFederatingPortletInvoker(FederatingPortletInvoker
federatingPortletInvoker)
+ {
+ this.federatingPortletInvoker = federatingPortletInvoker;
+ }
+
+ protected void startService() throws Exception
+ {
+ federatingPortletInvoker.registerInvoker(this);
+ }
+
+ protected void stopService() throws Exception
+ {
+ federatingPortletInvoker.unregisterInvoker(this);
+ }
+}
Property changes on:
trunk/federation/src/main/org/jboss/portal/portlet/federation/impl/PortletInvokerRegistrationService.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/federation/src/main/org/jboss/portal/portlet/federation/spi/PortletInvokerRegistration.java
===================================================================
---
trunk/federation/src/main/org/jboss/portal/portlet/federation/spi/PortletInvokerRegistration.java
(rev 0)
+++
trunk/federation/src/main/org/jboss/portal/portlet/federation/spi/PortletInvokerRegistration.java 2007-01-30
02:06:15 UTC (rev 6118)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * 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.portlet.federation.spi;
+
+import org.jboss.portal.portlet.PortletInvoker;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public interface PortletInvokerRegistration
+{
+ /**
+ * Return the invoker id.
+ *
+ * @return the invoker id
+ */
+ String getId();
+
+ /**
+ * Return the invoker.
+ *
+ * @return the invoker
+ */
+ PortletInvoker getPortletInvoker();
+}
Property changes on:
trunk/federation/src/main/org/jboss/portal/portlet/federation/spi/PortletInvokerRegistration.java
___________________________________________________________________
Name: svn:executable
+ *