User: user57  
  Date: 02/02/13 01:13:35

  Modified:    src/main/org/jboss/invocation/local LocalInvoker.java
  Log:
   o Added Invocation.INVOKE_SIGNATURE so we don't have to keep creating
     new String[]'s
   o Cleaned up LocalInvoker to use the ServiceMBeanSupport class properly
  
  Revision  Changes    Path
  1.5       +52 -108   jboss/src/main/org/jboss/invocation/local/LocalInvoker.java
  
  Index: LocalInvoker.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/invocation/local/LocalInvoker.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LocalInvoker.java 7 Feb 2002 07:48:49 -0000       1.4
  +++ LocalInvoker.java 13 Feb 2002 09:13:34 -0000      1.5
  @@ -1,11 +1,11 @@
   /*
  -* JBoss, the OpenSource J2EE webOS
  -*
  -* Distributable under LGPL license.
  -* See terms of license at gnu.org.
  -*/
  -package org.jboss.invocation.local;
  + * JBoss, the OpenSource J2EE webOS
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   
  +package org.jboss.invocation.local;
   
   import java.net.InetAddress;
   import javax.management.ObjectName;
  @@ -24,140 +24,84 @@
   import org.jboss.logging.Logger;
   
   /**
  -*  The Invoker is a local gate in the JMX system.
  -*  
  -*  @author <a href="mailto:[EMAIL PROTECTED]>Marc Fleury</a>
  -*
  -*  @version $Revision: 1.4 $
  -*
  -*/
  -
  + * The Invoker is a local gate in the JMX system.
  + *  
  + * @author <a href="mailto:[EMAIL PROTECTED]>Marc Fleury</a>
  + * @version $Revision: 1.5 $
  + */
   public class LocalInvoker
  -extends ServiceMBeanSupport
  -implements Invoker, LocalInvokerMBean
  +   extends ServiceMBeanSupport
  +   implements Invoker, LocalInvokerMBean
   {
  -   // Constants -----------------------------------------------------
  -   protected static Logger log = Logger.getLogger(LocalInvoker.class);
  -   
  -   // Attributes ----------------------------------------------------
  -   
  -   // The MBean Server
  -   protected MBeanServer server;
  -   
  -   // The ObjectName for the local invoker
  -   protected ObjectName name;
  -   // Static --------------------------------------------------------
  -   
  -   // Constructors --------------------------------------------------
  -   
  -   // Public --------------------------------------------------------
  -   
  -   // Service implementation -------------------------------
  -   
  -   public String getName() { return "LocalInvoker";}
  -   
  -   public void create()
  -   throws Exception
  +   protected void createService() throws Exception
      {
  -      //note on design: We need to call it ourselves as opposed to letting the 
client JRMPDelegate look it 
  -      // up through the use of Registry, the reason being including the classes in 
the client. 
  -      // If we move to a JNDI format (with local calls) for the registry we could 
remove the call below
  +      // note on design: We need to call it ourselves as opposed to 
  +      // letting the client JRMPDelegate look it 
  +      // up through the use of Registry, the reason being including
  +      // the classes in the client. 
  +      // If we move to a JNDI format (with local calls) for the
  +      // registry we could remove the call below
         JRMPInvokerProxy.setLocal(this);
         
  -      Registry.bind(name, this);
  +      Registry.bind(serviceName, this);
      }
      
  -   
  -   public void start()
  -   throws Exception
  +   protected void startService() throws Exception
      {
  -      
  -      GenericProxy.setTransactionManager((TransactionManager)new 
InitialContext().lookup("java:/TransactionManager"));
  -      
  +      InitialContext ctx = new InitialContext();
  +      try {
  +         TransactionManager tm = 
(TransactionManager)ctx.lookup("java:/TransactionManager");
  +         GenericProxy.setTransactionManager(tm);
  +      }
  +      finally {
  +         ctx.close();
  +      }
  +         
         log.debug("Local invoker for JMX node started");
      }
      
  -   public void stop()
  -   {
  -   }
  -   
  -   public void destroy()
  +   protected void destroyService()
      {
  -      Registry.unbind(name);
  +      Registry.unbind(serviceName);
      }
      
      // Invoker implementation --------------------------------
      
      public String getServerHostName() 
      { 
  -      try {return InetAddress.getLocalHost().getHostName();}
  -         
  -      catch (Exception ignored) {return null;}
  +      try {
  +         return InetAddress.getLocalHost().getHostName();
  +      }
  +      catch (Exception ignored) {
  +         return null;
  +      }
      }
      
  -   
      /**
  -   *  Invoke a  method.
  -   */
  -   public Object invoke(Invocation invocation)
  -   throws Exception
  +    * Invoke a method.
  +    */
  +   public Object invoke(Invocation invocation) throws Exception
      {     
  -      
         ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
         
         try
         {         
  +         ObjectName mbean = (ObjectName)
  +            Registry.lookup((Integer)invocation.getContainer());
            
  -         
  -         ObjectName mbean = (ObjectName) Registry.lookup((Integer) 
invocation.getContainer());
  -        
  -         return server.invoke(mbean, "",  new Object[] {invocation}, new String[] 
{"java.lang.Object"}); 
  +         return server.invoke(mbean,
  +                              "",
  +                              new Object[] { invocation },
  +                              Invocation.INVOKE_SIGNATURE);
  +      }
  +      catch (MBeanException e)
  +      {
  +         throw e.getTargetException();
         }
  -      
  -      catch (MBeanException mbe) { throw mbe.getTargetException(); }
  -      
         finally
         {
            Thread.currentThread().setContextClassLoader(oldCl);
         }      
      }
  -   
  -   // Package protected ---------------------------------------------
  -   
  -   // Protected -----------------------------------------------------
  -   
  -   // Private -------------------------------------------------------
  -   
  -   // MBeanRegistration implementation 
-------------------------------------------------------
  -   
  -   public ObjectName preRegister(MBeanServer server, ObjectName name)
  -   throws Exception
  -   {
  -      this.server = server;
  -      
  -      this.name = name;
  -      
  -      log.info("Local Invoker MBean online");
  -      //return name == null ? new ObjectName(OBJECT_NAME) : name;
  -      return name;
  -   }
  -   
  -   public void postRegister(Boolean registrationDone)
  -   {
  -      if (!registrationDone.booleanValue())
  -      {
  -         log.info( "Registration of JRMP Invoker MBean failed" );
  -      }
  -   }
  -   
  -   public void preDeregister()
  -   throws Exception
  -   {
  -   }
  -   
  -   public void postDeregister()
  -   {
  -   }
  -   // Inner classes -------------------------------------------------
   }
   
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to