Package org.exoplatform.services.rpc

Examples of org.exoplatform.services.rpc.RemoteCommand


            if (LOG.isTraceEnabled())
               LOG.trace("Command : " + commandId + " needs to be executed on the coordinator " +
                     "only and the local node is not the coordinator, the command will be ignored");
            return null;
         }
         RemoteCommand command = getCommand(commandId);
         if (command == null)
         {
            return new RPCException("Command " + commandId + " unkown, please register your command first");
         }
         Object execResult = command.execute(body.getArgs());
         if (LOG.isTraceEnabled())
            LOG.trace("Command : " + commandId + " executed, result is: " + execResult);
         return execResult;
      }
      catch (Throwable x)
View Full Code Here


         if (commandId == null)
         {
            throw new IllegalArgumentException("The command Id cannot be null");
         }
         Map<String, RemoteCommand> tmpCommands = new HashMap<String, RemoteCommand>(this.commands);
         RemoteCommand oldCommand = tmpCommands.put(commandId, command);
         if (oldCommand != null && PropertyManager.isDevelopping())
         {
            LOG.warn("A command has already been registered with the id " + commandId
               + ", this command will be replaced with the new one");
         }
View Full Code Here

      this.initialContextInitializer = initialContextInitializer;

      if (rpcService != null)
      {
         // register commands
         reserveRepositoryName = rpcService.registerCommand(new RemoteCommand()
         {

            public String getId()
            {
               return "org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationServiceImpl-reserveRepositoryName";
            }

            public Serializable execute(Serializable[] args) throws Throwable
            {
               String repositoryName = (String)args[0];
               return reserveRepositoryNameLocally(repositoryName);
            }
         });

         createRepository = rpcService.registerCommand(new RemoteCommand()
         {

            public String getId()
            {
               return "org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationServiceImpl-createRepository";
            }

            public Serializable execute(Serializable[] args) throws Throwable
            {
               String backupId = (String)args[0];
               String stringRepositoryEntry = (String)args[1];
               String rToken = (String)args[2];
               DBCreationProperties creationProps = (DBCreationProperties)args[3];

               try
               {
                  RepositoryEntry rEntry =
                     (RepositoryEntry)(getObject(RepositoryEntry.class,
                        stringRepositoryEntry.getBytes(Constants.DEFAULT_ENCODING)));

                  createRepositoryLocally(backupId, rEntry, rToken, creationProps);
                  return null;
               }
               finally
               {
                  // release tokens
                  pendingRepositories.remove(rToken);
               }
            }
         });

         startRepository = rpcService.registerCommand(new RemoteCommand()
         {
            public String getId()
            {
               return "org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationServiceImpl-startRepository";
            }

            public Serializable execute(Serializable[] args) throws Throwable
            {
               // must not be executed on coordinator node, since coordinator node already created the repository
               if (!rpcService.isCoordinator())
               {
                  //RepositoryEntry (as String) rEntry
                  String stringRepositoryEntry = (String)args[0];
                  RepositoryEntry rEntry =
                     (RepositoryEntry)(getObject(RepositoryEntry.class,
                        stringRepositoryEntry.getBytes(Constants.DEFAULT_ENCODING)));

                  DBCreationProperties creationProps = (DBCreationProperties)args[1];

                  startRepository(rEntry, creationProps);
               }
               return null;
            }
         });

         removeRepository = rpcService.registerCommand(new RemoteCommand()
         {
            public String getId()
            {
               return "org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationServiceImpl-removeRepository";
            }

            public Serializable execute(Serializable[] args) throws Throwable
            {
               String repositoryName = (String)args[0];
               Boolean forceRemove = (Boolean)args[1];

               removeRepositoryLocally(repositoryName, forceRemove);

               return null;
            }
         });

         canRemoveRepository = rpcService.registerCommand(new RemoteCommand()
         {
            public String getId()
            {
               return "org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationServiceImpl-checkRepositoryInUse";
            }
View Full Code Here

      ValueParam paramConf = new ValueParam();
      paramConf.setName(RPCServiceImpl.PARAM_JGROUPS_CONFIG);
      paramConf.setValue("jar:/conf/portal/udp.xml");     
      params.addParameter(paramConf);
      RPCServiceImpl service = null;
      RemoteCommand foo  = new RemoteCommand()
      {
        
         public String getId()
         {
            return "foo";
View Full Code Here

      params.addParameter(paramConf);
      RPCServiceImpl service = null;
      try
      {
         service = new RPCServiceImpl(container.getContext(), params, configManager);
         RemoteCommand fake = new RemoteCommand()
         {
           
            public String getId()
            {
               return "fake";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               return null;
            }
         };
         RemoteCommand fake2 = new RemoteCommand()
         {
           
            public String getId()
            {
               return "fake2";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               return null;
            }
         };
         RemoteCommand fake2_Unregistered = new RemoteCommand()
         {
           
            public String getId()
            {
               return "fake2";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               return null;
            }
         };        
         service.registerCommand(fake2);
         RemoteCommand Exception = new RemoteCommand()
         {
           
            public String getId()
            {
               return "Exception";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               throw new Exception("MyException");
            }
         };
         service.registerCommand(Exception);
         RemoteCommand Error = new RemoteCommand()
         {
           
            public String getId()
            {
               return "Error";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               throw new Error("MyError");
            }
         } ;
         service.registerCommand(Error);
         RemoteCommand StringValue = new RemoteCommand()
         {
           
            public String getId()
            {
               return "StringValue";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               return "OK";
            }
         };        
         service.registerCommand(StringValue);
         RemoteCommand NullValue = new RemoteCommand()
         {
           
            public String getId()
            {
               return "NullValue";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               return null;
            }
         };        
         service.registerCommand(NullValue);
         RemoteCommand LongTask = new RemoteCommand()
         {
           
            public String getId()
            {
               return "LongTask";
View Full Code Here

      RPCServiceImpl service1 = null, service2 = null;     
      try
      {
         service1 = new RPCServiceImpl(container.getContext(), params, configManager);
         service2 = new RPCServiceImpl(container.getContext(), params, configManager);
         RemoteCommand CmdUnknownOnNode2 = new RemoteCommand()
         {
           
            public String getId()
            {
               return "CmdUnknownOnNode2";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               return "OK";
            }
         };
         service1.registerCommand(CmdUnknownOnNode2);
         RemoteCommand ExceptionOnNode2 = new RemoteCommand()
         {
           
            public String getId()
            {
               return "ExceptionOnNode2";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               return "OK";
            }
         };        
         service1.registerCommand(ExceptionOnNode2);
         RemoteCommand ErrorOnNode2 = new RemoteCommand()
         {
           
            public String getId()
            {
               return "ErrorOnNode2";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               return "OK";
            }
         };          
         service1.registerCommand(ErrorOnNode2);
       
         RemoteCommand LongTaskOnNode2 = new RemoteCommand()
         {
           
            public String getId()
            {
               return "LongTaskOnNode2";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               return "OK";
            }
         };          
         service1.registerCommand(LongTaskOnNode2);
         service1.registerCommand(new RemoteCommand()
         {
           
            public String getId()
            {
               return "LongTask";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               Thread.sleep(3000);
               return "OldCoordinator";
            }
         });
         service1.registerCommand(new RemoteCommand()
         {
           
            public String getId()
            {
               return "OK";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               return "OK";
            }
         });        
         service2.registerCommand(new RemoteCommand()
         {
           
            public String getId()
            {
               return "ExceptionOnNode2";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               throw new Exception("MyException");
            }
         });
         service2.registerCommand(new RemoteCommand()
         {
           
            public String getId()
            {
               return "ErrorOnNode2";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               throw new Error("MyError");
            }
         });
         service2.registerCommand(new RemoteCommand()
         {
           
            public String getId()
            {
               return "LongTaskOnNode2";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               Thread.sleep(2000);
               return null;
            }
         });
         RemoteCommand OK = new RemoteCommand()
         {
           
            public String getId()
            {
               return "OK";
            }
           
            public String execute(Serializable[] args) throws Throwable
            {
               return "OK";
            }
         };
         service2.registerCommand(OK);
         final RemoteCommand LongTask = new RemoteCommand()
         {
           
            public String getId()
            {
               return "LongTask";
View Full Code Here

      params.addParameter(paramConf);
      RPCServiceImpl service = null;
      try
      {
         service = new RPCServiceImpl(container.getContext(), params, configManager);
         RemoteCommand getName = service.registerCommand(new SingleMethodCallCommand(myService, "getName"));
         RemoteCommand add = service.registerCommand(new SingleMethodCallCommand(myService, "add", int.class));
         RemoteCommand evaluate1 = service.registerCommand(new SingleMethodCallCommand(myService, "evaluate", int[].class));
         RemoteCommand evaluate2 = service.registerCommand(new SingleMethodCallCommand(myService, "evaluate", List.class));
         RemoteCommand total1 = service.registerCommand(new SingleMethodCallCommand(myService, "total", int.class));
         RemoteCommand total2 = service.registerCommand(new SingleMethodCallCommand(myService, "total", int.class, int.class));
         RemoteCommand total3 = service.registerCommand(new SingleMethodCallCommand(myService, "total", int[].class));
         RemoteCommand total4 = service.registerCommand(new SingleMethodCallCommand(myService, "total", String.class, long.class, int[].class));
         RemoteCommand testTypes1 = service.registerCommand(new SingleMethodCallCommand(myService, "testTypes", String[].class));
         RemoteCommand testTypes2 = service.registerCommand(new SingleMethodCallCommand(myService, "testTypes", int[].class));
         RemoteCommand testTypes3 = service.registerCommand(new SingleMethodCallCommand(myService, "testTypes", long[].class));
         RemoteCommand testTypes4 = service.registerCommand(new SingleMethodCallCommand(myService, "testTypes", byte[].class));
         RemoteCommand testTypes5 = service.registerCommand(new SingleMethodCallCommand(myService, "testTypes", short[].class));
         RemoteCommand testTypes6 = service.registerCommand(new SingleMethodCallCommand(myService, "testTypes", char[].class));
         RemoteCommand testTypes7 = service.registerCommand(new SingleMethodCallCommand(myService, "testTypes", double[].class));
         RemoteCommand testTypes8 = service.registerCommand(new SingleMethodCallCommand(myService, "testTypes", float[].class));
         RemoteCommand testTypes9 = service.registerCommand(new SingleMethodCallCommand(myService, "testTypes", boolean[].class));

         service.start();
         List<Object> result;
        
         assertEquals("name", service.executeCommandOnCoordinator(getName, true));
View Full Code Here

      RPCServiceImpl service1 = null;
      RPCServiceImpl service2 = null;
      try
      {
         service1 = new RPCServiceImpl(container.getContext(), params, configManager);
         RemoteCommand service1Cmd = new RemoteCommand()
         {
            public String getId()
            {
               return "CoordinatorExecutedCommand";
            }

            public String execute(Serializable[] args) throws Throwable
            {
               calledCommands.add(Boolean.TRUE);
               return "service 1";
            }
         };
         service1.registerCommand(service1Cmd);

         service2 = new RPCServiceImpl(container.getContext(), params, configManager);
         RemoteCommand service2Cmd = new RemoteCommand()
         {
            public String getId()
            {
               return "CoordinatorExecutedCommand";
            }
View Full Code Here

   private void initRemoteCommands()
   {
      if (rpcService != null)
      {
         // register commands
         suspend = rpcService.registerCommand(new RemoteCommand()
         {

            public String getId()
            {
               return "org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager-suspend-"
                  + dataContainer.getUniqueName();
            }

            public Serializable execute(Serializable[] args) throws Throwable
            {
               suspendLocally();
               return null;
            }
         });

         resume = rpcService.registerCommand(new RemoteCommand()
         {

            public String getId()
            {
               return "org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager-resume-"
                  + dataContainer.getUniqueName();
            }

            public Serializable execute(Serializable[] args) throws Throwable
            {
               resumeLocally();
               return null;
            }
         });

         requestForResponsibleForResuming = rpcService.registerCommand(new RemoteCommand()
         {

            public String getId()
            {
               return "org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager"
View Full Code Here

      ValueParam paramConf = new ValueParam();
      paramConf.setName(RPCServiceImpl.PARAM_JGROUPS_CONFIG);
      paramConf.setValue("jar:/conf/portal/udp.xml");     
      params.addParameter(paramConf);
      RPCServiceImpl service = null;
      RemoteCommand foo  = new RemoteCommand()
      {
        
         public String getId()
         {
            return "foo";
View Full Code Here

TOP

Related Classes of org.exoplatform.services.rpc.RemoteCommand

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.