All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.beans.samples.dips.license.PrintLicenseDip

java.lang.Object
   |
   +----com.ibm.beans.dip.SimpleDip
           |
           +----com.ibm.beans.samples.dips.license.PrintLicenseDip

public class PrintLicenseDip
extends SimpleDip
implements DipVetoableMethodListener, Serializable
This class implements a simple form of licensing dip by restricting access to print and printAll methods of a java.awt.Component instance. This class can only be applied to objects that are instances of java.awt.Component.

The licensing policy chosen for this dip ensures that the printing is enabled only on specific hosts and for a specific duration.

See the License Dip Usage Guide for information regarding how to setup and use a license dip.


Constructor Index

 o PrintLicenseDip()
Constructs a new print restricting license dip.

Method Index

 o createImplementation(Object)
Checks the object to which the dip is being applied to ensure that the object is an awt.compenent.
 o createVetoableMethodListener(Object, String[])
Creates the dip to receive notification when the print and printAll methods are called.
 o handleVetoableMethod(MethodCallEvent)
Checks for a valid license and vetos if the license is invalid.
 o includeInMorphedClass(String)
Determines if a method should be included in a morphed class.
 o isRemovable()
Allows removal of licensing.
 o needsArguments()
Indicates whether method calls need arguments.
 o recoverFromMethodVeto(MethodCallEvent)
Recovers from a print veto.
 o typeName()
Defines this dip to be related to licensing of print function where the license restricts use to a particular host for a particular duration.

Constructors

 o PrintLicenseDip
 public PrintLicenseDip()
Constructs a new print restricting license dip. The constructor handles instantiating a license policy. The owner of the dip is responsible for ensuring proper customization by invoking the customizer for this class.

Methods

 o typeName
 public final String typeName()
Defines this dip to be related to licensing of print function where the license restricts use to a particular host for a particular duration.

Returns:
The type name of the dip.
Overrides:
typeName in class SimpleDip
 o isRemovable
 public boolean isRemovable()
Allows removal of licensing. When an object is licensed, it must never be allowed to remove licensing. This method always returns false.

Returns:
true if removal allowed; false otherwise.
Overrides:
isRemovable in class SimpleDip
 o includeInMorphedClass
 public boolean includeInMorphedClass(String methodName)
Determines if a method should be included in a morphed class. When the dip is applied to a class as a pre-dip during morphing, and the user elects to only override those methods in the dippable class that the pre-dips agrees to, this method is used to determine if a dip agrees to including a specific method.

The only methods of the dippable bean that the PrintLicenseDip needs to be wrapped are the print and printAll methods.

Parameters:
methodName - Name of the method to be considered
Returns:
boolean indicating whether to wrap given method
Overrides:
includeInMorphedClass in class SimpleDip
 o createImplementation
 public Object createImplementation(Object obj) throws DipRejectAdditionException
Checks the object to which the dip is being applied to ensure that the object is an awt.compenent. If it is not, then an exception is thrown and the application of the dip is rejected.

Parameters:
obj - The bean being dipped.
Returns:
null (no other implementation necessary).
Throws: DipRejectAdditionException
This method will throw this exception if obj is not a java.awt.Component.
Overrides:
createImplementation in class SimpleDip
 o createVetoableMethodListener
 public DipVetoableMethodListener[] createVetoableMethodListener(Object imp,
                                                                 String methods[]) throws DipRejectAdditionException
Creates the dip to receive notification when the print and printAll methods are called. If either of these methods are called, the dip may veto the methods if the license is not valid.

Parameters:
imp - The implementation returned by createImplementation.
methods[] - The array of methods in the dippable bean.
Returns:
The array of DipVetoableMethodListeners with the dip itself set to listen at the appropriate method index to receive print and printAll calls.
Throws: DipRejectAdditionException
This method will throw this exception if the dippable bean's print or printAll methods were not wrapped when it was morphed.
Overrides:
createVetoableMethodListener in class SimpleDip
 o needsArguments
 public boolean needsArguments()
Indicates whether method calls need arguments. This method states that the dip does not care about arguments for any method calls.

Returns:
true if arguments needed; false otherwise.
 o handleVetoableMethod
 public void handleVetoableMethod(MethodCallEvent e) throws MethodVetoException
Checks for a valid license and vetos if the license is invalid.

Parameters:
e - Describes the method that was called.
Throws: MethodVetoException
This method throws this exception if the license is not valid.
 o recoverFromMethodVeto
 public void recoverFromMethodVeto(MethodCallEvent e)
Recovers from a print veto.

Parameters:
e - Description of the particular method that was vetoed.

All Packages  Class Hierarchy  This Package  Previous  Next  Index