com.sun.jini.reggie
Class EntryClass

java.lang.Object
  extended by com.sun.jini.reggie.EntryClass
All Implemented Interfaces:
Serializable

 class EntryClass
extends Object
implements Serializable

An EntryClass is a descriptor for an entry class, packaged up for transmission between client-side proxies and the registrar server. Instances are never visible to clients, they are private to the communication between the proxies and the server. Note that we don't transmit information about interfaces implemented by the class, because it isn't necessary given the specific use of type information for entries.

This class only has a bare minimum of methods, to minimize the amount of code downloaded into clients.

Author:
Sun Microsystems, Inc.
See Also:
ClassMapper

Field Summary
protected  long hash
          Hash for the type
private  boolean integrity
          Flag set to true if this instance was unmarshalled from an integrity-protected stream, or false otherwise
protected  String name
          Class name
protected  int numFields
          Number of public fields
protected  int numInstances
          Number of instances of this class in service registrations
protected  int numTemplates
          Number of templates of this class in event registrations
protected  EntryClass replacement
          An instance containing only name and hash, no superclass info.
private static long serialVersionUID
           
protected  EntryClass superclass
          Descriptor for the superclass
 
Constructor Summary
  EntryClass(Class clazz, EntryClass superclass)
          Should only be called by ClassMapper
private EntryClass(EntryClass orig)
          Constructor used for creating replacement instances, containing only name and hash.
 
Method Summary
private  void computeHash(ClassMapper.EntryField[] fields)
          Computes a SHA-1 digest from the hash of the superclass, if there is a superclass, followed by the name of this class, followed by the name and type for each field, if any, declared by this class and ordered alphabetically by field name.
 boolean equals(Object o)
          Returns true if the object passed in is an instance of EntryClass with the same type hash as this object.
 String getName()
          Returns the name of this type
 int getNumFields()
          Return the number of public fields (including superclasses)
 int getNumInstances()
          Returns the number of times this type is used in service registrations
 int getNumTemplates()
          Returns the number of times this type is used in event registrations
 EntryClass getReplacement()
          Return the replacement, if any, containing only name and rep.
 EntryClass getSuperclass()
          Return the superclass descriptor
 int hashCode()
          Return a hashcode for this type.
 boolean isAssignableFrom(EntryClass cls)
          This is really only needed in the registrar, but it's very convenient to have here.
private  void readObject(ObjectInputStream in)
          Samples integrity protection setting (if any) of the stream from which this instance is being deserialized and checks that valid values for this object have been read from the stream.
private  void readObjectNoData()
          Throws InvalidObjectException, since data for this class is required.
 void setNumInstances(int numInstances)
          Set the number of instances of this class
 void setNumTemplates(int numTemplates)
          Set the number of templates of this class
 Class toClass(String codebase)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

name

protected String name
Class name


hash

protected long hash
Hash for the type


superclass

protected EntryClass superclass
Descriptor for the superclass


numFields

protected int numFields
Number of public fields


numInstances

protected transient int numInstances
Number of instances of this class in service registrations


numTemplates

protected transient int numTemplates
Number of templates of this class in event registrations


replacement

protected transient EntryClass replacement
An instance containing only name and hash, no superclass info. This is only used on the registrar side, to minimize the amount of info transmitted back to clients.


integrity

private transient boolean integrity
Flag set to true if this instance was unmarshalled from an integrity-protected stream, or false otherwise

Constructor Detail

EntryClass

public EntryClass(Class clazz,
                  EntryClass superclass)
           throws MarshalException
Should only be called by ClassMapper

Throws:
MarshalException

EntryClass

private EntryClass(EntryClass orig)
Constructor used for creating replacement instances, containing only name and hash.

Method Detail

getSuperclass

public EntryClass getSuperclass()
Return the superclass descriptor


getNumFields

public int getNumFields()
Return the number of public fields (including superclasses)


setNumInstances

public void setNumInstances(int numInstances)
Set the number of instances of this class


setNumTemplates

public void setNumTemplates(int numTemplates)
Set the number of templates of this class


getReplacement

public EntryClass getReplacement()
Return the replacement, if any, containing only name and rep.


isAssignableFrom

public boolean isAssignableFrom(EntryClass cls)
This is really only needed in the registrar, but it's very convenient to have here.

See Also:
Class.isAssignableFrom(java.lang.Class)

getNumInstances

public int getNumInstances()
Returns the number of times this type is used in service registrations

Returns:
number of instances of this type in use in service registrations

getNumTemplates

public int getNumTemplates()
Returns the number of times this type is used in event registrations

Returns:
number of times this type is used in event registrations

toClass

public Class toClass(String codebase)
              throws IOException,
                     ClassNotFoundException
Throws:
IOException
ClassNotFoundException

getName

public String getName()
Returns the name of this type

Returns:
the name of this type

equals

public boolean equals(Object o)
Returns true if the object passed in is an instance of EntryClass with the same type hash as this object. Returns false otherwise.

Overrides:
equals in class Object
Parameters:
o - object to compare this object against
Returns:
true if this object equals the object passed in; false otherwise.

hashCode

public int hashCode()
Return a hashcode for this type.

Overrides:
hashCode in class Object
Returns:
int the hashcode for this type

toString

public String toString()
Overrides:
toString in class Object

computeHash

private void computeHash(ClassMapper.EntryField[] fields)
                  throws MarshalException
Computes a SHA-1 digest from the hash of the superclass, if there is a superclass, followed by the name of this class, followed by the name and type for each field, if any, declared by this class and ordered alphabetically by field name. The first 8 bytes of the digest are used to form the 64-bit hash value for this type.

Throws:
MarshalException

readObject

private void readObject(ObjectInputStream in)
                 throws IOException,
                        ClassNotFoundException
Samples integrity protection setting (if any) of the stream from which this instance is being deserialized and checks that valid values for this object have been read from the stream.

Throws:
IOException
ClassNotFoundException

readObjectNoData

private void readObjectNoData()
                       throws InvalidObjectException
Throws InvalidObjectException, since data for this class is required.

Throws:
InvalidObjectException


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.