net.ponder2
Class P2ObjectAdaptor

java.lang.Object
  extended by net.ponder2.objects.P2Object
      extended by net.ponder2.P2ObjectAdaptor
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, P2Serializable, Ponder2Message

public class P2ObjectAdaptor
extends P2Object
implements java.io.Externalizable

An object adaptor manages the interface between the ponder2 system and the actual managed object itself

Version:
$Id:$
Author:
Kevin Twidle
See Also:
Serialized Form

Nested Class Summary
static class P2ObjectAdaptor.CreateOperation
          Base class to map an operation with known arguments to a specific call within a managed object
static class P2ObjectAdaptor.CreateOrStaticOperation
           
static class P2ObjectAdaptor.InstanceOperation
          Base class to map an operation with known arguments to a specific call within a managed object
static class P2ObjectAdaptor.StaticOperation
          Base class to map an operation with known arguments to a specific call within a managed object
 
Field Summary
protected  ManagedObject objImpl
          The instance of the managed object to be called
 
Constructor Summary
P2ObjectAdaptor()
          Creates an empty object adaptor.
P2ObjectAdaptor(P2Object source, java.lang.String operation, P2Object... args)
           
 
Method Summary
 P2Object create(P2Object source, java.lang.String operation, P2Object... args)
          called as a result of an operation on the factory managed object for this managed object
static AuthorisationModule getAuthorisation()
          Returns the authorisation module in use, if any.
 P2ObjectAdaptor.CreateOperation getCreateOperation(java.lang.String opName)
           
 void getCreateOrStaticOperation(P2ObjectAdaptor.CreateOrStaticOperation opInfo)
           
 P2ObjectAdaptor.InstanceOperation getInstanceOperation(java.lang.String opName)
           
 ManagedObject getObj()
           
 P2Object operation(P2Object source, java.lang.String operation, P2Object... args)
          called as a result of an operation on the instantiated managed object
 void readExternal(java.io.ObjectInput in)
           
protected  java.lang.Object readResolve()
          Resolves instances being deserialised to the preexisting objects.
 P2Object readXml(com.twicom.qdparser.TaggedElement xml, java.util.Map<java.lang.Integer,P2Serializable> read)
           
static void setAuthorisation(AuthorisationModule auth)
          Turns authorisation checking on by setting the authorisation module that will be checking commands.
 void setObj(ManagedObject obj)
           
protected static void trace(java.lang.String opType, java.lang.String className, java.lang.String operation, P2Object... args)
          Prints a command trace line on stderr.
 void writeExternal(java.io.ObjectOutput out)
           
 com.twicom.qdparser.TaggedElement writeXml(java.util.Set<P2Object> written)
           
 
Methods inherited from class net.ponder2.objects.P2Object
asArray, asBlock, asBoolean, asClass, asDouble, asFloat, asHash, asInteger, asLong, asNumber, asP2Array, asString, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, fromXml, getManagedObject, getOID, getSMC, operation, setSMC
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objImpl

protected ManagedObject objImpl
The instance of the managed object to be called

Constructor Detail

P2ObjectAdaptor

public P2ObjectAdaptor()
Creates an empty object adaptor. Used only by factory object to create a new object. The create call must be made afterwards. See the other constructor.


P2ObjectAdaptor

public P2ObjectAdaptor(P2Object source,
                       java.lang.String operation,
                       P2Object... args)
                throws Ponder2Exception
Throws:
Ponder2Exception
Method Detail

setObj

public void setObj(ManagedObject obj)

getObj

public ManagedObject getObj()

setAuthorisation

public static void setAuthorisation(AuthorisationModule auth)
Turns authorisation checking on by setting the authorisation module that will be checking commands. If an authorisation is blocked then an error will be thrown.

Parameters:
auth - the authorisation module that will perform the checks

getAuthorisation

public static AuthorisationModule getAuthorisation()
Returns the authorisation module in use, if any.

Returns:
the current authorisation module

create

public P2Object create(P2Object source,
                       java.lang.String operation,
                       P2Object... args)
                throws Ponder2Exception
called as a result of an operation on the factory managed object for this managed object

Specified by:
create in interface Ponder2Message
Overrides:
create in class P2Object
Parameters:
source - the subject OID of the operation
operation - the name of the operation
args - arguments for the operation
Returns:
the result of the operation
Throws:
Ponder2Exception

operation

public P2Object operation(P2Object source,
                          java.lang.String operation,
                          P2Object... args)
                   throws Ponder2Exception
called as a result of an operation on the instantiated managed object

Specified by:
operation in interface Ponder2Message
Overrides:
operation in class P2Object
Parameters:
source - the subject OID of the operation
operation - the name of the operation
args - arguments for the operation
Returns:
the result of the operation
Throws:
Ponder2Exception
See Also:
Ponder2Message.operation(net.ponder2.objects.P2Object, java.lang.String, net.ponder2.objects.P2Object[])

trace

protected static void trace(java.lang.String opType,
                            java.lang.String className,
                            java.lang.String operation,
                            P2Object... args)
Prints a command trace line on stderr.

Parameters:
opType - the type of the operation, mainly "P2Op"
className - the class receiving the operation
operation - the name of the operation
args - the arguments for the operation

getCreateOrStaticOperation

public void getCreateOrStaticOperation(P2ObjectAdaptor.CreateOrStaticOperation opInfo)
                                throws Ponder2OperationException
Throws:
Ponder2OperationException

getCreateOperation

public P2ObjectAdaptor.CreateOperation getCreateOperation(java.lang.String opName)
                                                   throws Ponder2OperationException
Throws:
Ponder2OperationException

getInstanceOperation

public P2ObjectAdaptor.InstanceOperation getInstanceOperation(java.lang.String opName)
                                                       throws Ponder2OperationException
Throws:
Ponder2OperationException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

readResolve

protected java.lang.Object readResolve()
                                throws java.io.ObjectStreamException
Resolves instances being deserialised to the preexisting objects.

Returns:
the intended object
Throws:
java.io.ObjectStreamException - if something happens

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

writeXml

public com.twicom.qdparser.TaggedElement writeXml(java.util.Set<P2Object> written)
                                           throws Ponder2OperationException
Specified by:
writeXml in interface P2Serializable
Overrides:
writeXml in class P2Object
Throws:
Ponder2OperationException

readXml

public P2Object readXml(com.twicom.qdparser.TaggedElement xml,
                        java.util.Map<java.lang.Integer,P2Serializable> read)
                 throws Ponder2OperationException,
                        Ponder2ArgumentException
Specified by:
readXml in interface P2Serializable
Specified by:
readXml in class P2Object
Throws:
Ponder2OperationException
Ponder2ArgumentException


Copyright © 2008 Imperial College. All Rights Reserved.