Cisco Systems, Inc.

com.pcube.apps.engage.policy
Class Service

java.lang.Object
  extended by com.pcube.apps.engage.common.ArrayElement
      extended by com.pcube.apps.engage.common.UsableArrayElement
          extended by com.pcube.apps.engage.policy.Service
All Implemented Interfaces:
Formattable, java.io.Serializable, java.lang.Cloneable

public class Service
extends UsableArrayElement
implements java.io.Serializable, java.lang.Cloneable, Formattable

A collection of protocols. A protocol is limited to a direction (inbound, outbound or both) and can be limited by a list of ip addresses or ip ranges which the client or server belong to.
The http and rtsp protocols can be limited also by a list of host names.
The Service belongs to a Policy.

See Also:
Serialized Form

Constructor Summary
Service(Policy policy)
          Service Constructor.
Service(Policy policy, java.lang.String name, java.lang.String description, int sampleRate)
          Service Constructor.
 
Method Summary
 void allocateCounter(AccountingScope scope)
           
 java.lang.Object clone()
           
static Service findNearestAncestorWithExclusiveCounter(Policy policy, Service service, AccountingScope scope, java.lang.String parentServiceName, boolean exclusiveCounter)
           
 void freeCounter(AccountingScope scope)
          Checks if a ServiceElement containing a specific Protocol combined with a certain direction is found in this Service's ServiceElementArray.
 void fromStream(java.io.BufferedReader in, Formatter f)
          parse from stream using the default element tag name
static java.lang.String generatetHypotheticalCounterName(Policy policy, Service service, AccountingScope scope, java.lang.String parentServiceName, boolean exclusiveCounter)
          creates a counter name for the specified service in the specified scope, assuming it has the specified parent and exclusive counter definitions.
static java.lang.String generatetHypotheticalCounterName(Policy policy, Service service, AccountingScope scope, java.lang.String parentServiceName, boolean exclusiveCounter, java.lang.String nameSuffix)
          creates a counter name for the specified service in the specified scope, assuming it has the specified parent and exclusive counter definitions.
 int getActualCounterIndex(AccountingScope scope)
           
 Service[] getChildrenServices()
           
 int getCounterIndex(AccountingScope scope)
           
 java.lang.String getCounterName(AccountingScope scope)
           
 java.lang.String getDescription()
          Gets this Service's description.
 java.lang.String getName()
          Gets this Service's name.
 int getNumericId()
           
 java.lang.String getParentName()
           
 int getParentServiceNumericId()
           
 Policy getPolicy()
           
 int getSampleRate()
          Gets this Service's sample rate for generating the "Service access report".
 java.util.List getServiceElements()
          Gets this Service's ServiceElement
 java.util.List getServiceElementsAndChildrenServiceElements()
          get the service elements of this service and the service elements of its children services
 boolean isCounterExclusive(AccountingScope scope)
           
 boolean isDefaultService()
           
 boolean isGlobalCounterExclusice()
           
 boolean isSubsCounterExclusice()
           
 void moveCounter(AccountingScope scope, int newIndex)
          change the index of the specified counter to the specified new index.
 void setDescription(java.lang.String newDescription)
          Sets this Service's description.
 void setName(java.lang.String newName)
          Sets this Service's name.
 void setNumericId(int newId)
           
 void setParentServiceByName(java.lang.String parentServiceName)
           
 void setParentServiceByNumericId(int parentServiceNumericId)
           
 void setSampleRate(int newSampleRate)
          Sets this Service's rate for generating the "Service access report", which reports the number of times this Service has been accessed by different subscribers.
 void setUsed(boolean newUsed)
          Setting this Service as used in the ServiceArray
 void setVetoableNameChangeListener(java.beans.VetoableChangeListener listener)
          set the votable change listener:
 void toStream(java.io.PrintStream out, Formatter f)
          write to stream using default tag name
 java.lang.String toString()
          returns a string representation of this service.
 
Methods inherited from class com.pcube.apps.engage.common.UsableArrayElement
fromStream, isUsed, toStream
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Service

public Service(Policy policy)
Service Constructor.

Parameters:
policy - the Policy this Service belongs to

Service

public Service(Policy policy,
               java.lang.String name,
               java.lang.String description,
               int sampleRate)
Service Constructor.

Parameters:
policy - the Policy this Service belongs to
name - this Service's name
description - this Service's description
sampleRate - this Service's sample rate
Method Detail

findNearestAncestorWithExclusiveCounter

public static Service findNearestAncestorWithExclusiveCounter(Policy policy,
                                                              Service service,
                                                              AccountingScope scope,
                                                              java.lang.String parentServiceName,
                                                              boolean exclusiveCounter)

generatetHypotheticalCounterName

public static java.lang.String generatetHypotheticalCounterName(Policy policy,
                                                                Service service,
                                                                AccountingScope scope,
                                                                java.lang.String parentServiceName,
                                                                boolean exclusiveCounter)
creates a counter name for the specified service in the specified scope, assuming it has the specified parent and exclusive counter definitions.

Parameters:
service -
scope -
parentServiceName -
exclusiveCounter -
Returns:

generatetHypotheticalCounterName

public static java.lang.String generatetHypotheticalCounterName(Policy policy,
                                                                Service service,
                                                                AccountingScope scope,
                                                                java.lang.String parentServiceName,
                                                                boolean exclusiveCounter,
                                                                java.lang.String nameSuffix)
creates a counter name for the specified service in the specified scope, assuming it has the specified parent and exclusive counter definitions.

Parameters:
service -
scope -
parentServiceName -
exclusiveCounter -
nameSuffix -
Returns:

allocateCounter

public void allocateCounter(AccountingScope scope)
                     throws com.pcube.apps.engage.foundations.FullCollectionException
Parameters:
scope -
Throws:
com.pcube.apps.engage.foundations.FullCollectionException

clone

public java.lang.Object clone()
Specified by:
clone in class ArrayElement
See Also:
ArrayElement.clone()

freeCounter

public void freeCounter(AccountingScope scope)
Checks if a ServiceElement containing a specific Protocol combined with a certain direction is found in this Service's ServiceElementArray.

Parameters:
protocolName - the name of the Protocol
direction - the direction
See Also:
ServiceElement#DIRECTION_NETWORK_INITIATED, ServiceElement#DIRECTION_SUBSCRIBER_INITIATED, ServiceElement#DIRECTION_BOTH

fromStream

public void fromStream(java.io.BufferedReader in,
                       Formatter f)
                throws ImportExportException
Description copied from class: UsableArrayElement
parse from stream using the default element tag name

Specified by:
fromStream in interface Formattable
Overrides:
fromStream in class UsableArrayElement
Throws:
ImportExportException
See Also:
Formattable.fromStream(java.io.BufferedReader, com.pcube.apps.engage.common.Formatter)

getActualCounterIndex

public int getActualCounterIndex(AccountingScope scope)
Parameters:
scope -
Returns:

getChildrenServices

public Service[] getChildrenServices()
Returns:

getCounterIndex

public int getCounterIndex(AccountingScope scope)
Parameters:
scope -
Returns:

getCounterName

public java.lang.String getCounterName(AccountingScope scope)
Parameters:
scope -
Returns:

getDescription

public java.lang.String getDescription()
Gets this Service's description.

Returns:
this Service's description

getName

public java.lang.String getName()
Gets this Service's name.

Returns:
this Service's name

getNumericId

public int getNumericId()

setNumericId

public void setNumericId(int newId)
                  throws ItemNotFoundException
Throws:
ItemNotFoundException

getParentName

public java.lang.String getParentName()
Returns:
@throws ItemNotFoundException

getParentServiceNumericId

public int getParentServiceNumericId()
Returns:

getSampleRate

public int getSampleRate()
Gets this Service's sample rate for generating the "Service access report".

Returns:
the report's generation rate

getServiceElements

public java.util.List getServiceElements()
Gets this Service's ServiceElement

Returns:
this Service's ServiceElement

getServiceElementsAndChildrenServiceElements

public java.util.List getServiceElementsAndChildrenServiceElements()
get the service elements of this service and the service elements of its children services

Returns:

isCounterExclusive

public boolean isCounterExclusive(AccountingScope scope)

isDefaultService

public boolean isDefaultService()
Returns:

isGlobalCounterExclusice

public boolean isGlobalCounterExclusice()

isSubsCounterExclusice

public boolean isSubsCounterExclusice()

moveCounter

public void moveCounter(AccountingScope scope,
                        int newIndex)
                 throws DuplicateItemException,
                        ItemNotFoundException
change the index of the specified counter to the specified new index.

Parameters:
scope -
newIndex -
Throws:
DuplicateItemException - if the requested new index is not free
ItemNotFoundException - if no counter allocated for this service

setDescription

public void setDescription(java.lang.String newDescription)
Sets this Service's description.

Parameters:
newDescription - this Service's new description

setName

public void setName(java.lang.String newName)
             throws DuplicateItemException
Sets this Service's name.

Parameters:
newName - this Service's new name
Throws:
DuplicateItemException - if a Service with the same name already exists in the Policy's ServiceArray
ItemNotFoundException - if an item was missing while validating the rename

setParentServiceByName

public void setParentServiceByName(java.lang.String parentServiceName)
                            throws ItemNotFoundException
Parameters:
parentServiceName -
Throws:
ItemNotFoundException

setParentServiceByNumericId

public void setParentServiceByNumericId(int parentServiceNumericId)
                                 throws ItemNotFoundException
Parameters:
parentServiceNumericId -
Throws:
ItemNotFoundException

setSampleRate

public void setSampleRate(int newSampleRate)
Sets this Service's rate for generating the "Service access report", which reports the number of times this Service has been accessed by different subscribers. Value 0 will never generate a report.

Parameters:
newSampleRate - the new report generation rate

setUsed

public void setUsed(boolean newUsed)
Setting this Service as used in the ServiceArray

Overrides:
setUsed in class UsableArrayElement

toStream

public void toStream(java.io.PrintStream out,
                     Formatter f)
Description copied from class: UsableArrayElement
write to stream using default tag name

Specified by:
toStream in interface Formattable
Overrides:
toStream in class UsableArrayElement
See Also:
Formattable.toStream(java.io.PrintStream, com.pcube.apps.engage.common.Formatter)

toString

public java.lang.String toString()
returns a string representation of this service.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this service.

setVetoableNameChangeListener

public void setVetoableNameChangeListener(java.beans.VetoableChangeListener listener)
set the votable change listener:

Parameters:
listener -

getPolicy

public Policy getPolicy()

Cisco Systems, Inc.

Copyright © 2013 Cisco Systems, Inc. Confidential.