Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, a division of Red Hat
   * Copyright 2011, 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.gatein.wsrp.producer;
 
import  org.slf4j.Logger;
import  org.slf4j.LoggerFactory;

Author(s):
Chris Laprun
Version:
$Revision: 12286 $
Since:
2.4
public class WSRPProducerImpl implements WSRP2ProducerProducerHelper
{
   
logger used for logging ;)
   private static final Logger log = LoggerFactory.getLogger(WSRPProducerImpl.class);

   
The invoker used to retrieve portlet information and invoke methods.
   private PortletInvoker invoker;

   
Handles Markup interface calls.
   private final MarkupHandler markupHandler;

   
Handles ServiceDescription interface calls.
Handles Registration interface calls.
   private final RegistrationHandler registrationHandler;

   
Handles Portlet Management interface calls.
Registration Manager
   private RegistrationManager registrationManager//todo: make sure it's multi-thread safe

   
configuration service
   private ProducerConfigurationService configurationService//todo: make sure it's multi-thread safe

   
export manager
   private ExportManager exportManager;

   
producer context
   private boolean started = false;
   // On-demand class holder Singleton pattern (multi-thread safe)
   private static final class InstanceHolder
   {
      public static final WSRPProducerImpl producer = new WSRPProducerImpl();
   }
   {
      return .;
   }
   static boolean isProducerStarted()
   {
      return ..;
   }
   private WSRPProducerImpl()
   {
       = new MarkupHandler(this);
       = new RegistrationHandler(this);
      DefaultProducerExtensionAccessor.registerWithAPI();
   }
   {
   }
   // ServiceDescription implementation ********************************************************************************
   {
   }
   // MarkupService implementation *************************************************************************************
   {
      return .getMarkup(getMarkup);
   }
   {
      return .performBlockingInteraction(performBlockingInteraction);
   }
   {
      return .releaseSessions(releaseSessions);
   }
   {
      return .initCookie(initCookie);
   }
   {
      return .handleEvents(handleEvents);
   }
   {
      return .getResource(getResource);
   }
   // Registration implementation **************************************************************************************
   {
      return .register(register);
   }
   {
      return .deregister(deregister);
   }
   public RegistrationState modifyRegistration(ModifyRegistration modifyRegistrationthrows MissingParameters,
   {
      return .modifyRegistration(modifyRegistration);
   }
   {
      return .getRegistrationLifetime(getRegistrationLifetime);
   }
   {
      return .setRegistrationLifetime(setRegistrationLifetime);
   }
   // PortletManagement implementation *********************************************************************************
   {
      return .getPortletDescription(getPortletDescription);
   }
   {
      return .clonePortlet(clonePortlet);
   }
   {
      return .destroyPortlets(destroyPortlets);
   }
   public PortletContext setPortletProperties(SetPortletProperties setPortletPropertiesthrows OperationFailed,
   {
      return .setPortletProperties(setPortletProperties);
   }
   public PropertyList getPortletProperties(GetPortletProperties getPortletPropertiesthrows InvalidHandle,
   {
      return .getPortletProperties(getPortletProperties);
   }
   {
      return .getPortletPropertyDescription(getPortletPropertyDescription);
   }
   {
      return .getPortletsLifetime(getPortletsLifetime);
   }
   {
      return .setPortletsLifetime(setPortletsLifetime);
   }
   {
      return .copyPortlets(copyPortlets);
   }
   {
      return .exportPortlets(exportPortlets);
   }
   {
      return .importPortlets(importPortlets);
   }
   public List<ExtensionreleaseExport(ReleaseExport releaseExport)
   {
      return .releaseExport(releaseExport);
   }
   {
      return .setExportLifetime(setExportLifetime);
   }
   {
   }
   {
      return ;
   }
   public void setRegistrationManager(RegistrationManager registrationManager)
   {
      this. = registrationManager;
   }
   public void setConfigurationService(ProducerConfigurationService configurationService)
   {
      this. = configurationService;
   }
   {
      return ;
   }
   public void setExportManager(ExportManager exportManger)
   {
      this. = exportManger;
   }
   {
      return ;
   }
   public void setProducerContext(ProducerContext producerContext)
   {
      this. = producerContext;
   }
   {
      if ( == null)
      {
          = new ExportManagerImpl();
      }
      return ;
   }
   public synchronized void start()
   {
      if (!)
      {
         ProducerConfiguration configuration = .getConfiguration();
         // register to listen to changes in configuration and get initial state
         configuration.addChangeListener(this);
         usingStrictModeChangedTo(configuration.isUsingStrictMode());
         ProducerRegistrationRequirements registrationRequirements = getProducerRegistrationRequirements();
         registrationRequirements.addRegistrationPolicyChangeListener();
         registrationRequirements.addRegistrationPropertyChangeListener();
         .setPolicy(registrationRequirements.getPolicy());
          = true;
      }
   }
   public synchronized void stop()
   {
      if ()
      {
         ProducerRegistrationRequirements registrationRequirements = getProducerRegistrationRequirements();
         registrationRequirements.removeRegistrationPropertyChangeListener();
         registrationRequirements.removeRegistrationPolicyChangeListener();
          = false;
      }
   }
   {
   }
   {
   }
   {
      return ;
   }
   public void setPortletInvoker(PortletInvoker invoker)
   {
      this. = invoker;
   }
   public Portlet getPortletWith(org.gatein.pc.api.PortletContext portletContextRegistration registrationthrows InvalidHandlePortletInvokerException
   {
      Portlet portlet;
      try
      {
         RegistrationLocal.setRegistration(registration);
         portlet = .getPortlet(portletContext);
      }
      catch (NoSuchPortletException e)
      {
         throw WSRP2ExceptionFactory.throwWSException(InvalidHandle.class"Couldn't find portlet with handle '" + portletContext.getId() + "'"e);
      }
      finally
      {
         RegistrationLocal.setRegistration(null);
      }
      if (!isRemotable(portlet))
      {
         throw WSRP2ExceptionFactory.throwWSException(InvalidHandle.class"Portlet '" + portletContext.getId() + "' is not remotely available."null);
      }
      return portlet;
   }
   {
      .debug("Retrieving remotable portlets");
      Set<PortletallPortlets = .getPortlets();
      int portletNumber = allPortlets.size();
      Set<PortletremotablePortlets = Collections.emptySet();
      if (portletNumber > 0)
      {
         remotablePortlets = new HashSet<Portlet>(portletNumber);
         for (Portlet portlet : allPortlets)
         {
            .debug("Found portlet: " + portlet.getContext());
            if (isRemotable(portlet))
            {
               remotablePortlets.add(portlet);
               .debug("Adding remotable portlet to set: " + portlet.getContext());
            }
         }
      }
      return remotablePortlets;
   }
   public PortletDescription getPortletDescription(PortletContext portletContextList<StringlocalesRegistration registrationthrows InvalidHandleOperationFailed
   {
      return .getPortletDescription(portletContextlocalesregistration);
   }
   {
      Registration registration = .getRegistrationFrom(registrationContext);
      .isRegistrationValid(registrationtrue);
      return registration;
   }
   public void reset()
   {
   }
   {
      return ;
   }
   public void setRemotableByDefault(Boolean remotableByDefault)
   {
      this. = remotableByDefault;
   }
   private boolean isRemotable(Portlet portlet)
   {
      Map<StringRuntimeOptionInforuntimeOptions = portlet.getInfo().getRuntimeOptionsInfo();
      return .isRemotable(runtimeOptions);
   }
   {
      if ( != null)
      {
      }
      else
      {
         return WSRPConstants.getDefaultLocales();
      }
   }
   public void usingStrictModeChangedTo(boolean strictMode)
   {
      WSRPValidator.setStrict(strictMode);
   }
   // access to handlers for tests
   {
      return ;
   }
   {
      return ;
   }
   {
      return ;
   }
   {
      return ;
   }
   public void onEvent(ManagedObjectRegistryEvent event)
   {
   }
New to GrepCode? Check out our FAQ X