Class Factorization

      extended bycom.cosylab.jcosyne.server.RemoteTask
          extended bycom.cosylab.jcosyne.server.Factorization
All Implemented Interfaces:
FactorizationMBean,,,, RemoteTaskMBean, java.lang.Runnable

public class Factorization
extends RemoteTask
implements FactorizationMBean

This is a trivial implementation of the FactorizationMBean interface which uses naive brute search-for-factors algorithm. It contains delay loops on purpose so that the execution progress can be observed in JMXAdministrator GUI. This example is used in JCosyne tutorial.

Gasper Tkacik (
See Also:
FactorizationExample, JMXAdministrator

Field Summary
Fields inherited from class com.cosylab.jcosyne.server.RemoteTask
log, name, running, sequence, SERVER_DELEGATE, serverRef, suspended
Constructor Summary
Method Summary
 long[] getFactors()
          Returns a list of factors of LongNumber calculated up to now.
 long getLongNumber()
          Returns the number that will be factorized, or 0 if such number has not yet been set.
protected  void internalInitialize()
          Creates internal data structures.
 boolean isReadyToRun()
          Checks if the LongNumber obeys factorization constraints.
 void run()
          Implements brute force factorization.
 void setLongNumber(long number)
          Sets the number to factorize.
Methods inherited from class com.cosylab.jcosyne.server.RemoteTask
checkState, copyStateFrom, copyStateFrom, executeScript, getInputResource, getLastScriptResult, getName, getOutputResource, getPostExecutionScript, getPostInitializactionScript, getProgress, getSequence, getState, initialize, isAborting, isFinished, isInitialized, isRunning, isSuspended, loadMatrix, loadMatrix, notifyAttributeChange, notifyExecutionStarts, notifyExecutionStops, postDeregister, postRegister, preDeregister, preRegister, saveMatrix, setFinished, setPostExecutionScript, setPostInitializationScript, setProgress, setRunning, setSuspended
Methods inherited from class
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.cosylab.jcosyne.server.RemoteTaskMBean
copyStateFrom, copyStateFrom, equals, executeScript, getLastScriptResult, getName, getPostExecutionScript, getPostInitializactionScript, getProgress, getState, hashCode, initialize, isFinished, isInitialized, isRunning, isSuspended, setPostExecutionScript, setPostInitializationScript, setRunning, setSuspended

Constructor Detail


public Factorization()
Method Detail


public long[] getFactors()
Returns a list of factors of LongNumber calculated up to now.

Specified by:
getFactors in interface FactorizationMBean
a list of factors, null if calculation has not yet begun


public long getLongNumber()
Returns the number that will be factorized, or 0 if such number has not yet been set.

Specified by:
getLongNumber in interface FactorizationMBean
number to factorize


public void setLongNumber(long number)
Sets the number to factorize. Must be larger than 1.

Specified by:
setLongNumber in interface FactorizationMBean
number - the number to factorize


public boolean isReadyToRun()
Checks if the LongNumber obeys factorization constraints.

Specified by:
isReadyToRun in interface RemoteTaskMBean
true iff the number is greater than 1


public void run()
Implements brute force factorization. Emits Factors attribute change notifications.

Specified by:
run in interface java.lang.Runnable


protected void internalInitialize()
Creates internal data structures.

Specified by:
internalInitialize in class RemoteTask
See Also: