/*
 * JBoss, Home of Professional Open Source
 * Copyright 2005, JBoss Inc., 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.jboss.tm.plugins.tyrex;

import java.rmi.Remote;
import java.lang.reflect.Proxy;
import java.rmi.RemoteException;

import org.omg.CosTransactions.Coordinator;
import org.omg.CosTransactions._CoordinatorImplBase;
import org.omg.CosTransactions.RecoveryCoordinator;
import org.omg.CosTransactions.Resource;

import org.omg.CosTransactions.Inactive;

/**
 *   RMI Remote Proxy that enables the remote Transaction Manager
 *   to register the subordinate transaction as a resource
 *   with the originator's Coordinator
 *
 *   @see CoordinatorRemoteInterface, CoordinatorInvoker, ResourceRemote
 *   @author <a href="mailto:akkerman@cs.nyu.edu">Anatoly Akkerman</a>
 *   @version $Revision: 1.2.4.1 $
 */

public class CoordinatorRemote extends java.rmi.server.UnicastRemoteObject implements CoordinatorRemoteInterface {

  private org.omg.CosTransactions._CoordinatorImplBase localCoordinator;

  protected CoordinatorRemote(Coordinator coord) throws RemoteException {
    localCoordinator = (org.omg.CosTransactions._CoordinatorImplBase) coord;
  }

  public void register_resource(Resource serializableResource) throws Inactive, RemoteException {
    // DEBUG    Logger.debug("CoordinatorRemote: Registering resource");
    RecoveryCoordinator recoveryCoord = localCoordinator.register_resource(serializableResource);
    // ignore the recovery coordinator for now
    // if we choose, we can wrap the RecoveryCoordinator
    // and return its serializable dynamic proxy to the other side

    // DEBUG    Logger.debug("CoordinatorRemote: Resource registered");
  }
}