com.ptc.windchill.structconf
Class PropagationAction

java.lang.Object
  extended bycom.ptc.windchill.structconf.PropagationAction
Direct Known Subclasses:
IePropertiesAction, SamplePropagationAction, ServerCodebaseUrlCleaner

public abstract class PropagationAction
extends Object

Allows users to perform custom propagation activities after all xconfs have been processed and property info has been derived.

To declare a PropagationAction, add an entry like the following to a declarative xconf file:

   <PropagationAction className="fully-qualified-class-name"/>

Or to include a classpath, use the following notation to include classpath entries taking care to make the paths to the classpath entries be relative paths from the location of the declaring xconf file (e.g. if file="../lib/abc.jar" then the abc.jar is expected to be by in the peer directory named "lib" of the directory containing the xconf).

   <PropagationAction className="fully-qualified-class-name">
       <ClassPathEntry file="relpathtojar/jarfilename"/>
  </PropagationAction>

The corresponding implementation of the propagation action should be a subclass of this class. For an example see the source for SamplePropagationAction:

 package com.ptc.windchill.structconf;

 import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.TreeSet;

 import com.ptc.windchill.structconf.xconf.Paths;

 public class SamplePropagationAction
    extends PropagationAction
 {
    private MyTextDerivedFile aDerivedFile_;

    public SamplePropagationAction()
       throws PropagationActionException
    {
       File root = Paths.getTargetRootDirectory();
       File codebase = new File(root, "codebase");
       File target_file = new File(codebase, "a_derived_file.txt");
       aDerivedFile_ = new MyTextDerivedFile(target_file);
    }

    public DerivedFile[] getDerivedFiles()
    {
       return new DerivedFile[] { aDerivedFile_ };
    }

    public void evaluate(CollectedProperties collected_properties)
    {
       for(Iterator iter=collected_properties.getAllPropertyNames().iterator();
           iter.hasNext();)
       {
          String property_name = (String)iter.next();
          PropertyInfo property_info = collected_properties.getPropertyInfo(property_name);
          String[] values = property_info.getValues();

          if(values != null)
          {
             StringBuffer buffer = new StringBuffer(property_name).
                append(':');
             for(int i=0; i 0)
                   buffer.append(',');
                buffer.append(values[i]);
             }
             aDerivedFile_.addLine(buffer.toString());
          }
       }
    }

    private class MyTextDerivedFile
       extends DerivedFile
    {
       private File file_;
       private ArrayList lines_;
       MyTextDerivedFile(File file)
       {
          file_ = file;
          lines_ = new ArrayList();
       }
       public File getTargetFile()
       {
          return file_;
       }

       public void addLine(String line)
       {
          lines_.add(line);
       }

       public void write(BufferedOutputStream bos)
          throws IOException
       {
          OutputStreamWriter writer = null;
          try
          {
             writer = new OutputStreamWriter(bos, "UTF8");
             for(Iterator iter=lines_.iterator(); iter.hasNext();)
             {
                String line = (String)iter.next();
                writer.write(line, 0, line.length());
                writer.write("\n");
             }
          }
          finally
          {
             if(writer != null)
                writer.flush();
          }
       }
    }
 }


Constructor Summary
protected PropagationAction()
           
 
Method Summary
abstract  void evaluate(CollectedProperties collected_properties)
          Evaluate the custom action.
abstract  DerivedFile[] getDerivedFiles()
          Return the set of DerivedFile objects that will be updated if this custom propagation action is evaluated.
protected static PropagationActionException newPropagationActionException(String message, Throwable cause)
          Factory method for implementors to create new instances of the class PropagationActionException which has package protected constructors.
protected static PropagationActionException newPropgationActionException(String message)
          Factory method for implementors to create new instances of the class PropagationActionException which has package protected constructors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropagationAction

protected PropagationAction()
                     throws PropagationActionException
Throws:
PropagationActionException - if theres a problem initializing the PropagationAction
Method Detail

getDerivedFiles

public abstract DerivedFile[] getDerivedFiles()
Return the set of DerivedFile objects that will be updated if this custom propagation action is evaluated. Note that this method needs to function correctly before evaluation so that the StructConfManager can do timestamp- and file existence- based analysis of whether or not to perform propagation. If the knowledge of the product root is required to compute these files' paths, then the Paths API can be used. If kownledge about installed products/components/modules is required, you will have to wait another couple weeks for an install_tools API that will provide this information.


evaluate

public abstract void evaluate(CollectedProperties collected_properties)
                       throws PropagationActionException
Evaluate the custom action. The action will have access to the specified collected properties which can be used for whatever purpose the action wants.

A custom action should not ever write the derived file. Rather it should make changes in memory to the DerivedFile instances returned in getDerivedFiles. The StructConfManager will utilize the write methods on DerivedFile implementation to ensure that they get properly backed up and written in a safe way.

Throws:
PropagationActionException - if there are problems evaluating the action and updating derived file instances

newPropgationActionException

protected static final PropagationActionException newPropgationActionException(String message)
Factory method for implementors to create new instances of the class PropagationActionException which has package protected constructors.


newPropagationActionException

protected static final PropagationActionException newPropagationActionException(String message,
                                                                                Throwable cause)
Factory method for implementors to create new instances of the class PropagationActionException which has package protected constructors.