Package org.exoplatform.container.component

Examples of org.exoplatform.container.component.ComponentPlugin


         public Void execute(final CreationalContextComponentAdapter<?> cCtx) throws Exception
         {
            try
            {
               getContainer().loadArguments(args);
               ComponentPlugin cplugin = (ComponentPlugin)constructor.newInstance(args);
               cplugin.setName(plugin.getName());
               cplugin.setDescription(plugin.getDescription());
               Class<?> clazz = getComponentImplementation();

               final Method m = getSetMethod(clazz, plugin.getSetMethod(), pluginClass);
               if (m == null)
               {
                  LOG.error("Cannot find the method '" + plugin.getSetMethod()
                     + "' that has only one parameter of type '" + pluginClass.getName() + "' in the class '"
                     + clazz.getName() + "'.");
                  return null;
               }
               final Object[] params = {cplugin};

               SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
               {
                  public Void run() throws Exception
                  {
                     m.invoke(cCtx.get(), params);
                     return null;
                  }
               });

               if (debug)
                  LOG.debug("==> add component plugin: " + cplugin);

               cplugin.setName(plugin.getName());
               cplugin.setDescription(plugin.getDescription());
               return null;
            }
            catch (InvocationTargetException e)
            {
               if (e.getCause() instanceof Exception)
View Full Code Here


      assertTrue(tenants.observers.size() == 0);
   }

   public void testAddSupportedPlugin()
   {
      ComponentPlugin plugin = new SupportedPlugin();
      tenants.addPlugin(plugin);
      assertTrue(tenants.lookups.contains(plugin));
   }
View Full Code Here

      assertTrue(tenants.lookups.contains(plugin));
   }

   public void testAddNotSupportedPlugin()
   {
      ComponentPlugin plugin = new NotSupportedPlugin();
      tenants.addPlugin(plugin);
      assertFalse(tenants.lookups.contains(plugin));
   }
View Full Code Here

      {

         try
         {
            Class pluginClass = Class.forName(plugin.getType());
            ComponentPlugin cplugin = (ComponentPlugin)container.createComponent(pluginClass, plugin.getInitParams());
            cplugin.setName(plugin.getName());
            cplugin.setDescription(plugin.getDescription());
            Class clazz = component.getClass();

            final Method m = getSetMethod(clazz, plugin.getSetMethod(), pluginClass);
            if (m == null)
            {
               LOG.error("Cannot find the method '" + plugin.getSetMethod() + "' that has only one parameter of type '"
                  + pluginClass.getName() + "' in the class '" + clazz.getName() + "'.");
               continue;
            }
            final Object[] params = {cplugin};

            SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
            {
               public Void run() throws Exception
               {
                  m.invoke(component, params);
                  return null;
               }
            });

            if (debug)
               LOG.debug("==> add component plugin: " + cplugin);

            cplugin.setName(plugin.getName());
            cplugin.setDescription(plugin.getDescription());
         }
         catch (Exception ex)
         {
            LOG.error(
               "Failed to instanciate plugin " + plugin.getName() + " for component " + component + ": "
View Full Code Here

      {

         try
         {
            Class pluginClass = Class.forName(plugin.getType());
            ComponentPlugin cplugin = (ComponentPlugin)container.createComponent(pluginClass, plugin.getInitParams());
            cplugin.setName(plugin.getName());
            cplugin.setDescription(plugin.getDescription());
            Class clazz = component.getClass();

            final Method m = getSetMethod(clazz, plugin.getSetMethod(), pluginClass);
            if (m == null)
            {
               log.error("Cannot find the method '" + plugin.getSetMethod() + "' that has only one parameter of type '"
                  + pluginClass.getName() + "' in the class '" + clazz.getName() + "'.");
               continue;
            }
            final Object[] params = {cplugin};

            SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
            {
               public Void run() throws Exception
               {
                  m.invoke(component, params);
                  return null;
               }
            });

            if (debug)
               log.debug("==> add component plugin: " + cplugin);

            cplugin.setName(plugin.getName());
            cplugin.setDescription(plugin.getDescription());
         }
         catch (Exception ex)
         {
            log.error("Failed to instanciate plugin " + plugin.getName() + " for component " + component + ": "
               + ex.getMessage(), ex);
View Full Code Here

      {

         try
         {
            Class<?> pluginClass = Tools.forName(plugin.getType(), this);
            ComponentPlugin cplugin = (ComponentPlugin)container.createComponent(pluginClass, plugin.getInitParams());
            cplugin.setName(plugin.getName());
            cplugin.setDescription(plugin.getDescription());
            Class<?> clazz = component.getClass();

            final Method m = getSetMethod(clazz, plugin.getSetMethod(), pluginClass);
            if (m == null)
            {
               log.error("Cannot find the method '" + plugin.getSetMethod() + "' that has only one parameter of type '"
                  + pluginClass.getName() + "' in the class '" + clazz.getName() + "'.");
               continue;
            }
            final Object[] params = {cplugin};

            SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
            {
               public Void run() throws Exception
               {
                  m.invoke(component, params);
                  return null;
               }
            });

            if (debug)
               log.debug("==> add component plugin: " + cplugin);

            cplugin.setName(plugin.getName());
            cplugin.setDescription(plugin.getDescription());
         }
         catch (Exception ex)
         {
            log.error("Failed to instanciate plugin " + plugin.getName() + " for component " + component + ": "
               + ex.getMessage(), ex);
View Full Code Here

TOP

Related Classes of org.exoplatform.container.component.ComponentPlugin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.