package com.wiley.compbooks.brose.chapter9.tie;

import java.util.Calendar;
import org.omg.CORBA.*;
import com.wiley.compbooks.brose.chapter9.HelloWorld.*;

public class GoodDayImpl 
    implements GoodDayOperations 
{
    private String location;
    private ORB orb; /* singleton orb as a factory of anys */

    /** constructor */

    GoodDayImpl( String location ) 
    {
        this.location = location;
	orb = ORB.init();
    }

    /** operation */

    public Any hello( AnyHolder any_time)
        throws SystemException 
    {
        // get location time of the server
        Calendar date = Calendar.getInstance();

	// create time-structure assign hour and minute to it
	Time struct_time = new Time( (short) date.get(Calendar.HOUR),
				     (short) date.get(Calendar.MINUTE));

        // create an any and shuffle structure into it
        any_time.value = orb.create_any();
	TimeHelper.insert( any_time.value, struct_time );

	// create an any and shuffle location into it
	Any any_location = orb.create_any();
	any_location.insert_string( location );

        return any_location;
    }
}
