com.softwareag.sagd.PMQServer
Class PMQResource

java.lang.Object
  extended by com.softwareag.sagd.PMQServer.PMQResource

public class PMQResource
extends java.lang.Object

An instance of the class controls all allocated EntireX and PMQ objects which are created inside the context or added with the add() method.

See the PMQInputStream.main(String[]) or PMQOutputStream.main(String[]), how to use this class.

Version:
$Revision: 1.6 $

Constructor Summary
PMQResource(boolean isServer)
          Contructs an resource object and acts as server.
PMQResource(java.lang.String mode)
          Creates a new resource object.
 
Method Summary
 void add(com.softwareag.entirex.aci.Broker broker)
          Adds a broker in this resource.
 void add(com.softwareag.entirex.aci.BrokerService service)
          Adds BrokerService object.
 void add(PMQInputStream input)
          Adds the input stream into this resource object.
 void add(PMQOutputStream output)
          Adds the output stream into this resource object.
 com.softwareag.entirex.aci.Broker addBroker(java.lang.String brokerId, java.lang.String user, java.lang.String token, java.lang.String password)
          Adds the created Broker object in this resource object.
 com.softwareag.entirex.aci.Broker addBroker(java.lang.String brokerId, java.lang.String user, java.lang.String token, java.lang.String password, int traceLevel)
          Adds the created Broker object in this resource object.
 PMQInputStream addInputStream(boolean withOld)
          Add, create and return an input stream.
 PMQOutputStream addOutputStream(boolean withOld)
          Add, create and return an output stream.
 void addService(java.lang.String serviceName)
          Adds Broker service or a publication to this resource depending on serviceName.
 void backout()
          Backout all opened transactions and release allocated objects.
 void cleanup()
          All allocated and remembered Broker and BrokerService objects are released.
 void commit()
          Commit all opened UOWs and cleanup the allocated resources.
static com.softwareag.entirex.aci.Broker createBroker(java.lang.String brokerId, java.lang.String user, java.lang.String token, java.lang.String password)
          Creates and returns an EntireX Broker object without tracing.
static com.softwareag.entirex.aci.Broker createBroker(java.lang.String brokerId, java.lang.String user, java.lang.String token, java.lang.String password, int traceLevel, java.io.PrintWriter output)
          Creates and returns an EntireX Broker object with tracing option.
 PMQResource createNode(boolean isServer)
          Creates a new resource node and adds into the list.
 PMQResource createNode(java.lang.String mode)
          Creates next resource node.
protected  void finalize()
          Cleanup allocated resources.
 java.lang.String getContextData()
          Returns the context data of this allocated stream.
 PMQInputStream getInputStream()
          Returns the allocated input stream of this resource.
 PMQOutputStream getOutputStream()
          Returns the allocated output stream of this resource.
 java.lang.String getPublicationTopic(java.lang.String serviceName)
          Returns the topic name of the service name.
 com.softwareag.entirex.aci.BrokerService getService()
          Returns the allocated Broker service object.
 java.lang.String getUnitOfWorkID()
          Returns the Unit of Work ID of all allocated resources.
 boolean isPublication(java.lang.String serviceName)
          Returns true if serviceName contains a publication topic name.
 boolean prepareCommit()
          Prepare all resources to commit the streams in the next commit statement.
 void setCleanupOnFinalize(boolean value)
          Set value to true, if this resource should cleanup on the CG finalize.
 void setPrepareCommitActivityTime(long time)
          Set new wait time to do no prepareCommit() check.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PMQResource

public PMQResource(boolean isServer)
Contructs an resource object and acts as server.


PMQResource

public PMQResource(java.lang.String mode)
Creates a new resource object. Use server value for parameter mode to act as server.

Method Detail

createNode

public PMQResource createNode(java.lang.String mode)
Creates next resource node.


createNode

public PMQResource createNode(boolean isServer)
Creates a new resource node and adds into the list.


add

public void add(com.softwareag.entirex.aci.Broker broker)
Adds a broker in this resource.


add

public void add(com.softwareag.entirex.aci.BrokerService service)
         throws java.lang.Exception
Adds BrokerService object.

Throws:
java.lang.Exception

add

public void add(PMQInputStream input)
Adds the input stream into this resource object.


add

public void add(PMQOutputStream output)
Adds the output stream into this resource object.


