|
JDeveloper SCM API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--oracle.ide.scm.SCMClientAdapter | +--oracle.ide.scm.util.SCMSimpleClient
Simplification superclass for easier integration of a conventional and basic version control extension. Derive from this class if wishing to integrate a version control system fitting the 'reserved checkout model' within the minimum of fuss. Subclasses may implement any number of the provided operation methods, with code to process files.
If ascertaining whether to use make use of this utility in preference to the standard SCM API, consider the following points.
The concrete derivative of this class implements SCMClient and hence Addin, and should be deployed in the usual way.
Sample: RCS extension for JDeveloper.
This class is a code sample to illustrate the use of the SCM API with the framework's extension generalization utility, SCMSimpleClient. It provides a decent level of support for the Revision Control System, or RCS, a popular and fairly straightforward version system.
import oracle.ide.scm.SCMFile; import oracle.ide.scm.util.SCMLogWriter; import oracle.ide.scm.util.SCMEnvironmentVars; import oracle.ide.scm.util.SCMSimpleClient; import oracle.ide.scm.util.runner.SCMShellRunner; import oracle.ide.scm.util.runner.SCMProcess; import oracle.ide.scm.error.SCMException; import oracle.ide.scm.error.SCMMinimalException; import java.util.Iterator; import java.util.Map; import java.io.File; public final class RCSClient extends SCMSimpleClient { private static final String RCS_ADMIN_DIR_NAME = "RCS"; public RCSClient() { super(); Map envvars = SCMEnvironmentVars.getInstance().getVariables(); envvars.put("LOGNAME", System.getProperty("user.name")); envvars.put("TZ", "?"); getShellRunner().setEnvpMap(envvars); getShellRunner().setTimeout(10000); } protected final String getClientExeNameSpi() { return "rcs"; } protected final String getClientNameSpi() { return "Revision Control System (RCS, example)"; } protected final String getClientShortNameSpi() { return "RCS"; } protected boolean getUseCommentsSpi() { return true; } protected final boolean isVersionedSpi(SCMFile file) { return (getRCSFile(file) != null); } protected void doAddSpi( Iterator files, SCMShellRunner runner, SCMLogWriter log) throws SCMException { while (files.hasNext()) { SCMFile file = (SCMFile)files.next(); File parent = file.getParent().toFile(); File admin = new File(parent, RCS_ADMIN_DIR_NAME); if (! (admin.exists() || admin.mkdir())) { throw new SCMMinimalException( "Failed to create RCS administration directory." ); } runRCSCommand("ci -u", file, "", runner); } } protected void doCheckinSpi( Iterator files, SCMShellRunner runner, SCMLogWriter log, String comment) throws SCMException { while (files.hasNext()) runRCSCommand("ci -u", (SCMFile)files.next(), comment, runner); } protected void doCheckoutSpi( Iterator files, SCMShellRunner runner, SCMLogWriter log) throws SCMException { while (files.hasNext()) runRCSCommand("co -f -l", (SCMFile)files.next(), null, runner); } protected void doUndoCheckoutSpi( Iterator files, SCMShellRunner runner, SCMLogWriter log) throws SCMException { while (files.hasNext()) runRCSCommand("co -f -u", (SCMFile)files.next(), null, runner); } protected void doRemoveSpi( Iterator files, SCMShellRunner runner, SCMLogWriter log) throws SCMException { while (files.hasNext()) { SCMFile file = (SCMFile)files.next(); File rcsfile = getRCSFile(file); if (rcsfile != null) rcsfile.delete(); } } protected void viewComparisonSpi( SCMFile file, SCMShellRunner runner, SCMLogWriter log) throws SCMException { runRCSCommand("rcsdiff", file, null, runner); } protected void viewHistorySpi( SCMFile file, SCMShellRunner runner, SCMLogWriter log) throws SCMException { runRCSCommand("rlog", file, null, runner); } private final File getRCSFile(SCMFile file) { String path = RCS_ADMIN_DIR_NAME + File.separator + file.getFileName(); File parent = file.getParent().toFile(); File rcsfile = new File(parent, path); if (rcsfile.exists()) return rcsfile; rcsfile = new File(parent, path + ",v"); return (rcsfile.exists() ? rcsfile : null); } private final SCMProcess runRCSCommand(String cmd, SCMFile file, String input, SCMShellRunner runner) throws SCMException { runner.setCommand(cmd + ' ' + file.getFileName()); runner.setDirectory(file.getParent().toFile()); SCMProcess process = runner.exec(); if (input != null) { process.sendInputData(input); process.sendInputData("."); } return process.waitFor(); } }
Constructor Summary | |
SCMSimpleClient()
|
Method Summary | |
boolean |
canShutdown()
|
void |
detectClient()
Does not perform any actions for client detection. |
protected void |
doAddSpi(java.util.Iterator files,
SCMShellRunner runner,
SCMLogWriter log)
Adds the given files to version control through the client. |
protected void |
doCheckinSpi(java.util.Iterator files,
SCMShellRunner runner,
SCMLogWriter log,
java.lang.String comment)
Checks in the given files to version control through the client. |
protected void |
doCheckoutSpi(java.util.Iterator files,
SCMShellRunner runner,
SCMLogWriter log)
Checks out the given files from version control through the client. |
protected void |
doRemoveSpi(java.util.Iterator files,
SCMShellRunner runner,
SCMLogWriter log)
Removes the given files from version control through the client. |
protected void |
doUndoCheckoutSpi(java.util.Iterator files,
SCMShellRunner runner,
SCMLogWriter log)
Undoes checkouts for the given versioned files through the client. |
void |
finishClient()
Does not perform any actions for intermediate client finalization. |
protected abstract java.lang.String |
getClientExeNameSpi()
Gets the filename of the executable client program. |
protected abstract java.lang.String |
getClientNameSpi()
Gets the descriptive name for the version control client. |
protected abstract java.lang.String |
getClientShortNameSpi()
Gets the short name for the version control client. |
protected SCMLogWriter |
getLogWriter()
Gets the extension's reused log writer instance. |
SCMOperationSet |
getOperations()
Gets an empty operation set for the client. |
java.lang.String |
getSCMName()
Gets a user displayable name for the source control system this client represents. |
java.lang.String |
getSCMShortName()
Gets a user displayable short name for the source control system this client represents. |
protected SCMShellRunner |
getShellRunner()
Gets the extension's reused shell runner instance. |
SCMFileStatus |
getStatus(SCMFile file)
Gets a null status for the file. |
protected boolean |
getUseCommentsSpi()
Asks whether checkin comments are supported by this extension. |
float |
ideVersion()
|
void |
initialize()
|
boolean |
isSourceControlEnabled()
Gets a verdict of false for source control enablement. |
protected abstract boolean |
isVersionedSpi(SCMFile file)
Asks whether the given file is currently under version control. |
void |
prepareClient()
Does not perform any actions for intermediate client initialization. |
void |
shutdown()
|
float |
version()
|
protected void |
viewComparisonSpi(SCMFile file,
SCMShellRunner runner,
SCMLogWriter log)
View comparison information for the given file. |
protected void |
viewHistorySpi(SCMFile file,
SCMShellRunner runner,
SCMLogWriter log)
View historical information for the given file. |
Methods inherited from class oracle.ide.scm.SCMClientAdapter |
getCheckoutLister, getFileSystem, getPropertyCustomizer |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SCMSimpleClient()
Method Detail |
public float version()
public float ideVersion()
public boolean canShutdown()
public void shutdown()
public void initialize()
public void detectClient() throws SCMException
SCMClientAdapter
detectClient
in class SCMClientAdapter
oracle.ide.scm.SCMClient
SCMException
- if the client is absent or cannot be facilitated.public void prepareClient() throws SCMException
SCMClientAdapter
prepareClient
in class SCMClientAdapter
oracle.ide.scm.SCMClient
SCMException
- if an error occurs in preparing the client for use.public java.lang.String getSCMName()
SCMClient
oracle.ide.scm.SCMClient
public java.lang.String getSCMShortName()
SCMClient
oracle.ide.scm.SCMClient
public SCMOperationSet getOperations() throws SCMException
SCMClientAdapter
getOperations
in class SCMClientAdapter
oracle.ide.scm.SCMClientAdapter
public SCMFileStatus getStatus(SCMFile file) throws SCMException
SCMClientAdapter
getStatus
in class SCMClientAdapter
oracle.ide.scm.SCMClientAdapter
public boolean isSourceControlEnabled()
SCMClientAdapter
isSourceControlEnabled
in class SCMClientAdapter
oracle.ide.scm.SCMClientAdapter
public void finishClient() throws SCMException
SCMClientAdapter
finishClient
in class SCMClientAdapter
oracle.ide.scm.SCMClient
SCMException
- if an error occurs in finishing the client session.protected abstract java.lang.String getClientExeNameSpi()
protected abstract java.lang.String getClientNameSpi()
protected abstract java.lang.String getClientShortNameSpi()
protected abstract boolean isVersionedSpi(SCMFile file)
file
- the query file.protected boolean getUseCommentsSpi()
protected void doAddSpi(java.util.Iterator files, SCMShellRunner runner, SCMLogWriter log) throws SCMException
files
- an iterator over files to process.runner
- a shell runner instance, for convenience.log
- the log writer instance.SCMException
- if an error occurred processing files.protected void doCheckinSpi(java.util.Iterator files, SCMShellRunner runner, SCMLogWriter log, java.lang.String comment) throws SCMException
files
- an iterator over files to process.runner
- a shell runner instance, for convenience.log
- the log writer instance.comment
- a comment for the action, or null if not supported.SCMException
- if an error occurred processing files.protected void doCheckoutSpi(java.util.Iterator files, SCMShellRunner runner, SCMLogWriter log) throws SCMException
files
- an iterator over files to process.runner
- a shell runner instance, for convenience.log
- the log writer instance.SCMException
- if an error occurred processing files.protected void doUndoCheckoutSpi(java.util.Iterator files, SCMShellRunner runner, SCMLogWriter log) throws SCMException
files
- an iterator over files to process.runner
- a shell runner instance, for convenience.log
- the log writer instance.SCMException
- if an error occurred processing files.protected void doRemoveSpi(java.util.Iterator files, SCMShellRunner runner, SCMLogWriter log) throws SCMException
files
- an iterator over files to process.runner
- a shell runner instance, for convenience.log
- the log writer instance.SCMException
- if an error occurred processing files.protected void viewComparisonSpi(SCMFile file, SCMShellRunner runner, SCMLogWriter log) throws SCMException
file
- the versioned file to process.runner
- a shell runner instance, for convenience.log
- the log writer instance.SCMException
- if an error occurred processing the file.protected void viewHistorySpi(SCMFile file, SCMShellRunner runner, SCMLogWriter log) throws SCMException
file
- the versioned file to process.runner
- a shell runner instance, for convenience.log
- the log writer instance.SCMException
- if an error occurred processing the file.protected final SCMShellRunner getShellRunner()
protected final SCMLogWriter getLogWriter()
|
Copyright © 2002 Oracle Corporation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |