 |
Return to article.
package factorization.service.impl;
/**
* Title: Factorization Library
* Description: A factorization lib based on the quadratic sieve
* Copyright: Copyright (c) 2004
* Company: ACME
* @author Vladimir Silva
* @version 1.0
*/
import org.globus.ogsa.impl.ogsi.GridServiceImpl;
import factorization.service.Factorization.FactorizationPortType;
import java.rmi.RemoteException;
import javax.math.factorization.Factorizer;
/**
* Factorization service Implementation
*/
public class FactorizationImpl extends GridServiceImpl
implements FactorizationPortType
{
public FactorizationImpl() {
super("Factorization Service");
}
/**
* Factorization Method
* @param bigNum Number to factor
* @param outFile Full path to the server side Output file
* (Contains factors pd(1)^ exp(1) * .....
* @param options Use "-verbose" to display fac output in the GT server log
*/
public String factorize(String bigNum, String outFile, String options)
throws RemoteException
{
String[] args = {"-n", bigNum, "-out", outFile, options};
try {
Factorizer f = new Factorizer(args);
// dump output: to the console or a file
f.dumpOutput();
return buildXML(false, "Out in: " + outFile);
}
catch (Exception ex) {
return buildXML(true, ex.getClass().getName() + ": " +
ex.getMessage());
}
}
/*
* An XML string is returned w/ service status
*/
private String buildXML(boolean error, String text) {
return "<xml><error>" + error + "</error><text>" + text +
"</text></xml>";
}
}
|
Return to article.
|  |
|