Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * IronJacamar, a Java EE Connector Architecture implementation
    * Copyright 2012, Red Hat Inc, and individual contributors
    * as indicated by the @author tags. See the copyright.txt file 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.jca.core.workmanager.transport.remote.jgroups;
  
  
  import java.util.Arrays;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  
  
  
  import  org.jgroups.JChannel;
  import  org.jgroups.MembershipListener;
  import  org.jgroups.View;
  import  org.jgroups.blocks.MethodCall;
  import  org.jgroups.blocks.MethodLookup;
  import  org.jgroups.blocks.RequestOptions;
  import  org.jgroups.blocks.ResponseMode;
  import  org.jgroups.blocks.RpcDispatcher;
  import  org.jgroups.util.Rsp;
  import  org.jgroups.util.RspList;

The socket transport

Author(s):
Stefano Maestri
Jesper Pedersen
  
  public class JGroupsTransport extends AbstractRemoteTransport<org.jgroups.Address> implements MembershipListener
  {
   
The logger
  
     private static CoreLogger log = Logger.getMessageLogger(CoreLogger.classJGroupsTransport.class.getName());

   
Whether trace is enabled
  
     private static boolean trace = .isTraceEnabled();

   
The bundle
  
     private static CoreBundle bundle = Messages.getBundle(CoreBundle.class);

   
The JChannel used by this transport
  
     private JChannel channel;

   
Timeout
  
     private long timeout;

   
the cluster name to join
  
     private String clusterName;
  
     private RpcDispatcher disp;
  
     private boolean initialized;
  
     private static final short JOIN_METHOD = 1;
  
     private static final short LEAVE_METHOD = 2;
  
     private static final short PING_METHOD = 3;
  
     private static final short GET_WORKMANAGERS_METHOD = 4;
 
    private static final short WORKMANAGER_ADD_METHOD = 5;
 
    private static final short WORKMANAGER_REMOVE_METHOD = 6;
 
    private static final short DO_WORK_METHOD = 7;
 
    private static final short START_WORK_METHOD = 8;
 
    private static final short SCHEDULE_WORK_METHOD = 9;
 
    private static final short GET_SHORTRUNNING_FREE_METHOD = 10;
 
    private static final short GET_LONGRUNNING_FREE_METHOD = 11;
 
    private static final short UPDATE_SHORTRUNNING_FREE_METHOD = 12;
 
    private static final short UPDATE_LONGRUNNING_FREE_METHOD = 13;
 
    private static final short GET_DISTRIBUTED_STATISTICS_METHOD = 14;
 
    private static final short CLEAR_DISTRIBUTED_STATISTICS_METHOD = 15;
 
    private static final short DELTA_DOWORK_ACCEPTED_METHOD = 16;
 
    private static final short DELTA_DOWORK_REJECTED_METHOD = 17;
 
    private static final short DELTA_STARTWORK_ACCEPTED_METHOD = 18;
 
    private static final short DELTA_STARTWORK_REJECTED_METHOD = 19;
 
    private static final short DELTA_SCHEDULEWORK_ACCEPTED_METHOD = 20;
 
    private static final short DELTA_SCHEDULEWORK_REJECTED_METHOD = 21;
 
    private static final short DELTA_WORK_SUCCESSFUL_METHOD = 22;
 
    private static final short DELTA_WORK_FAILED_METHOD = 23;
 
    private static Map<ShortMethodmethods = new HashMap<ShortMethod>();
 
    static
    {
       try
       {
          .put(
                      JGroupsTransport.class.getMethod("join",
                                                       org.jboss.jca.core.spi.workmanager.Address.class,
                                                       org.jgroups.Address.class));
          
          .put(
                      JGroupsTransport.class.getMethod("leave",
                                                       org.jgroups.Address.class));
          
          .put(,
                      AbstractRemoteTransport.class.getMethod("localPing"));
 
                      JGroupsTransport.class.getMethod("getWorkManagers"));
 
          .put(
                      JGroupsTransport.class.getMethod("addWorkManager",
                                                       org.jboss.jca.core.spi.workmanager.Address.class,
                                                       org.jgroups.Address.class));
 
                      AbstractRemoteTransport.class.getMethod("localWorkManagerRemove",
                                                              org.jboss.jca.core.spi.workmanager.Address.class));
 
          .put(
                      JGroupsTransport.class.getMethod("executeDoWork",
                                                       org.jboss.jca.core.spi.workmanager.Address.class,
                                                       ClassBundle.class,
                                                       byte[].class));
 
          .put(,
                      JGroupsTransport.class.getMethod("executeStartWork",
                                                       org.jboss.jca.core.spi.workmanager.Address.class,
                                                       ClassBundle.class,
                                                       byte[].class));
 
          .put(,
                      JGroupsTransport.class.getMethod("executeScheduleWork",
                                                       org.jboss.jca.core.spi.workmanager.Address.class,
                                                       ClassBundle.class,
                                                       byte[].class));
 
                      AbstractRemoteTransport.class.getMethod("localGetShortRunningFree",
                                                              org.jboss.jca.core.spi.workmanager.Address.class));
 
                      AbstractRemoteTransport.class.getMethod("localGetLongRunningFree",
                                                              org.jboss.jca.core.spi.workmanager.Address.class));
 
                      AbstractRemoteTransport.class.getMethod("localUpdateShortRunningFree",
                                                              org.jboss.jca.core.spi.workmanager.Address.class,
                                                              Long.class));
 
                      AbstractRemoteTransport.class.getMethod("localUpdateLongRunningFree",
                                                              org.jboss.jca.core.spi.workmanager.Address.class,
                                                              Long.class));
 
                      AbstractRemoteTransport.class.getMethod("localGetDistributedStatistics",
                                                              org.jboss.jca.core.spi.workmanager.Address.class));
 
                      AbstractRemoteTransport.class.getMethod("localClearDistributedStatistics",
                                                              org.jboss.jca.core.spi.workmanager.Address.class));
 
                      AbstractRemoteTransport.class.getMethod("localDeltaDoWorkAccepted",
                                                              org.jboss.jca.core.spi.workmanager.Address.class));
 
                      AbstractRemoteTransport.class.getMethod("localDeltaDoWorkRejected",
                                                              org.jboss.jca.core.spi.workmanager.Address.class));
 
                      AbstractRemoteTransport.class.getMethod("localDeltaStartWorkAccepted",
                                                              org.jboss.jca.core.spi.workmanager.Address.class));
                      AbstractRemoteTransport.class.getMethod("localDeltaStartWorkRejected",
                                                              org.jboss.jca.core.spi.workmanager.Address.class));
 
                      AbstractRemoteTransport.class.getMethod("localDeltaScheduleWorkAccepted",
                                                              org.jboss.jca.core.spi.workmanager.Address.class));
                      AbstractRemoteTransport.class.getMethod("localDeltaScheduleWorkRejected",
                                                              org.jboss.jca.core.spi.workmanager.Address.class));
 
          .put(AbstractRemoteTransport.class.getMethod("localDeltaWorkSuccessful",
                                                              org.jboss.jca.core.spi.workmanager.Address.class));
 
          .put(AbstractRemoteTransport.class.getMethod("localDeltaWorkFailed",
                                                              org.jboss.jca.core.spi.workmanager.Address.class));
       }
       catch (NoSuchMethodException e)
       {
          throw new RuntimeException(e);
       }
    }

   