commit

public void commit()
            throws java.io.IOException
Commit all opened UOWs and cleanup the allocated resources. Before the commit is sent to all resources, all resources are asked for preparing prepareCommit() transaktion.

Throws:
java.io.IOException - if transaction fails

backout

public void backout()
Backout all opened transactions and release allocated objects.


prepareCommit

public boolean prepareCommit()
                      throws java.io.IOException
Prepare all resources to commit the streams in the next commit statement.

Throws:
java.io.IOException - if next commit() is not possible

setPrepareCommitActivityTime

public void setPrepareCommitActivityTime(long time)
Set new wait time to do no prepareCommit() check. The default is 5 seconds.

Parameters:
time - in milliseconds

cleanup

public void cleanup()
All allocated and remembered Broker and BrokerService objects are released. Opened UOWs are not handled.


addBroker

public com.softwareag.entirex.aci.Broker addBroker(java.lang.String brokerId,
                                                   java.lang.String user,
                                                   java.lang.String token,
                                                   java.lang.String password)
                                            throws com.softwareag.entirex.aci.BrokerException
Adds the created Broker object in this resource object.

Throws:
com.softwareag.entirex.aci.BrokerException

addBroker

public com.softwareag.entirex.aci.Broker addBroker(java.lang.String brokerId,
                                                   java.lang.String user,
                                                   java.lang.String token,
                                                   java.lang.String password,
                                                   int traceLevel)
                                            throws com.softwareag.entirex.aci.BrokerException
Adds the created Broker object in this resource object.

Throws:
com.softwareag.entirex.aci.BrokerException

addService

public void addService(java.lang.String serviceName)
                throws com.softwareag.entirex.aci.BrokerException,
                       java.lang.Exception
Adds Broker service or a publication to this resource depending on serviceName.

Throws:
com.softwareag.entirex.aci.BrokerException
java.lang.Exception

isPublication

public boolean isPublication(java.lang.String serviceName)
Returns true if serviceName contains a publication topic name.


getPublicationTopic

public java.lang.String getPublicationTopic(java.lang.String serviceName)
Returns the topic name of the service name.


getUnitOfWorkID

public java.lang.String getUnitOfWorkID()
Returns the Unit of Work ID of all allocated resources. In case of publication, the publication ID is returned.


getService

public com.softwareag.entirex.aci.BrokerService getService()
Returns the allocated Broker service object.


getContextData

public java.lang.String getContextData()
Returns the context data of this allocated stream.


addInputStream

public PMQInputStream addInputStream(boolean withOld)
                              throws com.softwareag.entirex.aci.BrokerException
Add, create and return an input stream.

Throws:
com.softwareag.entirex.aci.BrokerException

addOutputStream

public PMQOutputStream addOutputStream(boolean withOld)
                                throws com.softwareag.entirex.aci.BrokerException
Add, create and return an output stream.

Throws:
com.softwareag.entirex.aci.BrokerException

getInputStream

public PMQInputStream getInputStream()
Returns the allocated input stream of this resource.


getOutputStream

public PMQOutputStream getOutputStream()
Returns the allocated output stream of this resource.


createBroker

public static com.softwareag.entirex.aci.Broker createBroker(java.lang.String brokerId,
                                                             java.lang.String user,
                                                             java.lang.String token,
                                                             java.lang.String password)
                                                      throws com.softwareag.entirex.aci.BrokerException
Creates and returns an EntireX Broker object without tracing.

Throws:
com.softwareag.entirex.aci.BrokerException

createBroker

public static com.softwareag.entirex.aci.Broker createBroker(java.lang.String brokerId,
                                                             java.lang.String user,
                                                             java.lang.String token,
                                                             java.lang.String password,
                                                             int traceLevel,
                                                             java.io.PrintWriter output)
                                                      throws com.softwareag.entirex.aci.BrokerException
Creates and returns an EntireX Broker object with tracing option.

Throws:
com.softwareag.entirex.aci.BrokerException

setCleanupOnFinalize

public void setCleanupOnFinalize(boolean value)
Set value to true, if this resource should cleanup on the CG finalize. The default initialization is false.


finalize

protected void finalize()
Cleanup allocated resources.

Overrides:
finalize in class java.lang.Object


Copyright © 2004-2008 Software AG. All Rights Reserved.