You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
(39) |
May
(165) |
Jun
(164) |
Jul
(127) |
Aug
(81) |
Sep
(146) |
Oct
(375) |
Nov
(241) |
Dec
(77) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(42) |
Feb
(38) |
Mar
(30) |
Apr
(6) |
May
(17) |
Jun
|
Jul
(15) |
Aug
(59) |
Sep
(31) |
Oct
(44) |
Nov
(30) |
Dec
(12) |
| 2008 |
Jan
(9) |
Feb
(63) |
Mar
(18) |
Apr
(43) |
May
(28) |
Jun
(32) |
Jul
(61) |
Aug
(5) |
Sep
(72) |
Oct
(48) |
Nov
(6) |
Dec
|
|
From: <li...@us...> - 2008-07-29 16:47:01
|
Revision: 2106
http://cogkit.svn.sourceforge.net/cogkit/?rev=2106&view=rev
Author: liuwt
Date: 2008-07-29 16:46:58 +0000 (Tue, 29 Jul 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTOptionsPanel.java
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTOptionsPanel.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTOptionsPanel.java 2008-07-29 16:42:57 UTC (rev 2105)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTOptionsPanel.java 2008-07-29 16:46:58 UTC (rev 2106)
@@ -1,12 +1,8 @@
package org.globus.transfer.reliable.client;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
-import javax.swing.JCheckBox;
import javax.swing.JFrame;
-import javax.swing.JTextField;
public class RFTOptionsPanel extends javax.swing.JPanel implements ItemListener {
@@ -22,50 +18,23 @@
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
-
-// jLabel1 = new javax.swing.JLabel();
-// binary = new javax.swing.JCheckBox();
-// jLabel2 = new javax.swing.JLabel();
-// blockSize = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
tcpBufferSize = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
-// jLabel6 = new javax.swing.JLabel();
-// noTpt = new javax.swing.JCheckBox();
jLabel7 = new javax.swing.JLabel();
parallelStream = new javax.swing.JTextField();
-// jLabel8 = new javax.swing.JLabel();
-// dCAU = new javax.swing.JCheckBox();
jLabel9 = new javax.swing.JLabel();
concurrent = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
sourceSN = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
destSN = new javax.swing.JTextField();
-// enable_rft = new javax.swing.JLabel();
-// enable_rft_checkbox = new javax.swing.JCheckBox();
-// jLabel12 = new javax.swing.JLabel();
-// allOrNone = new javax.swing.JCheckBox();
- //jLabel13 = new javax.swing.JLabel();
-// maxAttempts = new javax.swing.JTextField();
-
+
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(org.globus.transfer.reliable.client.GridFTPGUIApp.class).getContext().getResourceMap(RFTOptionsPanel.class);
setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("Form.border.title"))); // NOI18N
setName("Form"); // NOI18N
-// jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
-// jLabel1.setName("jLabel1"); // NOI18N
-//
-// binary.setText(resourceMap.getString("binary.text")); // NOI18N
-// binary.setName("binary"); // NOI18N
-//
-// jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
-// jLabel2.setName("jLabel2"); // NOI18N
-//
-// blockSize.setText(resourceMap.getString("blockSize.text")); // NOI18N
-// blockSize.setName("blockSize"); // NOI18N
-
jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
jLabel3.setName("jLabel3"); // NOI18N
@@ -76,15 +45,8 @@
jLabel4.setName("jLabel4"); // NOI18N
jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
- jLabel5.setName("jLabel5"); // NOI18N
-
- //enable_rft.setText("enable RFT");
+ jLabel5.setName("jLabel5"); // NOI18N
-// jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
-// jLabel6.setName("jLabel6"); // NOI18N
-//
-// noTpt.setText(resourceMap.getString("noTpt.text")); // NOI18N
-// noTpt.setName("noTpt"); // NOI18N
jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
jLabel7.setName("jLabel7"); // NOI18N
@@ -92,12 +54,6 @@
parallelStream.setText(resourceMap.getString("parallelStream.text")); // NOI18N
parallelStream.setName("parallelStream"); // NOI18N
-// jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
-// jLabel8.setName("jLabel8"); // NOI18N
-//
-// dCAU.setText(resourceMap.getString("dCAU.text")); // NOI18N
-// dCAU.setName("dCAU"); // NOI18N
-
jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
jLabel9.setName("jLabel9"); // NOI18N
@@ -116,22 +72,8 @@
destSN.setText(resourceMap.getString("destSN.text")); // NOI18N
destSN.setName("destSN"); // NOI18N
-// jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
-// jLabel12.setName("jLabel12"); // NOI18N
-//
-// allOrNone.setText(resourceMap.getString("allOrNone.text")); // NOI18N
-// allOrNone.setName("allOrNone"); // NOI18N
-
-// jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
-// jLabel13.setName("jLabel13"); // NOI18N
-
-// maxAttempts.setText(resourceMap.getString("maxAttempts.text")); // NOI18N
-// maxAttempts.setName("maxAttempts"); // NOI18N
-
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
- this.setLayout(layout);
-
- /////////////////////////////////////////////////////////////////////////////////////////////////
+ this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@@ -141,44 +83,13 @@
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(jLabel7)
- //.add(jLabel9)
- .add(jLabel3))
- //.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jLabel7)
+ .add(jLabel3))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
- .add(parallelStream, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 76, Short.MAX_VALUE)
- //.add(concurrent, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 76, Short.MAX_VALUE)
- .add(tcpBufferSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 76, Short.MAX_VALUE))
-
- //.add(jLabel4)
- //.add(93, 93, 93)
-// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
-//// .add(layout.createSequentialGroup()
-//// .add(enable_rft, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-//// .add(enable_rft_checkbox))
-// )
-// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-//
-// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-//
-// .addContainerGap()
+ .add(parallelStream, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 76, Short.MAX_VALUE)
+ .add(tcpBufferSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 76, Short.MAX_VALUE))
)
-// .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
-//// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
-////// .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
-////// //.add(jLabel10)
-////// //.add(34, 34, 34)
-////// //.add(sourceSN, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 677, Short.MAX_VALUE)
-////// )
-////// .add(layout.createSequentialGroup()
-////// //.add(jLabel11)
-////// //.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-////// //.add(destSN, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 677, Short.MAX_VALUE)
-////// )
-//// )
-// .add(262, 262, 262))
))
);
layout.setVerticalGroup(
@@ -188,152 +99,18 @@
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel7)
.add(parallelStream, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .add(jLabel3)
-// .add(tcpBufferSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .add(jLabel4)
+
)
.add(11, 11, 11)
-// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
-// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-// .add(jLabel9)
-// .add(concurrent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-//
-// )
-//// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-//// .add(enable_rft)
-//// .add(enable_rft_checkbox))
-// )
-// .add(11, 11, 11)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(tcpBufferSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- //.add(jLabel4)
+ )
)
-// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-// .add(enable_rft)
-// .add(enable_rft_checkbox))
- )
- //.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
-// //.add(jLabel10)
-// //.add(sourceSN, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// )
- //.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
-// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-// //.add(jLabel11)
-// //.add(destSN, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// )
- //.addContainerGap(127, Short.MAX_VALUE)
)
- );
-
+ );
- ////////////////////////////////////////////////////////////////////////////////////////////////
-// layout.setHorizontalGroup(
-// layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-// .add(layout.createSequentialGroup()
-// .addContainerGap()
-// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
-// .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel11)
-// .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
-// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-//// .add(layout.createSequentialGroup()
-//// .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
-//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-//// .add(binary)
-//// .add(44, 44, 44)
-//// .add(jLabel6)
-//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
-// .add(layout.createSequentialGroup()
-// .add(jLabel7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
-// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-// .add(parallelStream, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 35, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .add(18, 18, 18))
-// .add(layout.createSequentialGroup()
-// .add(jLabel10)
-// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
-// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-//// .add(layout.createSequentialGroup()
-//// .add(noTpt)
-//// .add(38, 38, 38)
-//// .add(jLabel8)
-//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
-//// .add(dCAU)
-//// .add(31, 31, 31)
-//// .add(jLabel12, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 74, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-//// .add(allOrNone)
-// )
-// .add(layout.createSequentialGroup()
-// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-// .add(layout.createSequentialGroup()
-//// .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
-//// .add(blockSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-// .add(jLabel4)
-// .add(30, 30, 30)
-// .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-// .add(tcpBufferSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-// .add(jLabel5)
-// .add(32, 32, 32)
-//// .add(jLabel13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 85, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-// .add(concurrent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-//// .add(18, 18, 18)
-//// .add(jLabel9)
-// .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
-// //.add(maxAttempts, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 37, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// )
-// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
-// .add(org.jdesktop.layout.GroupLayout.LEADING, destSN)
-// .add(org.jdesktop.layout.GroupLayout.LEADING, sourceSN, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 723, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
-// // .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-// ))
-// .add(23, 23, 23))
-// ;
-// layout.setVerticalGroup(
-// layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-// .add(layout.createSequentialGroup()
-//// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-//// .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
-//// .add(binary)
-//// .add(jLabel6)
-//// .add(noTpt)
-//// .add(jLabel8)
-//// .add(dCAU)
-//// .add(jLabel12)
-//// .add(allOrNone)
-// )
-//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-// .add(jLabel7)
-// .add(parallelStream, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// //.add(blockSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .add(jLabel4)
-// .add(jLabel3)
-// .add(tcpBufferSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .add(jLabel5)
-//// .add(jLabel13)
-// .add(concurrent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// //.add(jLabel9)
-// //.add(maxAttempts, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// //.add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// )
-// //.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-// .add(sourceSN, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .add(jLabel10))
-// .add(18, 18, 18)
-// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-// .add(jLabel11)
-// .add(destSN, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-// //.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-// );
}// </editor-fold>//GEN-END:initComponents
@@ -346,34 +123,6 @@
return isBinary;
}
-// public int getBlockSize() {
-// String value = blockSize.getText();
-// int size = 16000;
-// if (null != value) {
-// try {
-// size = Integer.valueOf(value);
-// } catch (NumberFormatException e) {
-// size = 16000;
-// }
-// }
-//
-// return size;
-// }
-
-// public int getConcurrent() {
-// String value = concurrent.getText();
-// int con = 1;
-// if (null != value) {
-// try {
-// con = Integer.valueOf(value);
-// } catch (NumberFormatException e) {
-// con = 1;
-// }
-// }
-//
-// return con;
-// }
-
public boolean getDCAU() {
return isDCAU;
}
@@ -382,21 +131,6 @@
return destSN.getText();
}
-
-// public int getMaxAttempts() {
-// String value = maxAttempts.getText();
-// int max = 1;
-// if (null != value) {
-// try {
-// max = Integer.valueOf(value);
-// } catch (NumberFormatException e) {
-// max = 1;
-// }
-// }
-//
-// return max;
-// }
-
public boolean getNoTpt() {
return isNoTpt;
}
@@ -439,48 +173,23 @@
f.setVisible(true);
}
// Variables declaration - do not modify//GEN-BEGIN:variables
- //private javax.swing.JCheckBox allOrNone;
- //private javax.swing.JCheckBox binary;
- //private javax.swing.JTextField blockSize;
- private javax.swing.JTextField concurrent;
- //private javax.swing.JCheckBox dCAU;
+ private javax.swing.JTextField concurrent;
private javax.swing.JTextField destSN;
- //private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
- //private javax.swing.JLabel jLabel12;
- //private javax.swing.JLabel jLabel13;
- //private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
- //private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
- //private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
- //private javax.swing.JTextField maxAttempts;
- //private javax.swing.JCheckBox noTpt;
private javax.swing.JTextField parallelStream;
private javax.swing.JTextField sourceSN;
private javax.swing.JTextField tcpBufferSize;
- // End of variables declaration//GEN-END:variables
private boolean isBinary = true;
private boolean isNoTpt = false;
private boolean isDCAU = true;
private boolean isAllorNone = false;
-// private javax.swing.JLabel enable_rft;
-// private javax.swing.JCheckBox enable_rft_checkbox;
- public void itemStateChanged(ItemEvent e) {
-// Object source = e.getItemSelectable();
-// if (source == binary) {
-// isBinary = !isBinary;
-// } else if (source == noTpt) {
-// isNoTpt = !isNoTpt;
-// } else if (source == dCAU) {
-// isDCAU = !isDCAU;
-// } else if (source == allOrNone) {
-// isAllorNone = !isAllorNone;
-// }
+ public void itemStateChanged(ItemEvent e) {
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-29 16:43:00
|
Revision: 2105
http://cogkit.svn.sourceforge.net/cogkit/?rev=2105&view=rev
Author: liuwt
Date: 2008-07-29 16:42:57 +0000 (Tue, 29 Jul 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTPanel.java
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTPanel.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTPanel.java 2008-07-29 16:08:41 UTC (rev 2104)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTPanel.java 2008-07-29 16:42:57 UTC (rev 2105)
@@ -93,130 +93,18 @@
okButtonActionPerformed(evt);
}
});
-
-// jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel1.border.title"))); // NOI18N
-// jPanel1.setName("jPanel1"); // NOI18N
-//
-// jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
-// jLabel1.setName("jLabel1"); // NOI18N
-
-// finishedField.setText(resourceMap.getString("finishedField.text")); // NOI18N
-// finishedField.setBorder(javax.swing.BorderFactory.createEtchedBorder());
-// finishedField.setName("finishedField"); // NOI18N
-
-// jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
-// jLabel3.setName("jLabel3"); // NOI18N
-
-// activeField.setText(resourceMap.getString("activeField.text")); // NOI18N
-// activeField.setBorder(javax.swing.BorderFactory.createEtchedBorder());
-// activeField.setName("activeField"); // NOI18N
-
-// jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
-// jLabel5.setName("jLabel5"); // NOI18N
-
-// failedField.setText(resourceMap.getString("failedField.text")); // NOI18N
-// failedField.setBorder(javax.swing.BorderFactory.createEtchedBorder());
-// failedField.setName("failedField"); // NOI18N
-
-// jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
-// jLabel7.setName("jLabel7"); // NOI18N
-
-// restartedField.setText(resourceMap.getString("restartedField.text")); // NOI18N
-// restartedField.setBorder(javax.swing.BorderFactory.createEtchedBorder());
-// restartedField.setName("restartedField"); // NOI18N
-
-// jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
-// jLabel9.setName("jLabel9"); // NOI18N
-
-// pendingField.setText(resourceMap.getString("pendingField.text")); // NOI18N
-// pendingField.setBorder(javax.swing.BorderFactory.createEtchedBorder());
-// pendingField.setName("pendingField"); // NOI18N
-
-// jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
-// jLabel11.setName("jLabel11"); // NOI18N
-
-// cancelledField.setText(resourceMap.getString("cancelledField.text")); // NOI18N
-// cancelledField.setBorder(javax.swing.BorderFactory.createEtchedBorder());
-// cancelledField.setName("cancelledField"); // NOI18N
-
- //org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
- // jPanel1.setLayout(jPanel1Layout);
-// jPanel1Layout.setHorizontalGroup(
-// jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-// .add(jPanel1Layout.createSequentialGroup()
-// .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-// .add(finishedField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 39, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .add(48, 48, 48)
-// .add(jLabel3)
-// .add(18, 18, 18)
-// .add(activeField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .add(60, 60, 60)
-// .add(jLabel5)
-// .add(45, 45, 45)
-// .add(failedField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 48, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .add(40, 40, 40)
-// .add(jLabel7)
-// .add(28, 28, 28)
-// .add(restartedField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 42, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .add(38, 38, 38)
-// .add(jLabel9)
-// .add(18, 18, 18)
-// .add(pendingField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 43, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .add(42, 42, 42)
-// .add(jLabel11)
-// .add(18, 18, 18)
-// .add(cancelledField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 38, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .addContainerGap(317, Short.MAX_VALUE))
-// );
-// jPanel1Layout.setVerticalGroup(
-// jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-// .add(jPanel1Layout.createSequentialGroup()
-// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-// .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 26, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .add(jLabel3)
-// .add(finishedField)
-// .add(activeField)
-// .add(jLabel5)
-// .add(failedField)
-// .add(jLabel7)
-// .add(restartedField)
-// .add(jLabel9)
-// .add(pendingField)
-// .add(jLabel11)
-// .add(cancelledField))
-// .addContainerGap(21, Short.MAX_VALUE))
-// );
-
+
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-// .add(layout.createSequentialGroup()
-// //.addContainerGap()
-// //.add(rftQueuePanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1230, Short.MAX_VALUE)
-// )
-// .add(layout.createSequentialGroup()
-// .addContainerGap()
-// .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-// .addContainerGap())
- .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
- // .addContainerGap()
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(rFTOptions1, 100, 300, 400)
- .addContainerGap())
- //.add(layout.createSequentialGroup()
- // .addContainerGap()
+ .addContainerGap())
.add(rFTTransferParam1, 100, 300, 400)
- // .addContainerGap()
- //)
.add(layout.createSequentialGroup()
- //.add(299, 299, 299)
- //.add(startButton)
- //.add(58, 58, 58)
- //.add(stopButton)
.add(200, 200, 200)
- .add(okButton)
- // .addContainerGap(616, Short.MAX_VALUE)
+ .add(okButton)
)
);
@@ -225,19 +113,11 @@
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
- //.addContainerGap()
- //.add(rftQueuePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 215, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- // .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
-// .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-// .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
- .add(rFTOptions1, 80, 100, 130)
- //.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
- .add(rFTTransferParam1, 100, 150, 200)
+ .add(rFTOptions1, 80, 100, 130)
+ .add(rFTTransferParam1, 150, 200, 250)
.add(18, 18, 18)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-// .add(startButton)
-// .add(stopButton)
- .add(okButton))
+ .add(okButton))
.add(92, 92, 92))
);
@@ -291,10 +171,7 @@
Properties prop = new Properties();
try {
File prop_file = new File("rft.properties");
-// if (!prop_file.exists()) {
-// prop_file.createNewFile();
-// }
- //prop.load(new FileInputStream(prop_file));
+
prop.setProperty("rft_enabled", String.valueOf(rFTTransferParam1.isRFTEnabled()));
prop.setProperty("host", rFTTransferParam1.getServerHost());
prop.setProperty("port", rFTTransferParam1.getServerPort());
@@ -359,35 +236,8 @@
}
}
- }
+ }
- /**
- * update Overall Status Panel of the GUI
- * @param finished
- * @param active
- * @param failed
- * @param retrying
- * @param pending
- * @param cancelled
- */
-// public void updateOverallStatus(int finished, int active, int failed,
-// int retrying, int pending, int cancelled) {
-//// int oldFinished = Integer.valueOf(finishedField.getText());
-//// int oldActive = Integer.valueOf(activeField.getText());
-//// int oldFailed = Integer.valueOf(failedField.getText());
-//// int oldRetrying = Integer.valueOf(restartedField.getText());
-//// int oldPending = Integer.valueOf(pendingField.getText());
-//// int oldCancelled = Integer.valueOf(cancelledField.getText());
-// finishedField.setText(Integer.toString(finished));
-// //activeField.setText(Integer.toString(active + oldActive));
-// activeField.setText(Integer.toString(active));
-// failedField.setText(Integer.toString(failed));
-// restartedField.setText(Integer.toString(retrying));
-// //pendingField.setText(Integer.toString(pending + oldPending));
-// pendingField.setText(Integer.toString(pending));
-// cancelledField.setText(Integer.toString(cancelled));
-// }
-
public QueuePanel getQueuePanel() {
return rftQueuePanel;
}
@@ -405,22 +255,10 @@
private RFTButtonActionListener actionListener;
// Variables declaration - do not modify//GEN-BEGIN:variables
-// private javax.swing.JLabel activeField;
-// private javax.swing.JLabel cancelledField;
-// private javax.swing.JLabel failedField;
-// private javax.swing.JLabel finishedField;
- //private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel11;
- //private javax.swing.JLabel jLabel3;
- //private javax.swing.JLabel jLabel5;
- //private javax.swing.JLabel jLabel7;
- //private javax.swing.JLabel jLabel9;
- //private javax.swing.JPanel jPanel1;
- //private javax.swing.JLabel pendingField;
private RFTOptionsPanel rFTOptions1;
private RFTTransferParamPanel rFTTransferParam1;
- private javax.swing.JButton okButton;
- //private javax.swing.JLabel restartedField;
+ private javax.swing.JButton okButton;
private org.globus.ogce.beans.filetransfer.gui.monitor.QueuePanel rftQueuePanel;
private javax.swing.JButton startButton;
private javax.swing.JButton stopButton;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-29 16:08:44
|
Revision: 2104
http://cogkit.svn.sourceforge.net/cogkit/?rev=2104&view=rev
Author: liuwt
Date: 2008-07-29 16:08:41 +0000 (Tue, 29 Jul 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTOptionsPanel.properties
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTOptionsPanel.properties
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTOptionsPanel.properties 2008-07-28 00:14:57 UTC (rev 2103)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTOptionsPanel.properties 2008-07-29 16:08:41 UTC (rev 2104)
@@ -1,7 +1,7 @@
# To change this template, choose Tools | Templates
# and open the template in the editor.
-Form.border.title=Options
+Form.border.title=Optimization Parameter
jLabel1.text=Binary
jLabel2.text=BlockSize
jLabel3.text=TCP Buffer Size
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-28 00:14:58
|
Revision: 2103
http://cogkit.svn.sourceforge.net/cogkit/?rev=2103&view=rev
Author: hategan
Date: 2008-07-28 00:14:57 +0000 (Mon, 28 Jul 2008)
Log Message:
-----------
updated launchers
Modified Paths:
--------------
branches/karajan2/src/cog/modules/karajan2/launchers.xml
Modified: branches/karajan2/src/cog/modules/karajan2/launchers.xml
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/launchers.xml 2008-07-28 00:14:35 UTC (rev 2102)
+++ branches/karajan2/src/cog/modules/karajan2/launchers.xml 2008-07-28 00:14:57 UTC (rev 2103)
@@ -8,6 +8,10 @@
<property name="launcher-name" value="kc"/>
<property name="class-name" value="org.globus.cog.karajan.compiler.Compiler"/>
</ant>
+ <ant antfile="${main.buildfile}" target="launcher">
+ <property name="launcher-name" value="test-runner"/>
+ <property name="class-name" value="org.globus.cog.karajan.TestRunner"/>
+ </ant>
</target>
<target name="webstart">
</target>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-28 00:14:37
|
Revision: 2102
http://cogkit.svn.sourceforge.net/cogkit/?rev=2102&view=rev
Author: hategan
Date: 2008-07-28 00:14:35 +0000 (Mon, 28 Jul 2008)
Log Message:
-----------
updated tests
Modified Paths:
--------------
branches/karajan2/src/cog/modules/karajan2/tests/run
branches/karajan2/src/cog/modules/karajan2/tests/types.k
Added Paths:
-----------
branches/karajan2/src/cog/modules/karajan2/tests/lists.k
branches/karajan2/src/cog/modules/karajan2/tests/lists.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k
branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k
branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k
branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k
branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k.expected
Added: branches/karajan2/src/cog/modules/karajan2/tests/lists.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/lists.k (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/lists.k 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,17 @@
+import(sys)
+import(list)
+
+l1 := List(Integer)(1, 2, 3, 4)
+
+print(l1)
+print(first(l1) + last(l1))
+print(butFirst(l1))
+print(butLast(l1))
+print(butFirst(butLast(l1)))
+print(concat(butFirst(l1), butLast(l1)))
+print(subList(l1, 2))
+print(subList(l1, 1, 3))
+
+l2 := List(?)(1, "abc", 3.0)
+
+print(l2)
Added: branches/karajan2/src/cog/modules/karajan2/tests/lists.k.expected
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/lists.k.expected (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/lists.k.expected 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,9 @@
+[1, 2, 3, 4]
+5
+[2, 3, 4]
+[1, 2, 3]
+[2, 3]
+[2, 3, 4, 1, 2, 3]
+[3, 4]
+[2, 3]
+[1, abc, 3.0]
Added: branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,23 @@
+import(sys)
+import(string)
+
+Tree := type(value, left:Tree, right:Tree) {
+ toString := function() {
+ concat(
+ value, "["
+ if (left != nil, (left::toString(), ", "))
+ if (right != nil, right::toString())
+ "]"
+ )
+ }
+}
+
+t := Tree("a",
+ Tree("b"
+ nil
+ Tree("c", nil, nil)
+ )
+ Tree("d", nil, nil)
+)
+
+print(t::toString())
\ No newline at end of file
Added: branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k.expected
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k.expected (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k.expected 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1 @@
+a[b[c[]], d[]]
Modified: branches/karajan2/src/cog/modules/karajan2/tests/run
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/run 2008-07-28 00:14:14 UTC (rev 2101)
+++ branches/karajan2/src/cog/modules/karajan2/tests/run 2008-07-28 00:14:35 UTC (rev 2102)
@@ -2,7 +2,7 @@
# make up a tc.data file
-COUNT=4
+COUNT=2
checkOutput() {
for e in $EXPECTEDS; do
@@ -67,12 +67,9 @@
else
echo Running test $t
echo expecting $EXPECTEDS
- for i in `seq $COUNT`; do
- k -intermediate ${t}.k > "$testfn.out" 2>&1
- if [ "$?" -ne "0" ]; then echo "K RETURN CODE NON-ZERO"; exit 1; fi
- checkOutput
- echo -n "."
- done
+
+ test-runner ${t}.k $COUNT
+ if [ "$?" -ne "0" ]; then echo "K RETURN CODE NON-ZERO"; exit 1; fi
echo
fi
@@ -83,7 +80,7 @@
done
if [ "$SUB" == "" ]; then
- echo All language behaviour tests passed
+ echo All tests passed
fi
exit 0
Added: branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,24 @@
+import(sys)
+
+integerf := function() {
+ Integer
+}
+
+mirror := function(t:Type) {
+ t
+}
+
+x:Integer = 1
+y:integerf() = 1
+z:mirror(Integer) = 1
+
+myInt := mirror(Integer)
+w:myInt = 1
+
+print(mirror)
+print(x)
+print(y)
+print(z)
+print(myInt)
+print(w)
+
Added: branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k.expected
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k.expected (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k.expected 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,6 @@
+Type -> Type
+1
+1
+1
+Integer
+1
Added: branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,17 @@
+import(sys)
+
+f := function(t:Type) {
+ type(x:t, y:t) {
+ }
+}
+
+ti := f(Integer)
+tii := ti(1, 2)
+
+print(tii::x + tii::y)
+
+tr := f(Real)
+trr := tr(1.1, 2.2)
+
+print(trr::x + trr::y)
+
Added: branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k.expected
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k.expected (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k.expected 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,2 @@
+3
+3.3000000000000003
Added: branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,9 @@
+import(sys)
+
+f := function(x: Integer | Real) {
+ print(x)
+}
+
+print(f)
+f(1)
+f(2.0)
\ No newline at end of file
Added: branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k.expected
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k.expected (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k.expected 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,3 @@
+Integer | Real -> |stdout:?|
+1
+2.0
Modified: branches/karajan2/src/cog/modules/karajan2/tests/types.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/types.k 2008-07-28 00:14:14 UTC (rev 2101)
+++ branches/karajan2/src/cog/modules/karajan2/tests/types.k 2008-07-28 00:14:35 UTC (rev 2102)
@@ -1,22 +1,22 @@
import(sys)
-Address := type(
+Address:Type = type(
number:Integer
street:String
city:String
state:String
- zip:Integer
-) {
+ zip:Integer) {
+
toString := function() {
"{number} {street}\n{city}, {state} {zip}"
}
}
-Person := type(
+Person:Type = type(
name:String
age:Integer
- address:Address
-) {
+ address:Address) {
+
toString := function() {
"{name}, {age}\n" + address::toString()
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-28 00:14:18
|
Revision: 2101
http://cogkit.svn.sourceforge.net/cogkit/?rev=2101&view=rev
Author: hategan
Date: 2008-07-28 00:14:14 +0000 (Mon, 28 Jul 2008)
Log Message:
-----------
updated libraries
Modified Paths:
--------------
branches/karajan2/src/cog/modules/karajan2/resources/karajan-language.gr
branches/karajan2/src/cog/modules/karajan2/resources/string.class
branches/karajan2/src/cog/modules/karajan2/resources/string.java
branches/karajan2/src/cog/modules/karajan2/resources/sys.class
branches/karajan2/src/cog/modules/karajan2/resources/sys.java
branches/karajan2/src/cog/modules/karajan2/resources/sys.k
Added Paths:
-----------
branches/karajan2/src/cog/modules/karajan2/resources/list.class
branches/karajan2/src/cog/modules/karajan2/resources/list.java
branches/karajan2/src/cog/modules/karajan2/resources/list.k
Modified: branches/karajan2/src/cog/modules/karajan2/resources/karajan-language.gr
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/resources/karajan-language.gr 2008-07-28 00:13:43 UTC (rev 2100)
+++ branches/karajan2/src/cog/modules/karajan2/resources/karajan-language.gr 2008-07-28 00:14:14 UTC (rev 2101)
@@ -16,23 +16,15 @@
maybeElse := else | E() ;
itemOrCommentOrNone :=
- else moreItems |
+ else moreItems |
comment moreItems |
expression moreItems |
- LITERAL(":=") IDENTIFIER("k.set") op |
- LITERAL(":") HSPACES() IDENTIFIER() HSPACES() typedecl? |
- LITERAL("=") IDENTIFIER("k.map") op |
- LITERAL("->") sigdef |
- LITERAL("...") IDENTIFIER("...") VARIABLE() moreItems |
+ LITERAL("->") sigdef |
LITERAL(".") IDENTIFIER() HSPACES() invocation SWAP() ADDCHILD() itemOrCommentOrNone |
E() ;
op := BEGINELEMENT() SWAP() HVSPACES() expression maybeElse ENDELEMENT() moreItems ;
-typedecl? :=
- LITERAL("=") IDENTIFIER("k.set") BEGINELEMENT() ROT() HVSPACES() expression ENDELEMENT() moreItems |
- IDENTIFIER("k.typedecl") BEGINELEMENT() ROT() ENDELEMENT() moreItems ;
-
/* Rather crappy this one */
sigdef :=
REMOVECHILD() IDENTIFIER("k.sig") BEGINELEMENT() ENDELEMENT() SWAP() ADDCHILD()
@@ -51,8 +43,13 @@
blockReference |
varIndirection |
LITERAL("{") block |
- IDENTIFIER() HSPACES() action HVSPACES() ;
+ IDENTIFIER() HSPACES() action HSPACES() maybeApply ;
+maybeApply :=
+ LITERAL("(") IDENTIFIER("k.apply") BEGINELEMENT() SWAP() moreItems ENDELEMENT() LITERAL(")") HSPACES() maybeApply |
+ E() ;
+
+
identifierReference := LITERAL("'") IDENTIFIER("k.vref") BEGINELEMENT() IDENTIFIER() VARIABLE() ENDELEMENT() ;
blockReference := LITERAL("&") IDENTIFIER("k.bref") BEGINELEMENT() IDENTIFIER() VARIABLE() ENDELEMENT() ;
@@ -73,11 +70,10 @@
action :=
invocation |
- LITERAL("==") VARIABLE() IDENTIFIER("==") infixop< expression endExpr> |
- LITERAL("=") TRANSLITERATE() HVSPACES() expression NAMED() |
+ LITERAL("==") VARIABLE() IDENTIFIER("==") infixop< expression endExpr> |
LITERAL("{") TRANSLITERATE() BEGINELEMENT() block ENDELEMENT() |
VARIABLE() ;
-
+
invocation :=
LITERAL("(") TRANSLITERATE() BEGINELEMENT() moreItems LITERAL(")") HVSPACES() maybeBlock ENDELEMENT() ;
@@ -106,9 +102,9 @@
comment moreExpression |
e0 moreExpression | e1 moreExpression | e2 moreExpression |
e3 moreExpression | e4 moreExpression | e5 moreExpression |
- e6 moreExpression |
+ e6 moreExpression | e7 moreExpression | e8 moreExpression |
E() ;
-
+
e0 := o0 infixop< expitem me0> ;
me0> := endExpr> ge0 ;
@@ -194,11 +190,40 @@
o5 :=
LITERAL("&") IDENTIFIER("&") ;
-e6 := o6 infixop< expression endExpr> ;
+e6 := o6 infixop< expitem me6> ;
+me6> := lt6 mlt6 endExpr> ge6 | endExpr> ge6 ;
+
+lt6 := e5 | lt5 ;
+
+mlt6 := lt6 mlt6 | E() ;
+
+ge6 := e6 | E() ;
+
o6 :=
LITERAL("|") IDENTIFIER("|") ;
+
+e7 := o7 infixop< expitem me7> ;
+me7> := lt7 mlt7 endExpr> ge7 | endExpr> ge7 ;
+
+lt7 := e6 | lt6 ;
+
+mlt7 := lt7 mlt7 | E() ;
+
+ge7 := e7 | E() ;
+
+o7 :=
+ LITERAL(":=") IDENTIFIER("k.set") |
+ LITERAL(":") IDENTIFIER("k.typedecl") ;
+
+
+e8 := o8 infixop< expression endExpr> ;
+
+o8 :=
+ LITERAL("=") IDENTIFIER("k.named") ;
+
+
endExpr> := ENDELEMENT() HVSPACES() commentOrNone ;
infixop< := TRANSLITERATE() BEGINELEMENT() SWAP() HVSPACES() ;
Property changes on: branches/karajan2/src/cog/modules/karajan2/resources/list.class
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/karajan2/src/cog/modules/karajan2/resources/list.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/resources/list.java (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/resources/list.java 2008-07-28 00:14:14 UTC (rev 2101)
@@ -0,0 +1,198 @@
+import org.globus.cog.karajan.runtime.*;
+import org.globus.cog.karajan.compiler.*;
+import org.globus.cog.karajan.compiler.types.*;
+import org.globus.cog.karajan.threading.*;
+import org.globus.cog.karajan.runtime.StdSink.StdoutSink;
+import org.globus.cog.karajan.runtime.StdSink.StderrSink;
+import java.util.Collection;
+import java.util.Iterator;
+import org.globus.cog.karajan.compiler.Compiler;
+import org.globus.cog.karajan.runtime.Signature.Positional;
+import org.globus.cog.karajan.runtime.Signature.Optional;
+import org.globus.cog.karajan.runtime.Signature.Return;
+
+
+public final class list implements Runnable {
+ public static final String __ORIGNAME = "list.k";
+ public static void main(String[] args) {
+ LWThread thread = new LWThread(new list());
+ thread.start();
+ try {
+ thread.waitFor();
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ public void run() {
+ final LWThread thread = LWThread.currentThread();
+ thread.checkSlice();
+ int __state__ = thread.popState();
+ switch(__state__) {
+ case 0: //main (list:1)
+ thread.ctx = new Context(39, thread.ctx);
+ case 1: //main (list:1)
+ thread.ctx.pushChannel(1, new StdoutSink());
+ thread.ctx.pushChannel(2, new StderrSink());
+ //[butLast, last, butFirst, List?, subList, List, concat, first]
+ thread.ctx = new Context(8, thread.ctx);
+ case 2: //main (list:1)
+ k_dot_set_1_0000();
+ case 3: //main (list:1)
+ k_dot_set_2_0001();
+ case 4: //main (list:1)
+ k_dot_set_3_0002();
+ case 5: //main (list:1)
+ k_dot_set_4_0003();
+ case 6: //main (list:1)
+ k_dot_set_5_0004();
+ case 7: //main (list:1)
+ k_dot_set_6_0005();
+ case 8: //main (list:1)
+ k_dot_set_7_0006();
+ case 9: //main (list:1)
+ k_dot_set_8_0007();
+ case 10: //main (list:1)
+ // namespace (list:12)
+ k_dot_block_13_0008();
+ thread.popCtx();
+ thread.popCtx();
+ }
+ }
+
+ private void checkMismatch(int expected, int actual) throws ExecutionException {
+ if(expected != actual) {
+ throw new ExecutionException("Got " + expected + " identifier(s) and " + actual + " values");
+ }
+ }
+ // k.set (list:1)
+ private void k_dot_set_1_0000() {
+ final LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (list:1)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.list.Lst.Polymorphic());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(0, def.get(0));
+ }
+
+ // k.set (list:2)
+ private void k_dot_set_2_0001() {
+ final LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (list:2)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.list.Lst.Unknown());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(1, def.get(0));
+ }
+
+ // k.set (list:3)
+ private void k_dot_set_3_0002() {
+ final LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (list:3)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.list.Lst.First());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(2, def.get(0));
+ }
+
+ // k.set (list:4)
+ private void k_dot_set_4_0003() {
+ final LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (list:4)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.list.Lst.Last());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(3, def.get(0));
+ }
+
+ // k.set (list:5)
+ private void k_dot_set_5_0004() {
+ final LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (list:5)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.list.Lst.ButFirst());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(4, def.get(0));
+ }
+
+ // k.set (list:6)
+ private void k_dot_set_6_0005() {
+ final LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (list:6)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.list.Lst.ButLast());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(5, def.get(0));
+ }
+
+ // k.set (list:7)
+ private void k_dot_set_7_0006() {
+ final LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (list:7)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.list.Lst.Concat());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(6, def.get(0));
+ }
+
+ // k.set (list:8)
+ private void k_dot_set_8_0007() {
+ final LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // | (list:10)
+ thread.ctx.pushChannel(0, new AltCallable());
+ // native (list:9)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.list.Lst.SubList1());
+ // native (list:10)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.list.Lst.SubList2());
+ thread.ctx.append(0, thread.ctx.popChannel(0));
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(7, def.get(0));
+ }
+
+ public static final Type TYPE = new UnionType(
+ new NamedType("List", SimpleType.Type.instance(NativeFunction.getInstance(org.globus.cog.karajan.lib.list.Lst.Polymorphic.class))),
+ new NamedType("List?", NativeFunction.getInstance(org.globus.cog.karajan.lib.list.Lst.Unknown.class)),
+ new NamedType("first", NativeFunction.getInstance(org.globus.cog.karajan.lib.list.Lst.First.class)),
+ new NamedType("last", NativeFunction.getInstance(org.globus.cog.karajan.lib.list.Lst.Last.class)),
+ new NamedType("butFirst", NativeFunction.getInstance(org.globus.cog.karajan.lib.list.Lst.ButFirst.class)),
+ new NamedType("butLast", NativeFunction.getInstance(org.globus.cog.karajan.lib.list.Lst.ButLast.class)),
+ new NamedType("concat", NativeFunction.getInstance(org.globus.cog.karajan.lib.list.Lst.Concat.class)),
+ new NamedType("subList", new AltType(
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.list.Lst.SubList1.class),
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.list.Lst.SubList2.class)
+ ))
+ );
+ // k.block (list:13)
+ private void k_dot_block_13_0008() {
+ final LWThread thread = LWThread.currentThread();
+ thread.checkSlice();
+ int __state__ = thread.popState();
+ switch(__state__) {
+ case 0: //k.block (list:13)
+ // export (list:14)
+ thread.ctx.getChannel(0).append(thread.ctx.get(0));
+ thread.ctx.getChannel(0).append(thread.ctx.get(1));
+ thread.ctx.getChannel(0).append(thread.ctx.get(2));
+ thread.ctx.getChannel(0).append(thread.ctx.get(3));
+ thread.ctx.getChannel(0).append(thread.ctx.get(4));
+ thread.ctx.getChannel(0).append(thread.ctx.get(5));
+ thread.ctx.getChannel(0).append(thread.ctx.get(6));
+ thread.ctx.getChannel(0).append(thread.ctx.get(7));
+ }
+ }
+
+ public static final int[] __LINE_TABLE = new int[] {
+ 34, 36, 41, 43, 45, 47, 49, 51, 53, 55, 57, 62, //run
+ 175//k_dot_block_13_0008
+ };
+ public static final int[] __STATE_TABLE = new int[] {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, //run
+ 0//k_dot_block_13_0008
+ };
+ static {
+ StateTables.register(list.class);
+ }
+}
Added: branches/karajan2/src/cog/modules/karajan2/resources/list.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/resources/list.k (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/resources/list.k 2008-07-28 00:14:14 UTC (rev 2101)
@@ -0,0 +1,18 @@
+List := native(org.globus.cog.karajan.lib.list.Lst$Polymorphic)
+List? := native(org.globus.cog.karajan.lib.list.Lst$Unknown)
+first := native(org.globus.cog.karajan.lib.list.Lst$First)
+last := native(org.globus.cog.karajan.lib.list.Lst$Last)
+butFirst := native(org.globus.cog.karajan.lib.list.Lst$ButFirst)
+butLast := native(org.globus.cog.karajan.lib.list.Lst$ButLast)
+concat := native(org.globus.cog.karajan.lib.list.Lst$Concat)
+subList :=
+ native(org.globus.cog.karajan.lib.list.Lst$SubList1)
+ | native(org.globus.cog.karajan.lib.list.Lst$SubList2)
+
+namespace(list) {
+ export(
+ List, List?, first, last,
+ butFirst, butLast,
+ concat, subList
+ )
+}
\ No newline at end of file
Modified: branches/karajan2/src/cog/modules/karajan2/resources/string.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/resources/string.java 2008-07-28 00:13:43 UTC (rev 2100)
+++ branches/karajan2/src/cog/modules/karajan2/resources/string.java 2008-07-28 00:14:14 UTC (rev 2101)
@@ -1,25 +1,15 @@
-import org.globus.cog.karajan.threading.LWThread;
-import org.globus.cog.karajan.threading.Yield;
-import org.globus.cog.karajan.runtime.Context;
-import org.globus.cog.karajan.runtime.Channel;
-import org.globus.cog.karajan.runtime.Exceptions;
-import org.globus.cog.karajan.runtime.Callable;
+import org.globus.cog.karajan.runtime.*;
+import org.globus.cog.karajan.compiler.*;
+import org.globus.cog.karajan.compiler.types.*;
+import org.globus.cog.karajan.threading.*;
import org.globus.cog.karajan.runtime.StdSink.StdoutSink;
import org.globus.cog.karajan.runtime.StdSink.StderrSink;
-import org.globus.cog.karajan.runtime.NVPair;
-import org.globus.cog.karajan.runtime.Arguments;
import java.util.Collection;
-import org.globus.cog.karajan.threading.StateTables;
-import org.globus.cog.karajan.threading.LWThreadDeath;
-import org.globus.cog.karajan.runtime.OrderedParallelChannel;
import java.util.Iterator;
-import org.globus.cog.karajan.runtime.LookAheadIterator;
-import org.globus.cog.karajan.runtime.ExecutionException;
-import org.globus.cog.karajan.runtime.Abort;
-import org.globus.cog.karajan.compiler.VariableNotFoundException;
-import org.globus.cog.karajan.runtime.FutureValueChannel;
-import org.globus.cog.karajan.runtime.Futures;
import org.globus.cog.karajan.compiler.Compiler;
+import org.globus.cog.karajan.runtime.Signature.Positional;
+import org.globus.cog.karajan.runtime.Signature.Optional;
+import org.globus.cog.karajan.runtime.Signature.Return;
public final class string implements Runnable {
@@ -42,7 +32,7 @@
int __state__ = thread.popState();
switch(__state__) {
case 0: //main (string:1)
- thread.ctx = new Context(33, thread.ctx);
+ thread.ctx = new Context(39, thread.ctx);
case 1: //main (string:1)
thread.ctx.pushChannel(1, new StdoutSink());
thread.ctx.pushChannel(2, new StderrSink());
@@ -83,7 +73,7 @@
}
// k.set (string:1)
private void k_dot_set_1_0000() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (string:1)
thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.Substring());
@@ -93,7 +83,7 @@
// k.set (string:3)
private void k_dot_set_3_0001() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (string:3)
thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.Concat());
@@ -103,7 +93,7 @@
// k.set (string:4)
private void k_dot_set_4_0002() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (string:4)
thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.StartsWith());
@@ -113,7 +103,7 @@
// k.set (string:5)
private void k_dot_set_5_0003() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (string:5)
thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.EndsWith());
@@ -123,7 +113,7 @@
// k.set (string:6)
private void k_dot_set_6_0004() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (string:6)
thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.IndexOf());
@@ -133,7 +123,7 @@
// k.set (string:7)
private void k_dot_set_7_0005() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (string:7)
thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.LastIndexOf());
@@ -143,7 +133,7 @@
// k.set (string:8)
private void k_dot_set_8_0006() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (string:8)
thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.Matches());
@@ -153,7 +143,7 @@
// k.set (string:10)
private void k_dot_set_10_0007() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (string:10)
thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.ToUpperCase());
@@ -163,7 +153,7 @@
// k.set (string:11)
private void k_dot_set_11_0008() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (string:11)
thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.ToLowerCase());
@@ -173,7 +163,7 @@
// k.set (string:12)
private void k_dot_set_12_0009() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (string:12)
thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.Trim());
@@ -181,6 +171,18 @@
thread.ctx.set(9, def.get(0));
}
+ public static final Type TYPE = new UnionType(
+ new NamedType("substring", NativeFunction.getInstance(org.globus.cog.karajan.lib.string.Str.Substring.class)),
+ new NamedType("concat", NativeFunction.getInstance(org.globus.cog.karajan.lib.string.Str.Concat.class)),
+ new NamedType("startsWith", NativeFunction.getInstance(org.globus.cog.karajan.lib.string.Str.StartsWith.class)),
+ new NamedType("endsWith", NativeFunction.getInstance(org.globus.cog.karajan.lib.string.Str.EndsWith.class)),
+ new NamedType("indexOf", NativeFunction.getInstance(org.globus.cog.karajan.lib.string.Str.IndexOf.class)),
+ new NamedType("lastIndexOf", NativeFunction.getInstance(org.globus.cog.karajan.lib.string.Str.LastIndexOf.class)),
+ new NamedType("matches", NativeFunction.getInstance(org.globus.cog.karajan.lib.string.Str.Matches.class)),
+ new NamedType("toUpperCase", NativeFunction.getInstance(org.globus.cog.karajan.lib.string.Str.ToUpperCase.class)),
+ new NamedType("toLowerCase", NativeFunction.getInstance(org.globus.cog.karajan.lib.string.Str.ToLowerCase.class)),
+ new NamedType("trim", NativeFunction.getInstance(org.globus.cog.karajan.lib.string.Str.Trim.class))
+ );
// k.block (string:15)
private void k_dot_block_15_0010() {
final LWThread thread = LWThread.currentThread();
@@ -203,8 +205,8 @@
}
public static final int[] __LINE_TABLE = new int[] {
- 44, 46, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 76, //run
- 190//k_dot_block_15_0010
+ 34, 36, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 66, //run
+ 193//k_dot_block_15_0010
};
public static final int[] __STATE_TABLE = new int[] {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, -1, //run
@@ -213,6 +215,4 @@
static {
StateTables.register(string.class);
}
- public static void __exports__() {
- }
}
Modified: branches/karajan2/src/cog/modules/karajan2/resources/sys.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/resources/sys.java 2008-07-28 00:13:43 UTC (rev 2100)
+++ branches/karajan2/src/cog/modules/karajan2/resources/sys.java 2008-07-28 00:14:14 UTC (rev 2101)
@@ -1,25 +1,15 @@
-import org.globus.cog.karajan.threading.LWThread;
-import org.globus.cog.karajan.threading.Yield;
-import org.globus.cog.karajan.runtime.Context;
-import org.globus.cog.karajan.runtime.Channel;
-import org.globus.cog.karajan.runtime.Exceptions;
-import org.globus.cog.karajan.runtime.Callable;
+import org.globus.cog.karajan.runtime.*;
+import org.globus.cog.karajan.compiler.*;
+import org.globus.cog.karajan.compiler.types.*;
+import org.globus.cog.karajan.threading.*;
import org.globus.cog.karajan.runtime.StdSink.StdoutSink;
import org.globus.cog.karajan.runtime.StdSink.StderrSink;
-import org.globus.cog.karajan.runtime.NVPair;
-import org.globus.cog.karajan.runtime.Arguments;
import java.util.Collection;
-import org.globus.cog.karajan.threading.StateTables;
-import org.globus.cog.karajan.threading.LWThreadDeath;
-import org.globus.cog.karajan.runtime.OrderedParallelChannel;
import java.util.Iterator;
-import org.globus.cog.karajan.runtime.LookAheadIterator;
-import org.globus.cog.karajan.runtime.ExecutionException;
-import org.globus.cog.karajan.runtime.Abort;
-import org.globus.cog.karajan.compiler.VariableNotFoundException;
-import org.globus.cog.karajan.runtime.FutureValueChannel;
-import org.globus.cog.karajan.runtime.Futures;
import org.globus.cog.karajan.compiler.Compiler;
+import org.globus.cog.karajan.runtime.Signature.Positional;
+import org.globus.cog.karajan.runtime.Signature.Optional;
+import org.globus.cog.karajan.runtime.Signature.Return;
public final class sys implements Runnable {
@@ -42,12 +32,12 @@
int __state__ = thread.popState();
switch(__state__) {
case 0: //main (sys:1)
- thread.ctx = new Context(33, thread.ctx);
+ thread.ctx = new Context(39, thread.ctx);
case 1: //main (sys:1)
thread.ctx.pushChannel(1, new StdoutSink());
thread.ctx.pushChannel(2, new StderrSink());
- //[Exception, range, __times_, __fwslash_, __gt___eq_, wait, __lt___eq_, echo, print, throw, __eq___eq_, __plus_, __gt_, __lt_, __minus_]
- thread.ctx = new Context(15, thread.ctx);
+ //[Exception, range, __times_, __fwslash_, __gt___eq_, wait, __lt___eq_, echo, print, throw, __eq___eq_, __plus_, __gt_, __bang___eq_, __lt_, __minus_]
+ thread.ctx = new Context(16, thread.ctx);
case 2: //main (sys:1)
k_dot_set_1_0000();
case 3: //main (sys:1)
@@ -61,26 +51,28 @@
case 7: //main (sys:1)
k_dot_set_6_0005();
case 8: //main (sys:1)
- k_dot_set_9_0006();
+ k_dot_set_8_0006();
case 9: //main (sys:1)
- k_dot_set_13_0007();
+ k_dot_set_11_0007();
case 10: //main (sys:1)
- k_dot_set_16_0008();
+ k_dot_set_15_0008();
case 11: //main (sys:1)
- k_dot_set_20_0009();
+ k_dot_set_18_0009();
case 12: //main (sys:1)
- k_dot_set_25_0010();
+ k_dot_set_22_0010();
case 13: //main (sys:1)
- k_dot_set_29_0011();
+ k_dot_set_27_0011();
case 14: //main (sys:1)
- k_dot_set_33_0012();
+ k_dot_set_31_0012();
case 15: //main (sys:1)
- k_dot_set_37_0013();
+ k_dot_set_35_0013();
case 16: //main (sys:1)
- k_dot_set_38_0014();
+ k_dot_set_39_0014();
case 17: //main (sys:1)
- // namespace (sys:41)
- k_dot_block_42_0015();
+ k_dot_set_40_0015();
+ case 18: //main (sys:1)
+ // namespace (sys:42)
+ k_dot_block_43_0016();
thread.popCtx();
thread.popCtx();
}
@@ -93,7 +85,7 @@
}
// k.set (sys:1)
private void k_dot_set_1_0000() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (sys:1)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Echo());
@@ -103,7 +95,7 @@
// k.set (sys:2)
private void k_dot_set_2_0001() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (sys:2)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Print());
@@ -113,7 +105,7 @@
// k.set (sys:3)
private void k_dot_set_3_0002() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (sys:3)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Range());
@@ -123,7 +115,7 @@
// k.set (sys:4)
private void k_dot_set_4_0003() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (sys:4)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Wait());
@@ -133,7 +125,7 @@
// k.set (sys:5)
private void k_dot_set_5_0004() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
// native (sys:5)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Equals());
@@ -143,188 +135,240 @@
// k.set (sys:6)
private void k_dot_set_6_0005() {
- LWThread thread = LWThread.currentThread();
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
- // | (sys:8)
+ // native (sys:6)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.NotEquals());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(5, def.get(0));
+ }
+
+ // k.set (sys:8)
+ private void k_dot_set_8_0006() {
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
- // native (sys:7)
+ // | (sys:10)
+ thread.ctx.pushChannel(0, new AltCallable());
+ // native (sys:9)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.GreaterThan.Real());
- // native (sys:8)
+ // native (sys:10)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.GreaterThan.Integer());
thread.ctx.append(0, thread.ctx.popChannel(0));
Channel def = thread.ctx.popChannel(0);
- thread.ctx.set(5, def.get(0));
+ thread.ctx.set(6, def.get(0));
}
- // k.set (sys:9)
- private void k_dot_set_9_0006() {
- LWThread thread = LWThread.currentThread();
+ // k.set (sys:11)
+ private void k_dot_set_11_0007() {
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
- // | (sys:11)
- thread.ctx.pushChannel(0);
- // native (sys:10)
+ // | (sys:13)
+ thread.ctx.pushChannel(0, new AltCallable());
+ // native (sys:12)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.LessThan.Real());
- // native (sys:11)
+ // native (sys:13)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.LessThan.Integer());
thread.ctx.append(0, thread.ctx.popChannel(0));
Channel def = thread.ctx.popChannel(0);
- thread.ctx.set(6, def.get(0));
+ thread.ctx.set(7, def.get(0));
}
- // k.set (sys:13)
- private void k_dot_set_13_0007() {
- LWThread thread = LWThread.currentThread();
+ // k.set (sys:15)
+ private void k_dot_set_15_0008() {
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
- // | (sys:15)
- thread.ctx.pushChannel(0);
- // native (sys:14)
+ // | (sys:17)
+ thread.ctx.pushChannel(0, new AltCallable());
+ // native (sys:16)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.GreaterOrEqual.Real());
- // native (sys:15)
+ // native (sys:17)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.GreaterOrEqual.Integer());
thread.ctx.append(0, thread.ctx.popChannel(0));
Channel def = thread.ctx.popChannel(0);
- thread.ctx.set(7, def.get(0));
+ thread.ctx.set(8, def.get(0));
}
- // k.set (sys:16)
- private void k_dot_set_16_0008() {
- LWThread thread = LWThread.currentThread();
+ // k.set (sys:18)
+ private void k_dot_set_18_0009() {
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
- // | (sys:18)
- thread.ctx.pushChannel(0);
- // native (sys:17)
+ // | (sys:20)
+ thread.ctx.pushChannel(0, new AltCallable());
+ // native (sys:19)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.LessOrEqual.Real());
- // native (sys:18)
+ // native (sys:20)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.LessOrEqual.Integer());
thread.ctx.append(0, thread.ctx.popChannel(0));
Channel def = thread.ctx.popChannel(0);
- thread.ctx.set(8, def.get(0));
+ thread.ctx.set(9, def.get(0));
}
- // k.set (sys:20)
- private void k_dot_set_20_0009() {
- LWThread thread = LWThread.currentThread();
+ // k.set (sys:22)
+ private void k_dot_set_22_0010() {
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
- // | (sys:22)
+ // | (sys:25)
+ thread.ctx.pushChannel(0, new AltCallable());
+ // native (sys:25)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Plus.String());
thread.ctx.pushChannel(0);
- // native (sys:21)
+ // | (sys:24)
+ thread.ctx.pushChannel(0, new AltCallable());
+ // native (sys:23)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Plus.Real());
- thread.ctx.pushChannel(0);
- // | (sys:23)
- thread.ctx.pushChannel(0);
- // native (sys:22)
+ // native (sys:24)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Plus.Integer());
- // native (sys:23)
- thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Plus.String());
thread.ctx.append(0, thread.ctx.popChannel(0));
thread.ctx.appendAll(0, (Channel) ((Channel) thread.ctx.popChannel(0)).get(0));
thread.ctx.append(0, thread.ctx.popChannel(0));
Channel def = thread.ctx.popChannel(0);
- thread.ctx.set(9, def.get(0));
+ thread.ctx.set(10, def.get(0));
}
- // k.set (sys:25)
- private void k_dot_set_25_0010() {
- LWThread thread = LWThread.currentThread();
+ // k.set (sys:27)
+ private void k_dot_set_27_0011() {
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
- // | (sys:27)
- thread.ctx.pushChannel(0);
- // native (sys:26)
+ // | (sys:29)
+ thread.ctx.pushChannel(0, new AltCallable());
+ // native (sys:28)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Minus.Real());
- // native (sys:27)
+ // native (sys:29)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Minus.Integer());
thread.ctx.append(0, thread.ctx.popChannel(0));
Channel def = thread.ctx.popChannel(0);
- thread.ctx.set(10, def.get(0));
+ thread.ctx.set(11, def.get(0));
}
- // k.set (sys:29)
- private void k_dot_set_29_0011() {
- LWThread thread = LWThread.currentThread();
+ // k.set (sys:31)
+ private void k_dot_set_31_0012() {
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
- // | (sys:31)
- thread.ctx.pushChannel(0);
- // native (sys:30)
+ // | (sys:33)
+ thread.ctx.pushChannel(0, new AltCallable());
+ // native (sys:32)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Times.Integer());
- // native (sys:31)
+ // native (sys:33)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Times.Real());
thread.ctx.append(0, thread.ctx.popChannel(0));
Channel def = thread.ctx.popChannel(0);
- thread.ctx.set(11, def.get(0));
+ thread.ctx.set(12, def.get(0));
}
- // k.set (sys:33)
- private void k_dot_set_33_0012() {
- LWThread thread = LWThread.currentThread();
+ // k.set (sys:35)
+ private void k_dot_set_35_0013() {
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
- // | (sys:35)
- thread.ctx.pushChannel(0);
- // native (sys:34)
+ // | (sys:37)
+ thread.ctx.pushChannel(0, new AltCallable());
+ // native (sys:36)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Div.Integer());
- // native (sys:35)
+ // native (sys:37)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Div.Real());
thread.ctx.append(0, thread.ctx.popChannel(0));
Channel def = thread.ctx.popChannel(0);
- thread.ctx.set(12, def.get(0));
+ thread.ctx.set(13, def.get(0));
}
- // k.set (sys:37)
- private void k_dot_set_37_0013() {
- LWThread thread = LWThread.currentThread();
+ // k.set (sys:39)
+ private void k_dot_set_39_0014() {
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
- // native (sys:37)
+ // native (sys:39)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Throw());
Channel def = thread.ctx.popChannel(0);
- thread.ctx.set(13, def.get(0));
+ thread.ctx.set(14, def.get(0));
}
- // k.set (sys:38)
- private void k_dot_set_38_0014() {
- LWThread thread = LWThread.currentThread();
+ // k.set (sys:40)
+ private void k_dot_set_40_0015() {
+ final LWThread thread = LWThread.currentThread();
thread.ctx.pushChannel(0);
- // native (sys:38)
+ // native (sys:40)
thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.KException());
Channel def = thread.ctx.popChannel(0);
- thread.ctx.set(14, def.get(0));
+ thread.ctx.set(15, def.get(0));
}
- // k.block (sys:42)
- private void k_dot_block_42_0015() {
+ public static final Type TYPE = new UnionType(
+ new NamedType("echo", NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Echo.class)),
+ new NamedType("print", NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Print.class)),
+ new NamedType("range", NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Range.class)),
+ new NamedType("wait", NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Wait.class)),
+ new NamedType("__eq___eq_", NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Equals.class)),
+ new NamedType("__bang___eq_", NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.NotEquals.class)),
+ new NamedType("__lt_", new AltType(
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.LessThan.Real.class),
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.LessThan.Integer.class)
+ )),
+ new NamedType("__gt_", new AltType(
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.GreaterThan.Real.class),
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.GreaterThan.Integer.class)
+ )),
+ new NamedType("__lt___eq_", new AltType(
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.LessOrEqual.Real.class),
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.LessOrEqual.Integer.class)
+ )),
+ new NamedType("__gt___eq_", new AltType(
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.GreaterOrEqual.Real.class),
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.GreaterOrEqual.Integer.class)
+ )),
+ new NamedType("__plus_", new AltType(
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Plus.String.class),
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Plus.Real.class),
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Plus.Integer.class)
+ )),
+ new NamedType("__minus_", new AltType(
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Minus.Real.class),
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Minus.Integer.class)
+ )),
+ new NamedType("__times_", new AltType(
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Times.Integer.class),
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Times.Real.class)
+ )),
+ new NamedType("__fwslash_", new AltType(
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Div.Integer.class),
+ NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Div.Real.class)
+ )),
+ new NamedType("throw", NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.Throw.class)),
+ new NamedType("Exception", SimpleType.Type.instance(NativeFunction.getInstance(org.globus.cog.karajan.lib.sys.KException.class)))
+ );
+ // k.block (sys:43)
+ private void k_dot_block_43_0016() {
final LWThread thread = LWThread.currentThread();
thread.checkSlice();
int __state__ = thread.popState();
switch(__state__) {
- case 0: //k.block (sys:42)
- // export (sys:43)
+ case 0: //k.block (sys:43)
+ // export (sys:44)
thread.ctx.getChannel(0).append(thread.ctx.get(0));
thread.ctx.getChannel(0).append(thread.ctx.get(1));
thread.ctx.getChannel(0).append(thread.ctx.get(2));
thread.ctx.getChannel(0).append(thread.ctx.get(3));
thread.ctx.getChannel(0).append(thread.ctx.get(4));
- thread.ctx.getChannel(0).append(thread.ctx.get(6));
thread.ctx.getChannel(0).append(thread.ctx.get(5));
- thread.ctx.getChannel(0).append(thread.ctx.get(8));
thread.ctx.getChannel(0).append(thread.ctx.get(7));
+ thread.ctx.getChannel(0).append(thread.ctx.get(6));
thread.ctx.getChannel(0).append(thread.ctx.get(9));
+ thread.ctx.getChannel(0).append(thread.ctx.get(8));
thread.ctx.getChannel(0).append(thread.ctx.get(10));
thread.ctx.getChannel(0).append(thread.ctx.get(11));
thread.ctx.getChannel(0).append(thread.ctx.get(12));
thread.ctx.getChannel(0).append(thread.ctx.get(13));
thread.ctx.getChannel(0).append(thread.ctx.get(14));
+ thread.ctx.getChannel(0).append(thread.ctx.get(15));
}
}
public static final int[] __LINE_TABLE = new int[] {
- 44, 46, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 86, //run
- 297//k_dot_block_42_0015
+ 34, 36, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 78, //run
+ 343//k_dot_block_43_0016
};
public static final int[] __STATE_TABLE = new int[] {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1, //run
- 0//k_dot_block_42_0015
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, //run
+ 0//k_dot_block_43_0016
};
static {
StateTables.register(sys.class);
}
- public static void __exports__() {
- }
}
Modified: branches/karajan2/src/cog/modules/karajan2/resources/sys.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/resources/sys.k 2008-07-28 00:13:43 UTC (rev 2100)
+++ branches/karajan2/src/cog/modules/karajan2/resources/sys.k 2008-07-28 00:14:14 UTC (rev 2101)
@@ -3,6 +3,8 @@
range := native(org.globus.cog.karajan.lib.sys.Range)
wait := native(org.globus.cog.karajan.lib.sys.Wait)
__eq___eq_ := native(org.globus.cog.karajan.lib.sys.Equals)
+__bang___eq_ := native(org.globus.cog.karajan.lib.sys.NotEquals)
+
__gt_ :=
native(org.globus.cog.karajan.lib.sys.GreaterThan$Real)
| native(org.globus.cog.karajan.lib.sys.GreaterThan$Integer)
@@ -37,11 +39,10 @@
throw := native(org.globus.cog.karajan.lib.sys.Throw)
Exception := native(org.globus.cog.karajan.lib.sys.KException)
-
namespace(sys) {
export(
echo, print, range, wait,
- __eq___eq_, __lt_, __gt_, __lt___eq_, __gt___eq_,
+ __eq___eq_, __bang___eq_, __lt_, __gt_, __lt___eq_, __gt___eq_,
__plus_, __minus_, __times_, __fwslash_,
throw, Exception
)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-28 00:13:46
|
Revision: 2100
http://cogkit.svn.sourceforge.net/cogkit/?rev=2100&view=rev
Author: hategan
Date: 2008-07-28 00:13:43 +0000 (Mon, 28 Jul 2008)
Log Message:
-----------
removed debugging thing
Modified Paths:
--------------
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Compiler.java
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Compiler.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Compiler.java 2008-07-28 00:12:58 UTC (rev 2099)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Compiler.java 2008-07-28 00:13:43 UTC (rev 2100)
@@ -129,7 +129,7 @@
Writer wr = new IndentingWriter(new FileWriter(of));
oc.commit(wr);
wr.close();
- copyFile(of, "../src/" + of.getName());
+ //copyFile(of, "../src/" + of.getName());
compileJava(of);
return new File(of.getParentFile(), name);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-28 00:13:03
|
Revision: 2099
http://cogkit.svn.sourceforge.net/cogkit/?rev=2099&view=rev
Author: hategan
Date: 2008-07-28 00:12:58 +0000 (Mon, 28 Jul 2008)
Log Message:
-----------
and more...
Modified Paths:
--------------
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/Loader.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/KException.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/Print.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Arguments.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Context.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/NativeCallable.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Signature.java
Added Paths:
-----------
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/TestRunner.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/list/
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/list/Lst.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/NotEquals.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/AltCallable.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Nil.java
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/Loader.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/Loader.java 2008-07-28 00:11:50 UTC (rev 2098)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/Loader.java 2008-07-28 00:12:58 UTC (rev 2099)
@@ -41,8 +41,10 @@
public static final String ARG_CSTDOUT = "stdoutUnordered";
public static void main(String[] argv) {
- //new Trr().trr();
- //System.exit(0);
+ System.exit(run(argv));
+ }
+
+ public static int run(String[] argv) {
ArgumentParser ap = buildArgumentParser();
boolean debug = false, cache = false;
long start = System.currentTimeMillis();
@@ -51,7 +53,7 @@
ap.parse(argv);
if (ap.isPresent(ARG_HELP)) {
ap.usage();
- System.exit(0);
+ return 0;
}
if (ap.isPresent(ARG_SHOWSTATS)) {
Configuration.getDefault().set(Configuration.SHOW_STATISTICS, true);
@@ -76,13 +78,13 @@
}
if (ap.hasValue(ARG_EXECUTE)) {
if (ap.hasValue(ArgumentParser.DEFAULT)) {
- error("Cannot use both -" + ARG_EXECUTE + " and a file");
+ return error("Cannot use both -" + ARG_EXECUTE + " and a file");
}
source = ap.getStringValue(ARG_EXECUTE);
}
else {
if (!ap.hasValue(ArgumentParser.DEFAULT)) {
- error("No project specified");
+ return error("No project specified");
}
project = ap.getStringValue(ArgumentParser.DEFAULT);
}
@@ -90,7 +92,7 @@
catch (ArgumentParserException e) {
System.err.println("Error parsing arguments: " + e.getMessage() + "\n");
ap.usage();
- System.exit(1);
+ return 1;
}
boolean runerror = false;
@@ -137,7 +139,7 @@
/ 1024 + "KB");
}
- System.exit(runerror ? 2 : 0);
+ return(runerror ? 2 : 0);
}
public static ElementTree load(String project) throws SpecificationException, IOException {
@@ -156,6 +158,7 @@
ElementTree source;
if (xml) {
source = XMLConverter.readSource(reader, name);
+ //source = XMLConverter.readSource(reader, name);
}
else {
source = XMLConverter.readSource(new KarajanTranslator(reader, name).translate(),
@@ -198,9 +201,9 @@
return ap;
}
- protected static void error(final String err) {
+ protected static int error(final String err) {
System.err.println(err);
- System.exit(1);
+ return 1;
}
private static void installKeyboardHooks() {
Added: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/TestRunner.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/TestRunner.java (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/TestRunner.java 2008-07-28 00:12:58 UTC (rev 2099)
@@ -0,0 +1,85 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Jul 10, 2008
+ */
+package org.globus.cog.karajan;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.PrintStream;
+
+public class TestRunner {
+
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ error("Usage: test-runner <file> <count>");
+ }
+ String name = args[0];
+ int count = Integer.parseInt(args[1]);
+ PrintStream outSave = System.out;
+ PrintStream errSave = System.err;
+ for (int i = 0; i < count; i++) {
+ PrintStream ow = new PrintStream(new FileOutputStream(name + ".out"));
+ System.setOut(ow);
+ System.setErr(ow);
+ int exit = Loader.run(new String[] { "-intermediate", name });
+ System.setOut(outSave);
+ System.setErr(errSave);
+ if (exit != 0) {
+ System.err.println("NON-ZERO EXIT CODE");
+ System.exit(2);
+ }
+ if (!compareOutputToExpected(name)) {
+ System.err.println("Output differs");
+ System.exit(1);
+ }
+ }
+ System.out.println();
+ System.exit(0);
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ System.exit(3);
+ }
+ }
+
+ private static boolean compareOutputToExpected(String name) throws IOException {
+ File expected = new File(name + ".expected");
+ File out = new File(name + ".out");
+ if (!expected.exists()) {
+ System.out.print("n.");
+ return true;
+ }
+
+ BufferedReader bre = new BufferedReader(new FileReader(expected));
+ BufferedReader bro = new BufferedReader(new FileReader(out));
+ String line = bre.readLine();
+ while (line != null) {
+ if (!line.equals(bro.readLine())) {
+ return false;
+ }
+ line = bre.readLine();
+ }
+ if (bro.readLine() != null) {
+ return false;
+ }
+ else {
+ System.out.print("o.");
+ return true;
+ }
+ }
+
+ private static void error(String message) {
+ System.err.println(message);
+ System.exit(1);
+ }
+}
Added: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/list/Lst.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/list/Lst.java (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/list/Lst.java 2008-07-28 00:12:58 UTC (rev 2099)
@@ -0,0 +1,276 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Jul 24, 2008
+ */
+package org.globus.cog.karajan.lib.list;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.globus.cog.karajan.compiler.QName;
+import org.globus.cog.karajan.compiler.Type;
+import org.globus.cog.karajan.compiler.types.SimpleType;
+import org.globus.cog.karajan.compiler.types.Types;
+import org.globus.cog.karajan.compiler.types.UnknownType;
+import org.globus.cog.karajan.compiler.types.UserType;
+import org.globus.cog.karajan.runtime.Arguments;
+import org.globus.cog.karajan.runtime.Context;
+import org.globus.cog.karajan.runtime.NativeCallable;
+import org.globus.cog.karajan.runtime.Signature;
+import org.globus.cog.karajan.runtime.Signature.Optional;
+import org.globus.cog.karajan.runtime.Signature.Parameter;
+import org.globus.cog.karajan.runtime.Signature.Positional;
+import org.globus.cog.karajan.runtime.Signature.VarArgs;
+
+public class Lst {
+ public static final Type TLIST = new SimpleType(new QName("List"));
+
+ public static class Polymorphic extends NativeCallable {
+ public static final Signature SIGNATURE = new Signature(
+ Polymorphic.class);
+
+ public static final Parameter<Type> TYPE = new Positional<Type>("type",
+ Types.TYPE);
+
+ static {
+ SIGNATURE.add(TYPE);
+ SIGNATURE.setReturnType(TLIST);
+ SIGNATURE.setType(true);
+ }
+
+ @Override
+ public void invoke(final Arguments a) {
+ ret(a, new List(a) {
+ @Override
+ public String toString() {
+ return TLIST + "(" + TYPE.getValue(a) + ")";
+ }
+ });
+ }
+
+ @Override
+ public Type invokeStatic(Type type, Type args) {
+ Signature sig = new Signature();
+ sig.add(new Signature.VarArgs((Type) args.value));
+ sig.setType(true);
+ UserType ut = new UserType(sig, null);
+ ut.name = new QName("List(" + args.value + ")");
+ sig.setReturnType(TLIST);
+ return Types.TYPE.instance(ut);
+ }
+ }
+
+ public static class Unknown extends NativeCallable {
+ public static final Signature SIGNATURE = new Signature(Unknown.class);
+
+ static {
+ SIGNATURE.add(Signature.VARARGS);
+ SIGNATURE.setReturnType(TLIST);
+ }
+
+ @Override
+ public void invoke(Arguments a) {
+ ret(a, new ArrayList<Object>(a.getVarArgs().getAll()));
+ }
+ }
+
+ public static class List extends NativeCallable {
+ public static final Signature SIGNATURE = new Signature(Unknown.class);
+
+ static {
+ SIGNATURE.add(Signature.VARARGS);
+ SIGNATURE.setReturnType(TLIST);
+ }
+
+ public List(Context ctx) {
+ super(ctx);
+ }
+
+ @Override
+ public void invoke(Arguments a) {
+ ret(a, new ArrayList<Object>(a.getVarArgs().getAll()));
+ }
+ }
+
+ public static class First extends NativeCallable {
+ public static final Signature SIGNATURE = new Signature(First.class);
+
+ public static final Parameter<ArrayList<Object>> LIST = new Positional<ArrayList<Object>>(
+ "list", TLIST);
+
+ static {
+ SIGNATURE.add(LIST);
+ SIGNATURE.setReturnType(new UnknownType());
+ }
+
+ @Override
+ public void invoke(Arguments a) {
+ ret(a, LIST.getValue(a).get(0));
+ }
+
+ @Override
+ public Type invokeStatic(Type type, Type args) {
+ UserType ut = (UserType) args;
+ return ut.signature.getVarArgsType();
+ }
+ }
+
+ public static class Last extends NativeCallable {
+ public static final Signature SIGNATURE = new Signature(Last.class);
+
+ public static final Parameter<java.util.List<Object>> LIST = new Positional<java.util.List<Object>>(
+ "list", TLIST);
+
+ static {
+ SIGNATURE.add(LIST);
+ SIGNATURE.setReturnType(new UnknownType());
+ }
+
+ @Override
+ public void invoke(Arguments a) {
+ java.util.List<Object> l = LIST.getValue(a);
+ ret(a, l.get(l.size() - 1));
+ }
+
+ @Override
+ public Type invokeStatic(Type type, Type args) {
+ UserType ut = (UserType) args;
+ return ut.signature.getVarArgsType();
+ }
+ }
+
+ public static class ButFirst extends NativeCallable {
+ public static final Signature SIGNATURE = new Signature(First.class);
+
+ public static final Parameter<java.util.List<Object>> LIST = new Positional<java.util.List<Object>>(
+ "list", TLIST);
+
+ static {
+ SIGNATURE.add(LIST);
+ SIGNATURE.setReturnType(TLIST);
+ }
+
+ @Override
+ public void invoke(Arguments a) {
+ java.util.List<?> l = LIST.getValue(a);
+ ret(a, l.subList(1, l.size()));
+ }
+
+ @Override
+ public Type invokeStatic(Type type, Type args) {
+ return args;
+ }
+ }
+
+ public static class ButLast extends NativeCallable {
+ public static final Signature SIGNATURE = new Signature(First.class);
+
+ public static final Parameter<java.util.List<Object>> LIST = new Positional<java.util.List<Object>>(
+ "list", TLIST);
+
+ static {
+ SIGNATURE.add(LIST);
+ SIGNATURE.setReturnType(TLIST);
+ }
+
+ @Override
+ public void invoke(Arguments a) {
+ java.util.List<?> l = LIST.getValue(a);
+ ret(a, l.subList(0, l.size() - 1));
+ }
+
+ @Override
+ public Type invokeStatic(Type type, Type args) {
+ return args;
+ }
+ }
+
+ public static class Concat extends NativeCallable {
+ public static final Signature SIGNATURE = new Signature(First.class);
+
+ public static final VarArgs<java.util.List<Object>> LISTS = new VarArgs<java.util.List<Object>>(
+ TLIST);
+
+ static {
+ SIGNATURE.add(LISTS);
+ SIGNATURE.setReturnType(TLIST);
+ }
+
+ @Override
+ public void invoke(Arguments a) {
+ Collection<java.util.List<Object>> lists = LISTS.get(a);
+ if (lists.size() == 0) {
+ ret(a, lists.iterator().next());
+ }
+ else {
+ ArrayList<Object> l = new ArrayList<Object>();
+ for (java.util.List<Object> li : lists) {
+ l.addAll(li);
+ }
+ ret(a, l);
+ }
+ }
+
+ @Override
+ public Type invokeStatic(Type type, Type args) {
+ return args;
+ }
+ }
+
+ public static class SubList1 extends NativeCallable {
+ public static final Signature SIGNATURE = new Signature(First.class);
+
+ public static final Parameter<java.util.List<Object>> LIST = new Positional<java.util.List<Object>>(
+ "list", TLIST);
+ public static final Positional<Integer> FROM = new Positional<Integer>("from", Types.INTEGER);
+
+ static {
+ SIGNATURE.add(LIST);
+ SIGNATURE.add(FROM);
+ SIGNATURE.setReturnType(TLIST);
+ }
+
+ @Override
+ public void invoke(Arguments a) {
+ java.util.List<?> l = LIST.getValue(a);
+ ret(a, l.subList(FROM.getValue(a), l.size()));
+ }
+
+ @Override
+ public Type invokeStatic(Type type, Type args) {
+ return args;
+ }
+ }
+
+ public static class SubList2 extends NativeCallable {
+ public static final Signature SIGNATURE = new Signature(First.class);
+
+ public static final Parameter<java.util.List<Object>> LIST = new Positional<java.util.List<Object>>(
+ "list", TLIST);
+ public static final Positional<Integer> FROM = new Positional<Integer>("from", Types.INTEGER);
+ public static final Positional<Integer> TO = new Positional<Integer>("to", Types.INTEGER);
+
+ static {
+ SIGNATURE.add(LIST);
+ SIGNATURE.add(FROM);
+ SIGNATURE.add(TO);
+ SIGNATURE.setReturnType(TLIST);
+ }
+
+ @Override
+ public void invoke(Arguments a) {
+ java.util.List<?> l = LIST.getValue(a);
+ ret(a, l.subList(FROM.getValue(a), TO.getValue(a)));
+ }
+
+ @Override
+ public Type invokeStatic(Type type, Type args) {
+ return args;
+ }
+ }
+}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/KException.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/KException.java 2008-07-28 00:11:50 UTC (rev 2098)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/KException.java 2008-07-28 00:12:58 UTC (rev 2099)
@@ -9,6 +9,7 @@
*/
package org.globus.cog.karajan.lib.sys;
+import org.globus.cog.karajan.compiler.Type;
import org.globus.cog.karajan.compiler.types.Types;
import org.globus.cog.karajan.runtime.Arguments;
import org.globus.cog.karajan.runtime.ExecutionException;
@@ -19,19 +20,27 @@
import org.globus.cog.karajan.runtime.Signature.Positional;
public class KException extends NativeCallable {
- public static final Signature SIGNATURE = new Signature(KException.class);
+ public static final Signature SIGNATURE = new Signature(KException.class);
- public static final Parameter MESSAGE = new Positional("message", Types.STRING);
- public static final Parameter PREV = new Optional("prev", null, Types.EXCEPTION);
+ public static final Parameter<String> MESSAGE = new Positional<String>(
+ "message", Types.STRING);
+ public static final Parameter<Exception> PREV = new Optional<Exception>(
+ "prev", null, Types.EXCEPTION);
- static {
- SIGNATURE.add(MESSAGE, PREV);
- SIGNATURE.setReturnType(Types.EXCEPTION);
- SIGNATURE.setType(true);
- }
+ static {
+ SIGNATURE.add(MESSAGE, PREV);
+ SIGNATURE.setReturnType(Types.EXCEPTION);
+ SIGNATURE.setType(true);
+ }
- @Override
- public void invoke(Arguments a) {
- ret(a, new ExecutionException((String) MESSAGE.getValue(a), (Exception) PREV.getValue(a), this));
- }
+ @Override
+ public void invoke(Arguments a) {
+ ret(a, new ExecutionException(MESSAGE.getValue(a), PREV.getValue(a),
+ this));
+ }
+
+ @Override
+ public Type invokeStatic(Type type, Type args) {
+ return Types.EXCEPTION;
+ }
}
Added: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/NotEquals.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/NotEquals.java (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/NotEquals.java 2008-07-28 00:12:58 UTC (rev 2099)
@@ -0,0 +1,34 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Dec 30, 2007
+ */
+package org.globus.cog.karajan.lib.sys;
+
+import org.globus.cog.karajan.compiler.types.SimpleType;
+import org.globus.cog.karajan.runtime.Arguments;
+import org.globus.cog.karajan.runtime.NativeCallable;
+import org.globus.cog.karajan.runtime.Signature;
+import org.globus.cog.karajan.runtime.Signature.Parameter;
+import org.globus.cog.karajan.runtime.Signature.Positional;
+
+public class NotEquals extends NativeCallable {
+ public static final Signature SIGNATURE = new Signature(NotEquals.class);
+
+ public static final Parameter OP1 = new Positional("op1");
+ public static final Parameter OP2 = new Positional("op2");
+
+ static {
+ SIGNATURE.add(OP1, OP2);
+ SIGNATURE.setReturnType(SimpleType.Boolean);
+ }
+
+ @Override
+ public void invoke(Arguments a) {
+ ret(a, !OP1.getValue(a).equals(OP2.getValue(a)));
+ }
+}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/Print.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/Print.java 2008-07-28 00:11:50 UTC (rev 2098)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/Print.java 2008-07-28 00:12:58 UTC (rev 2099)
@@ -21,7 +21,7 @@
public class Print extends NativeCallable {
public static final Signature SIGNATURE = new Signature(Print.class);
- public static final Parameter NL = new Optional("nl", Boolean.TRUE, Types.BOOLEAN);
+ public static final Parameter<Boolean> NL = new Optional<Boolean>("nl", Boolean.TRUE, Types.BOOLEAN);
static {
SIGNATURE.add(Signature.VARARGS, NL);
@@ -34,7 +34,7 @@
for (Object v: a.getVarArgs()) {
sb.append(String.valueOf(v));
}
- if (Boolean.TRUE.equals(NL.getValue(a))) {
+ if (NL.getValue(a)) {
sb.append('\n');
}
a.getChannel(1).append(sb.toString());
Added: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/AltCallable.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/AltCallable.java (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/AltCallable.java 2008-07-28 00:12:58 UTC (rev 2099)
@@ -0,0 +1,70 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Jul 3, 2008
+ */
+package org.globus.cog.karajan.runtime;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+public class AltCallable implements Channel {
+ private List<Object> l;
+
+ public AltCallable() {
+ l = new ArrayList<Object>(3);
+ }
+
+ @Override
+ public void append(Object value) {
+ l.add(value);
+ }
+
+ @Override
+ public void appendAll(Collection<Object> values) {
+ l.addAll(values);
+ }
+
+ @Override
+ public Callable get(int index) {
+ return (Callable) l.get(index);
+ }
+
+ @Override
+ public Collection<Object> getAll() {
+ return l;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return l.isEmpty();
+ }
+
+ @Override
+ public int size() {
+ return l.size();
+ }
+
+ @Override
+ public Iterator<Object> iterator() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ Iterator<Object> i = l.iterator();
+ while (i.hasNext()) {
+ sb.append(i.next().toString());
+ if (i.hasNext()) {
+ sb.append(" | ");
+ }
+ }
+ return sb.toString();
+ }
+}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Arguments.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Arguments.java 2008-07-28 00:11:50 UTC (rev 2098)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Arguments.java 2008-07-28 00:12:58 UTC (rev 2099)
@@ -90,4 +90,14 @@
public String toString() {
return "A" + super.toString();
}
+
+ public void setVargIndex(int i) {
+ stack[osize + i] = vargs;
+ }
+
+ @Override
+ public Context getS() {
+ return s;
+ }
+
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Context.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Context.java 2008-07-28 00:11:50 UTC (rev 2098)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Context.java 2008-07-28 00:12:58 UTC (rev 2099)
@@ -111,7 +111,12 @@
}
public String toString() {
- return Arrays.asList(stack).toString();
+ if (stack == null) {
+ return "[]";
+ }
+ else {
+ return Arrays.asList(stack).toString();
+ }
}
public final Context getParent() {
@@ -131,4 +136,8 @@
System.arraycopy(stack, 0, ctx.stack, 0, stack.length);
return ctx;
}
+
+ public Context getS() {
+ return p;
+ }
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/NativeCallable.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/NativeCallable.java 2008-07-28 00:11:50 UTC (rev 2098)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/NativeCallable.java 2008-07-28 00:12:58 UTC (rev 2099)
@@ -11,15 +11,42 @@
import java.lang.reflect.Field;
+import org.globus.cog.karajan.compiler.Lambda;
+import org.globus.cog.karajan.compiler.Type;
+
public abstract class NativeCallable extends Callable {
+ private String str;
+
+ public NativeCallable() {
+ super();
+ }
+
+ public NativeCallable(Context ctx) {
+ super(ctx);
+ }
+
public String toString() {
try {
- Class<? extends NativeCallable> cls = this.getClass();
- Field signature = cls.getField("SIGNATURE");
- return signature.get(null).toString();
+ if (str == null) {
+ Class<? extends NativeCallable> cls = this.getClass();
+ Field signature = cls.getField("SIGNATURE");
+ Signature sig = (Signature) signature.get(null);
+ if (sig.isType()) {
+ str = sig.getReturnType().toString();
+ }
+ else {
+ str = sig.toString();
+ }
+ }
+ return str;
}
catch (Exception e) {
return super.toString();
}
}
+
+ public Type invokeStatic(Type type, Type args) {
+ Lambda l = (Lambda) type;
+ return l.signature.getReturnType();
+ }
}
Added: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Nil.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Nil.java (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Nil.java 2008-07-28 00:12:58 UTC (rev 2099)
@@ -0,0 +1,22 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Jun 27, 2008
+ */
+package org.globus.cog.karajan.runtime;
+
+import org.globus.cog.karajan.compiler.Type;
+import org.globus.cog.karajan.compiler.types.SimpleType;
+
+public class Nil {
+ public static final Type type = SimpleType.Nil;
+ public static final Nil value = new Nil();
+
+ public String toString() {
+ return "nil";
+ }
+}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Signature.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Signature.java 2008-07-28 00:11:50 UTC (rev 2098)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Signature.java 2008-07-28 00:12:58 UTC (rev 2099)
@@ -21,9 +21,9 @@
public class Signature extends Type {
public static final VarArgs VARARGS = new VarArgs();
- private boolean vargs;
- private List<Parameter<?>> positional;
- private List<Parameter<?>> optional;
+ public Parameter<?> vargs;
+ public List<Parameter<?>> positional;
+ public List<Parameter<?>> optional;
private Type returnType;
private List<Object> defaultValues;
private String defaultValuesRepr;
@@ -43,12 +43,17 @@
+ ".SIGNATURE.getDefaultValues()";
}
- public Signature(Parameter... params) {
+ public Signature(Parameter<?>... params) {
this();
- for (Parameter param : params) {
+ for (Parameter<?> param : params) {
add(param);
}
}
+
+ public Signature(String defaultValuesRepr, Parameter<?>... params) {
+ this(params);
+ this.defaultValuesRepr = defaultValuesRepr;
+ }
public int getLocals() {
return locals;
@@ -60,7 +65,7 @@
public void add(Parameter<?> param) {
if (param instanceof VarArgs) {
- vargs = true;
+ vargs = param;
}
else if (param instanceof Positional) {
param.index = positional.size();
@@ -69,14 +74,17 @@
else if (param instanceof Optional) {
param.index = optional.size();
optional.add(param);
- defaultValues.add(((Optional) param).defaultValue);
+ defaultValues.add(((Optional<?>) param).defaultValue);
}
else if (param instanceof Field) {
if (fields == null) {
fields = new ArrayList<Field<?>>();
}
- fields.add((Field) param);
+ fields.add((Field<?>) param);
}
+ else if (param instanceof Return) {
+ returnType = param.type;
+ }
}
public void add(Parameter<?>... params) {
@@ -86,9 +94,18 @@
}
public boolean hasVarArgs() {
- return vargs;
+ return vargs != null;
}
+ public Type getVarArgsType() {
+ if (vargs == null) {
+ return null;
+ }
+ else {
+ return vargs.type;
+ }
+ }
+
public boolean isType() {
return type;
}
@@ -139,9 +156,10 @@
}
public String toString() {
- if (type) {
- return returnType.toString();
- }
+ return toString(true);
+ }
+
+ public String toString(boolean ret) {
StringBuffer sb = new StringBuffer();
sb.append('(');
Iterator<Parameter<?>> i;
@@ -149,28 +167,63 @@
while (i.hasNext()) {
Positional<?> p = (Positional<?>) i.next();
sb.append(p.toString());
- if (i.hasNext() || !optional.isEmpty() || vargs) {
+ if (i.hasNext() || !optional.isEmpty() || vargs != null) {
sb.append(", ");
}
}
i = optional.iterator();
while (i.hasNext()) {
- Optional o = (Optional) i.next();
+ Optional<?> o = (Optional<?>) i.next();
sb.append(o.toString());
- if (i.hasNext() || vargs) {
+ if (i.hasNext() || vargs != null) {
sb.append(", ");
}
}
- if (vargs) {
- sb.append("...");
+ if (vargs != null) {
+ sb.append(vargs);
}
- sb.append(") -> (");
- if (!Null.type.equals(returnType)) {
- sb.append(returnType);
+ if (ret) {
+ sb.append(')');
+ sb.append(" -> ");
+ sb.append('(');
+ if (!Null.type.equals(returnType)) {
+ sb.append(returnType);
+ }
}
sb.append(')');
return sb.toString();
}
+
+ public String repr() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("new Signature(");
+ if (defaultValuesRepr != null) {
+ sb.append('"');
+ sb.append(defaultValuesRepr);
+ sb.append('"');
+ sb.append(", ");
+ }
+ Iterator<Parameter<?>> i;
+ i = positional.iterator();
+ while (i.hasNext()) {
+ Positional<?> p = (Positional<?>) i.next();
+ sb.append("new Positional(\"" + p.name + "\", " + p.type.repr() + ")");
+ sb.append(", ");
+ }
+ i = optional.iterator();
+ while (i.hasNext()) {
+ Optional<?> p = (Optional<?>) i.next();
+ sb.append("new Optional(\"" + p.name + "\", " + p.type.repr() + ")");
+ sb.append(", ");
+ }
+ if (vargs != null) {
+ sb.append("Signature.VARARGS, ");
+ }
+ sb.append("new Return(");
+ sb.append(returnType.repr());
+ sb.append("))");
+ return sb.toString();
+ }
public int getOptionalParameterIndex(String name) {
for (int i = 0; i < optional.size(); i++) {
@@ -238,7 +291,7 @@
}
public String toString() {
- return type.toString();
+ return String.valueOf(type);
}
}
@@ -257,13 +310,13 @@
}
}
- public static final class Return extends Parameter {
+ public static final class Return<T> extends Parameter<T> {
public Return(Type type) {
this.type = type;
}
@Override
- public Object getValue(Arguments a) {
+ public T getValue(Arguments a) {
return null;
}
}
@@ -292,7 +345,7 @@
}
}
- public static final class VarArgs extends Parameter {
+ public static final class VarArgs<T> extends Parameter<Channel> {
public VarArgs() {
this(new UnknownType());
}
@@ -303,16 +356,16 @@
}
@Override
- public Object getValue(Arguments a) {
+ public Channel getValue(Arguments a) {
return a.getVarArgs();
}
- public Collection<Object> get(Arguments a) {
- return new FutureCheckingCollection(a.getVarArgs());
+ public Collection<T> get(Arguments a) {
+ return new FutureCheckingCollection<T>(a.getVarArgs());
}
}
- private static class FutureCheckingCollection implements Collection<Object> {
+ private static class FutureCheckingCollection<T> implements Collection<T> {
private Channel c;
public FutureCheckingCollection(Channel c) {
@@ -323,12 +376,12 @@
}
@Override
- public boolean add(Object e) {
+ public boolean add(T e) {
throw new UnsupportedOperationException();
}
@Override
- public boolean addAll(Collection<? extends Object> c) {
+ public boolean addAll(Collection<? extends T> c) {
throw new UnsupportedOperationException();
}
@@ -352,9 +405,10 @@
return c.isEmpty();
}
+ @SuppressWarnings("unchecked")
@Override
- public Iterator<Object> iterator() {
- return new FutureCheckingIterator(c.iterator());
+ public Iterator<T> iterator() {
+ return new FutureCheckingIterator<T>((Iterator<T>) c.iterator());
}
@Override
@@ -388,10 +442,10 @@
}
}
- private static class FutureCheckingIterator implements Iterator<Object> {
- private Iterator<Object> it;
+ private static class FutureCheckingIterator<T> implements Iterator<T> {
+ private Iterator<T> it;
- public FutureCheckingIterator(Iterator<Object> it) {
+ public FutureCheckingIterator(Iterator<T> it) {
this.it = it;
}
@@ -401,8 +455,8 @@
}
@Override
- public Object next() {
- Object o = it.next();
+ public T next() {
+ T o = it.next();
Futures.futureCheck(o);
return o;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-28 00:11:55
|
Revision: 2098
http://cogkit.svn.sourceforge.net/cogkit/?rev=2098&view=rev
Author: hategan
Date: 2008-07-28 00:11:50 +0000 (Mon, 28 Jul 2008)
Log Message:
-----------
updated compiler stuff
Modified Paths:
--------------
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Compiler.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/InlineFunction.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Lambda.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/NativeFunction.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/OutputContext.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/QName.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Scope.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Self.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/State.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Type.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/VarRef.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Access.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Catch.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Def.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Export.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/For.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Function.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/If.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Import.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Invoke.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/InvokeField.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/KType.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Main.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Named.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Native.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Or.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/ParallelFor.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Set.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/StringToken.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Var.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/AltType.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/ChannelType.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/NamedType.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/Null.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/SimpleType.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/TypeReductor.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/Types.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/UnionType.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/UnknownType.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/UserType.java
Added Paths:
-----------
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/ProcessWaiter.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/TypeDecl.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/PartialType.java
Removed Paths:
-------------
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/InlineValue.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/TypedValue.java
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Compiler.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Compiler.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Compiler.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -24,6 +24,7 @@
import org.globus.cog.karajan.Loader;
import org.globus.cog.karajan.compiler.kernel.*;
import org.globus.cog.karajan.compiler.types.Types;
+import org.globus.cog.karajan.compiler.types.UnknownType;
import org.globus.cog.karajan.parser.ElementTree;
import org.globus.cog.karajan.parser.Node;
import org.globus.cog.karajan.runtime.Context;
@@ -43,6 +44,8 @@
private File tmpdir;
+ private static Scope kernel;
+
public Compiler() {
}
@@ -68,6 +71,10 @@
return analyze(tree.getRoot(), className(tree));
}
+ public String className(String ident) {
+ return replaceSymbols(base(ident));
+ }
+
public String className(ElementTree tree) {
return replaceSymbols(base(tree.getName()));
}
@@ -122,7 +129,7 @@
Writer wr = new IndentingWriter(new FileWriter(of));
oc.commit(wr);
wr.close();
- //copyFile(of, "../src/" + of.getName());
+ copyFile(of, "../src/" + of.getName());
compileJava(of);
return new File(of.getParentFile(), name);
}
@@ -143,7 +150,7 @@
State state = new State(kernel);
state = state.forkScope();
state.setClassName("");
- return analize(root, state);
+ return analyze(root, state);
}
catch (VariableNotFoundException e) {
throw new CompilationException(root, e);
@@ -221,8 +228,9 @@
ByteArrayOutputStream err = new ByteArrayOutputStream();
InputStream os = p.getInputStream();
InputStream es = p.getErrorStream();
+ ProcessWaiter pw = ProcessWaiter.waitFor(p);
byte[] buf = new byte[128];
- while (!processDone(p)) {
+ while (!pw.isDone()) {
int oa = os.available();
if (oa > 0) {
int len = os.read(buf, 0, Math.min(oa, buf.length));
@@ -234,22 +242,12 @@
err.write(buf, 0, len);
}
if (oa + ea == 0) {
- Thread.sleep(20);
+ Thread.sleep(50);
}
}
return new String[] { out.toString(), err.toString() };
}
- private boolean processDone(Process p) {
- try {
- p.exitValue();
- return true;
- }
- catch (IllegalThreadStateException e) {
- return false;
- }
- }
-
private void copyFile(File src, String dest) throws IOException {
byte[] buf = new byte[1024];
FileInputStream fis = new FileInputStream(src);
@@ -270,7 +268,7 @@
String name = def.compile(node, oc);
}
- private Type analize(Node node, State state) throws CompilationException,
+ private Type analyze(Node node, State state) throws CompilationException,
VariableNotFoundException {
Def def = state.getScope().lookupDef(new QName(node.getNodeType()));
return def.analyze(node, state);
@@ -278,64 +276,93 @@
public static final String KERNELNS = "k";
- private Scope initializeKernel() {
- Scope s = new Scope();
- addDef(s, "__pipe_", new Or());
- addDef(s, "seq", new Seq());
- addDef(s, "par", new Par());
- addDef(s, "main", new Main());
- addDef(s, "set", new Set());
- addDef(s, "var", new Var());
- addDef(s, "::", new Access());
- addDef(s, "number", new Num());
- addDef(s, "string", new Str());
- addDef(s, "native", new Native());
- addDef(s, "function", new Function());
- addDef(s, "type", new KType());
- addDef(s, "named", new Named());
- addDef(s, "bref", new GenericSeq());
- addDef(s, "block", new GenericSeq());
- // addDef(s, "connect", new GenericSeq());
- addDef(s, "to", new GenericSeq());
- addDef(s, "if", new If());
- addDef(s, "for", new For());
- addDef(s, "import", new Import());
- addDef(s, "export", new Export());
- addDef(s, "parallelFor", new ParallelFor());
- addDef(s, "future", new Future());
- addDef(s, "to", new ToChannel());
- addDef(s, "from", new FromChannel());
- addDef(s, "try", new Try());
- addDef(s, "catch", new Catch());
- addDef(s, "namespace", new Namespace());
- s.set(s.addVar(new QName("k", "true")), new InlineValue(Types.BOOLEAN,
- Boolean.TRUE, "Boolean.TRUE"));
- s.set(s.addVar(new QName("k", "false")), new InlineValue(Types.BOOLEAN,
- Boolean.FALSE, "Boolean.FALSE"));
- addType(s, "Integer", Types.INTEGER);
- addType(s, "Real", Types.REAL);
- addType(s, "Boolean", Types.BOOLEAN);
- addType(s, "String", Types.STRING);
- KERNEL = new Context(s.size());
- for (int i = 0; i < s.size(); i++) {
- KERNEL.set(i, s.get(i).type);
+ private Scope initializeKernel() throws CompilationException {
+ synchronized (Compiler.class) {
+ if (kernel != null) {
+ return kernel;
+ }
+ Scope s = new Scope();
+ addDef(s, "__pipe_", new Or());
+ addDef(s, "typedecl", new TypeDecl());
+ addDef(s, "seq", new Seq());
+ addDef(s, "par", new Par());
+ addDef(s, "main", new Main());
+ addDef(s, "set", new Set());
+ addDef(s, "var", new Var());
+ addDef(s, "identifier", new Var());
+ addDef(s, "::", new Access());
+ addDef(s, "number", new Num());
+ addDef(s, "string", new Str());
+ addDef(s, "native", new Native());
+ addDef(s, "function", new Function());
+ addDef(s, "type", new KType());
+ addDef(s, "named", new Named());
+ addDef(s, "bref", new GenericSeq());
+ addDef(s, "block", new GenericSeq());
+ // addDef(s, "connect", new GenericSeq());
+ addDef(s, "to", new GenericSeq());
+ addDef(s, "if", new If());
+ addDef(s, "for", new For());
+ addDef(s, "import", new Import());
+ addDef(s, "export", new Export());
+ addDef(s, "parallelFor", new ParallelFor());
+ addDef(s, "future", new Future());
+ addDef(s, "to", new ToChannel());
+ addDef(s, "from", new FromChannel());
+ addDef(s, "try", new Try());
+ addDef(s, "catch", new Catch());
+ addDef(s, "namespace", new Namespace());
+ addDef(s, "apply", new Invoke());
+ addValue(s, "true", Types.BOOLEAN.instance(Boolean.TRUE,
+ "Boolean.TRUE"));
+ addValue(s, "false", Types.BOOLEAN.instance(Boolean.FALSE,
+ "Boolean.FALSE"));
+ addValue(s, "nil", Types.NIL);
+ addSimpleType(s, "Integer", "INTEGER");
+ addSimpleType(s, "Real", "REAL");
+ addSimpleType(s, "Boolean", "BOOLEAN");
+ addSimpleType(s, "String", "STRING");
+ addSimpleType(s, "Type", "TYPE");
+ addType(s, "?", new UnknownType(), "new UnknownType()");
+ kernel = s;
+ return s;
}
- return s;
}
private void addDef(Scope s, String name, Def def) {
QName qn = new QName(KERNELNS, name);
VarRef ref = s.addVar(qn);
def.setName(qn);
- s.set(ref, new TypedValue(new Lambda(), def));
+ s.set(ref, new Lambda(def));
}
- private void addType(Scope s, String name, Type type) {
+ private void addValue(Scope s, String name, Type v) {
QName qn = new QName(KERNELNS, name);
VarRef ref = s.addVar(qn);
- s.set(ref, new TypedValue(type, type));
+ s.set(ref, v);
}
+ private void addSimpleType(Scope s, String name, String tfield)
+ throws CompilationException {
+ QName qn = new QName(KERNELNS, name);
+ VarRef ref = s.addVar(qn);
+ try {
+ Type t = (Type) Types.class.getField(tfield).get(null);
+ s.set(ref, Types.TYPE.instance(t, "Types." + tfield));
+ }
+ catch (Exception e) {
+ throw new CompilationException(null,
+ "Could not add type " + tfield, e);
+ }
+ }
+
+ private void addType(Scope s, String name, Type t, String repr)
+ throws CompilationException {
+ QName qn = new QName(KERNELNS, name);
+ VarRef ref = s.addVar(qn);
+ s.set(ref, Types.TYPE.instance(t, repr));
+ }
+
public static Context KERNEL;
public static void main(String[] args) {
@@ -343,10 +370,11 @@
error("Missing argument");
}
String project = args[0];
-
+
try {
ElementTree tree = Loader.load(project);
Compiler.getDefault().compile(tree);
+ System.exit(0);
}
catch (CompilationException e) {
e.printStackTrace();
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/InlineFunction.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/InlineFunction.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/InlineFunction.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -22,4 +22,9 @@
public String getInlineName() {
return inlineName;
}
+
+ @Override
+ public Lambda clone() {
+ return new InlineFunction(signature, inlineName);
+ }
}
Deleted: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/InlineValue.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/InlineValue.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/InlineValue.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -1,20 +0,0 @@
-//----------------------------------------------------------------------
-//This code is developed as part of the Java CoG Kit project
-//The terms of the license can be found at http://www.cogkit.org/license
-//This message may not be removed or altered.
-//----------------------------------------------------------------------
-
-/*
- * Created on Jun 13, 2008
- */
-package org.globus.cog.karajan.compiler;
-
-public class InlineValue extends TypedValue {
- public final String inlineValue;
-
- public InlineValue(Type type, Object value, String inlineValue) {
- super(type, value);
- this.inlineValue = inlineValue;
- }
-
-}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Lambda.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Lambda.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Lambda.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -9,6 +9,7 @@
*/
package org.globus.cog.karajan.compiler;
+import org.globus.cog.karajan.compiler.kernel.Def;
import org.globus.cog.karajan.runtime.Signature;
@@ -18,6 +19,11 @@
public Lambda() {
}
+ public Lambda(Def def) {
+ this();
+ this.value = def;
+ }
+
public Lambda(Signature signature) {
this.signature = signature;
}
@@ -25,4 +31,13 @@
public String toString() {
return signature == null ? "[]" : signature.toString();
}
+
+ public Lambda clone() {
+ return new Lambda(signature);
+ }
+
+ @Override
+ public String repr() {
+ return "new Lambda(" + signature.repr() + ")";
+ }
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/NativeFunction.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/NativeFunction.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/NativeFunction.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -9,21 +9,100 @@
*/
package org.globus.cog.karajan.compiler;
+import java.io.InvalidClassException;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.globus.cog.karajan.runtime.NativeCallable;
import org.globus.cog.karajan.runtime.Signature;
public class NativeFunction extends Lambda {
- private int locals;
-
- public NativeFunction(Signature signature, int locals) {
- super(signature);
- this.locals = locals;
- }
-
- public int getLocals() {
- return locals;
- }
-
- public String toString() {
- return "native " + super.toString();
- }
+ private static final Map<String, NativeFunction> cache;
+ static {
+ cache = new HashMap<String, NativeFunction>();
+ }
+
+ private String clsname;
+ private NativeCallable prototype;
+
+ public NativeFunction(NativeCallable prototype, Signature signature, String clsname) {
+ super(signature);
+ this.clsname = clsname;
+ this.prototype = prototype;
+ }
+
+ public static NativeFunction getInstance(String clsname)
+ throws InvalidClassException {
+ NativeFunction t;
+ synchronized (cache) {
+ t = cache.get(clsname);
+ }
+ if (t == null) {
+ Class<NativeCallable> cls = getNativeClass(clsname);
+ t = buildNative(cls, clsname);
+ synchronized (cache) {
+ cache.put(clsname, t);
+ }
+ }
+ return t;
+ }
+
+ public static NativeFunction getInstance(Class<?> cls) {
+ try {
+ return getInstance(cls.getName());
+ }
+ catch (InvalidClassException e) {
+ throw new LinkageError(e.getMessage());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected static Class<NativeCallable> getNativeClass(String clsname)
+ throws InvalidClassException {
+ try {
+ return (Class<NativeCallable>) Class.forName(clsname);
+ }
+ catch (ClassNotFoundException e) {
+ throw new InvalidClassException("Invalid native: " + clsname);
+ }
+ }
+
+ protected static NativeFunction buildNative(Class<NativeCallable> cls, String clsname)
+ throws InvalidClassException {
+ try {
+ Field f = cls.getField("SIGNATURE");
+ Signature p = (Signature) f.get(null);
+ if (p.getReturnType() == null) {
+ throw new InvalidClassException("Invalid native "
+ + cls.getName() + ". Return type is null");
+ }
+ return new NativeFunction(cls.newInstance(), p, clsname);
+ }
+ catch (InvalidClassException e) {
+ throw e;
+ }
+ catch (Exception e) {
+ throw new InvalidClassException("Invalid native " + cls.getName()
+ + ":" + e.getMessage());
+ }
+ }
+
+ @Override
+ public Lambda clone() {
+ return new NativeFunction(prototype, signature, clsname);
+ }
+
+ public String toString() {
+ return "native " + super.toString();
+ }
+
+ @Override
+ public String repr() {
+ return "NativeFunction.getInstance(" + clsname.replace('$', '.') + ".class)";
+ }
+
+ public Type invokeStatic(Type args) {
+ return prototype.invokeStatic(this, args);
+ }
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/OutputContext.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/OutputContext.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/OutputContext.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -95,12 +95,15 @@
return l;
}
- private int countNewLines(String str) {
+ private int countNewLines(final String str) {
int c = 0;
for (int i = 0; i < str.length(); i++) {
- if (Character.getType(str.charAt(i)) == Character.LINE_SEPARATOR) {
+ /*if (Character.getType(str.charAt(i)) == Character.LINE_SEPARATOR) {
c++;
- }
+ }*/
+ if (str.charAt(i) == '\n') {
+ c++;
+ }
}
return c;
}
Added: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/ProcessWaiter.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/ProcessWaiter.java (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/ProcessWaiter.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -0,0 +1,50 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Jul 11, 2008
+ */
+package org.globus.cog.karajan.compiler;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public class ProcessWaiter implements Runnable {
+ private static ExecutorService pool = Executors.newCachedThreadPool();
+
+ public static ProcessWaiter waitFor(Process p) {
+ ProcessWaiter pw = new ProcessWaiter(p);
+ pool.execute(pw);
+ return pw;
+ }
+
+ private Process p;
+ private int ec;
+
+ public ProcessWaiter(Process p) {
+ this.p = p;
+ ec = -1;
+ }
+
+
+ @Override
+ public void run() {
+ try {
+ ec = p.waitFor();
+ }
+ catch (InterruptedException e) {
+ ec = 250;
+ }
+ }
+
+ public int getExitCode() {
+ return ec;
+ }
+
+ public boolean isDone() {
+ return ec >= 0;
+ }
+}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/QName.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/QName.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/QName.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -10,32 +10,38 @@
package org.globus.cog.karajan.compiler;
public final class QName {
- public final String ns;
- public final String name;
-
- public QName(String name) {
- int i = name.lastIndexOf('.');
- if (i == -1) {
- this.ns = null;
- this.name = name;
- }
- else {
- this.ns = name.substring(0, i);
- this.name = name.substring(i + 1);
- }
- }
-
- public QName(String ns, String name) {
- this.ns = ns;
- this.name = name;
- }
-
- public String toString() {
- if (ns == null) {
- return name;
- }
- else {
- return ns + "." + name;
- }
- }
+ public final String ns;
+ public final String name;
+
+ public QName(String name) {
+ if (name.equals("...")) {
+ this.ns = null;
+ this.name = name;
+ }
+ else {
+ int i = name.lastIndexOf('.');
+ if (i == -1) {
+ this.ns = null;
+ this.name = name;
+ }
+ else {
+ this.ns = name.substring(0, i);
+ this.name = name.substring(i + 1);
+ }
+ }
+ }
+
+ public QName(String ns, String name) {
+ this.ns = ns;
+ this.name = name;
+ }
+
+ public String toString() {
+ if (ns == null) {
+ return name;
+ }
+ else {
+ return ns + "." + name;
+ }
+ }
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Scope.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Scope.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Scope.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -17,9 +17,11 @@
import java.util.Map;
import org.globus.cog.karajan.compiler.kernel.Def;
+import org.globus.cog.karajan.compiler.types.Types;
+import org.globus.cog.karajan.compiler.types.UserType;
public class Scope {
- private List<TypedValue> values;
+ private List<Type> values;
private Map<String, Map<String, VarRef>> vars;
private Scope prev;
public int offset;
@@ -36,7 +38,7 @@
public Scope(Scope prev, boolean hard) {
vars = new HashMap<String, Map<String, VarRef>>();
- values = new ArrayList<TypedValue>();
+ values = new ArrayList<Type>();
softChildren = new ArrayList<Scope>();
hardChildren = new ArrayList<Scope>();
if (prev != null) {
@@ -56,6 +58,14 @@
name = prev.name + prev.softChildren.size();
}
}
+
+ public Scope dup() {
+ Scope s = new Scope();
+ s.hard = hard;
+ s.vars = vars;
+ s.values = values;
+ return s;
+ }
public Scope() {
this(null);
@@ -89,16 +99,19 @@
public Def lookupDef(QName name) {
VarRef ref = getVar(name);
- TypedValue tv = ref.get();
+ Type tv = ref.get();
if (tv == null) {
return null;
}
+ else if (tv.equals(Types.TYPE)) {
+ return null;
+ }
else {
return (Def) tv.value;
}
}
- public void set(VarRef ref, TypedValue value) {
+ public void set(VarRef ref, Type value) {
while (values.size() <= ref.addr) {
values.add(null);
}
@@ -113,11 +126,11 @@
return ref.addr;
}
- public TypedValue get(VarRef ref) {
+ public Type get(VarRef ref) {
return get(ref.addr);
}
- public TypedValue get(int index) {
+ public Type get(int index) {
try {
return values.get(index);
}
@@ -238,4 +251,15 @@
}
return depth;
}
+
+ public String allToString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(this.toString());
+ sb.append(", ");
+ for (Scope s : softChildren) {
+ sb.append(s.allToString());
+ sb.append(", ");
+ }
+ return sb.toString();
+ }
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Self.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Self.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Self.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -9,6 +9,52 @@
*/
package org.globus.cog.karajan.compiler;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.globus.cog.karajan.compiler.types.Types;
+
public class Self extends Lambda {
+ private List<CTask> runOnClose;
+ public Type org;
+ private String str;
+ public void runOnClose(CTask r) {
+ if (runOnClose == null) {
+ runOnClose = new LinkedList<CTask>();
+ }
+ runOnClose.add(r);
+ }
+
+ public void close(Type t) throws CompilationException {
+ org = t;
+ if (runOnClose != null) {
+ for (CTask r : runOnClose) {
+ r.run();
+ }
+ }
+ }
+
+ public static interface CTask {
+ void run() throws CompilationException;
+ }
+
+ @Override
+ public String toString() {
+ if (org == null) {
+ return "Self";
+ }
+ else {
+ return "s/" + org.toString();
+ }
+ }
+
+ public Type actualType() {
+ if (Types.TYPE.equals(org)) {
+ return (Type) org.value;
+ }
+ else {
+ return org;
+ }
+ }
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/State.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/State.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/State.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -33,11 +33,19 @@
public boolean customContextInitialization;
public boolean loop;
public boolean threadInit;
+ public String id;
+ private int crtid;
public State(State parent, Scope defs) {
this.scope = defs;
this.parent = parent;
lines = new HashMap<String, Map<LineMarker, Integer>>();
+ if (parent != null) {
+ id = parent.id + "/" + parent.crtid++;
+ }
+ else {
+ id = "0";
+ }
}
public State(Scope defs) {
@@ -93,6 +101,10 @@
public State forkScopeHard() {
return new State(this, new Scope(scope, true));
}
+
+ public State dup() {
+ return new State(this.parent, scope.dup());
+ }
public void setClassName(String name) {
this.className = name;
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Type.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Type.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Type.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -10,6 +10,9 @@
package org.globus.cog.karajan.compiler;
public class Type {
+ public Object value;
+ public String inlineValue;
+
public boolean isFuture() {
return false;
}
@@ -21,4 +24,8 @@
public int getArity() {
return 1;
}
+
+ public String repr() {
+ return "?";
+ }
}
Deleted: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/TypedValue.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/TypedValue.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/TypedValue.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -1,24 +0,0 @@
-//----------------------------------------------------------------------
-//This code is developed as part of the Java CoG Kit project
-//The terms of the license can be found at http://www.cogkit.org/license
-//This message may not be removed or altered.
-//----------------------------------------------------------------------
-
-/*
- * Created on May 31, 2008
- */
-package org.globus.cog.karajan.compiler;
-
-public class TypedValue {
- public Type type;
- public Object value;
-
- public TypedValue(Type type, Object value) {
- this.type = type;
- this.value = value;
- }
-
- public String toString() {
- return type + "/" + value;
- }
-}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/VarRef.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/VarRef.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/VarRef.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -19,7 +19,7 @@
this.addr = addr;
}
- public TypedValue get() {
+ public Type get() {
return scope.get(this);
}
@@ -31,7 +31,7 @@
return addr + scope.offset;
}
- public void set(TypedValue tv) {
+ public void set(Type tv) {
scope.set(this, tv);
}
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Access.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Access.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Access.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -16,9 +16,12 @@
import org.globus.cog.karajan.compiler.Lambda;
import org.globus.cog.karajan.compiler.OutputContext;
import org.globus.cog.karajan.compiler.QName;
+import org.globus.cog.karajan.compiler.Self;
import org.globus.cog.karajan.compiler.State;
import org.globus.cog.karajan.compiler.Type;
import org.globus.cog.karajan.compiler.VarRef;
+import org.globus.cog.karajan.compiler.Self.CTask;
+import org.globus.cog.karajan.compiler.types.UnknownType;
import org.globus.cog.karajan.compiler.types.UserType;
import org.globus.cog.karajan.parser.Node;
import org.globus.cog.karajan.runtime.Signature.Parameter;
@@ -26,8 +29,23 @@
public class Access extends Def {
@Override
- public Type analyze(Node n, State state) throws CompilationException {
+ public Type analyze(final Node n, final State state)
+ throws CompilationException {
Type tobj = this.analyzeChild(n.getNode(0), state);
+ if (tobj instanceof Self) {
+ Self s = (Self) tobj;
+ if (s.org == null) {
+ ((Self) tobj).runOnClose(new CTask() {
+ public void run() throws CompilationException {
+ Access.this.analyze(n, state);
+ }
+ });
+ return new UnknownType();
+ }
+ else {
+ tobj = concreteType(n, s.org);
+ }
+ }
if (!(tobj instanceof UserType)) {
throw new CompilationException(n, "Invalid access. Type " + tobj
+ " does not have any fields");
@@ -53,7 +71,8 @@
+ tobj + " does not have a field named " + field);
}
if (p.type instanceof Lambda) {
- InvokeField ivf = new InvokeField(n.getNode(1), p.type);
+ InvokeField ivf = new InvokeField(act, p.type);
+ ivf.analyze(act, state.fork());
n.setProperty("field", p);
n.setProperty("invoke", ivf);
act.setState(state.fork());
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Catch.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Catch.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Catch.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -39,7 +39,7 @@
else if (c.getNodeType().equals("k.typedecl")) {
etr = state.getScope().getVar(
new QName((String) c.getNode(1).getProperty(Node.TEXT)));
- etype = etr.get().type;
+ etype = etr.get();
ref = s2.getScope().addVar(
new QName((String) c.getNode(0).getProperty(Node.TEXT)));
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Def.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Def.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Def.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -17,11 +17,13 @@
import org.globus.cog.karajan.compiler.OutputContext;
import org.globus.cog.karajan.compiler.QName;
import org.globus.cog.karajan.compiler.Scope;
+import org.globus.cog.karajan.compiler.Self;
import org.globus.cog.karajan.compiler.State;
import org.globus.cog.karajan.compiler.Type;
import org.globus.cog.karajan.compiler.VarRef;
import org.globus.cog.karajan.compiler.VariableNotFoundException;
import org.globus.cog.karajan.compiler.types.TypeReductor;
+import org.globus.cog.karajan.compiler.types.Types;
import org.globus.cog.karajan.compiler.types.UnionType;
import org.globus.cog.karajan.parser.Node;
@@ -82,12 +84,13 @@
}
public Type analyzeChild(Node s, State state) throws CompilationException {
+ transform(s);
Def def;
try {
def = lookupDef(s, state);
}
catch (ClassCastException e) {
- throw new CompilationException(s, "Cannot invoke a non-lambda");
+ throw new CompilationException(s, "Cannot invoke a non-lambda", e);
}
return analyzeChild(s, def, state);
}
@@ -97,16 +100,23 @@
State fork;
fork = state.forkScope();
s.setState(fork);
- Type t = TypeReductor.reduce(def.analyze(s, fork));
- if (!def.inline(s)) {
- state.recordState = true;
+ try {
+ Type t = TypeReductor.reduce(def.analyze(s, fork));
+
+ if (!def.inline(s)) {
+ state.recordState = true;
+ }
+ if (t == null) {
+ def.analyze(s, fork);
+ throw new CompilationException(s, "Type returned was null");
+ }
+ else {
+ return t;
+ }
}
- if (t == null) {
- throw new CompilationException(s, "Type returned was null");
+ catch (RuntimeException e) {
+ throw new CompilationException(s, e.getMessage(), e);
}
- else {
- return t;
- }
}
public String compile(Node n, OutputContext oc) throws CompilationException {
@@ -123,17 +133,19 @@
protected void fnStart(Node n, State state, OutputContext oc, String name) {
Object line = unknownify(getTreeProperty(n, Node.LINE));
state.method = name;
+ state.threadInit = false;
+ state.crt = 0;
oc.emit("private void " + name + "() {");
}
-
+
protected void requireThread(Node n, OutputContext oc) {
while (n.getState().method == null) {
n = n.getParent();
}
State s = n.getState();
- if (!s.threadInit && !s.recordState) {
+ if (!s.threadInit) {
s.threadInit = true;
- oc.emit("LWThread thread = LWThread.currentThread();");
+ oc.emit("final LWThread thread = LWThread.currentThread();");
}
}
@@ -145,7 +157,7 @@
return orig.toString();
}
}
-
+
protected void stateCaptureStart(Node n, OutputContext oc) {
stateCaptureStart(n, oc, false);
}
@@ -153,14 +165,13 @@
protected void stateCaptureStart(Node n, OutputContext oc, boolean loop) {
n.getState().recordState = true;
n.getState().loop = loop;
- oc.emit("final LWThread thread = LWThread.currentThread();");
+ requireThread(n, oc);
oc.emit("thread.checkSlice();");
oc.emit("int __state__ = thread.popState();");
if (loop) {
oc.emit("while(true) {");
}
oc.emit("switch(__state__) {");
- n.getState().crt = 0;
state(n, oc);
OutputContext ocs = n.getState().getExtraInitialization();
if (ocs != null) {
@@ -181,9 +192,11 @@
@SuppressWarnings("unchecked")
protected void forkContext(Node n, OutputContext oc) {
State state = n.getState();
- if (state.getScope().collapsedSize() > 0 && !state.customContextInitialization) {
+ if (state.getScope().collapsedSize() > 0
+ && !state.customContextInitialization) {
oc.emit("//" + state.getScope().getCollapsedNames());
- List<String> l = (List<String>) n.getRoot().getProperty("methodsWithFrames");
+ List<String> l = (List<String>) n.getRoot().getProperty(
+ "methodsWithFrames");
l.add(state.method);
forkContext(n, oc, state.getScope().collapsedSize());
}
@@ -211,23 +224,32 @@
protected void compileChildren(Node n, State state, OutputContext oc)
throws CompilationException {
- for (int i = 0; i < n.nodeCount(); i++) {
+ compileChildren(n, state, oc, 0);
+ }
+
+ protected void compileChildren(Node n, State state, OutputContext oc,
+ int first) throws CompilationException {
+ for (int i = first; i < n.nodeCount(); i++) {
compileChild(n, i, oc);
}
}
protected void compileChild(Node n, int index, OutputContext oc)
throws CompilationException {
- State state = n.getState();
- Node child = n.getNode(index);
- //System.out.println(child);
+ compileChild(n.getNode(index), oc);
+ }
+
+ protected void compileChild(Node child, OutputContext oc)
+ throws CompilationException {
+ State state = child.getParent().getState();
+ // System.out.println(child);
OutputContext cc = oc.fork();
try {
Def def = lookupDef(child, state);
if (state.recordState || !def.inline(child)) {
- state(n, oc);
+ state(child.getParent(), oc);
}
- cc.emit("// " + child);
+ cc.emit("// " + def.toString(child));
String sn = def.compile(child, cc);
if (sn == null) {
// inline
@@ -239,16 +261,20 @@
}
}
catch (VariableNotFoundException e) {
- throw new CompilationException(n, e);
+ throw new CompilationException(child.getParent(), e);
}
}
+ protected String toString(Node child) {
+ return child.toString();
+ }
+
protected static void state(Node n, OutputContext oc) {
if (oc.clean) {
return;
}
State state = n.getState();
- while (!state.recordState) {
+ while (state.method == null) {
state = state.getParent();
}
@@ -372,11 +398,12 @@
sb.append("get(" + ref.getIndex() + ")");
return sb.toString();
}
-
+
protected static String set(VarRef ref, Scope s, String value) {
- return varContext("thread.ctx", s, ref) + ".set(" + ref.getIndex() + ", " + value + ");";
+ return varContext("thread.ctx", s, ref) + ".set(" + ref.getIndex()
+ + ", " + value + ");";
}
-
+
protected static int getDepth(Scope s) {
int count = 0;
while (s != null) {
@@ -430,4 +457,61 @@
public boolean isStateful() {
return false;
}
+
+ protected String getText(Node n) {
+ return (String) n.getProperty(Node.TEXT);
+ }
+
+ protected void transform(Node n) {
+ if (n.getNodeType().equals("k.apply")) {
+ // apply(fn, args) -> lambda := fn, lambda(args)
+ n.setNodeType("k.seq");
+ Node fn = n.getNode(0);
+ Node id2 = newNode(n, "lambda");
+ for (int i = 1; i < n.nodeCount(); i++) {
+ reparent(n.getNode(i), id2);
+ }
+ n.elements().clear();
+
+ Node set = newNode(n, "k.set");
+ set.setProperty("notype", Boolean.TRUE);
+ Node id1 = newNode(set, "k.var", "lambda");
+ reparent(id1, set);
+ reparent(fn, set);
+
+ reparent(set, n);
+ reparent(id2, n);
+ }
+ }
+
+ private Node newNode(Node parent, String type) {
+ return newNode(parent, type, null);
+ }
+
+ private Node newNode(Node parent, String type, String text) {
+ Node n = new Node();
+ n.setParent(parent);
+ n.setNodeType(type);
+ if (text != null) {
+ n.setProperty(Node.TEXT, text);
+ }
+ return n;
+ }
+
+ private void reparent(Node n, Node parent) {
+ parent.addNode(n);
+ n.setParent(parent);
+ }
+
+ public static Type concreteType(Node n, Type t) throws CompilationException {
+ if (t.equals(Types.TYPE)) {
+ return (Type) t.value;
+ }
+ else if (t instanceof Self) {
+ return t;
+ }
+ else {
+ throw new CompilationException(n, "Not a type: " + t);
+ }
+ }
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Export.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Export.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Export.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -44,6 +44,7 @@
ut.add(new NamedType((String) n.getNode(i).getProperty(Node.TEXT), l.get(i)));
}
}
+ n.setProperty("type", ut);
return ut;
}
@@ -59,6 +60,10 @@
throw new CompilationException(n, e);
}
}
+ OutputContext oc2 = oc.fork();
+ oc2.reparentToRoot();
+ Type t = (Type) n.getProperty("type");
+ oc2.emit("public static final Type TYPE = " + t.repr() + ";");
return null;
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/For.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/For.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/For.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -16,6 +16,7 @@
import org.globus.cog.karajan.compiler.Type;
import org.globus.cog.karajan.compiler.VarRef;
import org.globus.cog.karajan.compiler.VariableNotFoundException;
+import org.globus.cog.karajan.compiler.types.ChannelType;
import org.globus.cog.karajan.compiler.types.ProductType;
import org.globus.cog.karajan.compiler.types.Types;
import org.globus.cog.karajan.parser.Node;
@@ -35,7 +36,7 @@
n.setProperty("iterref", iterref);
n.setProperty("idref", idref);
Type it = this.analyzeChild(n.getNode(1), state);
- if (!Types.ITERABLE.equals(it)) {
+ if (!Types.ITERABLE.equals(it) && !(it instanceof ChannelType)) {
throw new CompilationException(n,
"Argument type mismatch. Expected an " + Types.ITERABLE
+ ", got " + it);
@@ -82,7 +83,7 @@
oc
.emit("thread.ctx.set("
+ ref.getIndex()
- + ", ((Collection<Object>) thread.ctx.popChannel(0).get(0)).iterator());");
+ + ", ((Iterable<Object>) thread.ctx.popChannel(0).get(0)).iterator());");
return null;
}
catch (VariableNotFoundException e) {
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Function.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Function.java 2008-07-27 23:59:47 UTC (rev 2097)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Function.java 2008-07-28 00:11:50 UTC (rev 2098)
@@ -10,6 +10,7 @@
package org.globus.cog.karajan.compiler.kernel;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.globus.cog.karajan.compiler.CompilationException;
@@ -18,135 +19,268 @@
import org.globus.cog.karajan.compiler.QName;
import org.globus.cog.karajan.compiler.State;
import org.globus.cog.karajan.compiler.Type;
-import org.globus.cog.karajan.compiler.TypedValue;
import org.globus.cog.karajan.compiler.VarRef;
+import org.globus.cog.karajan.compiler.types.ChannelType;
+import org.globus.cog.karajan.compiler.types.PartialType;
+import org.globus.cog.karajan.compiler.types.NamedType;
+import org.globus.cog.karajan.compiler.types.Null;
+import org.globus.cog.karajan.compiler.types.Types;
+import org.globus.cog.karajan.compiler.types.UnionType;
import org.globus.cog.karajan.compiler.types.UnknownType;
import org.globus.cog.karajan.parser.Node;
import org.globus.cog.karajan.runtime.Signature;
import org.globus.cog.karajan.runtime.Signature.Optional;
import org.globus.cog.karajan.runtime.Signature.Parameter;
import org.globus.cog.karajan.runtime.Signature.Positional;
+import org.globus.cog.karajan.runtime.Signature.VarArgs;
public class Function extends Def {
-
- public Type analyze(Node n, State state) throws CompilationException {
- n.setState(state);
- State s2 = state.forkScopeHard();
- for (int i = 0; i < n.nodeCount() - 1; i++) {
- Node c = n.getNode(i);
- if (c.getNodeType().equals("k.var")) {
- QName arg = new QName((String) c.getProperty(Node.TEXT));
- VarRef ref = s2.getScope().addVar(arg);
- ref.set(new TypedValue(new UnknownType(), null));
- }
- else if (c.getNodeType().equals("k.typedecl")) {
- QName arg = new QName((String) c.getNode(0).getProperty(Node.TEXT));
- VarRef ref = s2.getScope().addVar(arg);
- QName argType = new QName((String) c.getNode(1).getProperty(Node.TEXT));
- VarRef tref = s2.getScope().getVar(argType);
- ref.set(new TypedValue(tref.get().type, null));
- }
- else {
- throw new CompilationException(n, "Invalid argument: " + c);
- }
- }
- Node block = n.getNode(n.nodeCount() - 1);
- Type blockType = analyzeChild(block, s2);
- Signature s = getSignature(n, blockType);
- int pc = (s.getPositionalParameters().size() + s.getOptionalParameters().size());
- s.setLocals(s2.getScope().collapsedSize() - pc);
- //addParams(n, s, s2);
- String name = state.getUniqueID(identifier(getName().toString()));
- n.setProperty("name", name);
- n.setProperty("signature", s);
- return new InlineFunction(s, name);
- }
-
- private List<VarRef> addParams(Node n, Signature s, State state) {
- List<VarRef> l;
- l = new ArrayList<VarRef>();
- for( Parameter op : s.getOptionalParameters()) {
- l.add(state.getScope().addVar(new QName(op.name)));
- }
- n.setProperty("orefs", l);
- l = new ArrayList<VarRef>();
- for( Parameter pp : s.getPositionalParameters()) {
+
+ public Type analyze(Node n, State state) throws CompilationException {
+ return analyze(n, state, new UnionType(), false);
+ }
+
+ public Type analyze(Node n, State state, Type actual)
+ throws CompilationException {
+ return analyze(n, state, actual, true);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Type analyze(Node n, State state, Type actual, boolean dependent)
+ throws CompilationException {
+ n.setState(state);
+ State s2 = state.forkScopeHard();
+ boolean dependentType = false;
+ for (int i = 0; i < n.nodeCount() - 1; i++) {
+ Node c = n.getNode(i);
+ if (c.getNodeType().equals("k.var")) {
+ QName arg = new QName(getText(c));
+ VarRef ref = s2.getScope().addVar(arg);
+ if (arg.ns == null && arg.name.equals("...")) {
+ ref.set(new ChannelType("...", false, new UnknownType()));
+ }
+ else {
+ ref.set(new UnknownType());
+ }
+ }
+ else if (c.getNodeType().equals("k.typedecl")) {
+ NamedType nt = (NamedType) this.analyzeChild(c, state);
+ QName arg = new QName(getText(c.getNode(0)));
+ VarRef ref = s2.getScope().addVar(arg);
+ Type t = concreteType(c, nt.src);
+
+ if (Types.TYPE.equals(t)) {
+ t = Types.TYPE.instance(new PartialType(arg, n, ref));
+ }
+ c.setProperty("type", t);
+ ref.set(t);
+ }
+ else {
+ throw new CompilationException(n, "Invalid argument: " + c);
+ }
+ }
+ Node block = n.getNode(n.nodeCount() - 1);
+
+ Type blockType = analyzeChild(block, s2);
+ Signature s = getSignature(n, blockType);
+ int pc = (s.getPositionalParameters().size() + s
+ .getOptionalParameters().size());
+ s.setLocals(s2.getScope().collapsedSize() - pc);
+ // addParams(n, s, s2);
+ String name = (String) block.getProperty("name");
+
+ name = state.getUniqueID(identifier(getName().toString()));
+ block.setProperty("name", name);
+
+ block.setProperty("name", name);
+ block.setProperty("signature", s);
+ InlineFunction iff = new InlineFunction(s, name);
+ // System.out.println(iff);
+ return iff;
+ }
+
+ private Type getType(Type t, int n) {
+ if (t instanceof UnionType) {
+ UnionType ut = (UnionType) t;
+ if (ut.fields != null && ut.fields.size() > n) {
+ return ut.fields.get(n);
+ }
+ else {
+ return null;
+ }
+ }
+ else {
+ return null;
+ }
+ }
+
+ private List<VarRef> addParams(Node n, Signature s, State state) {
+ List<VarRef> l;
+ l = new ArrayList<VarRef>();
+ for (Parameter<?> op : s.getOptionalParameters()) {
+ l.add(state.getScope().addVar(new QName(op.name)));
+ }
+ n.setProperty("orefs", l);
+ l = new ArrayList<VarRef>();
+ for (Parameter<?> pp : s.getPositionalParameters()) {
l.add(state.getScope().addVar(new QName(pp.name)));
}
- n.setProperty("prefs", l);
- return l;
- }
+ n.setProperty("prefs", l);
+ return l;
+ }
- @Override
- public String compile(Node n, OutputContext oc) throws CompilationException {
- State state = n.getState();
- state.recordState = false;
- Signature sig = (Signature) n.getProperty("signature");
- String name = (String) n.getProperty("name");
- oc.emit(" thread.ctx.append(0, new Callable(thread.ctx) {public void invoke(Arguments args) {" + name + "();}});");
- OutputContext oc2 = oc.fork();
- oc2.reparentToRoot();
- compileBody(n, state, oc2, name, sig);
- sig.setDefaultValuesRepr(name + "_defaults");
- return null;
- }
+ @Override
+ @SuppressWarnings("unchecked")
+ public String compile(Node n, OutputContext oc) throws CompilationException {
+ Node block = n.getNode(n.nodeCount() - 1);
+ compile(n, oc, block, n.getState());
+ return null;
+ }
- private void compileBody(Node n, State state, OutputContext oc, String name, Signature sig)
- throws CompilationException {
- oc.emit("static Object[] " + name + "_defaults = null;");
- fnStart(n, state, oc, name);
- int pc = (sig.getPositionalParameters().size() + sig.getOptionalParameters().size());
-
- Node body = n.getNode(n.nodeCount() - 1);
- OutputContext boc = new OutputContext();
- body.getState().setExtraInitialization(boc);
- boc.emit("Arguments a = (Arguments) thread.ctx;");
- body.getState().customContextInitialization = true;
- compileChild(n, n.nodeCount() - 1, oc);
- beforeFnEnd(oc);
- fnEnd(n, oc);
- }
-
- protected void beforeFnEnd(OutputContext oc) {
-
- }
+ public String compile(Node n, OutputContext oc, Node instance, State state)
+ throws CompilationException {
+ state.recordState = false;
+ Signature sig = (Signature) instance.getProperty("signature");
+ String name = (String) instance.getProperty("name");
+ oc
+ .emit(" thread.ctx.append(0, new Callable(thread.ctx) {public void invoke(Arguments args) {"
+ + name + "();} " + stringRepr(n, sig) + "});");
+ OutputContext oc2 = oc.fork();
+ oc2.reparentToRoot();
+ compileBody(n, state, instance, oc2, name, sig);
+ sig.setDefaultValuesRepr(name + "_defaults");
+ return null;
+ }
- private Signature getSignature(Node n, Type returnType) throws CompilationException {
- List<Parameter> l = new ArrayList<Parameter>();
- boolean block = false;
- for (Node c : n.elements()) {
- if (c.getNodeType().equals("k.block")) {
- block = true;
- }
- else {
- if (block) {
- throw new CompilationException(n, "Invalid argument" + c);
- }
- else {
- if (c.getNodeType() == "k.var") {
- l.add(new Positional((String) c.getProperty(Node.TEXT)));
- }
- else if (c.getNodeType() == "k.typedecl") {
- QName argType = new QName((String) c.getNode(1).getProperty(Node.TEXT));
- VarRef tref = n.getState().getScope().getVar(argType);
- l.add(new Positional((String) c.getNode(0).getProperty(Node.TEXT), tref.get().type));
- }
- else if (c.getNodeType() == "k.named") {
- l.add(new Optional((String) c.getProperty("name"), null));
- }
- }
- }
- }
- Signature sig = new Signature(l);
- sig.setReturnType(returnType);
- sig.setLocals(n.getState().getScope().size());
- return sig;
- }
+ protected String stringRepr(Node n, Signature sig) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("public String toString() { return \"");
+ if (sig.isType()) {
+ sb.append(sig.getReturnType());
+ }
+ else {
+ Iterator<Parameter<?>> i;
+ i = sig.positional.iterator();
+ while (i.hasNext()) {
+ Positional<?> p = (Positional<?>) i.next();
+ sb.append(stringRepr(n, p.type));
+ if (i.hasNext() || !sig.optional.isEmpty() || sig.vargs != null) {
+ sb.append(", ");
+ }
+ }
+ i = sig.optional.iterator();
+ while (i.hasNext()) {
+ Optional<?> o = (Optional<?>) i.next();
+ sb.append(stringRepr(n, o.type));
+ if (i.hasNext() || sig.vargs != null) {
+ sb.append(", ");
+ }
+ }
+ if (sig.vargs != null) {
+ sb.append(sig.vargs);
+ }
+ sb.append(" -> ");
+ if (!Null.type.equals(sig.getReturnType())) {
+ sb.append(stringRepr(n, sig.getReturnType()));
+ }
+ }
+ sb.append("\";}");
+ return sb.toString();
+ }
- @Override
- public boolean inline(Node n) {
- return true;
- }
-
-
+ private String stringRepr(Node nref, Type t) {
+ if (t instanceof PartialType) {
+ PartialType dt = (PartialType) t;
+ Node n = ((PartialType) t).n;
+ if (n != nref) {
+ n = n.getNode(n.nodeCount() - 1);
+ VarRef ref = ((PartialType) t).ref;
+ return "\" + " + varRef("ctx", n.getState().getScope(), ref)
+ + "+ \"";
+ }
+ }
+ return t.toString();
+ }
+
+ private void c...
[truncated message content] |
|
From: <ha...@us...> - 2008-07-27 23:59:49
|
Revision: 2097
http://cogkit.svn.sourceforge.net/cogkit/?rev=2097&view=rev
Author: hategan
Date: 2008-07-27 23:59:47 +0000 (Sun, 27 Jul 2008)
Log Message:
-----------
parser optimizations
Modified Paths:
--------------
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/BeginElement.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/CommaSeparator.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/EndElement.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/Identifier.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/MultiLineComment.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/SingleLineComment.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/StringValue.java
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/BeginElement.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/BeginElement.java 2008-07-27 23:59:16 UTC (rev 2096)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/BeginElement.java 2008-07-27 23:59:47 UTC (rev 2097)
@@ -40,7 +40,7 @@
}
public static class Eval implements Evaluator {
- private final String name;
+ private String name;
private final int line;
public Eval(String name, int line) {
@@ -64,5 +64,9 @@
public int getLine() {
return line;
}
+
+ public void setName(String name) {
+ this.name = name;
+ }
}
}
\ No newline at end of file
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/CommaSeparator.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/CommaSeparator.java 2008-07-27 23:59:16 UTC (rev 2096)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/CommaSeparator.java 2008-07-27 23:59:47 UTC (rev 2097)
@@ -9,6 +9,10 @@
*/
package org.globus.cog.karajan.translator.predicates;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
import org.globus.cog.karajan.parser.ParserContext;
import org.globus.cog.karajan.parser.ParsingException;
import org.globus.cog.karajan.parser.Stack;
@@ -17,18 +21,33 @@
public class CommaSeparator extends AbstractPredicate {
- public boolean parse(final ParserContext context, final Stack<Evaluator> stack) throws ParsingException {
- boolean comma = false;
- while(context.tok.hasMoreChars()) {
- final char c = context.tok.peekChar();
- if (c == ',') {
- comma = true;
- }
- else if (!Character.isWhitespace(c)) {
- return comma;
- }
- context.tok.nextChar();
- }
- return false;
- }
+ public boolean parse(final ParserContext context,
+ final Stack<Evaluator> stack) throws ParsingException {
+ boolean comma = false;
+ while (context.tok.hasMoreChars()) {
+ final char c = context.tok.peekChar();
+ if (c == ',') {
+ comma = true;
+ }
+ else if (!Character.isWhitespace(c)) {
+ return comma;
+ }
+ context.tok.nextChar();
+ }
+ return false;
+ }
+
+ private static final List<Character> chars = Arrays.asList(new Character[] {
+ ',', ' ', '\t', '\n', '\r' });
+
+ @Override
+ public Collection<Character> getFirstChars() {
+ return chars;
+ }
+
+ @Override
+ public String toString() {
+ return "COMMASEP()";
+ }
+
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/EndElement.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/EndElement.java 2008-07-27 23:59:16 UTC (rev 2096)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/EndElement.java 2008-07-27 23:59:47 UTC (rev 2097)
@@ -71,6 +71,7 @@
}
public void write(Writer wr, IndentationLevel l) throws IOException, EvaluationException {
+ checkTypedecl();
l.write(wr);
wr.write("<");
wr.write(begin.getName());
@@ -103,7 +104,18 @@
}
}
- public void setProperty(String name, String value) {
+ private void checkTypedecl() {
+ if (begin.getName().equals("k.named") && children.size() > 0) {
+ KarajanEvaluator child = (KarajanEvaluator) children.get(0);
+ if (child instanceof Eval) {
+ if (((Eval) child).begin.getName().equals("k.typedecl")) {
+ begin.setName("k.set");
+ }
+ }
+ }
+ }
+
+ public void setProperty(String name, String value) {
if (properties == null) {
properties = new HashMap<String, String>();
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/Identifier.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/Identifier.java 2008-07-27 23:59:16 UTC (rev 2096)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/Identifier.java 2008-07-27 23:59:47 UTC (rev 2097)
@@ -63,8 +63,18 @@
return isCharOk0(c);
}
}
+
+ @Override
+ public String toString() {
+ if (value != null) {
+ return "IDENTIFIER(" + value + ")";
+ }
+ else {
+ return "IDENTIFIER()";
+ }
+ }
- public boolean parse(final ParserContext context, final Stack<Evaluator> stack) throws ParsingException {
+ public boolean parse(final ParserContext context, final Stack<Evaluator> stack) throws ParsingException {
if (value != null) {
stack.push(new Eval(value));
return true;
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/MultiLineComment.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/MultiLineComment.java 2008-07-27 23:59:16 UTC (rev 2096)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/MultiLineComment.java 2008-07-27 23:59:47 UTC (rev 2097)
@@ -9,6 +9,9 @@
*/
package org.globus.cog.karajan.translator.predicates;
+import java.util.Collection;
+import java.util.Collections;
+
import org.globus.cog.karajan.parser.ParserContext;
import org.globus.cog.karajan.parser.ParsingException;
import org.globus.cog.karajan.parser.Stack;
@@ -39,4 +42,15 @@
}
return true;
}
+
+ @Override
+ public Collection<Character> getFirstChars() {
+ return Collections.singletonList('/');
+ }
+
+ @Override
+ public String toString() {
+ return "MULTILINECOMMENT()";
+ }
+
}
\ No newline at end of file
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/SingleLineComment.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/SingleLineComment.java 2008-07-27 23:59:16 UTC (rev 2096)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/SingleLineComment.java 2008-07-27 23:59:47 UTC (rev 2097)
@@ -11,6 +11,8 @@
import java.io.IOException;
import java.io.Writer;
+import java.util.Collection;
+import java.util.Collections;
import org.globus.cog.karajan.parser.ParserContext;
import org.globus.cog.karajan.parser.ParsingException;
@@ -34,8 +36,22 @@
stack.push(new Eval(sb.toString()));
return true;
}
+
+
- public static class Eval extends AbstractKarajanEvaluator {
+ @Override
+ public Collection<Character> getFirstChars() {
+ return Collections.singletonList('/');
+ }
+
+ @Override
+ public String toString() {
+ return "SINGLELINECOMMENT()";
+ }
+
+
+
+ public static class Eval extends AbstractKarajanEvaluator {
private final String value;
public Eval(String value) {
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/StringValue.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/StringValue.java 2008-07-27 23:59:16 UTC (rev 2096)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/StringValue.java 2008-07-27 23:59:47 UTC (rev 2097)
@@ -11,6 +11,8 @@
import java.io.IOException;
import java.io.Writer;
+import java.util.Collection;
+import java.util.Collections;
import org.globus.cog.karajan.parser.Lexer;
import org.globus.cog.karajan.parser.ParserContext;
@@ -82,7 +84,16 @@
return false;
}
}
+
+ public String toString() {
+ return "STRINGVALUE()";
+ }
+ @Override
+ public Collection<Character> getFirstChars() {
+ return Collections.singletonList('"');
+ }
+
private char gc(Lexer l) throws ParsingException {
if (!l.hasMoreChars()) {
throw new ParsingException("Unterminated string literal");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-27 23:59:19
|
Revision: 2096
http://cogkit.svn.sourceforge.net/cogkit/?rev=2096&view=rev
Author: hategan
Date: 2008-07-27 23:59:16 +0000 (Sun, 27 Jul 2008)
Log Message:
-----------
parser optimizations
Modified Paths:
--------------
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/AbstractGrammarElement.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/And.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/GrammarElement.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Node.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Or.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Rule.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Rules.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Digits.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Literal.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Newline.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Underscore.java
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/AbstractGrammarElement.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/AbstractGrammarElement.java 2008-07-27 23:58:18 UTC (rev 2095)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/AbstractGrammarElement.java 2008-07-27 23:59:16 UTC (rev 2096)
@@ -9,6 +9,7 @@
*/
package org.globus.cog.karajan.parser;
+import java.util.Collection;
import java.util.Enumeration;
public abstract class AbstractGrammarElement implements GrammarElement {
@@ -59,4 +60,11 @@
public String errorForm() {
return toString();
}
+
+ @Override
+ public Collection<Character> getFirstChars() {
+ return null;
+ }
+
+
}
\ No newline at end of file
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/And.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/And.java 2008-07-27 23:58:18 UTC (rev 2095)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/And.java 2008-07-27 23:59:16 UTC (rev 2096)
@@ -10,6 +10,9 @@
package org.globus.cog.karajan.parser;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Set;
import org.apache.log4j.Logger;
@@ -120,5 +123,10 @@
return null;
}
+ @Override
+ public Collection<Character> getFirstChars() {
+ return elements[0].getFirstChars();
+ }
+
}
\ No newline at end of file
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/GrammarElement.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/GrammarElement.java 2008-07-27 23:58:18 UTC (rev 2095)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/GrammarElement.java 2008-07-27 23:59:16 UTC (rev 2096)
@@ -9,6 +9,7 @@
*/
package org.globus.cog.karajan.parser;
+import java.util.Collection;
import java.util.Set;
import org.globus.cog.karajan.parser.predicates.Evaluator;
@@ -24,4 +25,6 @@
Set<Character> getDP();
String errorForm();
+
+ Collection<Character> getFirstChars();
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Node.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Node.java 2008-07-27 23:58:18 UTC (rev 2095)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Node.java 2008-07-27 23:59:16 UTC (rev 2096)
@@ -51,6 +51,22 @@
nodes = Collections.emptyList();
properties = Collections.emptyMap();
}
+
+ public Node deepCopy() {
+ Node copy = new Node();
+ copy.properties = new HashMap<String, Object>();
+ copy.properties.putAll(properties);
+ copy.nodeType = nodeType;
+ copy.parent = parent;
+ copy.state = state;
+ copy.nodes = new ArrayList<Node>();
+ for (Node c : nodes) {
+ Node cc = c.deepCopy();
+ copy.nodes.add(cc);
+ cc.parent = copy;
+ }
+ return copy;
+ }
public String get_locator() {
return locator;
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Or.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Or.java 2008-07-27 23:58:18 UTC (rev 2095)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Or.java 2008-07-27 23:59:16 UTC (rev 2096)
@@ -10,87 +10,174 @@
package org.globus.cog.karajan.parser;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
+import org.globus.cog.karajan.parser.predicates.Evaluator;
+
public final class Or extends AbstractGrammarElement {
- private GrammarElement[] ands;
+ private GrammarElement[] ands;
+ private Map<Character, List<GrammarElement>> filtered;
+ private List<GrammarElement> open;
+ private boolean strict;
- public Or() {
- }
+ public Or() {
+ }
- public void read(PeekableEnumeration st, PredicateMapping mapping) {
- List a = new ArrayList();
- while (true) {
- And and = new And();
- and.read(st, mapping);
- a.add(and);
- if (st.peek().equals(";")) {
- ands = (GrammarElement[]) a.toArray(GEATYPE);
- break;
- }
- expect(st, "|");
- }
- expect(st, ";");
- }
+ public void read(PeekableEnumeration st, PredicateMapping mapping) {
+ List<And> a = new ArrayList<And>();
+ while (true) {
+ And and = new And();
+ and.read(st, mapping);
+ a.add(and);
+ if (st.peek().equals(";")) {
+ ands = a.toArray(GEATYPE);
+ break;
+ }
+ expect(st, "|");
+ }
+ expect(st, ";");
+ }
- public boolean parse(ParserContext context, Stack stack) throws ParsingException {
- for (int i = 0; i < ands.length; i++) {
- int mark = stack.mark();
- if (ands[i].parse(context, stack)) {
- return true;
- }
- stack.forget(mark);
- }
- return false;
- }
+ private void populateFirstChars() {
+ //System.out.println(this);
+ if (filtered != null) {
+ return;
+ }
+ filtered = new HashMap<Character, List<GrammarElement>>();
+ strict = true;
+ List<Collection<Character>> all = new ArrayList<Collection<Character>>();
+ open = new ArrayList<GrammarElement>();
+ for (GrammarElement ge : ands) {
+ Collection<Character> l = ge.getFirstChars();
+ all.add(l);
+ if (l != null) {
+ for (Character c : l) {
+ if (!filtered.containsKey(c)) {
+ filtered.put(c, new ArrayList<GrammarElement>());
+ }
+ }
+ }
+ else {
+ strict = false;
+ }
+ }
+ for (int i = 0; i < all.size(); i++) {
+ Collection<Character> l = all.get(i);
+ if (l == null) {
+ for (List<GrammarElement> lg : filtered.values()) {
+ lg.add(ands[i]);
+ }
+ open.add(ands[i]);
+ }
+ else {
+ for (Character c : l) {
+ filtered.get(c).add(ands[i]);
+ }
+ }
+ }
+ if (open.isEmpty()) {
+ open = null;
+ }
+ }
- public String toString() {
- StringBuffer sb = new StringBuffer();
- boolean first = true;
- for (int i = 0; i < ands.length; i++) {
- if (first) {
- first = false;
- }
- else {
- sb.append(" |\n");
- }
- sb.append(ands[i]);
- }
- sb.append(" ;\n");
- return sb.toString();
- }
-
- public String errorForm() {
- StringBuffer sb = new StringBuffer();
- boolean first = true;
- for(int i = 0; i < ands.length; i++) {
- if (first) {
- first = false;
- }
- else {
- sb.append(" or ");
- }
- sb.append(ands[i].errorForm());
- }
- return sb.toString();
- }
+ @Override
+ public Collection<Character> getFirstChars() {
+ populateFirstChars();
+ if (open != null) {
+ return null;
+ }
+ else {
+ return filtered.keySet();
+ }
+ }
- public GrammarElement _optimize(Rules rules) {
- if (ands.length == 1) {
- return ands[0].optimize(rules);
- }
- for (int i = 0; i < ands.length; i++) {
- ands[i] = ands[i].optimize(rules);
- }
- return this;
- }
+ public boolean parse(ParserContext context, Stack<Evaluator> stack)
+ throws ParsingException {
- public Set<Character> getDP() {
- return null;
- }
+ List<GrammarElement> l = null;
+ char c = 0;
+ if (context.tok.hasMoreChars()) {
+ c = context.tok.peekChar();
+ l = filtered.get(c);
+ if (l == null) {
+ l = open;
+ }
+ }
+ if (l == null) {
+ if (!strict) {
+ for (GrammarElement and : ands) {
+ int mark = stack.mark();
+ if (and.parse(context, stack)) {
+ return true;
+ }
+ stack.forget(mark);
+ }
+ }
+ }
+ else {
+ for (GrammarElement ge : l) {
+ int mark = stack.mark();
+ if (ge.parse(context, stack)) {
+ return true;
+ }
+ stack.forget(mark);
+ }
+ }
+ return false;
+ }
-
-
-
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ boolean first = true;
+ for (int i = 0; i < ands.length; i++) {
+ if (first) {
+ first = false;
+ }
+ else {
+ sb.append(" |\n");
+ }
+ sb.append(ands[i]);
+ }
+ sb.append(" ;\n");
+ return sb.toString();
+ }
+
+ public String errorForm() {
+ StringBuffer sb = new StringBuffer();
+ boolean first = true;
+ for (int i = 0; i < ands.length; i++) {
+ if (first) {
+ first = false;
+ }
+ else {
+ sb.append(" or ");
+ }
+ sb.append(ands[i].errorForm());
+ }
+ return sb.toString();
+ }
+
+ public GrammarElement _optimize(Rules rules) {
+ GrammarElement r;
+ if (ands.length == 1) {
+ r = ands[0].optimize(rules);
+ }
+ else {
+ for (int i = 0; i < ands.length; i++) {
+ ands[i] = ands[i].optimize(rules);
+ }
+ r = this;
+ populateFirstChars();
+ }
+ return r;
+ }
+
+ public Set<Character> getDP() {
+ return null;
+ }
+
}
\ No newline at end of file
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Rule.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Rule.java 2008-07-27 23:58:18 UTC (rev 2095)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Rule.java 2008-07-27 23:59:16 UTC (rev 2096)
@@ -9,6 +9,7 @@
*/
package org.globus.cog.karajan.parser;
+import java.util.Collection;
import java.util.Set;
public final class Rule extends AbstractGrammarElement {
@@ -56,10 +57,18 @@
public String errorForm() {
return or.errorForm();
}
+
+
- public GrammarElement _optimize(Rules rules) {
+ @Override
+ public Collection<Character> getFirstChars() {
+ return or.getFirstChars();
+ }
+
+ public GrammarElement _optimize(Rules rules) {
or = or.optimize(rules);
- return this;
+ //return this;
+ return or;
}
public Set<Character> getDP() {
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Rules.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Rules.java 2008-07-27 23:58:18 UTC (rev 2095)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Rules.java 2008-07-27 23:59:16 UTC (rev 2096)
@@ -9,6 +9,7 @@
*/
package org.globus.cog.karajan.parser;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -41,7 +42,12 @@
return rules.get(name);
}
- public GrammarElement _optimize(Rules rules) {
+ @Override
+ public Collection<Character> getFirstChars() {
+ return null;
+ }
+
+ public GrammarElement _optimize(Rules rules) {
Iterator<Map.Entry<String, GrammarElement>> i = this.rules.entrySet().iterator();
while (i.hasNext()) {
Map.Entry<String, GrammarElement> entry = i.next();
@@ -56,7 +62,7 @@
public String toString() {
StringBuffer sb = new StringBuffer();
- Iterator i = rules.values().iterator();
+ Iterator<?> i = rules.values().iterator();
while (i.hasNext()) {
sb.append(i.next());
sb.append('\n');
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Digits.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Digits.java 2008-07-27 23:58:18 UTC (rev 2095)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Digits.java 2008-07-27 23:59:16 UTC (rev 2096)
@@ -9,29 +9,40 @@
*/
package org.globus.cog.karajan.parser.predicates;
+import java.util.Arrays;
+import java.util.Collection;
+
import org.globus.cog.karajan.parser.ParserContext;
import org.globus.cog.karajan.parser.Stack;
-
public class Digits extends AbstractPredicate {
- protected void setParams(String[] params) {
- assertEquals(params.length, 0, getClass());
- }
+ protected void setParams(String[] params) {
+ assertEquals(params.length, 0, getClass());
+ }
- public boolean parse(final ParserContext context, final Stack stack) {
- if (context.tok.hasMoreTokens()) {
- if (!context.tok.isDigits()) {
- return false;
- }
- final String token = context.tok.peekToken();
- stack.push(context.tok.nextToken());
- return true;
- }
- return false;
- }
-
- public String toString() {
- return "DIGITS()";
- }
+ public boolean parse(final ParserContext context, final Stack stack) {
+ if (context.tok.hasMoreTokens()) {
+ if (!context.tok.isDigits()) {
+ return false;
+ }
+ final String token = context.tok.peekToken();
+ stack.push(context.tok.nextToken());
+ return true;
+ }
+ return false;
+ }
+
+ private static final Collection<Character> chars = Arrays
+ .asList(new Character[] { '0', '1', '2', '3', '4', '5', '6', '7', '8',
+ '9' });
+
+ @Override
+ public Collection<Character> getFirstChars() {
+ return chars;
+ }
+
+ public String toString() {
+ return "DIGITS()";
+ }
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Literal.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Literal.java 2008-07-27 23:58:18 UTC (rev 2095)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Literal.java 2008-07-27 23:59:16 UTC (rev 2096)
@@ -9,6 +9,9 @@
*/
package org.globus.cog.karajan.parser.predicates;
+import java.util.Collection;
+import java.util.Collections;
+
import org.globus.cog.karajan.parser.Lexer;
import org.globus.cog.karajan.parser.ParserContext;
import org.globus.cog.karajan.parser.Stack;
@@ -48,8 +51,15 @@
}
return true;
}
+
+
- public String toString() {
+ @Override
+ public Collection<Character> getFirstChars() {
+ return Collections.singletonList(value.charAt(0));
+ }
+
+ public String toString() {
return "LITERAL(" + value + ")";
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Newline.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Newline.java 2008-07-27 23:58:18 UTC (rev 2095)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Newline.java 2008-07-27 23:59:16 UTC (rev 2096)
@@ -9,6 +9,9 @@
*/
package org.globus.cog.karajan.parser.predicates;
+import java.util.Collection;
+import java.util.Collections;
+
import org.globus.cog.karajan.parser.ParserContext;
import org.globus.cog.karajan.parser.Stack;
@@ -30,7 +33,14 @@
return false;
}
- public String toString() {
+
+
+ @Override
+ public Collection<Character> getFirstChars() {
+ return Collections.singletonList('\n');
+ }
+
+ public String toString() {
return "NEWLINE()";
}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Underscore.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Underscore.java 2008-07-27 23:58:18 UTC (rev 2095)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/predicates/Underscore.java 2008-07-27 23:59:16 UTC (rev 2096)
@@ -9,6 +9,9 @@
*/
package org.globus.cog.karajan.parser.predicates;
+import java.util.Collection;
+import java.util.Collections;
+
import org.globus.cog.karajan.parser.ParserContext;
import org.globus.cog.karajan.parser.Stack;
@@ -37,7 +40,12 @@
return false;
}
- public String toString() {
+ @Override
+ public Collection<Character> getFirstChars() {
+ return Collections.singletonList('_');
+ }
+
+ public String toString() {
return "UNDERSCORE()";
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-27 23:58:22
|
Revision: 2095
http://cogkit.svn.sourceforge.net/cogkit/?rev=2095&view=rev
Author: hategan
Date: 2008-07-27 23:58:18 +0000 (Sun, 27 Jul 2008)
Log Message:
-----------
cache converters
Modified Paths:
--------------
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/AbstractKarajanConverter.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/XMLConverter.java
Added Paths:
-----------
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/ConverterCache.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/SimpleXStream.java
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/AbstractKarajanConverter.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/AbstractKarajanConverter.java 2008-07-27 19:56:07 UTC (rev 2094)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/AbstractKarajanConverter.java 2008-07-27 23:58:18 UTC (rev 2095)
@@ -18,7 +18,7 @@
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
public abstract class AbstractKarajanConverter implements Converter {
- private final KarajanSerializationContext kcontext;
+ private KarajanSerializationContext kcontext;
public AbstractKarajanConverter(KarajanSerializationContext kcontext) {
this.kcontext = kcontext;
@@ -27,6 +27,10 @@
public KarajanSerializationContext getKContext() {
return kcontext;
}
+
+ public void setKContext(KarajanSerializationContext kcontext) {
+ this.kcontext = kcontext;
+ }
public void marshalObject(HierarchicalStreamWriter writer, MarshallingContext context,
String tag, Object value) {
Added: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/ConverterCache.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/ConverterCache.java (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/ConverterCache.java 2008-07-27 23:58:18 UTC (rev 2095)
@@ -0,0 +1,43 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Jul 10, 2008
+ */
+package org.globus.cog.karajan.util.serialization;
+
+import java.util.LinkedList;
+
+import org.globus.cog.karajan.parser.Node;
+
+import com.thoughtworks.xstream.XStream;
+
+public class ConverterCache {
+ private static LinkedList<XMLConverter> cache = new LinkedList<XMLConverter>();
+
+ public synchronized static XMLConverter getConverter() {
+ if (!cache.isEmpty()) {
+ XMLConverter con = cache.removeFirst();
+ con.setKContext(new KarajanSerializationContext());
+ return con;
+ }
+ else {
+ XMLConverter con = new XMLConverter();
+ con.alias("main", Node.class);
+ con.xstream.setMode(XStream.ID_REFERENCES);
+ con.xstream.getClassMapper().setOverrideRootType(Node.class);
+ return con;
+ }
+ }
+
+ public synchronized static void release(XMLConverter con) {
+ if (cache.isEmpty()) {
+ con.setKContext(null);
+ cache.add(con);
+ }
+ }
+
+}
Added: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/SimpleXStream.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/SimpleXStream.java (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/SimpleXStream.java 2008-07-27 23:58:18 UTC (rev 2095)
@@ -0,0 +1,26 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Jul 12, 2008
+ */
+package org.globus.cog.karajan.util.serialization;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.ext.MXppDriver;
+
+public class SimpleXStream extends XStream {
+
+ public SimpleXStream(MXppDriver driver) {
+ super(driver);
+ }
+
+ @Override
+ protected void setupConverters() {
+
+ }
+
+}
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/XMLConverter.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/XMLConverter.java 2008-07-27 19:56:07 UTC (rev 2094)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/util/serialization/XMLConverter.java 2008-07-27 23:58:18 UTC (rev 2095)
@@ -21,17 +21,14 @@
import com.thoughtworks.xstream.ext.MXppDriver;
public class XMLConverter {
- private XStream xstream;
- private KarajanSerializationContext kcontext;
+ protected XStream xstream;
+ protected KarajanSerializationContext kcontext;
+ protected NodeConverter nodeConverter;
public XMLConverter() {
this(new KarajanSerializationContext());
}
- public XMLConverter(ElementTree tree) {
- this(new KarajanSerializationContext(tree));
- }
-
public XMLConverter(KarajanSerializationContext kcontext) {
this(kcontext, false);
}
@@ -39,19 +36,17 @@
public XMLConverter(KarajanSerializationContext kcontext, boolean restricted) {
this.kcontext = kcontext;
if (restricted) {
- xstream = new XStream(new MXppDriver()) {
+ xstream = new SimpleXStream(new MXppDriver()) {
protected final ClassMapper buildMapper(String classAttributeIdentifier) {
return new RestrictedClassMapper(super.buildMapper(classAttributeIdentifier));
}
};
}
else {
- xstream = new XStream(new MXppDriver());
+ xstream = new SimpleXStream(new MXppDriver());
}
registerConverter(new NullConverter());
- registerConverter(new NodeConverter(kcontext));
- registerConverter(new SimpleDateFormatConverter(kcontext));
- registerConverter(new DecimalFormatConverter(kcontext));
+ setNodeConverter(new NodeConverter(kcontext));
xstream.setMode(XStream.NO_REFERENCES);
kcontext.setClassMapper(xstream.getClassMapper());
kcontext.setConverterLookup(xstream.getConverterLookup());
@@ -82,15 +77,11 @@
}
public static ElementTree readSource(Reader reader, String name, boolean lineNumbers) {
- XMLConverter loader = new XMLConverter();
+ XMLConverter loader = ConverterCache.getConverter();
loader.getKContext().setKmode(lineNumbers);
- loader.registerConverter(new NodeConverter(loader.kcontext));
- loader.alias("project", Node.class);
- loader.alias("karajan", Node.class);
- loader.xstream.setMode(XStream.ID_REFERENCES);
- loader.xstream.getClassMapper().setOverrideRootType(Node.class);
Object o = loader.xstream.fromXML(reader);
ElementTree tree = loader.getKContext().getTree();
+ ConverterCache.release(loader);
tree.setRoot((Node) o);
tree.setName(name);
return tree;
@@ -103,4 +94,18 @@
public KarajanSerializationContext getKContext() {
return kcontext;
}
+
+ protected void setKContext(KarajanSerializationContext kcontext) {
+ this.kcontext = kcontext;
+ if (this.nodeConverter != null) {
+ this.nodeConverter.setKContext(kcontext);
+ }
+ }
+
+ public void setNodeConverter(NodeConverter nodeConverter) {
+ if (this.nodeConverter == null) {
+ this.nodeConverter = nodeConverter;
+ registerConverter(nodeConverter);
+ }
+ }
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <b_...@us...> - 2008-07-27 19:56:10
|
Revision: 2094
http://cogkit.svn.sourceforge.net/cogkit/?rev=2094&view=rev
Author: b_z_c
Date: 2008-07-27 19:56:07 +0000 (Sun, 27 Jul 2008)
Log Message:
-----------
coastersPerNode parameter to cause multiple workers to start per coaster worker job submission
Modified Paths:
--------------
trunk/current/src/cog/modules/provider-coaster/resources/worker.pl
trunk/current/src/cog/modules/provider-coaster/src/org/globus/cog/abstraction/coaster/service/job/manager/WorkerManager.java
Modified: trunk/current/src/cog/modules/provider-coaster/resources/worker.pl
===================================================================
--- trunk/current/src/cog/modules/provider-coaster/resources/worker.pl 2008-07-22 22:33:51 UTC (rev 2093)
+++ trunk/current/src/cog/modules/provider-coaster/resources/worker.pl 2008-07-27 19:56:07 UTC (rev 2094)
@@ -25,7 +25,7 @@
my %REQUESTS = ();
my %REPLIES = ();
-my $LOG = "$ENV{HOME}/worker$ARGV[0].log";
+my $LOG = "$ENV{HOME}/worker$ARGV[1].log";
my %HANDLERS = (
@@ -36,8 +36,8 @@
my @CMDQ = ();
-my $ID=$ARGV[0];
-my $URI=$ARGV[1];
+my $ID;
+my $URI=$ARGV[0];
my $SCHEME;
my $HOSTNAME;
my $PORT;
@@ -405,12 +405,32 @@
die "Could not execute $executable: $!";
}
-my $MSG="0";
+my @wp;
-my $myhost=`hostname -i`;
-$myhost =~ s/\s+$//;
-init();
+my $i;
-queueCmd(\®isterCB, "REGISTER", $ID, "wid://$ID");
+for($i=1; $i<=$#ARGV ; $i++) {
+ my $waitpid;
+ if(($waitpid=fork())==0) {
+ $ID =$ARGV[$i];
+ my $MSG="0";
-mainloop();
+ my $myhost=`hostname -i`;
+ $myhost =~ s/\s+$//;
+ init();
+
+ print LOG time(), " Initialized coaster worker $i\n";
+ queueCmd(\®isterCB, "REGISTER", $ID, "wid://$ID");
+
+ mainloop();
+ exit(0);
+ } else {
+ $wp[$i]=$waitpid;
+ }
+}
+
+for($i=1; $i<=$#ARGV ; $i++) {
+ waitpid($wp[$i],0);
+}
+
+
Modified: trunk/current/src/cog/modules/provider-coaster/src/org/globus/cog/abstraction/coaster/service/job/manager/WorkerManager.java
===================================================================
--- trunk/current/src/cog/modules/provider-coaster/src/org/globus/cog/abstraction/coaster/service/job/manager/WorkerManager.java 2008-07-22 22:33:51 UTC (rev 2093)
+++ trunk/current/src/cog/modules/provider-coaster/src/org/globus/cog/abstraction/coaster/service/job/manager/WorkerManager.java 2008-07-27 19:56:07 UTC (rev 2094)
@@ -146,38 +146,60 @@
private void startWorker(int maxWallTime, Task prototype)
throws InvalidServiceContactException {
- int id = sr.nextInt();
- if (logger.isInfoEnabled()) {
- logger.info("Starting worker with id=" + id + " and maxwalltime=" + maxWallTime + "s");
+ String numWorkersString = (String)((JobSpecification) prototype.getSpecification()).getAttribute("coastersPerNode");
+ int numWorkers;
+ if(numWorkersString==null) {
+ numWorkers = 1;
+ } else {
+ numWorkers = Integer.parseInt(numWorkersString);
}
- String sid = String.valueOf(id);
+
+ logger.info("Starting new worker set with "+numWorkers+" workers");
+
Task t = new TaskImpl();
t.setType(Task.JOB_SUBMISSION);
- t.setSpecification(buildSpecification(sid, prototype));
+ t.setSpecification(buildSpecification(prototype));
copyAttributes(t, prototype, maxWallTime);
t.setRequiredService(1);
t.setService(0, buildService(prototype));
+
+ Map newlyRequested = new HashMap();
+ for(int n = 0; n<numWorkers; n++) {
+
+ int id = sr.nextInt();
+ if (logger.isInfoEnabled()) {
+ logger.info("Starting worker with id=" + id + " and maxwalltime=" + maxWallTime + "s");
+ }
+ String sid = String.valueOf(id);
+
+ ((JobSpecification)t.getSpecification()).addArgument(sid);
+
+ try {
+ Worker wr = new Worker(this, sid, maxWallTime, t, prototype);
+ newlyRequested.put(sid, wr);
+ }
+ catch (Exception e) {
+ prototype.setStatus(new StatusImpl(Status.FAILED, e.getMessage(),
+ e));
+ }
+ }
try {
- Worker wr = new Worker(this, sid, maxWallTime, t, prototype);
handler.submit(t);
- synchronized (requested) {
- requested.put(sid, wr);
- }
+ } catch(Exception e) {
+ prototype.setStatus(new StatusImpl(Status.FAILED, e.getMessage(), e));
}
- catch (Exception e) {
- prototype.setStatus(new StatusImpl(Status.FAILED, e.getMessage(),
- e));
+ synchronized(requested) {
+ requested.putAll(newlyRequested);
}
}
- private JobSpecification buildSpecification(String id,
- Task prototype) {
+ private JobSpecification buildSpecification(Task prototype) {
JobSpecification ps = (JobSpecification) prototype.getSpecification();
JobSpecification js = new JobSpecificationImpl();
js.setExecutable("/usr/bin/perl");
js.addArgument(script.getAbsolutePath());
- js.addArgument(id);
js.addArgument(callbackURI.toString());
+ // js.addArgument(id);
return js;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-22 22:33:54
|
Revision: 2093
http://cogkit.svn.sourceforge.net/cogkit/?rev=2093&view=rev
Author: hategan
Date: 2008-07-22 22:33:51 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
fixed super constructor calls overriden method that needs my constructor to initialize something before working NPE
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/local/LocalTreePanel.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/common/RemoteTreeFrame.java
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/local/LocalTreePanel.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/local/LocalTreePanel.java 2008-07-22 22:32:38 UTC (rev 2092)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/local/LocalTreePanel.java 2008-07-22 22:33:51 UTC (rev 2093)
@@ -75,8 +75,7 @@
public String LclFile_Sep = new String(System.getProperty("file.separator"));
String userHome = System.getProperty("user.home") + LclFile_Sep;
boolean home = true;
- private PropertyChangeSupport pceListeners =
- new PropertyChangeSupport(this);;
+ private PropertyChangeSupport pceListeners;
@@ -129,7 +128,6 @@
}
public void init() {
-
seekNode = null;
lastExp = null;
toolkit = Toolkit.getDefaultToolkit();
@@ -294,6 +292,9 @@
}
public void addPropertyChangeListener(PropertyChangeListener l) {
+ if (pceListeners == null) {
+ pceListeners = new PropertyChangeSupport(this);
+ }
pceListeners.addPropertyChangeListener(l);
}
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/common/RemoteTreeFrame.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/common/RemoteTreeFrame.java 2008-07-22 22:32:38 UTC (rev 2092)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/common/RemoteTreeFrame.java 2008-07-22 22:33:51 UTC (rev 2093)
@@ -197,6 +197,9 @@
}
public void addPropertyChangeListener(PropertyChangeListener l) {
+ if (pceListeners == null) {
+ pceListeners = new PropertyChangeSupport(this);
+ }
pceListeners.addPropertyChangeListener(l);
}
@@ -949,7 +952,7 @@
private String user;
private String file;
private String pwd;
- private PropertyChangeSupport pceListeners = new PropertyChangeSupport(this);
+ private PropertyChangeSupport pceListeners;
protected String rootRemote = null;
private String userHomeDir = null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-22 22:32:40
|
Revision: 2092
http://cogkit.svn.sourceforge.net/cogkit/?rev=2092&view=rev
Author: hategan
Date: 2008-07-22 22:32:38 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
updated project files
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/launchers.xml
trunk/current/src/cog/modules/transfer-gui/project.properties
Modified: trunk/current/src/cog/modules/transfer-gui/launchers.xml
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/launchers.xml 2008-07-22 22:31:46 UTC (rev 2091)
+++ trunk/current/src/cog/modules/transfer-gui/launchers.xml 2008-07-22 22:32:38 UTC (rev 2092)
@@ -7,8 +7,8 @@
<project name="Launchers" default="create" basedir=".">
<target name="create">
<ant antfile="${main.buildfile}" target="launcher">
- <property name="launcher-name" value="sample-launcher"/>
- <property name="class-name" value="org.globus.cog.example.Class"/>
+ <property name="launcher-name" value="cog-transfer-gui"/>
+ <property name="class-name" value="org.globus.ogce.beans.filetransfer.gui.MyGridSpaceFTP"/>
</ant>
</target>
<target name="webstart">
Modified: trunk/current/src/cog/modules/transfer-gui/project.properties
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/project.properties 2008-07-22 22:31:46 UTC (rev 2091)
+++ trunk/current/src/cog/modules/transfer-gui/project.properties 2008-07-22 22:32:38 UTC (rev 2092)
@@ -8,5 +8,6 @@
long.name = File Transfer Graphical Interface
version = 0.1
project = Java CoG Kit
-lib.deps = -
+debug = true
+lib.deps = GlobusPortal*.jar, bcprov-jdk*.jar, cog-ogce*.jar, gridant*.jar, ant-contrib*.jar, appframework*.jar, axis*.jar, beansbinding*.jar, commons-cli*.jar, concurrent*.jar, globus*.jar, swing-layout*.jar, swing-worker*.jar
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-22 22:31:49
|
Revision: 2091
http://cogkit.svn.sourceforge.net/cogkit/?rev=2091&view=rev
Author: hategan
Date: 2008-07-22 22:31:46 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
updated jars
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/lib/cog-ogce.jar
Removed Paths:
-------------
trunk/current/src/cog/modules/transfer-gui/lib/addressing-1.0.jar
trunk/current/src/cog/modules/transfer-gui/lib/ant.jar
trunk/current/src/cog/modules/transfer-gui/lib/axis-url.jar
trunk/current/src/cog/modules/transfer-gui/lib/cog-axis.jar
trunk/current/src/cog/modules/transfer-gui/lib/cog-jglobus.jar
trunk/current/src/cog/modules/transfer-gui/lib/commonj.jar
trunk/current/src/cog/modules/transfer-gui/lib/commons-beanutils.jar
trunk/current/src/cog/modules/transfer-gui/lib/commons-collections-3.0.jar
trunk/current/src/cog/modules/transfer-gui/lib/commons-digester.jar
trunk/current/src/cog/modules/transfer-gui/lib/commons-discovery.jar
trunk/current/src/cog/modules/transfer-gui/lib/commons-logging.jar
trunk/current/src/cog/modules/transfer-gui/lib/cryptix-asn1.jar
trunk/current/src/cog/modules/transfer-gui/lib/cryptix.jar
trunk/current/src/cog/modules/transfer-gui/lib/cryptix32.jar
trunk/current/src/cog/modules/transfer-gui/lib/jaxrpc.jar
trunk/current/src/cog/modules/transfer-gui/lib/jgss.jar
trunk/current/src/cog/modules/transfer-gui/lib/junit.jar
trunk/current/src/cog/modules/transfer-gui/lib/log4j-1.2.8.jar
trunk/current/src/cog/modules/transfer-gui/lib/naming-common.jar
trunk/current/src/cog/modules/transfer-gui/lib/naming-factory.jar
trunk/current/src/cog/modules/transfer-gui/lib/naming-java.jar
trunk/current/src/cog/modules/transfer-gui/lib/naming-resources.jar
trunk/current/src/cog/modules/transfer-gui/lib/puretls.jar
trunk/current/src/cog/modules/transfer-gui/lib/saaj.jar
trunk/current/src/cog/modules/transfer-gui/lib/wsdl4j.jar
trunk/current/src/cog/modules/transfer-gui/lib/wss4j.jar
trunk/current/src/cog/modules/transfer-gui/lib/xmlsec.jar
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-22 21:41:51
|
Revision: 2090
http://cogkit.svn.sourceforge.net/cogkit/?rev=2090&view=rev
Author: hategan
Date: 2008-07-22 21:41:49 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
override the default 1.4 java version requirement
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/build.xml
Modified: trunk/current/src/cog/modules/transfer-gui/build.xml
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/build.xml 2008-07-22 21:40:35 UTC (rev 2089)
+++ trunk/current/src/cog/modules/transfer-gui/build.xml 2008-07-22 21:41:49 UTC (rev 2090)
@@ -11,6 +11,7 @@
<property name="main.buildfile" value="${cog.dir}/mbuild.xml"/>
<property name="dist.dir" value="${cog.dir}/modules/${module.name}/dist/${module.name}-${version}"/>
<property name="build.dir" value="${cog.dir}/modules/${module.name}/build"/>
+ <property name="force.java.version" value="1.5"/>
<!-- ================================================ -->
<!-- Help -->
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-22 21:40:37
|
Revision: 2089
http://cogkit.svn.sourceforge.net/cogkit/?rev=2089&view=rev
Author: hategan
Date: 2008-07-22 21:40:35 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
allow overriding java version requirements in modules
Modified Paths:
--------------
trunk/current/src/cog/mbuild.xml
Modified: trunk/current/src/cog/mbuild.xml
===================================================================
--- trunk/current/src/cog/mbuild.xml 2008-07-22 19:24:50 UTC (rev 2088)
+++ trunk/current/src/cog/mbuild.xml 2008-07-22 21:40:35 UTC (rev 2089)
@@ -5,6 +5,7 @@
<property name="jar.name" value="cog-${module.name}-${version}.jar"/>
<property name="jar.file" value="${build.dir}/${jar.name}"/>
+ <property name="force.java.version" value="1.4"/>
<property name="javadoc.files" value="*"/>
<property name="javadoc.index.dir" value="${dist.dir}/javadoc"/>
@@ -223,8 +224,8 @@
debug="${debug}"
optimize="${optimize}"
deprecation="${deprecation}"
- source="1.4"
- target="1.4"/>
+ source="${force.java.version}"
+ target="${force.java.version}"/>
<copy todir="${build.dir}" >
<fileset dir="src" includes="**/*.properties" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-22 19:24:53
|
Revision: 2088
http://cogkit.svn.sourceforge.net/cogkit/?rev=2088&view=rev
Author: hategan
Date: 2008-07-22 19:24:50 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
removed what seems to be a build
Removed Paths:
-------------
trunk/current/src/cog/modules/transfer-gui/package/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-22 19:15:43
|
Revision: 2087
http://cogkit.svn.sourceforge.net/cogkit/?rev=2087&view=rev
Author: hategan
Date: 2008-07-22 19:15:39 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
attempt II at fixing scheduler issues
Modified Paths:
--------------
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/LateBindingScheduler.java
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/OverloadedHostMonitor.java
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/LateBindingScheduler.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/LateBindingScheduler.java 2008-07-22 05:46:29 UTC (rev 2086)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/LateBindingScheduler.java 2008-07-22 19:15:39 UTC (rev 2087)
@@ -78,7 +78,7 @@
private InstanceSubmitQueue submitQueue;
- private volatile boolean tasksFinished;
+ private boolean tasksFinished;
public LateBindingScheduler() {
virtualContacts = new HashMap();
@@ -678,7 +678,7 @@
return (Contact[]) taskContacts.get(t);
}
- protected void raiseTasksFinished() {
+ protected synchronized void raiseTasksFinished() {
this.tasksFinished = true;
}
}
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/OverloadedHostMonitor.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/OverloadedHostMonitor.java 2008-07-22 05:46:29 UTC (rev 2086)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/OverloadedHostMonitor.java 2008-07-22 19:15:39 UTC (rev 2087)
@@ -35,7 +35,9 @@
public void add(WeightedHost wh, int dir) {
synchronized (hosts) {
- hosts.put(wh, DIRS[dir + 1]);
+ if (!hosts.containsKey(wh)) {
+ hosts.put(wh, DIRS[dir + 1]);
+ }
}
}
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java 2008-07-22 05:46:29 UTC (rev 2086)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java 2008-07-22 19:15:39 UTC (rev 2087)
@@ -139,7 +139,7 @@
this.delayedDelta = delayedDelta;
}
- public int isOverloaded() {
+ public synchronized int isOverloaded() {
double ml = maxLoad();
if (tscore >= 1) {
// the site is mostly good. permit 1 or more jobs
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java 2008-07-22 05:46:29 UTC (rev 2086)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java 2008-07-22 19:15:39 UTC (rev 2087)
@@ -23,7 +23,7 @@
private double scoreHighCap;
private volatile int overloadedCount;
private OverloadedHostMonitor monitor;
-
+
public WeightedHostSet(double scoreHighCap) {
this(scoreHighCap, null);
}
@@ -44,53 +44,60 @@
scores.add(wh);
weightedHosts.put(wh.getHost(), wh);
sum += wh.getTScore();
- overloadedCount += checkOverloaded(wh, 1);
+ checkOverloaded(wh, 1);
}
public void changeScore(WeightedHost wh, double newScore) {
scores.remove(wh);
sum -= wh.getTScore();
- overloadedCount += checkOverloaded(wh, -1);
+ checkOverloaded(wh, -1);
wh.setScore(newScore);
weightedHosts.put(wh.getHost(), wh);
scores.add(wh);
sum += wh.getTScore();
- overloadedCount += checkOverloaded(wh, 1);
+ checkOverloaded(wh, 1);
}
public void changeLoad(WeightedHost wh, int dl) {
- overloadedCount += checkOverloaded(wh, -1);
+ checkOverloaded(wh, -1);
wh.changeLoad(dl);
- overloadedCount += checkOverloaded(wh, 1);
+ checkOverloaded(wh, 1);
}
public double remove(WeightedHost wh) {
scores.remove(wh);
weightedHosts.remove(wh.getHost());
sum -= wh.getScore();
- overloadedCount += checkOverloaded(wh, -1);
+ checkOverloaded(wh, -1);
return wh.getScore();
}
- private int checkOverloaded(WeightedHost wh, final int dir) {
+ private void checkOverloaded(WeightedHost wh, final int dir) {
int v = wh.isOverloaded();
- if (v >= 0) {
- if (dir > 0) {
- return v;
- }
- else {
- return -v;
- }
+ int countDelta;
+ if (v == 0) {
+ // not overloaded
+ countDelta = 0;
}
+ else if (v > 0) {
+ // overloaded either too many tasks (v == 1) or delay already expired (v > 0)
+ // there's a bit of ambiguity there, but it does not make a difference
+ if (dir > 0) {
+ countDelta = v;
+ }
+ else {
+ countDelta = -v;
+ }
+ }
else {
if (monitor != null) {
monitor.add(wh, -dir);
}
- return dir;
+ countDelta = dir;
}
+ updateOverloadedCount(countDelta);
}
-
public WeightedHost findHost(BoundContact bc) {
return (WeightedHost) weightedHosts.get(bc);
}
@@ -139,8 +146,10 @@
public boolean allOverloaded() {
return overloadedCount == weightedHosts.size();
}
-
+
protected void updateOverloadedCount(int dif) {
- this.overloadedCount += dif;
+ if (dif != 0) {
+ this.overloadedCount += dif;
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-22 05:46:34
|
Revision: 2086
http://cogkit.svn.sourceforge.net/cogkit/?rev=2086&view=rev
Author: liuwt
Date: 2008-07-22 05:46:29 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
Added Paths:
-----------
trunk/current/src/cog/modules/transfer-gui/package/
trunk/current/src/cog/modules/transfer-gui/package/SignJarCommand.pl
trunk/current/src/cog/modules/transfer-gui/package/bcprov-jdk15-139.jar
trunk/current/src/cog/modules/transfer-gui/package/build.xml
trunk/current/src/cog/modules/transfer-gui/package/cog-ogce.jar
trunk/current/src/cog/modules/transfer-gui/package/gui.bat
trunk/current/src/cog/modules/transfer-gui/package/gui.jar
trunk/current/src/cog/modules/transfer-gui/package/gui.sh
trunk/current/src/cog/modules/transfer-gui/package/jce_jdk.jnlp
trunk/current/src/cog/modules/transfer-gui/package/lib/
trunk/current/src/cog/modules/transfer-gui/package/lib/FileTransferMainPanel.class
trunk/current/src/cog/modules/transfer-gui/package/lib/GlobusPortal-0.0.1.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/GridClient.class
trunk/current/src/cog/modules/transfer-gui/package/lib/GridClient.jad
trunk/current/src/cog/modules/transfer-gui/package/lib/QueuePanel.class
trunk/current/src/cog/modules/transfer-gui/package/lib/QueuePanel.jad
trunk/current/src/cog/modules/transfer-gui/package/lib/addressing-1.0.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/ant-contrib-1.0b3.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/ant-launcher.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/ant.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/appframework-1.0.3.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/axis-url.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/axis.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/beansbinding-1.2.1.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/cog-axis.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/cog-jglobus.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/cog-ogce.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/commonj.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/commons-beanutils.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/commons-cli-2.0.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/commons-collections-3.0.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/commons-digester.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/commons-discovery.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/commons-logging.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/concurrent.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/cryptix-asn1.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/cryptix.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/cryptix32.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/globus_delegation_client.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/globus_delegation_service.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/globus_delegation_stubs.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/globus_delegation_test.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/globus_wsrf_rft.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/globus_wsrf_rft_client.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/globus_wsrf_rft_stubs.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/gridant-old.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/gridant.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/gridsdk.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/jad.exe
trunk/current/src/cog/modules/transfer-gui/package/lib/jaxrpc.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/jce-jdk13-120.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/jgss.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/junit.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/log4j-1.2.8.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/naming-common.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/naming-factory.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/naming-java.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/naming-resources.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/ogsa.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/puretls.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/saaj.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/swing-layout-1.0.3.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/swing-worker-1.1.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/wsdl4j.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/wsrf_core.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/wsrf_core_stubs.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/wsrf_tools.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/wss4j.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/xercesImpl.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/xml4j.jar
trunk/current/src/cog/modules/transfer-gui/package/lib/xmlsec.jar
trunk/current/src/cog/modules/transfer-gui/package/mykeystore
trunk/current/src/cog/modules/transfer-gui/package/path.pl
trunk/current/src/cog/modules/transfer-gui/package/tmp
trunk/current/src/cog/modules/transfer-gui/package/?\229?\164?\141?\228?\187?\182 gui.jar
Added: trunk/current/src/cog/modules/transfer-gui/package/SignJarCommand.pl
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/package/SignJarCommand.pl (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/package/SignJarCommand.pl 2008-07-22 05:46:29 UTC (rev 2086)
@@ -0,0 +1,29 @@
+#!/bin/perl
+if (opendir(DIR, "lib")) {
+
+ $output_file=">tmp";
+ open(OUTPUT_FILE, $output_file);
+ @entries = readdir(DIR);
+ closedir(DIR);
+ $alias = "mykey";
+ $keystore="mykeystore";
+ $storepass="mcs123";
+ `keytool -genkey -alias $alias -keystore $keystore -keypass mcs123 -storepass $storepass`;
+ $sign_jar_cmd_base = "jarsigner -keystore $keystore -storepass $storepass ";
+ $sign_jar_cmd = $sign_jar_cmd_base."gui.jar ".$alias;
+ `$sign_jar_cmd`;
+ foreach (@entries) {
+ if ($_ ne "." && $_ ne "..") {
+ $entry = "lib/".$_;
+ $sign_jar_cmd = $sign_jar_cmd_base.$entry." ".$alias;
+ print $sign_jar_cmd;
+ print "\n";
+ `$sign_jar_cmd`;
+
+ }
+ }
+
+ close(OUTPUT_FILE);
+
+
+}
\ No newline at end of file
Property changes on: trunk/current/src/cog/modules/transfer-gui/package/bcprov-jdk15-139.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/current/src/cog/modules/transfer-gui/package/build.xml
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/package/build.xml (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/package/build.xml 2008-07-22 05:46:29 UTC (rev 2086)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="IGTFScratcher" default="run" basedir=".">
+ <property name="dist_base_name" value="igtf-policy-installation-bundle-1.22"/>
+ <property name="dist_package_name" value="${dist_base_name}.tar.gz"/>
+ <property name="IGTFDist" value="https://dist.eugridpma.info/distribution/igtf/current/accredited/${dist_package_name}"/>
+ <property name="tmp_file" value="tmf_file"/>
+ <property name="home_dir" value="${user.home}"/>
+ <property name="root_home" value="/root"/>
+ <property name="cert_files" value="${dist_base_name}/src/accredited/"/>
+
+
+ <!-- add support for "Ant-Contrib" -->
+ <!-- this resource is searched from CLASSPATH -->
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties">
+ <classpath>
+ <pathelement location="./gridftpgui_lib/ant-contrib-1.0b3.jar"/>
+ </classpath>
+ </taskdef>
+
+ <target name="downloadIGTFDist">
+ <get src="${IGTFDist}" dest="./${dist_package_name}"/>
+ </target>
+
+ <target name="decompressDist">
+ <gunzip src="${dist_package_name}" dest="${tmp_file}"/>
+ <untar src="${tmp_file}" dest="."/>
+ </target>
+
+ <target name="run" depends="downloadIGTFDist, decompressDist">
+ <if>
+ <!-- UNIX-like system -->
+ <os family="unix"/>
+ <then>
+ <if>
+ <!-- root user -->
+ <equlas arg1="${home_dir}" arg2="${root_home}"/>
+ <then>
+ <copy todir="/etc/grid-security/certificates/">
+ <fileset dir="${cert_files}"/>
+ </copy>
+ </then>
+
+ <!-- non-root user -->
+ <else>
+ <copy todir="${home_dir}/.globus/certificates/">
+ <fileset dir="${cert_files}"/>
+ </copy>
+ </else>
+ </if>
+ </then>
+
+ <!-- Windows System -->
+ <else>
+ <copy todir="${home_dir}/.globus/certificates/">
+ <fileset dir="${cert_files}"/>
+ </copy>
+ </else>
+ </if>
+ </target>
+
+
+</project>
\ No newline at end of file
Property changes on: trunk/current/src/cog/modules/transfer-gui/package/cog-ogce.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/current/src/cog/modules/transfer-gui/package/gui.bat
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/package/gui.bat (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/package/gui.bat 2008-07-22 05:46:29 UTC (rev 2086)
@@ -0,0 +1,19 @@
+@echo off
+
+if "%GLOBUS_LOCATION%" == "" goto nogl
+goto run
+
+:nogl
+
+ echo Error: GLOBUS_LOCATION not set
+ goto end
+
+:run
+
+ set _RUNJAVA=java
+ if not "%JAVA_HOME%" == "" set _RUNJAVA="%JAVA_HOME%\bin\java"
+ %_RUNJAVA% -DGLOBUS_LOCATION="%GLOBUS_LOCATION%" -Daxis.ClientConfigFile="%GLOBUS_LOCATION%"\client-config.wsdd -jar gui.jar
+
+:end
+
+
\ No newline at end of file
Property changes on: trunk/current/src/cog/modules/transfer-gui/package/gui.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/current/src/cog/modules/transfer-gui/package/gui.sh
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/package/gui.sh (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/package/gui.sh 2008-07-22 05:46:29 UTC (rev 2086)
@@ -0,0 +1,14 @@
+# !/bin/sh
+
+if [ ! -d "$GLOBUS_LOCATION" ] then
+ echo "Error: GLOBUS_LOCATION invalid or not set: $GLOBUS_LOCATION" 1>&2
+ exit 1
+fi
+
+if [ "X$JAVA_HOME" = "X" ] then
+ _RUNJAVA=java
+else
+ _RUNJAVA="$JAVA_HOME"/bin/java
+fi
+
+exec $_RUNJAVA -Daxis.ClientConfigFile="$GLOBUS_LOCATION"\client-config.wsdd -jar gui.jar
\ No newline at end of file
Added: trunk/current/src/cog/modules/transfer-gui/package/jce_jdk.jnlp
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/package/jce_jdk.jnlp (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/package/jce_jdk.jnlp 2008-07-22 05:46:29 UTC (rev 2086)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jnlp spec="1.0+" codebase="https://jaxb-workshop.dev.java.net/webstart/" href="jce_jdk.jnlp">
+ <information>
+ <title>JCE_JDK</title>
+ <vendor>Sun Microsystems, Inc.</vendor>
+ <offline-allowed/>
+ </information>
+ <offline-allowed/>
+ <resources>
+ <jar href="jce-jdk13-120.jar"/>
+ </resources>
+ <component-desc/>
+</jnlp>
\ No newline at end of file
Property changes on: trunk/current/src/cog/modules/transfer-gui/package/lib/FileTransferMainPanel.class
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/current/src/cog/modules/transfer-gui/package/lib/GlobusPortal-0.0.1.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/current/src/cog/modules/transfer-gui/package/lib/GridClient.class
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/current/src/cog/modules/transfer-gui/package/lib/GridClient.jad
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/package/lib/GridClient.jad (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/package/lib/GridClient.jad 2008-07-22 05:46:29 UTC (rev 2086)
@@ -0,0 +1,1192 @@
+// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
+// Jad home page: http://www.kpdus.com/jad.html
+// Decompiler options: fullnames
+// Source File Name: GridClient.java
+
+package org.globus.ogce.beans.filetransfer.gui.remote.gridftp;
+
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.GridLayout;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.Serializable;
+import java.io.StringReader;
+import java.util.Vector;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import org.apache.log4j.Logger;
+import org.globus.common.CoGProperties;
+import org.globus.ftp.DataChannelAuthentication;
+import org.globus.ftp.GridFTPClient;
+import org.globus.ftp.exception.ServerException;
+import org.globus.gsi.GlobusCredential;
+import org.globus.gsi.gssapi.GlobusGSSCredentialImpl;
+import org.globus.ogce.beans.filetransfer.gui.FileTransferMainPanel;
+import org.globus.ogce.beans.filetransfer.gui.monitor.WindowProgress;
+import org.globus.ogce.beans.filetransfer.gui.remote.common.DisplayInterface;
+import org.globus.ogce.beans.filetransfer.gui.remote.common.GridEvent;
+import org.globus.ogce.beans.filetransfer.gui.remote.common.GridListener;
+import org.globus.ogce.beans.filetransfer.gui.remote.common.RemoteTree;
+import org.globus.ogce.beans.filetransfer.gui.remote.common.RemoteTreeFrame;
+import org.globus.ogce.beans.filetransfer.util.DirQueue;
+import org.globus.tools.ui.util.UITools;
+
+// Referenced classes of package org.globus.ogce.beans.filetransfer.gui.remote.gridftp:
+// RemDirListener, RemDirEvent
+
+public class GridClient extends javax.swing.JPanel
+ implements java.beans.PropertyChangeListener, org.globus.ogce.beans.filetransfer.gui.remote.common.DisplayInterface, org.globus.ogce.beans.filetransfer.gui.remote.common.GridListener, java.awt.event.ActionListener, java.lang.Runnable, java.io.Serializable
+{
+
+ public void addRemDirListener(org.globus.ogce.beans.filetransfer.gui.remote.gridftp.RemDirListener l)
+ {
+ remdirlisteners.addElement(l);
+ }
+
+ public void removeRemDirListener(org.globus.ogce.beans.filetransfer.gui.remote.gridftp.RemDirListener l)
+ {
+ remdirlisteners.removeElement(l);
+ }
+
+ public void fireRemDirEvent(org.globus.ogce.beans.filetransfer.gui.remote.gridftp.RemDirEvent e, org.globus.ogce.beans.filetransfer.util.DirQueue dirqueue, java.lang.String path, org.globus.ogce.beans.filetransfer.gui.remote.gridftp.GridClient gc)
+ {
+ java.util.Vector list = (java.util.Vector)remdirlisteners.clone();
+ for(int i = 0; i < list.size(); i++)
+ {
+ org.globus.ogce.beans.filetransfer.gui.remote.gridftp.RemDirListener listener = (org.globus.ogce.beans.filetransfer.gui.remote.gridftp.RemDirListener)list.elementAt(i);
+ try
+ {
+ switch(e.getID())
+ {
+ case 2: // '\002'
+ listener.dropGridFtp(e, path, gc);
+ break;
+
+ case 3: // '\003'
+ listener.dragGridFtp(e, path, gc);
+ break;
+
+ case 4: // '\004'
+ listener.gridCounter(e, gc);
+ break;
+ }
+ }
+ catch(java.lang.Exception direx)
+ {
+ direx.printStackTrace();
+ }
+ }
+
+ }
+
+ public GridClient()
+ {
+ this(null, true);
+ bean = true;
+ org.globus.ogce.beans.filetransfer.gui.FileTransferMainPanel.mainPanel.registerRemoteComponent(this, 1);
+ remoteTreeFrame.statusOut("Status: Not connected");
+ }
+
+ public GridClient(java.lang.String s)
+ {
+ this(s, false);
+ }
+
+ public GridClient(java.lang.String s, boolean bean)
+ {
+ wndPreload = null;
+ isConnected = false;
+ put = false;
+ status = null;
+ url = null;
+ this.bean = false;
+ remdirlisteners = new Vector();
+ remoteTreeFrame = new RemoteTreeFrame(this, bean);
+ remoteTreeFrame.setVisible(true);
+ setLayout(new GridLayout(1, 1));
+ add(remoteTreeFrame);
+ setVisible(true);
+ remoteTreeFrame.addPropertyChangeListener(this);
+ remoteTreeFrame.addGridListener(this);
+ txtHost = null;
+ txtPort = null;
+ host = null;
+ port = 2811;
+ FileSep = null;
+ isConnected = false;
+ dlgConnect = null;
+ gbc = new GridBagConstraints();
+ queue = new DirQueue();
+ remoteTreeFrame.setProtocol("gsiftp");
+ remoteTreeFrame.setPort(2811);
+ }
+
+ public java.lang.String getStatus()
+ {
+ return status;
+ }
+
+ public java.lang.String getUrl()
+ {
+ return url;
+ }
+
+ public void setStatus(java.lang.String status)
+ {
+ this.status = status;
+ remoteTreeFrame.statusOut(status);
+ }
+
+ public void setUrl(java.lang.String url)
+ {
+ this.url = url;
+ remoteTreeFrame.setUrl(url);
+ }
+
+ public void connectDlg(javax.swing.JFrame frame)
+ {
+ if(isConnected)
+ {
+ remoteTreeFrame.statusOut("Connection Exists");
+ return;
+ } else
+ {
+ remoteTreeFrame.statusOut("Please wait. Connecting");
+ dlgConnect = new JDialog(frame);
+ dlgConnect.setTitle("Connect to GridFTP");
+ org.globus.tools.ui.util.UITools.center(frame, dlgConnect);
+ dlgConnect.addWindowListener(new Object() /* anonymous class not found */
+ class org.globus.ogce.beans.filetransfer.gui.remote.gridftp._anm1 {}
+
+);
+ txtHost = new JTextField(20);
+ txtHost.setFont(new Font("Times New Roman", 0, 15));
+ txtprofileName = new JTextField(20);
+ txtprofileName.setText("2811");
+ txtprofileName.setFont(new Font("Times New Roman", 0, 15));
+ javax.swing.JLabel jhost = new JLabel("Host ");
+ javax.swing.JLabel jprofile = new JLabel("Port ");
+ javax.swing.JButton jbutton = new JButton("ok");
+ jbutton.addActionListener(this);
+ jbutton.setActionCommand("10");
+ javax.swing.JButton jbutton1 = new JButton("cancel");
+ jbutton1.addActionListener(this);
+ jbutton1.setActionCommand("11");
+ javax.swing.JPanel jpanel4 = new JPanel();
+ jpanel4.add(jbutton);
+ jpanel4.add(jbutton1);
+ java.awt.Container container = dlgConnect.getContentPane();
+ container.setLayout(new BorderLayout());
+ javax.swing.JPanel jp = new JPanel();
+ jp.setLayout(new GridBagLayout());
+ jp.setPreferredSize(new Dimension(350, 200));
+ jp.add(jhost, getGBC(0, 16, 0.29999999999999999D, 1.0D, 0, 2, 1, 2));
+ jp.add(txtHost, getGBC(0, 16, 0.69999999999999996D, 0.0D, 1, 3, 4, 1));
+ jp.add(jprofile, getGBC(0, 16, 0.29999999999999999D, 1.0D, 0, 4, 1, 2));
+ jp.add(txtprofileName, getGBC(0, 16, 0.69999999999999996D, 0.0D, 1, 5, 4, 1));
+ jp.add(jpanel4, getGBC(0, 16, 0.29999999999999999D, 1.0D, 1, 7, 1, 2));
+ container.add(jp, "Center");
+ txtHost.addKeyListener(new Object() /* anonymous class not found */
+ class org.globus.ogce.beans.filetransfer.gui.remote.gridftp._anm2 {}
+
+);
+ txtprofileName.addKeyListener(new Object() /* anonymous class not found */
+ class org.globus.ogce.beans.filetransfer.gui.remote.gridftp._anm3 {}
+
+);
+ dlgConnect.pack();
+ dlgConnect.setVisible(true);
+ dlgConnect.show();
+ return;
+ }
+ }
+
+ protected java.awt.GridBagConstraints getGBC(int i, int j, double d, double d1, int k,
+ int l, int i1, int j1)
+ {
+ gbc.fill = i;
+ gbc.anchor = j;
+ gbc.weightx = d;
+ gbc.weighty = d1;
+ gbc.gridx = k;
+ gbc.gridy = l;
+ gbc.gridwidth = i1;
+ gbc.gridheight = j1;
+ return gbc;
+ }
+
+ public void doConnectOK()
+ {
+ dlgConnect.setVisible(false);
+ dlgConnect.dispose();
+ dlgConnect.removeAll();
+ dlgConnect = null;
+ java.lang.System.gc();
+ wndPreload = new WindowProgress("Connecting ... Please wait", 25);
+ org.globus.ogce.beans.filetransfer.gui.remote.gridftp.GridClient.centerWindow(wndPreload);
+ wndPreload.setProgressValue(5);
+ try
+ {
+ port = java.lang.Integer.parseInt(txtprofileName.getText());
+ }
+ catch(java.lang.Exception e)
+ {
+ e.printStackTrace(java.lang.System.out);
+ remoteTreeFrame.setConnected(false);
+ }
+ host = txtHost.getText();
+ profile = host + ":" + port;
+ if(profile.length() <= 0)
+ profile = host;
+ wndPreload.setProgressValue(8);
+ setConnectDetails(true);
+ }
+
+ public boolean setConnectDetails(boolean interactive)
+ {
+ remoteTreeFrame.setProtocol("gsiftp");
+ remoteTreeFrame.setHost(host);
+ remoteTreeFrame.setPort(port);
+ if(wndPreload != null)
+ wndPreload.setProgressValue(10);
+ boolean isInteractive = interactive;
+ java.lang.Thread connectThread = new Object(isInteractive) /* anonymous class not found */
+ class org.globus.ogce.beans.filetransfer.gui.remote.gridftp._anm4 {}
+
+;
+ connectThread.start();
+ if(wndPreload != null)
+ wndPreload.setProgressValue(24);
+ if(wndPreload != null)
+ {
+ wndPreload.setProgressValue(25);
+ wndPreload.setVisible(false);
+ wndPreload = null;
+ }
+ return isConnected;
+ }
+
+ public void refresh()
+ {
+ remoteTreeFrame._actionRefresh();
+ }
+
+ public void connectRemote()
+ {
+ java.lang.System.out.println("\n HOST = " + host + " port = " + port);
+ try
+ {
+ client = new GridFTPClient(host, port);
+ client1 = new GridFTPClient(host, port);
+ client2 = new GridFTPClient(host, port);
+ client3 = new GridFTPClient(host, port);
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "The host: " + host + "\n or the port number: " + port + " is invalid.\n Please try again. ");
+ logger.debug("ServerException instantiating client.");
+ logger.debug(fte.getMessage());
+ return;
+ }
+ catch(java.io.IOException ioe)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "The host : " + host + "\n or the port number: " + port + " is invalid.\n Please try again.");
+ logger.debug("IOException instantiating client.");
+ logger.debug(ioe.getMessage());
+ return;
+ }
+ if(wndPreload != null)
+ wndPreload.setProgressValue(13);
+ java.lang.String file = null;
+ org.globus.gsi.GlobusCredential credentials = null;
+ org.ietf.jgss.GSSCredential proxy = null;
+ try
+ {
+ if(file == null)
+ file = org.globus.common.CoGProperties.getDefault().getProxyFile();
+ credentials = new GlobusCredential(file);
+ proxy = new GlobusGSSCredentialImpl(credentials, 2);
+ }
+ catch(java.lang.Exception e)
+ {
+ java.lang.System.err.println("Unable to load the user proxy : " + e.getMessage());
+ javax.swing.JOptionPane.showMessageDialog(this, "No valid Grid proxy certificate.\n\nUse the [Security]->[Create Proxy] menu item\nto create a new certificate.", "Security Message", 2);
+ return;
+ }
+ if(wndPreload != null)
+ wndPreload.setProgressValue(16);
+ try
+ {
+ client.authenticate(null);
+ client1.authenticate(null);
+ client2.authenticate(null);
+ client3.authenticate(null);
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ java.lang.System.out.println("aaaaaaaaaaaaaaaa");
+ fte.printStackTrace();
+ javax.swing.JOptionPane.showMessageDialog(this, "No valid Grid proxy certificate.\n\nUse the [Security]->[Create Proxy] menu item\nto create a new certificate.", "Security Message", 2);
+ logger.debug("Credentials are not valid. Use the Security menu");
+ logger.debug(fte.getMessage());
+ return;
+ }
+ catch(java.io.IOException ioe)
+ {
+ java.lang.System.out.println("bbbbbbbbbbbbbbbbbbbb");
+ ioe.printStackTrace();
+ javax.swing.JOptionPane.showMessageDialog(this, "No valid Grid proxy certificate.\n\nUse the [Security]->[Create Proxy] menu item\nto create a new certificate.", "Security Message", 2);
+ logger.debug("Credentials are not valid. Use the Security Menu");
+ logger.debug(ioe.getMessage());
+ return;
+ }
+ if(wndPreload != null)
+ wndPreload.setProgressValue(18);
+ try
+ {
+ client.setDataChannelAuthentication(org.globus.ftp.DataChannelAuthentication.NONE);
+ client1.setDataChannelAuthentication(org.globus.ftp.DataChannelAuthentication.NONE);
+ client2.setDataChannelAuthentication(org.globus.ftp.DataChannelAuthentication.NONE);
+ client3.setDataChannelAuthentication(org.globus.ftp.DataChannelAuthentication.NONE);
+ logger.debug("Setting Data Channel Authorization to none.");
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Error setting Data Channel Authentication.");
+ return;
+ }
+ catch(java.io.IOException ioe)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Error setting Data Channel Authentication.");
+ return;
+ }
+ if(wndPreload != null)
+ wndPreload.setProgressValue(20);
+ isConnected = true;
+ remoteTreeFrame.setConnected(true);
+ }
+
+ public void disconnect()
+ {
+ remoteTreeFrame._actionDisconnect();
+ }
+
+ public boolean createClient(org.globus.ftp.GridFTPClient newClient)
+ {
+ try
+ {
+ newClient = null;
+ newClient = new GridFTPClient(host, port);
+ newClient.authenticate(null);
+ }
+ catch(java.lang.Exception e)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public java.lang.String getCurrentDir()
+ {
+ try
+ {
+ remoterootDir = client.getCurrentDir();
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ logger.debug("ServerException getting remote root directory.");
+ java.lang.String errorMsg = fte.getMessage();
+ if(errorMsg.indexOf("Timeout") > 0)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Connection Timed Out");
+ remoteTreeFrame.setConnected(false);
+ }
+ logger.debug(errorMsg);
+ return null;
+ }
+ catch(java.io.IOException ioe)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Disconnected due to Network problems");
+ logger.debug("IOException getting remote root directory.");
+ logger.debug(ioe.getMessage());
+ remoteTreeFrame.setConnected(false);
+ return null;
+ }
+ catch(java.lang.Exception ioe)
+ {
+ logger.debug("Exception getting remote root directory.");
+ logger.debug(ioe.getMessage());
+ return null;
+ }
+ remoteTreeFrame.setServerOpSys(1);
+ return remoterootDir;
+ }
+
+ public void disconnectRemote(boolean connectionAndGUI)
+ {
+ if(client != null || client1 != null || client2 != null || client3 != null)
+ try
+ {
+ client.close();
+ client = null;
+ if(client1 != null)
+ {
+ client1.close();
+ client1 = null;
+ }
+ if(client2 != null)
+ {
+ client2.close();
+ client2 = null;
+ }
+ if(client3 != null)
+ {
+ client3.close();
+ client3 = null;
+ }
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ logger.debug("ServerException disconnecting.");
+ logger.debug(fte.getMessage());
+ }
+ catch(java.io.IOException ioe)
+ {
+ logger.debug("IOException disconnecting.");
+ logger.debug(ioe.getMessage());
+ }
+ if(isConnected)
+ isConnected = false;
+ if(connectionAndGUI)
+ {
+ java.lang.System.gc();
+ fireRemDirEvent(new RemDirEvent(this, 4), null, "", this);
+ }
+ logger.debug("Returned correctly after disconnect.");
+ }
+
+ public void propertyChange(java.beans.PropertyChangeEvent evt)
+ {
+ java.lang.System.out.println("\n In the property change method.");
+ host = remoteTreeFrame.getHost();
+ remoteTreeFrame.statusOut("Connecting. Please wait ....");
+ isConnected = false;
+ setConnectDetails(true);
+ logger.debug("Remote url changed.display the authorization dialog ");
+ }
+
+ public java.util.Vector listDir(java.lang.String dirname)
+ {
+ logger.debug("\nEntered the listdir function in grid client.");
+ java.util.Vector listing = null;
+ if(client1 == null)
+ {
+ logger.debug("Client null...Trying to create a new instance");
+ try
+ {
+ client1 = new GridFTPClient(host, port);
+ client1.authenticate(null);
+ client1.setDataChannelAuthentication(org.globus.ftp.DataChannelAuthentication.NONE);
+ }
+ catch(java.lang.Exception e)
+ {
+ logger.debug("Client null...Failed the trial to create one.");
+ remoteTreeFrame.setConnected(false);
+ return null;
+ }
+ }
+ try
+ {
+ client1.setClientWaitParams(0xaba9500, 300);
+ client1.changeDir(dirname);
+ client1.setPassive();
+ client1.setLocalActive();
+ client1.setLocalNoDataChannelAuthentication();
+ logger.debug("\nSET THE PARAMETERS." + client1);
+ listing = client1.list();
+ logger.debug("Returned correctly from list.");
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ logger.debug("ServerException listing directory." + client1);
+ fte.printStackTrace(java.lang.System.out);
+ java.lang.String errorMsg = fte.getMessage();
+ if(errorMsg.indexOf("Timeout") > 0)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Connection Timed Out");
+ remoteTreeFrame.setConnected(false);
+ }
+ logger.debug(errorMsg);
+ return null;
+ }
+ catch(java.io.IOException ioe)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Disconnected due to Network problems");
+ logger.debug("IOException listing directory.");
+ logger.debug(ioe.getMessage());
+ ioe.printStackTrace(java.lang.System.out);
+ remoteTreeFrame.setConnected(false);
+ return null;
+ }
+ catch(java.lang.Exception ioe)
+ {
+ logger.debug("Exception listing the remote directory.");
+ logger.debug(ioe.getMessage());
+ ioe.printStackTrace(java.lang.System.out);
+ return null;
+ }
+ return listing;
+ }
+
+ public java.util.Vector listAllDir(java.lang.String dirname)
+ {
+ java.util.Vector listing = null;
+ java.util.Vector list = new Vector();
+ if(client == null)
+ {
+ logger.debug("Client null...Trying to create a new instance");
+ try
+ {
+ client = new GridFTPClient(host, port);
+ client.authenticate(null);
+ client.setDataChannelAuthentication(org.globus.ftp.DataChannelAuthentication.NONE);
+ }
+ catch(java.lang.Exception e)
+ {
+ logger.debug("Client null...Failed the trial to create one.");
+ remoteTreeFrame.setConnected(false);
+ return null;
+ }
+ }
+ java.io.ByteArrayOutputStream received = new ByteArrayOutputStream(1000);
+ java.lang.String output = null;
+ try
+ {
+ client.setClientWaitParams(0xaba9500, 300);
+ client.changeDir(dirname);
+ client.setPassive();
+ client.setLocalActive();
+ client.setLocalNoDataChannelAuthentication();
+ client.list("*", "-d", new Object(received) /* anonymous class not found */
+ class org.globus.ogce.beans.filetransfer.gui.remote.gridftp._anm5 {}
+
+);
+ output = received.toString();
+ logger.debug("\nReceived of directory listing\n" + output);
+ java.io.BufferedReader reader = new BufferedReader(new StringReader(received.toString()));
+ for(java.lang.String line = null; (line = reader.readLine()) != null;)
+ if(!line.startsWith("total"))
+ {
+ list.addElement(line);
+ logger.debug("\nline = " + line);
+ }
+
+ listing = list;
+ }
+ catch(java.lang.Exception e)
+ {
+ logger.debug("Parameterized list also failed");
+ e.printStackTrace(java.lang.System.out);
+ }
+ return listing;
+ }
+
+ public java.util.Vector listTransferDir(java.lang.String dirname)
+ {
+ java.util.Vector listing = null;
+ if(client2 == null)
+ {
+ logger.debug("Client null...Trying to create a new instance");
+ try
+ {
+ client2 = new GridFTPClient(host, port);
+ client2.authenticate(null);
+ client2.setDataChannelAuthentication(org.globus.ftp.DataChannelAuthentication.NONE);
+ }
+ catch(java.lang.Exception e)
+ {
+ logger.debug("Client null...Failed the trial to create one.");
+ javax.swing.JOptionPane.showMessageDialog(this, "Please drag a smallerdirectory.\n Server is not to remain connected.");
+ remoteTreeFrame.setConnected(false);
+ return null;
+ }
+ }
+ try
+ {
+ client2.setClientWaitParams(0xaba9500, 300);
+ client2.changeDir(dirname);
+ client2.setPassive();
+ client2.setLocalActive();
+ client2.setLocalNoDataChannelAuthentication();
+ listing = client2.list();
+ logger.debug("Returned correctly from list.");
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ logger.debug("ServerException listing directory.");
+ fte.printStackTrace(java.lang.System.out);
+ java.lang.String errorMsg = fte.getMessage();
+ if(errorMsg.indexOf("Timeout") > 0)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Connection Timed Out");
+ remoteTreeFrame.setConnected(false);
+ }
+ logger.debug(errorMsg);
+ return null;
+ }
+ catch(java.io.IOException ioe)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Disconnected due to Network problems");
+ logger.debug("IOException listing directory.");
+ logger.debug(ioe.getMessage());
+ ioe.printStackTrace(java.lang.System.out);
+ remoteTreeFrame.setConnected(false);
+ return null;
+ }
+ catch(java.lang.Exception ioe)
+ {
+ logger.debug("Exception listing the remote directory.");
+ logger.debug(ioe.getMessage());
+ ioe.printStackTrace(java.lang.System.out);
+ return null;
+ }
+ return listing;
+ }
+
+ public java.util.Vector listDeleteDir(java.lang.String dirname)
+ {
+ java.util.Vector listing = null;
+ if(client3 == null)
+ {
+ logger.debug("Client null...returning from listCurrentDirectory");
+ try
+ {
+ client3 = new GridFTPClient(host, port);
+ client3.authenticate(null);
+ client3.setDataChannelAuthentication(org.globus.ftp.DataChannelAuthentication.NONE);
+ }
+ catch(java.lang.Exception e)
+ {
+ logger.debug("Client null...Failed the trial to create one.");
+ remoteTreeFrame.setConnected(false);
+ return null;
+ }
+ }
+ try
+ {
+ client3.setClientWaitParams(0xaba9500, 300);
+ client3.changeDir(dirname);
+ client3.setPassive();
+ client3.setLocalActive();
+ client3.setLocalNoDataChannelAuthentication();
+ listing = client3.list();
+ logger.debug("Returned correctly from list.");
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ logger.debug("ServerException listing directory.");
+ java.lang.String errorMsg = fte.getMessage();
+ if(errorMsg.indexOf("Timeout") > 0)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Connection Timed Out");
+ remoteTreeFrame.setConnected(false);
+ }
+ logger.debug(errorMsg);
+ return null;
+ }
+ catch(java.io.IOException ioe)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Disconnected due to Network problems");
+ logger.debug("IOException listing directory.");
+ logger.debug(ioe.getMessage());
+ ioe.printStackTrace(java.lang.System.out);
+ remoteTreeFrame.setConnected(false);
+ return null;
+ }
+ catch(java.lang.Exception ioe)
+ {
+ logger.debug("Exception listing the remote directory.");
+ logger.debug(ioe.getMessage());
+ ioe.printStackTrace(java.lang.System.out);
+ return null;
+ }
+ return listing;
+ }
+
+ public void pwd()
+ {
+ try
+ {
+ client.getCurrentDir();
+ logger.debug("Returned correctly from pwd.");
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ logger.debug("ServerException showing pwd.");
+ java.lang.String errorMsg = fte.getMessage();
+ if(errorMsg.indexOf("Timeout") > 0)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Connection Timed Out");
+ remoteTreeFrame.setConnected(false);
+ }
+ logger.debug(errorMsg);
+ return;
+ }
+ catch(java.io.IOException ioe)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Disconnected due to Network problems");
+ logger.debug("IOException showing pwd.");
+ logger.debug(ioe.getMessage());
+ remoteTreeFrame.setConnected(false);
+ return;
+ }
+ }
+
+ public void get(java.lang.String s, java.io.File file)
+ {
+ }
+
+ public void put(java.io.File file, java.lang.String s)
+ {
+ }
+
+ public boolean chdir(java.lang.String s)
+ {
+ try
+ {
+ client.changeDir(s);
+ logger.debug("Returned correctly from change dir command");
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ logger.debug("ServerException during change dir command.");
+ java.lang.String errorMsg = fte.getMessage();
+ if(errorMsg.indexOf("Timeout") > 0)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Connection Timed Out");
+ remoteTreeFrame.setConnected(false);
+ }
+ logger.debug(errorMsg);
+ return false;
+ }
+ catch(java.io.IOException ioe)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Disconnected due to Network problems");
+ logger.debug("IOException during change dir command.");
+ logger.debug(ioe.getMessage());
+ remoteTreeFrame.setConnected(false);
+ return false;
+ }
+ catch(java.lang.Exception ioe)
+ {
+ logger.debug("Exception during change dir command.");
+ logger.debug(ioe.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ public void setType(boolean flag)
+ {
+ if(flag)
+ try
+ {
+ client.setType(2);
+ logger.debug("Returned correctly from setType.");
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ logger.debug("ServerException during setType.");
+ java.lang.String errorMsg = fte.getMessage();
+ if(errorMsg.indexOf("Timeout") > 0)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Connection Timed Out");
+ remoteTreeFrame.setConnected(false);
+ }
+ logger.debug(errorMsg);
+ return;
+ }
+ catch(java.io.IOException ioe)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Disconnected due to Network problems");
+ logger.debug("IOException during setType.");
+ logger.debug(ioe.getMessage());
+ remoteTreeFrame.setConnected(false);
+ return;
+ }
+ else
+ try
+ {
+ client.setType(1);
+ logger.debug("Returned correctly from setType.");
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ logger.debug("ServerException during setType.");
+ java.lang.String errorMsg = fte.getMessage();
+ if(errorMsg.indexOf("Timeout") > 0)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Connection Timed Out");
+ remoteTreeFrame.setConnected(false);
+ }
+ logger.debug(errorMsg);
+ return;
+ }
+ catch(java.io.IOException ioe)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Disconnected due to Network problems");
+ logger.debug("IOException in setType.");
+ logger.debug(ioe.getMessage());
+ remoteTreeFrame.setConnected(false);
+ return;
+ }
+ }
+
+ public boolean rename(java.lang.String s, java.lang.String s1)
+ {
+ try
+ {
+ client.rename(s, s1);
+ logger.debug("Returned correctly from rename.");
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ logger.debug("ServerException renaming directory.");
+ java.lang.String errorMsg = fte.getMessage();
+ if(errorMsg.indexOf("Timeout") > 0)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Connection Timed Out");
+ remoteTreeFrame.setConnected(false);
+ }
+ logger.debug(errorMsg);
+ return false;
+ }
+ catch(java.io.IOException ioe)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Disconnected due to Network problems");
+ logger.debug("IOException renaming directory.");
+ logger.debug(ioe.getMessage());
+ ioe.printStackTrace(java.lang.System.out);
+ remoteTreeFrame.setConnected(false);
+ return false;
+ }
+ return true;
+ }
+
+ public boolean exists(java.lang.String s1)
+ {
+ return client.exists(s1);
+ org.globus.ftp.exception.ServerException fte;
+ fte;
+ logger.debug("ServerException renaming directory.");
+ java.lang.String errorMsg = fte.getMessage();
+ if(errorMsg.indexOf("Timeout") > 0)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Connection Timed Out");
+ remoteTreeFrame.setConnected(false);
+ }
+ logger.debug(errorMsg);
+ return false;
+ java.io.IOException ioe;
+ ioe;
+ javax.swing.JOptionPane.showMessageDialog(this, "Disconnected due to Network problems");
+ logger.debug("IOException renaming directory.");
+ logger.debug(ioe.getMessage());
+ ioe.printStackTrace(java.lang.System.out);
+ remoteTreeFrame.setConnected(false);
+ return false;
+ }
+
+ public boolean mkdir(java.lang.String s)
+ {
+ try
+ {
+ if(!exists(s))
+ {
+ client.makeDir(s);
+ logger.debug("Returned correctly from make directory.");
+ } else
+ {
+ java.lang.System.out.println("The already directory exists");
+ }
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ logger.debug("Directory exists or Permission denied.");
+ java.lang.String errorMsg = fte.getMessage();
+ if(errorMsg.indexOf("exists") > 0)
+ {
+ remoteTreeFrame.setError("exists");
+ return true;
+ }
+ if(errorMsg.indexOf("Timeout") > 0)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Connection Timed Out");
+ remoteTreeFrame.setConnected(false);
+ logger.debug(errorMsg);
+ return false;
+ } else
+ {
+ logger.debug(errorMsg);
+ return false;
+ }
+ }
+ catch(java.io.IOException ioe)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Disconnected due to Network problems");
+ logger.debug("No network connection or Firewall prevents it.");
+ logger.debug(ioe.getMessage());
+ remoteTreeFrame.setConnected(false);
+ return false;
+ }
+ return true;
+ }
+
+ public boolean mkdirs(java.lang.String dir, java.lang.String path)
+ {
+ int index = dir.lastIndexOf("/");
+ int index1 = path.lastIndexOf("/");
+ logger.info("\nSTART DIR = " + dir + " index = " + index);
+ logger.info("\npath = " + path + " index1 = " + index1);
+ logger.info("\nMAKING DIR = " + path.substring(0, index1));
+ if(index1 > index)
+ mkdirs(dir, path.substring(0, index1));
+ return mkdir(path);
+ java.lang.Exception e;
+ e;
+ return true;
+ }
+
+ public boolean removeDir(java.lang.String s)
+ {
+ try
+ {
+ client.deleteDir(s);
+ logger.debug("Returned correctly after deleting directory.");
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ logger.debug("ServerException deleting directory.");
+ java.lang.String errorMsg = fte.getMessage();
+ if(errorMsg.indexOf("Timeout") > 0)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Connection Timed Out");
+ remoteTreeFrame.setConnected(false);
+ }
+ logger.debug(errorMsg);
+ return false;
+ }
+ catch(java.io.IOException ioe)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Disconnected due to Network problems");
+ logger.debug("IOException deleting directory.");
+ logger.debug(ioe.getMessage());
+ remoteTreeFrame.setConnected(false);
+ return false;
+ }
+ return true;
+ }
+
+ public boolean removeFile(java.lang.String s)
+ {
+ try
+ {
+ client.deleteFile(s);
+ logger.debug("Returned correctly after deleting file.");
+ }
+ catch(org.globus.ftp.exception.ServerException fte)
+ {
+ logger.debug("ServerException deleting file.");
+ java.lang.String errorMsg = fte.getMessage();
+ if(errorMsg.indexOf("Timeout") > 0)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Connection Timed Out");
+ remoteTreeFrame.setConnected(false);
+ }
+ logger.debug(errorMsg);
+ return false;
+ }
+ catch(java.io.IOException ioe)
+ {
+ javax.swing.JOptionPane.showMessageDialog(this, "Disconnected due to Network problems");
+ logger.debug("IOException deleting file.");
+ logger.debug(ioe.getMessage());
+ remoteTreeFrame.setConnected(false);
+ return false;
+ }
+ return true;
+ }
+
+ public void setHost(java.lang.String host)
+ {
+ this.host = host;
+ }
+
+ public java.lang.String getHost()
+ {
+ return host;
+ }
+
+ public void setPort(int port)
+ {
+ this.port = port;
+ }
+
+ public int getPort()
+ {
+ return port;
+ }
+
+ public void rootDirRemote()
+ {
+ remoteTreeFrame.setRootRemote(remoterootDir);
+ }
+
+ public java.lang.String getRootURL()
+ {
+ return remoteTreeFrame.getBaseUrl();
+ }
+
+ public void setDragDetails(org.globus.ogce.beans.filetransfer.gui.remote.common.GridEvent e, java.lang.String from)
+ {
+ remoteTreeFrame.statusOut("Copying the file ...");
+ fireRemDirEvent(new RemDirEvent(this, 3), null, from, this);
+ }
+
+ public void setDropDetails(org.globus.ogce.beans.filetransfer.gui.remote.common.GridEvent e, java.lang.String to)
+ {
+ fireRemDirEvent(new RemDirEvent(this, 2), null, to, this);
+ }
+
+ public void setSelectedSource()
+ {
+ remoteTreeFrame.right.setSelectedSource();
+ }
+
+ public void setSelectedDestination()
+ {
+ remoteTreeFrame.right.setSelectedDestination();
+ }
+
+ public void transfer()
+ {
+ remoteTreeFrame.right.transfer();
+ }
+
+ public void callGridEditFrame(org.globus.ogce.beans.filetransfer.gui.remote.common.GridEvent gridevent, java.lang.String s, java.lang.String as[])
+ {
+ }
+
+ public void run()
+ {
+ doConnectOK();
+ }
+
+ public void actionPerformed(java.awt.event.ActionEvent ae)
+ {
+ java.lang.String s = ae.getActionCommand();
+ int i = 0;
+ try
+ {
+ i = java.lang.Integer.valueOf(s).intValue();
+ }
+ catch(java.lang.NumberFormatException numberformatexception)
+ {
+ remoteTreeFrame.statusOut("Action Error: " + numberformatexception.getMessage());
+ }
+ switch(i)
+ {
+ default:
+ break;
+
+ case 10: // '\n'
+ java.lang.Thread connect = new Thread(this);
+ connect.start();
+ remoteTreeFrame.statusOut("Connecting ... Please wait");
+ break;
+
+ case 11: // '\013'
+ if(!bean)
+ remoteTreeFrame.setConnected(false);
+ dlgConnect.dispose();
+ break;
+ }
+ }
+
+ public static void centerWindow(java.awt.Window guiComponent)
+ {
+ java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
+ java.awt.Dimension frameSize = guiComponent.getSize();
+ if(frameSize.height > screenSize.height)
+ frameSize.height = screenSize.height;
+ if(frameSize.width > screenSize.width)
+ frameSize.width = screenSize.width;
+ guiComponent.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
+ }
+
+ public static void main(java.lang.String arg[])
+ {
+ org.globus.ogce.beans.filetransfer.gui.remote.gridftp.GridClient gridftpPanel = new GridClient();
+ javax.swing.JFrame sFrame = new JFrame("Remote FTP System: " + arg[0]);
+ sFrame.getContentPane().setLayout(new GridLayout(1, 1));
+ sFrame.getContentPane().add(gridftpPanel);
+ sFrame.pack();
+ sFrame.setSize(300, 400);
+ sFrame.setVisible(true);
+ org.globus.tools.ui.util.UITools.center(null, sFrame);
+ gridftpPanel.setHost(arg[0]);
+ gridftpPanel.setConnectDetails(true);
+ }
+
+ private static org.apache.log4j.Logger logger;
+ private org.globus.ftp.GridFTPClient client;
+ private org.globus.ftp.GridFTPClient client1;
+ private org.globus.ftp.GridFTPClient client2;
+ private org.globus.ftp.GridFTPClient client3;
+ org.globus.ogce.beans.filetransfer.gui.monitor.WindowProgress wndPreload;
+ private final int GRID_FTP_PORT = 2811;
+ public java.lang.String host;
+ private int port;
+ private java.lang.String profile;
+ public org.globus.ogce.beans.filetransfer.gui.remote.common.RemoteTreeFrame remoteTreeFrame;
+ public java.lang.String remoterootDir;
+ public boolean isConnected;
+ public boolean busy;
+ private boolean put;
+ protected javax.swing.JTextField txtHost;
+ protected javax.swing.JTextField txtPort;
+ protected javax.swing.JTextField txtUName;
+ protected javax.swing.JTextField txtprofileName;
+ public javax.swing.JDialog dlgConnect;
+ private java.lang.String FileSep;
+ private java.awt.GridBagConstraints gbc;
+ private org.globus.ogce.beans.filetransfer.util.DirQueue queue;
+ private java.lang.String status;
+ private java.lang.String url;
+ private boolean bean;
+ protected java.util.Vector remdirlisteners;
+
+ static
+ {
+ logger = org.apache.log4j.Logger.getLogger(org.globus.ogce.beans.filetransfer.gui.remote.gridftp.GridClient.class.getName());
+ }
+}
Property changes on: trunk/current/src/cog/modules/transfer-gui/package/lib/QueuePanel.class
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/current/src/cog/modules/transfer-gui/package/lib/QueuePanel.jad
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/package/lib/QueuePanel.jad (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/package/lib/QueuePanel.jad 2008-07-22 05:46:29 UTC (rev 2086)
@@ -0,0 +1,270 @@
+// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
+// Jad home page: http://www.kpdus.com/jad.html
+// Decompiler options: fullnames
+// Source File Name: QueuePanel.java
+
+package org.globus.ogce.beans.filetransfer.gui.monitor;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.Point;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.Vector;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.JTableHeader;
+import org.apache.log4j.Logger;
+
+// Referenced classes of package org.globus.ogce.beans.filetransfer.gui.monitor:
+// QueueTableModel
+
+public class QueuePanel extends javax.swing.JPanel
+ implements java.awt.event.MouseListener
+{
+
+ public QueuePanel()
+ {
+ queueTable = null;
+ jpopup = null;
+ completeTable = null;
+ setLayout(new BorderLayout());
+ setSize(200, 300);
+ setVisible(true);
+ queueTable = new JTable();
+ javax.swing.JScrollPane jobsScrollPane = new JScrollPane(queueTable);
+ add(jobsScrollPane, "Center");
+ javax.swing.border.Border jobsBorder = javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(1), "Transfer Queue");
+ setBorder(jobsBorder);
+ queueTable.addMouseListener(this);
+ jpopup = new JPopupMenu();
+ completeTable = queueTable;
+ }
+
+ public void createHeader(java.lang.String cols[])
+ {
+ org.globus.ogce.beans.filetransfer.gui.monitor.QueueTableModel tableModel = new QueueTableModel();
+ java.util.Vector columnIDs = new Vector();
+ for(int i = 0; i < cols.length; i++)
+ columnIDs.add(cols[i]);
+
+ tableModel.setColumnIdentifiers(columnIDs);
+ queueTable.setModel(tableModel);
+ queueTable.getTableHeader().setReorderingAllowed(false);
+ }
+
+ public void addTransfer(java.lang.String cols[])
+ {
+ javax.swing.table.DefaultTableModel tableModel = getModel();
+ int row = tableModel.getRowCount();
+ java.util.Vector rowData = new Vector();
+ for(int i = 0; i < cols.length; i++)
+ rowData.add(cols[i]);
+
+ tableModel.insertRow(row, rowData);
+ }
+
+ public void updateTransfer(java.lang.String cols[])
+ {
+ javax.swing.table.DefaultTableModel tableModel = getModel();
+ if(tableModel.getRowCount() > 0)
+ {
+ int selectedRow = getRowIndex(cols[0]);
+ for(int i = 0; i < cols.length; i++)
+ if(cols[i] != null)
+ tableModel.setValueAt(cols[i], selectedRow, i);
+
+ }
+ }
+
+ public void setFocus(java.lang.String jobID)
+ {
+ queueTable.repaint();
+ int row = getRowIndex(jobID);
+ javax.swing.table.De...
[truncated message content] |
|
From: <li...@us...> - 2008-07-22 05:31:08
|
Revision: 2085
http://cogkit.svn.sourceforge.net/cogkit/?rev=2085&view=rev
Author: liuwt
Date: 2008-07-22 05:31:04 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/utils/Utils.java
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/utils/Utils.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/utils/Utils.java 2008-07-22 05:30:54 UTC (rev 2084)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/utils/Utils.java 2008-07-22 05:31:04 UTC (rev 2085)
@@ -6,6 +6,10 @@
package org.globus.transfer.reliable.client.utils;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
/**
* Some utility functions
@@ -23,4 +27,24 @@
return roots;
}
+
+ public static String getProperty(String propertyName, String propertyFileName) {
+ File propFile = new File(propertyFileName);
+ String ret = null;
+ if (!propFile.exists()) {
+ return null;
+ }
+
+ Properties prop = new Properties();
+ try {
+ prop.load(new FileInputStream(propFile));
+ ret = prop.getProperty(propertyName);
+
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return ret;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-22 05:30:56
|
Revision: 2084
http://cogkit.svn.sourceforge.net/cogkit/?rev=2084&view=rev
Author: liuwt
Date: 2008-07-22 05:30:54 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/GridFTPGUIView.properties
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTOptionsPanel.properties
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTPanel.properties
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTTransferParamPanel.properties
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/GridFTPGUIView.properties
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/GridFTPGUIView.properties 2008-07-22 05:30:04 UTC (rev 2083)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/GridFTPGUIView.properties 2008-07-22 05:30:54 UTC (rev 2084)
@@ -43,17 +43,19 @@
jMenuItem11.text=Log Location
jMenuItem12.text=Log Config
#NOI18N
-jButton1.icon=unlock.png
-jButton3.text=Local
+local_button.icon=window_new.png
+local_button.text=Local
#NOI18N
jButton5.icon=rft.png
-jButton5.text=RFT
+jButton5.text=Advanced
#NOI18N
-jButton3.icon=window_new.png
-jButton2.toolTipText=Open remote directory
-jButton2.text=GridFTP
+
+gridftp_button.icon=window_new_gridftp.png
+gridftp_button.toolTipText=Open remote directory
+gridftp_button.text=GridFTP
#NOI18N
-jButton2.icon=window_new_gridftp.png
+
+jButton1.icon=unlock.png
jButton1.toolTipText=Create a new credential
jButton1.text=Generate Credential
#NOI18N
@@ -64,6 +66,10 @@
jButton8.icon=unlock.png
jButton8.toolTipText=setup a log file
jButton8.text=Log Config
+
+credential_button.icon=unlock.png
+credential_button.toolTipText=create credential
+credential_button.text= Credential
#NOI18N
jDesktopPane1.background=236, 233, 216
jMenuItem8.text=FTP
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTOptionsPanel.properties
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTOptionsPanel.properties 2008-07-22 05:30:04 UTC (rev 2083)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTOptionsPanel.properties 2008-07-22 05:30:54 UTC (rev 2084)
@@ -1,18 +1,18 @@
# To change this template, choose Tools | Templates
# and open the template in the editor.
-Form.border.title=RFTOptions
+Form.border.title=Options
jLabel1.text=Binary
jLabel2.text=BlockSize
-jLabel3.text=TCPBufferSize
+jLabel3.text=TCP Buffer Size
jLabel4.text=Bytes
jLabel5.text=Bytes
jLabel6.text=Notpt
-jLabel7.text=ParallelStream
+jLabel7.text=Parallel TCP Streams
jLabel8.text=DCAU
-jLabel9.text=Concurrency of the request
-jLabel10.text=Source SubjectName
-jLabel11.text=Destination SubjectName
+jLabel9.text=Concurrency
+jLabel10.text=Source Subject
+jLabel11.text=Destination Subject
jLabel12.text=All or None
jLabel13.text=Max Attempts
binary.text=
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTPanel.properties
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTPanel.properties 2008-07-22 05:30:04 UTC (rev 2083)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTPanel.properties 2008-07-22 05:30:54 UTC (rev 2084)
@@ -1,6 +1,6 @@
startButton.text=Start
stopButton.text=Stop
-restartButton.text=Load File
+restartButton.text=OK
jLabel1.text=Finished
jLabel3.text=Active
jLabel5.text=Failed
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTTransferParamPanel.properties
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTTransferParamPanel.properties 2008-07-22 05:30:04 UTC (rev 2083)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/resources/RFTTransferParamPanel.properties 2008-07-22 05:30:54 UTC (rev 2084)
@@ -1,14 +1,16 @@
# To change this template, choose Tools | Templates
# and open the template in the editor.
-Form.border.title=RFT Transfer Parameter
-jLabel1.text=Server Host
+Form.border.title=Reliable File Transfer Service (RFT) Parameters
+jLabel1.text=Service Host
serverHostField.text=
-jLabel2.text=Server Port
+jLabel2.text=Service Port
serverPortField.text=
jLabel3.text=From
fromField.text=
jLabel4.text=To
toField.text=
jLabel5.text=AuthType
-jLabel6.text=AuthzType
\ No newline at end of file
+jLabel6.text=AuthzType
+concurrencyLabel.text=Concurrency
+concurrencyField.text=
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-22 05:30:07
|
Revision: 2083
http://cogkit.svn.sourceforge.net/cogkit/?rev=2083&view=rev
Author: liuwt
Date: 2008-07-22 05:30:04 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/credential/myproxy/MyProxyLogon.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/credential/myproxy/MyProxyLogonGUI.java
Added Paths:
-----------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/credential/myproxy/
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/credential/myproxy/MyProxyLogon.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/myproxy/MyProxyLogon.java 2008-06-23 16:20:22 UTC (rev 2047)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/credential/myproxy/MyProxyLogon.java 2008-07-22 05:30:04 UTC (rev 2083)
@@ -37,7 +37,7 @@
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
*/
-package org.globus.transfer.reliable.client.myproxy;
+package org.globus.transfer.reliable.client.credential.myproxy;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/credential/myproxy/MyProxyLogonGUI.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/myproxy/MyProxyLogonGUI.java 2008-06-23 16:20:22 UTC (rev 2047)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/credential/myproxy/MyProxyLogonGUI.java 2008-07-22 05:30:04 UTC (rev 2083)
@@ -37,7 +37,7 @@
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
*/
-package org.globus.transfer.reliable.client.myproxy;
+package org.globus.transfer.reliable.client.credential.myproxy;
import java.awt.Component;
import java.awt.GridBagConstraints;
@@ -379,6 +379,7 @@
MyProxyLogonGUI gui = new MyProxyLogonGUI();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(gui);
+ frame.setLocation(50, 50);
frame.pack();
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
gui.passwordField.requestFocusInWindow();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-22 05:29:11
|
Revision: 2082
http://cogkit.svn.sourceforge.net/cogkit/?rev=2082&view=rev
Author: liuwt
Date: 2008-07-22 05:29:09 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
Removed Paths:
-------------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/myproxy/MyProxyLogon.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/myproxy/MyProxyLogonGUI.java
Deleted: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/myproxy/MyProxyLogon.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/myproxy/MyProxyLogon.java 2008-07-22 05:28:18 UTC (rev 2081)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/myproxy/MyProxyLogon.java 2008-07-22 05:29:09 UTC (rev 2082)
@@ -1,954 +0,0 @@
-/*
- * Copyright 2007 The Board of Trustees of the University of Illinois.
- * All rights reserved.
- *
- * Developed by:
- *
- * MyProxy Team
- * National Center for Supercomputing Applications
- * University of Illinois
- * http://myproxy.ncsa.uiuc.edu/
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal with the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimers.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimers in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the names of the National Center for Supercomputing
- * Applications, the University of Illinois, nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this Software without specific prior written permission.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
- */
-package org.globus.transfer.reliable.client.myproxy;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.EOFException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.net.InetAddress;
-import java.net.ProtocolException;
-import java.security.GeneralSecurityException;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.PrivateKey;
-import java.security.cert.CertPath;
-import java.security.cert.CertPathValidator;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.PKIXParameters;
-import java.security.cert.TrustAnchor;
-import java.security.cert.X509CRL;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-import javax.security.auth.login.FailedLoginException;
-import javax.security.auth.x500.X500Principal;
-
-import org.bouncycastle.asn1.ASN1InputStream;
-import org.bouncycastle.asn1.ASN1Sequence;
-import org.bouncycastle.asn1.DERObject;
-import org.bouncycastle.asn1.DEROutputStream;
-import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
-import org.bouncycastle.jce.PKCS10CertificationRequest;
-import org.bouncycastle.util.encoders.Base64;
-
-/**
- * The MyProxyLogon class provides an interface for retrieving credentials from
- * a MyProxy server.
- * <p>
- * First, use <code>setHost</code>, <code>setPort</code>,
- * <code>setUsername</code>, <code>setPassphrase</code>,
- * <code>setCredentialName</code>, <code>setLifetime</code> and
- * <code>requestTrustRoots</code> to configure. Then call <code>connect</code>,
- * <code>logon</code>, <code>getCredentials</code>, then
- * <code>disconnect</code>. Use <code>getCertificates</code> and
- * <code>getPrivateKey</code> to access the retrieved credentials, or
- * <code>writeProxyFile</code> or <code>saveCredentialsToFile</code> to
- * write them to a file. Use <code>writeTrustRoots</code>,
- * <code>getTrustedCAs</code>, <code>getCRLs</code>,
- * <code>getTrustRootData</code>, and <code>getTrustRootFilenames</code>
- * for trust root information.
- * @version 1.0
- * @see <a href="http://myproxy.ncsa.uiuc.edu/">MyProxy Project Home Page</a>
- */
-public class MyProxyLogon {
- static Logger logger = Logger.getLogger(MyProxyLogon.class.getName());
- public final static String version = "1.0";
- public final static String BouncyCastleLicense = org.bouncycastle.LICENSE.licenseText;
-
- protected enum State {
- READY, CONNECTED, LOGGEDON, DONE
- }
-
- private class MyTrustManager implements X509TrustManager {
- public X509Certificate[] getAcceptedIssuers() {
- X509Certificate[] issuers = null;
- String certDirPath = MyProxyLogon.getExistingTrustRootPath();
- if (certDirPath == null) {
- return null;
- }
- File dir = new File(certDirPath);
- if (!dir.isDirectory()) {
- return null;
- }
- String[] certFilenames = dir.list();
- String[] certData = new String[certFilenames.length];
- for (int i = 0; i < certFilenames.length; i++) {
- try {
- FileInputStream fileStream = new FileInputStream(
- certDirPath + File.separator + certFilenames[i]);
- byte[] buffer = new byte[fileStream.available()];
- fileStream.read(buffer);
- certData[i] = new String(buffer);
- } catch (Exception e) {
- // ignore
- }
- }
- try {
- issuers = getX509CertsFromStringList(certData, certFilenames);
- } catch (Exception e) {
- // ignore
- }
- return issuers;
- }
-
- public void checkClientTrusted(X509Certificate[] certs, String authType)
- throws CertificateException {
- throw new CertificateException(
- "checkClientTrusted not implemented by edu.uiuc.ncsa.MyProxy.MyProxyLogon.MyTrustManager");
- }
-
- public void checkServerTrusted(X509Certificate[] certs, String authType)
- throws CertificateException {
- checkServerCertPath(certs);
- checkServerDN(certs[0]);
- }
-
- private void checkServerCertPath(X509Certificate[] certs)
- throws CertificateException {
- try {
- CertPathValidator validator = CertPathValidator
- .getInstance(CertPathValidator.getDefaultType());
- CertificateFactory certFactory = CertificateFactory
- .getInstance("X.509");
- CertPath certPath = certFactory.generateCertPath(Arrays
- .asList(certs));
- X509Certificate[] acceptedIssuers = getAcceptedIssuers();
- if (acceptedIssuers == null) {
- String certDir = MyProxyLogon.getExistingTrustRootPath();
- if (certDir != null) {
- throw new CertificateException(
- "no CA certificates found in " + certDir);
- } else if (!requestTrustRoots) {
- throw new CertificateException(
- "no CA certificates directory found");
- }
- logger
- .info("no trusted CAs configured -- bootstrapping trust from MyProxy server");
- acceptedIssuers = new X509Certificate[1];
- acceptedIssuers[0] = certs[certs.length - 1];
- }
- Set<TrustAnchor> trustAnchors = new HashSet<TrustAnchor>(
- acceptedIssuers.length);
- for (int i = 0; i < acceptedIssuers.length; i++) {
- TrustAnchor ta = new TrustAnchor(acceptedIssuers[i], null);
- trustAnchors.add(ta);
- }
- PKIXParameters pkixParameters = new PKIXParameters(trustAnchors);
- pkixParameters.setRevocationEnabled(false);
- validator.validate(certPath, pkixParameters);
- } catch (CertificateException e) {
- throw e;
- } catch (GeneralSecurityException e) {
- throw new CertificateException(e);
- }
- }
-
- private void checkServerDN(X509Certificate cert)
- throws CertificateException {
- String subject = cert.getSubjectX500Principal().getName();
- logger.fine("MyProxy server DN: " + subject);
- int index = subject.indexOf("CN=");
- if (index == -1) {
- throw new CertificateException("Server certificate subject ("
- + subject + "does not contain a CN component.");
- }
- String CN = subject.substring(index + 3);
- index = CN.indexOf(',');
- if (index >= 0) {
- CN = CN.substring(0, index);
- }
- if ((index = CN.indexOf('/')) >= 0) {
- String service = CN.substring(0, index);
- CN = CN.substring(index + 1);
- if (!service.equals("host") && !service.equals("myproxy")) {
- throw new CertificateException(
- "Server certificate subject CN contains unknown service element: "
- + subject);
- }
- }
- String myHostname = host;
- if (myHostname.equals("localhost")) {
- try {
- myHostname = InetAddress.getLocalHost().getHostName();
- } catch (Exception e) {
- // ignore
- }
- }
- if (!CN.equals(myHostname)) {
- throw new CertificateException(
- "Server certificate subject CN (" + CN
- + ") does not match server hostname (" + host
- + ").");
- }
- }
- }
-
- private final static int b64linelen = 64;
- private final static String X509_USER_PROXY_FILE = "x509up_u";
- private final static String VERSION = "VERSION=MYPROXYv2";
- private final static String GETCOMMAND = "COMMAND=0";
- private final static String TRUSTROOTS = "TRUSTED_CERTS=";
- private final static String USERNAME = "USERNAME=";
- private final static String PASSPHRASE = "PASSPHRASE=";
- private final static String LIFETIME = "LIFETIME=";
- private final static String CREDNAME = "CRED_NAME=";
- private final static String RESPONSE = "RESPONSE=";
- private final static String ERROR = "ERROR=";
- private final static String DN = "CN=ignore";
- private final static String TRUSTED_CERT_PATH = "/.globus/certificates";
-
- protected final static int keySize = 1024;
- protected final int MIN_PASS_PHRASE_LEN = 6;
- protected final static String keyAlg = "RSA";
- protected final static String pkcs10SigAlgName = "SHA1withRSA";
- protected final static String pkcs10Provider = "SunRsaSign";
- protected State state = State.READY;
- protected String host = "localhost";
- protected String username;
- protected String credname;
- protected String passphrase;
- protected int port = 7512;
- protected int lifetime = 43200;
- protected boolean requestTrustRoots = false;
- protected SSLSocket socket;
- protected BufferedInputStream socketIn;
- protected BufferedOutputStream socketOut;
- protected KeyPair keypair;
- protected Collection certificateChain;
- protected String[] trustrootFilenames;
- protected String[] trustrootData;
-
- /**
- * Constructs a MyProxyLogon object.
- */
- public MyProxyLogon() {
- super();
- host = System.getenv("MYPROXY_SERVER");
- if (host == null) {
- host = "localhost";
- }
- String portString = System.getenv("MYPROXY_SERVER_PORT");
- if (portString != null) {
- port = Integer.parseInt(portString);
- }
- username = System.getProperty("user.name");
- }
-
- /**
- * Gets the hostname of the MyProxy server.
- * @return MyProxy server hostname
- */
- public String getHost() {
- return this.host;
- }
-
- /**
- * Sets the hostname of the MyProxy server. Defaults to localhost.
- * @param host
- * MyProxy server hostname
- */
- public void setHost(String host) {
- this.host = host;
- }
-
- /**
- * Gets the port of the MyProxy server.
- * @return MyProxy server port
- */
- public int getPort() {
- return this.port;
- }
-
- /**
- * Sets the port of the MyProxy server. Defaults to 7512.
- * @param port
- * MyProxy server port
- */
- public void setPort(int port) {
- this.port = port;
- }
-
- /**
- * Gets the MyProxy username.
- * @return MyProxy server port
- */
- public String getUsername() {
- return this.username;
- }
-
- /**
- * Sets the MyProxy username. Defaults to user.name.
- * @param username
- * MyProxy username
- */
- public void setUsername(String username) {
- this.username = username;
- }
-
- /**
- * Gets the optional MyProxy credential name.
- * @return credential name
- */
- public String getCredentialName() {
- return this.credname;
- }
-
- /**
- * Sets the optional MyProxy credential name.
- * @param credname
- * credential name
- */
- public void setCredentialName(String credname) {
- this.credname = credname;
- }
-
- /**
- * Sets the MyProxy passphrase.
- * @param passphrase
- * MyProxy passphrase
- */
- public void setPassphrase(String passphrase) {
- this.passphrase = passphrase;
- }
-
- /**
- * Gets the requested credential lifetime.
- * @return Credential lifetime
- */
- public int getLifetime() {
- return this.lifetime;
- }
-
- /**
- * Sets the requested credential lifetime. Defaults to 43200 seconds (12
- * hours).
- * @param seconds
- * Credential lifetime
- */
- public void setLifetime(int seconds) {
- this.lifetime = seconds;
- }
-
- /**
- * Gets the certificates returned from the MyProxy server by
- * getCredentials().
- * @return Collection of java.security.cert.Certificate objects
- */
- public Collection getCertificates() {
- return this.certificateChain;
- }
-
- /**
- * Gets the private key generated by getCredentials().
- * @return PrivateKey
- */
- public PrivateKey getPrivateKey() {
- return this.keypair.getPrivate();
- }
-
- /**
- * Sets whether to request trust roots (CA certificates, CRLs, signing
- * policy files) from the MyProxy server. Defaults to false (i.e., not
- * to request trust roots).
- * @param flag
- * If true, request trust roots. If false, don't request trust
- * roots.
- */
- public void requestTrustRoots(boolean flag) {
- this.requestTrustRoots = flag;
- }
-
- /**
- * Gets trust root filenames.
- * @return trust root filenames
- */
- public String[] getTrustRootFilenames() {
- return this.trustrootFilenames;
- }
-
- /**
- * Gets trust root data corresponding to the trust root filenames.
- * @return trust root data
- */
- public String[] getTrustRootData() {
- return this.trustrootData;
- }
-
- /**
- * Connects to the MyProxy server at the desired host and port. Requires
- * host authentication via SSL. The host's certificate subject must
- * match the requested hostname. If CA certificates are found in the
- * standard GSI locations, they will be used to verify the server's
- * certificate. If trust roots are requested and no CA certificates are
- * found, the server's certificate will still be accepted.
- */
- public void connect() throws IOException, GeneralSecurityException {
- SSLContext sc = SSLContext.getInstance("SSL");
- TrustManager[] trustAllCerts = new TrustManager[] { new MyTrustManager() };
- sc.init(null, trustAllCerts, new java.security.SecureRandom());
- SSLSocketFactory sf = sc.getSocketFactory();
- this.socket = (SSLSocket) sf.createSocket(this.host, this.port);
- this.socket.setEnabledProtocols(new String[] { "SSLv3" });
- this.socket.startHandshake();
- this.socketIn = new BufferedInputStream(this.socket.getInputStream());
- this.socketOut = new BufferedOutputStream(this.socket.getOutputStream());
- this.state = State.CONNECTED;
- }
-
- /**
- * Disconnects from the MyProxy server.
- */
- public void disconnect() throws IOException {
- this.socket.close();
- this.socket = null;
- this.socketIn = null;
- this.socketOut = null;
- this.state = State.READY;
- }
-
- /**
- * Logs on to the MyProxy server by issuing the MyProxy GET command.
- */
- public void logon() throws IOException, GeneralSecurityException {
- String line;
- char response;
-
- if (this.state != State.CONNECTED) {
- this.connect();
- }
-
- this.socketOut.write('0');
- this.socketOut.flush();
- this.socketOut.write(VERSION.getBytes());
- this.socketOut.write('\n');
- this.socketOut.write(GETCOMMAND.getBytes());
- this.socketOut.write('\n');
- this.socketOut.write(USERNAME.getBytes());
- this.socketOut.write(this.username.getBytes());
- this.socketOut.write('\n');
- this.socketOut.write(PASSPHRASE.getBytes());
- this.socketOut.write(this.passphrase.getBytes());
- this.socketOut.write('\n');
- this.socketOut.write(LIFETIME.getBytes());
- this.socketOut.write(Integer.toString(this.lifetime).getBytes());
- this.socketOut.write('\n');
- if (this.credname != null) {
- this.socketOut.write(CREDNAME.getBytes());
- this.socketOut.write(this.credname.getBytes());
- this.socketOut.write('\n');
- }
- if (this.requestTrustRoots) {
- this.socketOut.write(TRUSTROOTS.getBytes());
- this.socketOut.write("1\n".getBytes());
- }
- this.socketOut.flush();
-
- line = readLine(this.socketIn);
- if (line == null) {
- throw new EOFException();
- }
- if (!line.equals(VERSION)) {
- throw new ProtocolException("bad MyProxy protocol VERSION string: "
- + line);
- }
- line = readLine(this.socketIn);
- if (line == null) {
- throw new EOFException();
- }
- if (!line.startsWith(RESPONSE)
- || line.length() != RESPONSE.length() + 1) {
- throw new ProtocolException(
- "bad MyProxy protocol RESPONSE string: " + line);
- }
- response = line.charAt(RESPONSE.length());
- if (response == '1') {
- StringBuffer errString;
-
- errString = new StringBuffer("MyProxy logon failed");
- while ((line = readLine(this.socketIn)) != null) {
- if (line.startsWith(ERROR)) {
- errString.append('\n');
- errString.append(line.substring(ERROR.length()));
- }
- }
- throw new FailedLoginException(errString.toString());
- } else if (response == '2') {
- throw new ProtocolException(
- "MyProxy authorization RESPONSE not implemented");
- } else if (response != '0') {
- throw new ProtocolException(
- "unknown MyProxy protocol RESPONSE string: " + line);
- }
- while ((line = readLine(this.socketIn)) != null) {
- if (line.startsWith(TRUSTROOTS)) {
- String filenameList = line.substring(TRUSTROOTS.length());
- this.trustrootFilenames = filenameList.split(",");
- this.trustrootData = new String[this.trustrootFilenames.length];
- for (int i = 0; i < this.trustrootFilenames.length; i++) {
- String lineStart = "FILEDATA_" + this.trustrootFilenames[i]
- + "=";
- line = readLine(this.socketIn);
- if (line == null) {
- throw new EOFException();
- }
- if (!line.startsWith(lineStart)) {
- throw new ProtocolException(
- "bad MyProxy protocol RESPONSE: expecting "
- + lineStart + " but received " + line);
- }
- this.trustrootData[i] = new String(Base64.decode(line
- .substring(lineStart.length())));
- }
- }
- }
- this.state = State.LOGGEDON;
- }
-
- /**
- * Retrieves credentials from the MyProxy server.
- */
- public void getCredentials() throws IOException, GeneralSecurityException {
- int numCertificates;
- KeyPairGenerator keyGenerator;
- PKCS10CertificationRequest pkcs10;
- CertificateFactory certFactory;
-
- if (this.state != State.LOGGEDON) {
- this.logon();
- }
-
- keyGenerator = KeyPairGenerator.getInstance(keyAlg);
- keyGenerator.initialize(keySize);
- this.keypair = keyGenerator.genKeyPair();
- pkcs10 = new PKCS10CertificationRequest(pkcs10SigAlgName,
- new X500Principal(DN), this.keypair.getPublic(), null,
- this.keypair.getPrivate(), pkcs10Provider);
- this.socketOut.write(pkcs10.getEncoded());
- this.socketOut.flush();
- numCertificates = this.socketIn.read();
- if (numCertificates == -1) {
- System.err.println("connection aborted");
- System.exit(1);
- } else if (numCertificates == 0 || numCertificates < 0) {
- System.err.print("bad number of certificates sent by server: ");
- System.err.println(Integer.toString(numCertificates));
- System.exit(1);
- }
- certFactory = CertificateFactory.getInstance("X.509");
- this.certificateChain = certFactory.generateCertificates(this.socketIn);
- this.state = State.DONE;
- }
-
- /**
- * Writes the retrieved credentials to the Globus proxy file location.
- */
- public void writeProxyFile() throws IOException, GeneralSecurityException {
- saveCredentialsToFile(getProxyLocation());
- }
-
- /**
- * Writes the retrieved credentials to the specified filename.
- */
- public void saveCredentialsToFile(String filename) throws IOException,
- GeneralSecurityException {
- Iterator iter;
- X509Certificate certificate;
- PrintStream printStream;
-
- iter = this.certificateChain.iterator();
- certificate = (X509Certificate) iter.next();
- File outFile = new File(filename);
- outFile.delete();
- outFile.createNewFile();
- setFilePermissions(filename, "0600");
- printStream = new PrintStream(new FileOutputStream(outFile));
- printCert(certificate, printStream);
- printKey(keypair.getPrivate(), printStream);
- while (iter.hasNext()) {
- certificate = (X509Certificate) iter.next();
- printCert(certificate, printStream);
- }
- }
-
- /**
- * Writes the retrieved trust roots to the Globus trusted certificates
- * directory.
- * @return true if trust roots are written successfully, false if no
- * trust roots are available to be written
- */
- public boolean writeTrustRoots() throws IOException {
- return writeTrustRoots(getTrustRootPath());
- }
-
- /**
- * Writes the retrieved trust roots to a trusted certificates directory.
- * @param directory
- * path where the trust roots should be written
- * @return true if trust roots are written successfully, false if no
- * trust roots are available to be written
- */
- public boolean writeTrustRoots(String directory) throws IOException {
- if (this.trustrootFilenames == null || this.trustrootData == null) {
- return false;
- }
- File rootDir = new File(directory);
- if (!rootDir.exists()) {
- rootDir.mkdirs();
- }
- for (int i = 0; i < trustrootFilenames.length; i++) {
- FileOutputStream out = new FileOutputStream(directory
- + File.separator + this.trustrootFilenames[i]);
- out.write(this.trustrootData[i].getBytes());
- out.close();
- }
- return true;
- }
-
- /**
- * Gets the trusted CA certificates returned by the MyProxy server.
- * @return trusted CA certificates, or null if none available
- */
- public X509Certificate[] getTrustedCAs() throws CertificateException {
- if (trustrootData == null)
- return null;
- return getX509CertsFromStringList(trustrootData, trustrootFilenames);
- }
-
- private static X509Certificate[] getX509CertsFromStringList(
- String[] certList, String[] nameList) throws CertificateException {
- CertificateFactory certFactory = CertificateFactory
- .getInstance("X.509");
- Collection<X509Certificate> c = new ArrayList<X509Certificate>(
- certList.length);
- for (int i = 0; i < certList.length; i++) {
- int index = -1;
- String certData = certList[i];
- if (certData != null) {
- index = certData.indexOf("-----BEGIN CERTIFICATE-----");
- }
- if (index >= 0) {
- certData = certData.substring(index);
- ByteArrayInputStream inputStream = new ByteArrayInputStream(
- certData.getBytes());
- try {
- X509Certificate cert = (X509Certificate) certFactory
- .generateCertificate(inputStream);
- c.add(cert);
- } catch (Exception e) {
- if (nameList != null) {
- logger.warning(nameList[i]
- + " can not be parsed as an X509Certificate.");
- } else {
- logger.warning("failed to parse an X509Certificate");
- }
- }
- }
- }
- if (c.isEmpty())
- return null;
- return c.toArray(new X509Certificate[0]);
- }
-
- /**
- * Gets the CRLs returned by the MyProxy server.
- * @return CRLs or null if none available
- */
- public X509CRL[] getCRLs() throws CertificateException {
- if (trustrootData == null)
- return null;
- CertificateFactory certFactory = CertificateFactory
- .getInstance("X.509");
- Collection<X509CRL> c = new ArrayList<X509CRL>(trustrootData.length);
- for (int i = 0; i < trustrootData.length; i++) {
- String crlData = trustrootData[i];
- int index = crlData.indexOf("-----BEGIN X509 CRL-----");
- if (index >= 0) {
- crlData = crlData.substring(index);
- ByteArrayInputStream inputStream = new ByteArrayInputStream(
- crlData.getBytes());
- try {
- X509CRL crl = (X509CRL) certFactory
- .generateCRL(inputStream);
- c.add(crl);
- } catch (Exception e) {
- logger.warning(this.trustrootFilenames[i]
- + " can not be parsed as an X509CRL.");
- }
- }
- }
- if (c.isEmpty())
- return null;
- return c.toArray(new X509CRL[0]);
- }
-
- /**
- * Returns the trusted certificates directory location where
- * writeTrustRoots() will store certificates.
- */
- public static String getTrustRootPath() {
- String path;
-
- path = System.getenv("X509_CERT_DIR");
- if (path == null) {
- path = System.getProperty("X509_CERT_DIR");
- }
- if (path == null) {
- path = System.getProperty("user.home") + TRUSTED_CERT_PATH;
- }
- return path;
- }
-
- /**
- * Gets the existing trusted CA certificates directory.
- * @return directory path string or null if none found
- */
- public static String getExistingTrustRootPath() {
- String path, GL;
-
- GL = System.getenv("GLOBUS_LOCATION");
- if (GL == null) {
- GL = System.getProperty("GLOBUS_LOCATION");
- }
-
- path = System.getenv("X509_CERT_DIR");
- if (path == null) {
- path = System.getProperty("X509_CERT_DIR");
- }
- if (path == null) {
- path = getDir(System.getProperty("user.home") + TRUSTED_CERT_PATH);
- }
- if (path == null) {
- path = getDir("/etc/grid-security/certificates");
- }
- if (path == null) {
- path = getDir(GL + File.separator + "share" + File.separator
- + "certificates");
- }
-
- return path;
- }
-
- /**
- * Returns the default Globus proxy file location.
- */
- public static String getProxyLocation() throws IOException {
- String loc, suffix = null;
- Process proc;
- BufferedReader bufferedReader;
-
- loc = System.getenv("X509_USER_PROXY");
- if (loc == null) {
- loc = System.getProperty("X509_USER_PROXY");
- }
- if (loc != null) {
- return loc;
- }
-
- try {
- proc = Runtime.getRuntime().exec("id -u");
- bufferedReader = new BufferedReader(new InputStreamReader(proc
- .getInputStream()));
- suffix = bufferedReader.readLine();
- } catch (IOException e) {
- // will fail on windows
- }
-
- if (suffix == null) {
- suffix = System.getProperty("user.name");
- if (suffix != null) {
- suffix = suffix.toLowerCase();
- } else {
- suffix = "nousername";
- }
- }
- String tmpdir = System.getProperty("java.io.tmpdir");
- if (!tmpdir.endsWith(File.separator)) {
- tmpdir += File.separator;
- }
- System.out.println("location");
- return tmpdir + X509_USER_PROXY_FILE + suffix;
- }
-
- /**
- * Provides a simple command-line interface.
- */
- public static void main(String[] args) {
- try {
- MyProxyLogon m = new MyProxyLogon();
- // Console cons = System.console();
- String passphrase = null;
- X509Certificate[] CAcerts;
- X509CRL[] CRLs;
- MyProxyLogon.logger.setLevel(Level.ALL);
-
- // if (cons != null) {
- // char[] pass = cons.readPassword("[%s]", "MyProxy Passphrase:
- // ");
- // if (pass != null) {
- // passphrase = new String(pass);
- // }
- // } else {
- System.out
- .println("Warning: terminal will echo passphrase as you type.");
- System.out.print("MyProxy Passphrase: ");
- passphrase = readLine(System.in);
- // }
- if (passphrase == null) {
- System.err.println("Error reading passphrase.");
- System.exit(1);
- }
- m.setPassphrase(passphrase);
- m.requestTrustRoots(true);
- m.getCredentials();
- m.writeProxyFile();
- System.out.println("Credential written successfully.");
- CAcerts = m.getTrustedCAs();
- if (CAcerts != null) {
- System.out.println(Integer.toString(CAcerts.length)
- + " CA certificates received.");
- }
- CRLs = m.getCRLs();
- if (CRLs != null) {
- System.out.println(Integer.toString(CRLs.length)
- + " CRLs received.");
- }
- if (m.writeTrustRoots()) {
- System.out.println("Wrote trust roots to "
- + MyProxyLogon.getTrustRootPath() + ".");
- } else {
- System.out
- .println("Received no trust roots from MyProxy server.");
- }
- } catch (Exception e) {
- e.printStackTrace(System.err);
- }
- }
-
- private static void printB64(byte[] data, PrintStream out) {
- byte[] b64data;
-
- b64data = Base64.encode(data);
- for (int i = 0; i < b64data.length; i += b64linelen) {
- if ((b64data.length - i) > b64linelen) {
- out.write(b64data, i, b64linelen);
- } else {
- out.write(b64data, i, b64data.length - i);
- }
- out.println();
- }
- }
-
- private static void printCert(X509Certificate certificate, PrintStream out)
- throws CertificateEncodingException {
- out.println("-----BEGIN CERTIFICATE-----");
- printB64(certificate.getEncoded(), out);
- out.println("-----END CERTIFICATE-----");
- }
-
- private static void printKey(PrivateKey key, PrintStream out)
- throws IOException {
- out.println("-----BEGIN RSA PRIVATE KEY-----");
- ByteArrayInputStream inStream = new ByteArrayInputStream(key
- .getEncoded());
- ASN1InputStream derInputStream = new ASN1InputStream(inStream);
- DERObject keyInfo = derInputStream.readObject();
- PrivateKeyInfo pkey = new PrivateKeyInfo((ASN1Sequence) keyInfo);
- DERObject derKey = pkey.getPrivateKey();
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DEROutputStream der = new DEROutputStream(bout);
- der.writeObject(derKey);
- printB64(bout.toByteArray(), out);
- out.println("-----END RSA PRIVATE KEY-----");
- }
-
- private static void setFilePermissions(String file, String mode) {
- String command = "chmod " + mode + " " + file;
- try {
- Runtime.getRuntime().exec(command);
- } catch (IOException e) {
- logger.warning("Failed to run: " + command); // windows
- }
- }
-
- private static String readLine(InputStream is) throws IOException {
- StringBuffer sb = new StringBuffer();
- for (int c = is.read(); c > 0 && c != '\n'; c = is.read()) {
- sb.append((char) c);
- }
- if (sb.length() > 0) {
- return new String(sb);
- }
- return null;
- }
-
- private static String getDir(String path) {
- if (path == null)
- return null;
- File f = new File(path);
- if (f.isDirectory() && f.canRead()) {
- return f.getAbsolutePath();
- }
- return null;
- }
-}
Deleted: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/myproxy/MyProxyLogonGUI.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/myproxy/MyProxyLogonGUI.java 2008-07-22 05:28:18 UTC (rev 2081)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/myproxy/MyProxyLogonGUI.java 2008-07-22 05:29:09 UTC (rev 2082)
@@ -1,477 +0,0 @@
-/*
- * Copyright 2007 The Board of Trustees of the University of Illinois.
- * All rights reserved.
- *
- * Developed by:
- *
- * MyProxy Team
- * National Center for Supercomputing Applications
- * University of Illinois
- * http://myproxy.ncsa.uiuc.edu/
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal with the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimers.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimers in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the names of the National Center for Supercomputing
- * Applications, the University of Illinois, nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this Software without specific prior written permission.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
- */
-package org.globus.transfer.reliable.client.myproxy;
-
-import java.awt.Component;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Properties;
-
-import javax.swing.AbstractButton;
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JPasswordField;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-import javax.swing.SwingUtilities;
-import javax.swing.WindowConstants;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.globus.transfer.reliable.client.utils.LogFileUtils;
-
-/**
- * The MyProxyLogonGUI class provides a Swing user interface to
- * {@link MyProxyLogon}.
- * @version 1.0
- */
-public class MyProxyLogonGUI extends JPanel implements ActionListener {
- private static final long serialVersionUID = 1L;
- static Log logger = LogFactory.getLog(MyProxyLogonGUI.class.getName());
- public final static String version = "1.0";
-
- protected MyProxyLogon myproxy;
-
- protected Properties properties;
- protected static final String PROPERTIES_PATH = "/.MyProxyLogon";
-
- protected JTextField usernameField;
- protected JLabel usernameFieldLabel;
- protected static final String usernameFieldString = "Username";
- protected static final String usernameFieldProperty = "Username";
-
- protected JPasswordField passwordField;
- protected JLabel passwordFieldLabel;
- protected static final String passwordFieldString = "Passphrase";
- protected static final String passwordFieldProperty = "Passphrase";
- protected static final String passwordInfoString = "Enter passphrase to logon.\n";
-
- protected JTextField crednameField;
- protected JLabel crednameFieldLabel;
- protected static final String crednameFieldString = "Credential Name";
- protected static final String crednameFieldProperty = "CredentialName";
-
- protected JTextField lifetimeField;
- protected JLabel lifetimeFieldLabel;
- protected static final String lifetimeFieldString = "Lifetime (hours)";
- protected static final String lifetimeFieldProperty = "Lifetime";
-
- protected JTextField hostnameField;
- protected JLabel hostnameFieldLabel;
- protected static final String hostnameFieldString = "Hostname";
- protected static final String hostnameFieldProperty = "Hostname";
-
- protected JTextField portField;
- protected JLabel portFieldLabel;
- protected static final String portFieldString = "Port";
- protected static final String portFieldProperty = "Port";
-
- protected JTextField outputField;
- protected JLabel outputFieldLabel;
- protected static final String outputFieldString = "Output";
- protected static final String outputFieldProperty = "Output";
-
- protected JCheckBox trustRootsCheckBox;
- protected static final String trustRootsProperty = "TrustRoots";
- protected static final String trustRootsPropertyYes = "yes";
- protected static final String trustRootsPropertyNo = "no";
-
- protected JButton button;
- protected static final String buttonFieldString = "Logon";
-
- protected JTextArea statusTextArea;
- protected JScrollPane statusScrollPane;
-
- /**
- * Constructs a MyProxyLogonGUI object.
- */
- public MyProxyLogonGUI() {
- myproxy = new MyProxyLogon();
-
- loadProperties();
-
- GridBagLayout gridbag = new GridBagLayout();
- GridBagConstraints c = new GridBagConstraints();
- setLayout(gridbag);
- setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
- usernameField = createField(usernameFieldString, properties
- .getProperty(usernameFieldProperty, myproxy.getUsername()));
- usernameFieldLabel = createLabel(usernameFieldString, usernameField);
- usernameField.setToolTipText("Enter your MyProxy username.");
-
- passwordField = new JPasswordField(10);
- passwordField.setActionCommand(passwordFieldString);
- passwordField.addActionListener(this);
- passwordFieldLabel = createLabel(passwordFieldString, passwordField);
- passwordField.setToolTipText("Enter your MyProxy passphrase.");
-
- crednameField = createField(crednameFieldString,
- properties.getProperty(crednameFieldProperty, myproxy
- .getCredentialName()));
- crednameFieldLabel = createLabel(crednameFieldString, hostnameField);
- crednameField
- .setToolTipText("Optionally enter your MyProxy credential name. Leave blank to use your default credential.");
-
- lifetimeField = createField(lifetimeFieldString, properties
- .getProperty(lifetimeFieldProperty, Integer.toString(myproxy
- .getLifetime() / 3600)));
- lifetimeFieldLabel = createLabel(lifetimeFieldString, lifetimeField);
- lifetimeField
- .setToolTipText("Enter the number of hours for your requested credentials to be valid.");
-
- hostnameField = createField(hostnameFieldString, properties
- .getProperty(hostnameFieldProperty, myproxy.getHost()));
- hostnameFieldLabel = createLabel(hostnameFieldString, hostnameField);
- hostnameField
- .setToolTipText("Enter the hostname of your MyProxy server (for example: myproxy.ncsa.uiuc.edu).");
-
- portField = createField(portFieldString, properties.getProperty(
- portFieldProperty, Integer.toString(myproxy.getPort())));
- portFieldLabel = createLabel(portFieldString, portField);
- portField
- .setToolTipText("Enter the TCP port of your MyProxy server (usually 7512).");
-
- String trustRootPath = MyProxyLogon.getTrustRootPath();
- String existingTrustRootPath = MyProxyLogon.getExistingTrustRootPath();
- trustRootsCheckBox = new JCheckBox("Write trust roots to "
- + trustRootPath + ".");
- String trustRootsPropVal = properties.getProperty(trustRootsProperty);
- if (trustRootsPropVal != null
- && trustRootsPropVal.equals(trustRootsPropertyYes)) {
- trustRootsCheckBox.setSelected(true);
- } else if (trustRootsPropVal != null
- && trustRootsPropVal.equals(trustRootsPropertyNo)) {
- trustRootsCheckBox.setSelected(false);
- } else if (existingTrustRootPath == null
- || trustRootPath.equals(existingTrustRootPath)) {
- trustRootsCheckBox.setSelected(true);
- } else {
- trustRootsCheckBox.setSelected(false);
- }
- trustRootsCheckBox
- .setToolTipText("Check this box to download the latest CA certificates, certificate revocation lists, and CA signing policy files from MyProxy.");
-
- String proxyLoc;
- try {
- proxyLoc = MyProxyLogon.getProxyLocation();
- } catch (Exception e) {
- proxyLoc = "";
- }
- outputField = createField(outputFieldString, properties.getProperty(
- outputFieldProperty, proxyLoc));
- outputFieldLabel = createLabel(outputFieldString, outputField);
- outputField
- .setToolTipText("Enter the path to store your credential from MyProxy. Leave blank if you don't want to retrieve a credential.");
-
- JLabel[] labels = { usernameFieldLabel, passwordFieldLabel,
- crednameFieldLabel, lifetimeFieldLabel, hostnameFieldLabel,
- portFieldLabel, outputFieldLabel };
- JTextField[] textFields = { usernameField, passwordField,
- crednameField, lifetimeField, hostnameField, portField,
- outputField };
- int numLabels = labels.length;
-
- c.anchor = GridBagConstraints.LINE_END;
- for (int i = 0; i < numLabels; i++) {
- c.gridwidth = GridBagConstraints.RELATIVE;
- c.fill = GridBagConstraints.NONE;
- c.weightx = 0.0;
- add(labels[i], c);
-
- c.gridwidth = GridBagConstraints.REMAINDER;
- c.fill = GridBagConstraints.HORIZONTAL;
- c.weightx = 1.0;
- add(textFields[i], c);
- }
-
- button = new JButton(buttonFieldString);
- button.setActionCommand(buttonFieldString);
- button.addActionListener(this);
- button.setVerticalTextPosition(AbstractButton.CENTER);
- button.setHorizontalTextPosition(AbstractButton.CENTER);
- button.setToolTipText("Press this button to logon to MyProxy.");
-
- statusTextArea = new JTextArea(4, 10);
- statusTextArea.setEditable(false);
- statusTextArea.setLineWrap(true);
- statusTextArea.setWrapStyleWord(true);
- statusScrollPane = new JScrollPane(statusTextArea);
- statusTextArea.setText(passwordInfoString);
- statusTextArea.setToolTipText("This area contains status messages.");
-
- c.gridwidth = GridBagConstraints.REMAINDER; // last
- c.fill = GridBagConstraints.HORIZONTAL;
- c.weightx = 1.0;
- add(trustRootsCheckBox, c);
- add(button, c);
- add(statusScrollPane, c);
- }
-
- /**
- * Handles GUI events.
- */
- public void actionPerformed(ActionEvent e) {
- if (verifyInput()) {
- if (passwordFieldString.equals(e.getActionCommand())
- || buttonFieldString.equals(e.getActionCommand())) {
- logon();
- }
- }
- }
-
- /**
- * Calls createAndShowGUI().
- */
- public static void main(String[] args) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- createAndShowGUI();
- }
- });
- }
-
- protected void logon() {
- try {
- myproxy.setUsername(usernameField.getText());
- myproxy.setPassphrase(new String(passwordField.getPassword()));
- if (crednameField.getText().length() > 0) {
- myproxy.setCredentialName(crednameField.getText());
- }
- myproxy
- .setLifetime(Integer.parseInt(lifetimeField.getText()) * 3600);
- myproxy.setHost(hostnameField.getText());
- myproxy.setPort(Integer.parseInt(portField.getText()));
- myproxy.requestTrustRoots(trustRootsCheckBox.isSelected());
- statusTextArea.setText("Connecting to " + myproxy.getHost()
- + "...\n");
- myproxy.connect();
- statusTextArea.setText("Logging on...\n");
- myproxy.logon();
- if (outputField.getText().length() == 0) {
- statusTextArea.setText("Logon successful.\n");
- } else {
- statusTextArea.setText("Getting credentials...\n");
- myproxy.getCredentials();
- statusTextArea.setText("Writing credentials...\n");
- myproxy.saveCredentialsToFile(outputField.getText());
- statusTextArea.setText("Credentials written to "
- + outputField.getText() + ".\n");
- }
- if (trustRootsCheckBox.isSelected() && myproxy.writeTrustRoots()) {
- statusTextArea.append("Trust roots written to "
- + MyProxyLogon.getTrustRootPath() + ".\n");
- }
- saveProperties();
- } catch (Exception exception) {
- logger.debug(exception.getMessage(), exception);
- statusTextArea.append("Error: " + exception.getMessage());
- } finally {
- try {
- myproxy.disconnect();
- } catch (Exception e2) {
- }
- }
- }
-
- protected void saveProperties() {
- try {
- FileOutputStream out = new FileOutputStream(System
- .getProperty("user.home")
- + PROPERTIES_PATH);
- properties.setProperty(usernameFieldProperty, usernameField
- .getText());
- properties.setProperty(crednameFieldProperty, crednameField
- .getText());
- properties.setProperty(lifetimeFieldProperty, lifetimeField
- .getText());
- properties.setProperty(hostnameFieldProperty, hostnameField
- .getText());
- properties.setProperty(portFieldProperty, portField.getText());
- properties.setProperty(outputFieldProperty, outputField.getText());
- properties.setProperty(trustRootsProperty, trustRootsCheckBox
- .isSelected() ? trustRootsPropertyYes
- : trustRootsPropertyNo);
- properties.store(out, MyProxyLogonGUI.class.getName());
- } catch (FileNotFoundException e) {
- logger.debug(e.getMessage(), e);
- e.printStackTrace();
- } catch (IOException e) {
- logger.debug(e.getMessage(), e);
- e.printStackTrace();
- }
- }
-
- protected void loadProperties() {
- try {
- properties = new Properties();
- FileInputStream in = new FileInputStream(System
- .getProperty("user.home")
- + PROPERTIES_PATH);
- properties.load(in);
- } catch (FileNotFoundException e) {
- // ok, nothing to load
- } catch (IOException e) {
- logger.debug(e.getMessage(), e);
- e.printStackTrace();
- }
- }
-
- /**
- * Create the GUI and show it. For thread safety, this method should be
- * invoked from the event dispatch thread.
- */
- public static void createAndShowGUI() {
- final JFrame frame = new JFrame("MyProxyLogon " + version);
- MyProxyLogonGUI gui = new MyProxyLogonGUI();
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.add(gui);
- frame.pack();
- frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- gui.passwordField.requestFocusInWindow();
- frame.addWindowListener(new WindowAdapter()
- {
- public void windowClosing(WindowEvent e) {
- frame.dispose();
- }
- });
-
- frame.setVisible(true);
- }
-
- private JTextField createField(String fieldString, String text) {
- JTextField field = new JTextField(10);
- field.setActionCommand(fieldString);
- field.addActionListener(this);
- if (text != null) {
- field.setText(text);
- field.setColumns(text.length());
- }
- return field;
- }
-
- private JLabel createLabel(String fieldString, Component c) {
- JLabel label = new JLabel(fieldString + ": ");
- label.setLabelFor(c);
- return label;
- }
-
- private boolean verifyInput() {
- boolean valid = true;
- StringBuffer infoString = new StringBuffer();
- if (usernameField.getText().length() == 0) {
- valid = false;
- infoString.append("Please specify a username.\n");
- }
- if (passwordField.getPassword().length == 0) {
- valid = false;
- infoString.append(passwordInfoString);
- } else if (passwordField.getPassword().length < myproxy.MIN_PASS_PHRASE_LEN) {
- valid = false;
- infoString.append("Passphrase must be at least ");
- infoString.append(Integer.toString(myproxy.MIN_PASS_PHRASE_LEN));
- infoString.append(" characters in length.\n");
- }
- if (lifetimeField.getText().length() == 0) {
- lifetimeField.setText(Integer
- .toString(myproxy.getLifetime() / 3600));
- }
- try {
- Integer.parseInt(lifetimeField.getText());
- } catch (NumberFormatException e) {
- logger.debug(e.getMessage(), e);
- valid = false;
- infoString.append("Lifetime is not a valid integer.\n");
- }
- if (hostnameField.getText().length() == 0) {
- valid = false;
- infoString.append("Please specify a MyProxy server hostname.\n");
- } else {
- try {
- InetAddress.getByName(hostnameField.getText());
- } catch (UnknownHostException e) {
- logger.debug(e.getMessage(), e);
- valid = false;
- infoString.append("Hostname \"");
- infoString.append(hostnameField.getText());
- infoString
- .append("\" is not valid. Please specify a valid MyProxy server hostname.\n");
- }
- }
- if (portField.getText().length() == 0) {
- portField.setText(Integer.toString(myproxy.getPort()));
- }
- try {
- Integer.parseInt(portField.getText());
- } catch (NumberFormatException e) {
- logger.debug(e.getMessage(), e);
- valid = false;
- infoString
- .append("Port is not a valid integer. Please specify a valid MyProxy server port (default: 7514).\n");
- }
- if (outputField.getText().length() > 0) {
- File f = new File(outputField.getText());
- if (f.exists() && !f.canWrite()) {
- valid = false;
- infoString.append(f.getPath());
- infoString
- .append(" exists and is not writable. Please specify a valid output file or specify no output path to only perform authentication.\n");
- }
- }
- statusTextArea.setText(new String(infoString));
- return valid;
- }
-}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|