Constructor
 
    public JGroupsTransport()
    {
       super();
       this. = null;
       this. = null;
       this. = null;
       this. = false;
       this. = 10000L;
    }

   
Delegator

Parameters:
logicalAddress The logical address
address The address
 
    public void join(org.jboss.jca.core.spi.workmanager.Address logicalAddress, org.jgroups.Address address)
    {
       super.join(logicalAddressaddress);
    }

   
Delegator

Parameters:
address The address
 
    public void leave(org.jgroups.Address address)
    {
       super.leave(address);
    }

   
Get WorkManagers

Returns:
The value
 
    {
       return getAddresses(.getAddress());
    }

   
Delegator

Parameters:
logicalAddress The logical address
address The address
 
    public void addWorkManager(org.jboss.jca.core.spi.workmanager.Address logicalAddress, org.jgroups.Address address)
    {
       super.localWorkManagerAdd(logicalAddressaddress);
    }

   
Execute doWork

Parameters:
logicalAddress The logical address
classBundle The class bundle
b The bytes
Throws:
WorkException in case of error
 
    public void executeDoWork(org.jboss.jca.core.spi.workmanager.Address logicalAddress,
                              ClassBundle classBundlebyte[] b)
       throws WorkException
    {
       ByteArrayInputStream bias = new ByteArrayInputStream(b);
       WorkObjectInputStream wois = null;
       try
       {
          WorkClassLoader wcl = SecurityActions.createWorkClassLoader(classBundle);
          
          wois = new WorkObjectInputStream(biaswcl);
 
          DistributableWork dw = (DistributableWork)wois.readObject();
 
          localDoWork(logicalAddressdw);
       }
       catch (WorkException we)
       {
          throw we;
       }
       catch (Throwable t)
       {
          throw new WorkException("Error during doWork: " + t.getMessage(), t);
       }
       finally
       {
          if (wois != null)
          {
             try
             {
                wois.close();
             }
             catch (IOException ioe)
             {
                // Ignore
             }
          }
       }
    }

   
Execute startWork

Parameters:
logicalAddress The logical address
classBundle The class bundle
b The bytes
Returns:
the start value
Throws:
WorkException in case of error
 
    public long executeStartWork(org.jboss.jca.core.spi.workmanager.Address logicalAddress,
                                 ClassBundle classBundlebyte[] b)
       throws WorkException
    {
       ByteArrayInputStream bias = new ByteArrayInputStream(b);
       WorkObjectInputStream wois = null;
       try
       {
          WorkClassLoader wcl = SecurityActions.createWorkClassLoader(classBundle);
          
          wois = new WorkObjectInputStream(biaswcl);
 
          DistributableWork dw = (DistributableWork)wois.readObject();
 
          return localStartWork(logicalAddressdw);
       }
       catch (WorkException we)
       {
          throw we;
       }
       catch (Throwable t)
       {
          throw new WorkException("Error during doWork: " + t.getMessage(), t);
       }
       finally
       {
          if (wois != null)
          {
             try
             {
                wois.close();
             }
             catch (IOException ioe)
             {
                // Ignore
             }
          }
       }
    }

   
Execute scheduleWork

Parameters:
logicalAddress The logical address
classBundle The class bundle
b The bytes
Throws:
WorkException in case of error
 
    public void executeScheduleWork(org.jboss.jca.core.spi.workmanager.Address logicalAddress,
                                    ClassBundle classBundlebyte[] b)
       throws WorkException
    {
       ByteArrayInputStream bias = new ByteArrayInputStream(b);
       WorkObjectInputStream wois = null;
       try
       {
          WorkClassLoader wcl = SecurityActions.createWorkClassLoader(classBundle);
          
          wois = new WorkObjectInputStream(biaswcl);
 
          DistributableWork dw = (DistributableWork)wois.readObject();
 
          localScheduleWork(logicalAddressdw);
       }
       catch (WorkException we)
       {
          throw we;
       }
       catch (Throwable t)
       {
          throw new WorkException("Error during doWork: " + t.getMessage(), t);
       }
       finally
       {
          if (wois != null)
          {
             try
             {
                wois.close();
             }
             catch (IOException ioe)
             {
                // Ignore
             }
          }
       }
    }

   
 
    public void startup() throws Throwable
    {
        = new RpcDispatcher(nullthisthis);
 
       .setMethodLookup(new MethodLookup()
       {
          @Override
          public Method findMethod(short key)
          {
             return .get(key);
          }
       });
 
       if ( == null)
           = "jca";
 
       .connect();
    }

   
 
    public boolean isInitialized()
    {
       return ;
    }

   
 
    public void initialize() throws Throwable
    {
        = true;
    }

   
 
    public void shutdown() throws Throwable
    {
       if ( != null)
       {
          try
          {
             .stop();
          }
          catch (Throwable t)
          {
             if ()
                .tracef("Throwable during disp.stop(): %s"t.getMessage());
          }
 
           = null;
       }
 
       if ( != null)
       {
          try
          {
             .disconnect();
          }
          catch (Throwable t)
          {
             if ()
                .tracef("Throwable during channel.disconnect(): %s"t.getMessage());
          }
 
          try
          {
             .close();
          }
          catch (Throwable t)
          {
             if ()
                .tracef("Throwable during channel.close(): %s"t.getMessage());
          }
 
           = null;
       }
    }
 
    @Override
    public Serializable sendMessage(org.jgroups.Address destAddressRequest requestSerializable... parameters)
       throws WorkException
    {
       Serializable returnValue = null;
 
       if ()
          .tracef("%s: sending message=%s to %s".getAddressAsString(), requestdestAddress);
 
       if ( == null || !.isOpen() || !.isConnected())
       {
          if ()
             .tracef("%s: channel not connected" != null ? .getAddressAsString() : "<empty>");
 
          return null;
       }
 
       RequestOptions opts = new RequestOptions(ResponseMode.GET_ALL, );
       try
       {
          switch (request)
          {
             case  : {
                org.jgroups.Address joiningAddress = (org.jgroups.Address) parameters[0];
                List<org.jgroups.Address> dests = destAddress == null ? null : Arrays.asList(destAddress);
 
                RspList<ResponseValuesrspList = .callRemoteMethods(destsnew MethodCall(,
                                                                                               joiningAddress),
                   opts);
                throwWorkExceptionIfHasExption(rspList);
                break;
             }
             case  : {
                org.jgroups.Address leavingAddress = (org.jgroups.Address) parameters[0];
 
                List<org.jgroups.Address> dests = destAddress == null ? null : Arrays.asList(destAddress);
 
                RspList<ResponseValuesrspList = .callRemoteMethods(destsnew MethodCall(,
                                                                                               leavingAddress), opts);
                throwWorkExceptionIfHasExption(rspList);
                break;
             }
             case  : {
                try
                {
                   returnValue = (Serializable.callRemoteMethod(destAddress,
                                                                      new MethodCall(),
                                                                      opts);
                }
                catch (WorkException we)
                {
                   throw we;
                }
                catch (Exception e)
                {
                   throw new WorkException(e);
                }
 
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
                org.jgroups.Address physicalAddress = (org.jgroups.Address) parameters[1];
 
                .callRemoteMethod(destAddress,
                                      new MethodCall(addressphysicalAddress), opts);
 
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
 
                .callRemoteMethod(destAddress,
                                      new MethodCall(address), opts);
 
                break;
             }
             case  : {
                try
                {
                   returnValue = (Long.callRemoteMethod(destAddressnew MethodCall(),
                      opts);
                }
                catch (WorkException we)
                {
                   throw we;
                }
                catch (Exception e)
                {
                   throw new WorkException(e);
                }
 
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
                ClassBundle cb = (ClassBundle)parameters[1];
                DistributableWork work = (DistributableWorkparameters[2];
                try
                {
                   .callRemoteMethod(destAddress,
                                         new MethodCall(addresscbgetBytes(work)), opts);
                }
                catch (WorkException we)
                {
                   throw we;
                }
                catch (Exception e)
                {
                   throw new WorkException(e);
                }
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
                ClassBundle cb = (ClassBundle)parameters[1];
                DistributableWork work = (DistributableWorkparameters[2];
 
                returnValue = (Long.callRemoteMethod(destAddress,
                                                           new MethodCall(addresscb,
                                                                          getBytes(work)), opts);
 
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
                ClassBundle cb = (ClassBundle)parameters[1];
                DistributableWork work = (DistributableWorkparameters[2];
 
                .callRemoteMethod(destAddress,
                                      new MethodCall(addresscbgetBytes(work)), opts);
 
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
 
                returnValue = (Long.callRemoteMethod(destAddress,
                                                           new MethodCall(,
                                                                          address), opts);
 
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
 
                returnValue = (Long.callRemoteMethod(destAddress,
                                                           new MethodCall(,
                                                                          address), opts);
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
                Long freeCount = (Longparameters[1];
 
                .callRemoteMethod(destAddress,
                   new MethodCall(addressfreeCount), opts);
 
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
                Long freeCount = (Longparameters[1];
 
                .callRemoteMethod(destAddress,
                   new MethodCall(addressfreeCount), opts);
 
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
 
                returnValue = 
                   (Serializable).callRemoteMethod(destAddress,
                                                       new MethodCall(address),
                                                       opts);
 
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
 
                .callRemoteMethod(destAddress,
                                      new MethodCall(address),
                                      opts);
 
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
 
                .callRemoteMethod(destAddressnew MethodCall(address),
                                      opts);
 
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
 
                .callRemoteMethod(destAddressnew MethodCall(address),
                                      opts);
 
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
 
                .callRemoteMethod(destAddressnew MethodCall(address),
                                      opts);
                
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
 
                .callRemoteMethod(destAddressnew MethodCall(address),
                                      opts);
 
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
 
                .callRemoteMethod(destAddressnew MethodCall(address),
                                      opts);
                
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
 
                .callRemoteMethod(destAddressnew MethodCall(address),
                                      opts);
                
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
 
                .callRemoteMethod(destAddressnew MethodCall(address),
                                      opts);
 
                break;
             }
             case  : {
                org.jboss.jca.core.spi.workmanager.Address address =
                   (org.jboss.jca.core.spi.workmanager.Addressparameters[0];
 
                .callRemoteMethod(destAddressnew MethodCall(address),
                                      opts);
 
                break;
             }
             default :
                if (.isDebugEnabled())
                {
                   .debug("Unknown command received on socket Transport");
                }
                break;
          }
       }
       catch (WorkException we)
       {
          throw we;
       }
       catch (Throwable t)
       {
          WorkException we = new WorkException(t.getMessage());
          we.initCause(t);
          throw we;
       }
 
       return returnValue;
    }
 
    private void throwWorkExceptionIfHasExption(RspList<ResponseValuesrspListthrows WorkException
    {
       if (rspList != null && rspList.getFirst() != null)
       {
          for (Rsp<ResponseValuesrsp : rspList)
          {
             if (rsp.hasException())
             {
                Throwable t = rsp.getException();
                if (t instanceof WorkException)
                {
                   throw (WorkException)t;
                }
                else
                {
                   WorkException we = new WorkException(rsp.getException().getMessage());
                   we.initCause(rsp.getException());
                   throw we;
                }
             }
          }
       }
    }

   
Get the physical address

Returns:
The value
 
    public org.jgroups.Address getOwnAddress()
    {
       return .getAddress();
    }

   
Get the channel.

Returns:
the channel.
 
    public JChannel getChannel()
    {
       return ;
    }

   
Set the channel.

Parameters:
channel The channel to set.
 
    public void setChannel(JChannel channel)
    {
       this. = channel;
    }

   
Get the clustername.

Returns:
the clustername.
 
    public String getClusterName()
    {
       return ;
    }

   
Set the clustername.

Parameters:
clustername The clustername to set.
 
    public void setClusterName(String clustername)
    {
       this. = clustername;
    }

   
Get the timeout

Returns:
The value
 
    public long getTimeout()
    {
       return ;
    }

   
Set the timeout

Parameters:
v The value
 
    public void setTimeout(long v)
    {
        = v;
    }
 
    @Override
    public void viewAccepted(View view)
    {
       if ()
       {
          .tracef("java.net.preferIPv4Stack=%s", System.getProperty("java.net.preferIPv4Stack"));
          .tracef("viewAccepted called w/ View=%s"view);
       }
 
       synchronized (this)
       {
          for (org.jgroups.Address physicalAddress : .values())
          {
             if (physicalAddress != null && !view.containsMember(physicalAddress))
             {
                leave(physicalAddress);
             }
          }
          for (org.jgroups.Address address : view.getMembers())
          {
             if ( != null && !.getAddress().equals(address) && !.containsValue(address))
             {
                try
                {
                   Set<org.jboss.jca.core.spi.workmanager.AddresslogicalAddresses =
                      (Set<org.jboss.jca.core.spi.workmanager.Address>)sendMessage(address.);
 
                   if (logicalAddresses != null && logicalAddresses.size() > 0)
                   {
                      for (org.jboss.jca.core.spi.workmanager.Address logicalAddress : logicalAddresses)
                      {
                         join(logicalAddressaddress);
 
                         Long shortRunning = getShortRunningFree(logicalAddress);
                         Long longRunning = getLongRunningFree(logicalAddress);
                      
                         localUpdateShortRunningFree(logicalAddressshortRunning);
                         localUpdateLongRunningFree(logicalAddresslongRunning);
                      }
                   }
                }
                catch (Throwable t)
                {
                   .error("ViewAccepted: " + t.getMessage(), t);
                }
             }
          }
       }
    }
 
    @Override
    public void block()
    {
       if ()
          .tracef("block called");
    }
 
    @Override
    public void suspect(org.jgroups.Address address)
    {
       if ()
          .tracef("suspect called w/ Address=%s"address);
    }
 
    @Override
    public void unblock()
    {
       if ()
          .tracef("unblock called");
    }

   
Get the byte[] of a DistributableWork instance

Parameters:
dw The instance
Returns:
The value
 
    private byte[] getBytes(DistributableWork dw)
    {
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       ObjectOutputStream oos = null;
       try
       {
          oos = new ObjectOutputStream(baos);
          oos.writeObject(dw);
          oos.flush();
          return baos.toByteArray();
       }
       catch (Throwable t)
       {
          .error("Error during getBytes: " + t.getMessage(), t);
       }
       finally
      {
         if (oos != null)
         {
            try
            {
               oos.close();
            }
            catch (IOException ioe)
            {
               // Ignore
            }
         }
      }
      return null;
   }
   public String toString()
   {
      return "JGroupsTransport [channel=" +  + ", clustername=" +  + "]";
   }