Multi-thread application recompile object with make but runs with old value

Hi. I am working on a simulation in Java, and there is some behavior going on that I cannot understand. Granted, I'm a mechanical engineer, not a CS student (a fact that is probably made obvious by the code I'm posting below). The simulation comprises three parts: a controller, a robot, and a 3-d sensor. Here's the code for the "Simulation" application.
class Simulation {
    void go() {
     ThreeDSensor sensorRunner = new ThreeDSensor();
     VSController controllerRunner = new VSController();
     KukaKR15SL robotRunner = new KukaKR15SL();
     Thread sensorThread = new Thread(sensorRunner);
     Thread controllerThread = new Thread(controllerRunner);
     Thread robotThread = new Thread(robotRunner);
     sensorThread.start();
     try {
         Thread.sleep(1000);  // Give sensorThread time to start in order to catch first triggers
     } catch(InterruptedException ex) {
         ex.printStackTrace();
     controllerThread.start();
     try {
         Thread.sleep(1000);  // Give controllerThread time to open the socket for communication with robotThread
     } catch(InterruptedException ex) {
         ex.printStackTrace();
     robotThread.start();
    public static void main(String[] args) {
     Simulation sim = new Simulation();
     sim.go();
}I guess the big reason I'm using multi-threading is that once this simulation is working I want to be able to just run VSController alone and have it interface with a robot controller and a PC performing image processing. So with multiple threads I'm sending TCP and UDP messages around just like the final system will.
I have made an object for my VSController that just stores values used by the simulation. That way I could have them all in one place instead of hunting through methods to change them. One example is "double noiseThreshold". Quickly, here is the code for "ControllerSettings.java".
class ControllerSettings {
    final double cameraXOffset = 0;  // If > 0 then the origin of the camera CS is not on the center line of the lens
    final double cameraYOffset = 0;  // If > 0 then the origin of the camera CS is not on the center line of the lens
    final double cameraZOffset = 700;  // The distance that must be kept between the camera and the target
    // Error magnitude less than this is disregarded (in centimeters if roundingData else in millimeters)
    final double noiseThreshold = 60;
    final boolean estimatingEndPoints = false;  // If the controller is using two images per cycle then true
    final boolean roundingData = false;
    final boolean using3DData = true;  // How double[] sent from Matlab image processing is used
     * If the robot controller uses the output of this controller to command
     * motions in cartesian space then true.  This is used in two places: 1) initial guess of Jacobian,
     * and 2) "commandType" element sent to robot controller.
    final boolean useRobotControllerModel = false;
    final double thetaBumpValueForEstimationOfJacobian = .1;  // Distance each joint is jogged in estimation process
    final double bumpDistance = 50;  // Distance robot moves each time (magnitude of translation in mm)
    final double limitAngular = .5;  // Max amout robot joint will be commanded to rotate (in degrees)
}And here is some pertinent code from "VSController.java".
class VSController implements Runnable{
    ControllerSettings cSettings;  // Stores all the preferences used by the controller
    NGN controller;  // This is the controller algorithm.
    int dof;  // The degrees of freedom of the robot being controlled
    KukaSendData ksd;  // This provides communication to the robot.
    protected DatagramSocket socketForVisionSystem = null;
    ImageFeaturesData ifd;  // This parses and stores data from the image system.
    double[] errorVector;  // This is what's acted on by the algorithm
    PrintWriter errorTrackerOut = null;  // For analysis of error vector
    public void run() {
     VSController vsc = new VSController();
     vsc.go();
    public void go() {
     initWriters();
     cSettings = new ControllerSettings();
    public boolean isNoise() {
     boolean ret = false;
     double magnitude = 0;
     for (int i = 0; i < errorVector.length; i++) {
         magnitude += errorVector[i] * errorVector;
     magnitude = Math.sqrt(magnitude);
     if (magnitude <= cSettings.noiseThreshold) {
     System.out.println("VSController: magnitude (of errorVector) = " + magnitude +
               ", threshold = " + cSettings.noiseThreshold); // Debug
Now here's my issue: I change the value for "noiseThreshold" in "ControllerSettings.java" then run make from terminal (makefile code posted below) and rerun "Simulation". However, despite my changes to "ControllerSettings.java" the value for "noiseThreshold" is not changed, as evidenced by the output on the terminal screen:VSController: magnitude (of errorVector) = 6.085046125925263, threshold = 10.0 See, that value of 10.0 is what I used to have for noiseThreshold. I do not know why this value does not update even though I save the java file and execute make in between executions of Simulation. I would love it if someone could explain this problem to me.
Here's the contents of makefile.
JFLAGS = -cp ../Jama\-1\.0\.2.jar:../utils/:/usr/share/java/vecmath\-1\.5\.2.jar:.
JC = javac
.SUFFIXES: .java .class
.java.class:
     $(JC) $(JFLAGS) $*.java
CLASSES = \
     ControllerSettings.java \
     ImageFeaturesData.java \
     KukaKR15SL.java \
     ../utils/KukaSendData.java \
     NGN.java \
     Puma560.java \
     Robot.java \
     RobotSettings.java \
     Simulation.java \
     SimulationSettings.java \
     SixRRobot.java \
     Targets.java \
     TargetsSettings.java \
     ThreeDData.java \
     ThreeDSensor.java \
     VSController.java
default: classes
classes: $(CLASSES:.java=.class)
clean:
     $(RM) *.classEdited by: raequin on Apr 5, 2010 1:43 PM

I saw this explanation about what's causing my problem.
"When the Java compiler sees a reference to a final static primitive or String, it inserts the actual value of that constant into the class that uses it. If you then change the constant value in the defining class but don't recompile the using class, it will continue to use the old value."
I verified that the value updates if I also change something in VSController.java, forcing it to recompile. I think I will solve this problem by just making the variables in ControllerSettings no longer final (and then recompile VSController to make sure it takes effect!). Is there another solution? I saw intern(), but that seems to only apply to Strings.
Thanks.

Similar Messages

  • Immutable Objects in multi threaded application - how does it works?

    Hi
    I have this code will work in multithreaded application.
    I know that immutable object is thread safe because its state cannot be changed. And if we have volatile reference, if is changed with e.g.
    MyImmutableObject state = MyImmutableObject.newInstance(oldState, newArgs); i.e. if a thread wants to update the state it must create new immutable object initializing it with the old state and some new state arguments) and this will be visible to all other threads.
    But the question is, if a thread2 starts long operation with the state, in the middle of which thread1 updates the state with new instance, what will happen? Thread2 will use reference to the old object state i.e. it will use inconsistent state? Or thread2 will see the change made by thread1 because the reference to state is volatile, and in this case thread1 can use in the first part of its long operation the old state and in the second part the new state, which is incorrect?
    Therad1:                                                  Thead2:
    State state = cache.get();     //t1                  
    Result result1 = DoSomethingWithState(state);     //t1    
                               State state = cache.get(); //t2
       ->longOperation1(state); //t1
                               Result result2 = DoSomethingWithState(state); //t2
                                   ->longOperation1(state); //t2
       ->longOperation2(state);//t1
    cache.update(result1);    //t1             
                                   ->longOperation2(state);//t2
                               cache.update(result2);//t2
    Result DoSomethingWithState(State state) {
       longOperation1(state);
       //Imaging Thread1 finish here and update state, when Thread2 is going to execute next method
       longOperation2(state);
    return result;
    class cache {
    private volatile State state = State.newInstance(null, null);
    cache.update(result) {
       this.state = State.newInstance(result.getState, result.getNewFactors);
    get(){
    return state;
    }

    Please don't cross post
    http://stackoverflow.com/questions/6803487/immutable-objects-in-multi-threaded-application-how-does-it-work

  • Multi-Thread application and common data

    I try to make a multi-Thread application. All the Threads will update some common data.
    How could I access the variable �VALUE� with the Thread in the following code:
    public class Demo {
    private static long VALUE;
    public Demo(long SvId) {
    VALUE = 0;
    public static class makeThread extends Thread {
    public void run() {
    VALUE++;
    public static long getVALUE() {
    return VALUE;
    The goal is to get the �VALUE� updated by the Thread with �getVALUE()�
    Thanks for your reply
    Benoit

    That code is so wrong in so many ways......
    I know you're just experimenting here, learning what can and can't be done with Threads, but bad habits start early, and get harder to kick as time goes on. I am going to give a little explanation here about what's wrong, and what's right.. If you're going to do anything serious though, please, read some books, and don't pick up bad habits.
    Alright, The "answer" code. You don't use Thread.sleep() to wait for Threads to finish. That's just silly, use the join() method. It blocks until the threads execution is done. So if you have a whole bunch of threads in an array, and you want to start them up, and then do something once they finish. Do this.
    for(int k=0; k<threads.length; k++) {
      threads[k].start();
    for(int k=0; k<threads.length; k++) {
      threads[k].join();
    System.out.println("All Threads Done");Now that's the simple problem. No tears there.
    On to the java memory model. Here where the eye water starts flowing. The program you have written is not guarenteed to do what you expect it to do, that is, increment VALUE some amount of time and then print it out. The program is not "Thread Safe".
    Problem 1) - Atomic Operations and Synchronization
    Incrementing a 'long' is not an atomic operation via the JVM spec, icrementing an int is, so if you change the type of VALUE to an int you don't have to worry about corruption here. If a long is required, or any method with more then one operation that must complete without another thread entering. Then you must learn how to use the synchronized keyword.
    Problem 2) - Visiblity
    To get at this problem you have to understand low level computing terms. The variable VALUE will NOT be written out to main memory every time you increment it. It will be stored in the CPUs cache. If you have more then one CPU, and different CPUs get those threads you are starting up, one CPU won't know what the other is doing. You get memory overwrites, and nothing you expect. If you solve problem 1 by using a synchronized block, you also solve problem 2, because updating a variable under a lock will cause full visiblity of the change. However, there is another keyword in java.. "volatile".. A field modified with this keyword will always have it's changes visible.
    This is a very short explaination, barely scratching the surface. I won't even go into performance issues here. If you want to know more. Here's the resources.
    Doug Lea's book
    http://java.sun.com/docs/books/cp/
    Doug Lea's Site
    http://g.cs.oswego.edu
    -Spinoza

  • Clarification of the handle/body idiom in multi threaded applications

    Hello
    As some DBXML classes use the handle-body idiom (handle/body idiom in some docs), could someone please clarify the consequences of that in a multi threaded application like a web container?
    For 100% Java people, like me, this is known in the Java world as 'programming towards interfaces', or as the Bridge pattern; which is seen as good practice.
    Let's take an example. The class XmlQueryContext is not thread safe, but it has a copy constructor. Imagine that your web application has one XmlQueryContext, that we never use in a query, but that we prepare only to be copied in new threads. Is it thus safe to instantiate various new XmlQueryContexts using that copy constructor in various new threads and use them simultaneously?
    Thank you
    Koen
    PS What I am really asking here is if somebody could please translate the following to Java parlé:
    A copy constructor is provided for this class. The class is implemented using a handle-body idiom. When a handle is copied both handles maintain a reference to the same body.

    As a Java user you do not have to worry about how the C++ copy constructors behave. In the Java API if a copy constructor exists for the object, then the copy constructor will copy all of the original object's data into a new object (XmlContainer is the one exception to this rule, generally one should not use that copy constructor at all). So in short, what you plan to do will work.
    Lauren Foutz

  • Java Security Manager in Multi-threaded application

    I am writing a multi-threaded application listening (TCP and UDP) to several ports. To help implement certain security features (eg. refusing connections from certain ip address), I'm using the java.lang.SecurityManager (by subclassing it). I am having a few problems and queries and am hoping someone here can help me.
    1. As all the threads are calling the checkAccept(host, port) method. Is there a way to know which thread is currently accessing the security manager? For example if host A were to make 2 connections to the application, one to thread 1 (say listening to port 5001) and the other to to thread 2 (say listening to port 5002). I intend to refuse the connection to thread 2 but there is not way of differentiating the 2 connections since they are from the same host and there isnt any way of knowing their port number.
    2. Are calls to the Security Manager thread safe?
    I have been having this problem for a long time, would appreciate if someone can help point me to the right direction. cheers.

    1. As all the threads are calling the
    checkAccept(host, port) method. Is there a way to
    know which thread is currently accessing the security
    manager?Just use Thread.currentThread(). As specified in the Javadoc for e.g. SecurityManager.checkAccept().
    2. Are calls to the Security Manager thread safe? No.

  • Question using Java API in a multi threaded application for MDX queries

    Currently I’m building a web application that makes a lot of MDX calls using the Essbase Java API. Each time we run an MDX call we basically run the following code:
    IEssbase ess = IEssbase.Home.create(IEssbase.JAPI_VERSION);
    IEssDomain dom = ess.signOn(userName, password, false, null, "embedded");
    IEssCubeView cv = cv=dom.openCubeView("view", hostName, appName, cubeName);
    IEssOpMdxQuery op = cv.createIEssOpMdxQuery();
    op.setQuery(false,mdx,false,IEssOpMdxQuery.EEssMemberIdentifierType.NAME);
    cv.performOperation(op);
    IEssMdDataSet mddata = cv.getMdDataSet();
    cv.close();
    My questions is, is this the correct way to use the API in multi threaded environment where many users may be hitting the application at the same time? For every request do I need to create a separate IEssbase object and sign on to an IEssDomain? Or can I use a single IEssbase and IEssDomain object for the entire application? If not should I call the IEssDomain.signOff() method after each user’s request has completed? Which of the above objects are thread safe? I’m using Essabae 9.3.1. Any insight would be really appreciated.
    Thanks
    David

    Thanks for the input friend,
    I should have mentioned that in my application all
    connections to Essbase use the same user name and
    password so the filtering isn’t a concern. This is my
    first Java application using Essbase has a data
    source, I’m used to connecting to various SQL
    databases and I always use a connection pool, how is
    connection pooling handled in the Essbase java API?I'm not sure what happened to it since I never used it, but there used to be something called the High Availability Services or something that was essentially a connection pool for Essbase JAPI connections, but it required an extra license.
    Since you don't care about identity (everyone has full access to everything), you can create your own connection pool, but you'll have to manage your multithreading yourself. Its been this way since the beginning. The C API isn't/wasn't thread-safe either (we tried).

  • Multi-threaded application crashing the VM

    Hi,
    I have a multi-threaded (about 120 threads) application which crashes without after running for a while.
    I get this in the windows event viewer
    Faulting application java.exe, version 0.0.0.0, faulting module kernel32.dll, version 5.2.3790.0, fault address 0x000017b1.
    Anyone knows why this would happen?
    - vineet

    Hi Alexis,
    Thanks for the response to my post!!
    Which version of the JVM?C:\>java -version
    java version "1.4.2_05"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
    Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)
    Are you using the -server option?I was not using this option earlier but even on using this the jvm crashes after running for sometime.
    I am using these jvm options now -
    java -server -Xss128K -Xms256M -Xmx512M
    - vineet

  • Using dynamic sql in triggers with :OLD values

    i need to record all deleted rows from an entire schema in a single table. for that matter i created a function that receives a table name and generate an insert command according to it's primary key columns. i call this function in the table triggers. in order to insert the old values before the delete i use :OLD with "execute immediate" as followed :
    create or replace trigger trg_some_tbl_bd
    before delete on some_tbl
    for each row is
    declare
    v_sql varchar2(4000);
    begin
    v_sql := generate_insert_command('some_table');
    execute immediate v_sql;
    end;
    the return value from "generate_insert_command" function is the string:
    insert into deleted_table (table_name , date , pk1 , pk2) values
    ('some_table' , sysdate , :OLD.pk1 , :OLD.pk2)
    the execute immediate command notice the :OLD and looks for bind variables.
    i need to know i can i bypass that. i tried looking for escape characters but couldent find any...
    i would appriciate any help , it's kynda urgent
    Thanks !

    I don't believe this is going to work. Even if you could get around the fact that :old looks like a bind variable, the :old values are not visible to the dynamic SQL statement, they're like local variables in that respect.
    If you wanted to pass old values in, those values would have to be passed in as bind variables, i.e.
    EXECUTE IMMEDIATE v_sql USING :old.pk1, :old.pk2which defeats the purpose of using dynamic SQL.
    Since you have to create a trigger for each table, I don't see why you would bother with dynamic SQL inside the trigger-- your table structure is fixed when the trigger is created. You could write dynamic SQL that generated the triggers in the first place, but the code inside the trigger should be dynamic.
    As an aside, you realize that logging every audit record into a single table creates rather massive contention issues, right? And have you considered how painful it is to query this sort of table? Have you considered other options for maintaining history like Workspace Manager? Or at least separate history tables for each table?
    Justin

  • Error when using same QueueSession in a multi threaded application

    I have deployed a OSSJ Trouble Ticket refererence Implementation on Sun Java System App Server Platform Edition 8.1 default server.
    The TT server listens on queue MessageQueue and sends its reply on MessageReplyQueue
    The application that sends the request to the TT server should support concurrent requests using threads.
    The sender application creates a QueueConnection and a QueueSession.
    This QueueSession is shared by all the threads that send the request to the TT server.
    Each thread creates its own QueueSender, TemporaryQueue which is set as replyTo in the message, QueueReceiver using the TemporaryQueue in the run method
    When the application is run multiple times i get the following exception
    javax.jms.IllegalStateException: [C4055]: Resource in conflict. Concurrent operations on a session.
    at com.sun.messaging.jmq.jmsclient.SessionImpl.setInSyncState(SessionImpl.java:2177)
    at com.sun.messaging.jmq.jmsclient.SessionImpl.acknowledge(SessionImpl.java:972)
    at com.sun.messaging.jmq.jmsclient.MessageConsumerImpl.receive(MessageConsumerImpl.java:375)
    at com.sun.messaging.jmq.jmsclient.MessageConsumerImpl.receive(MessageConsumerImpl.java:347)
    at xvt.tt.MessageSenderMultiThread.run(MessageSenderMultiThread.java:112)
    The code looks as follows
    public class MessageSenderMultiThread extends Thread {
    private String strMessage = null;
    private QueueSender queueSender = null;
    private QueueReceiver queueReceiver = null;
    private TextMessage message = null;
    private TemporaryQueue tempQueue = null;
    private QueueConnection tempQC = null;
    private QueueSession tempQS = null;
    private Queue tempQ = null;
    String inputQname = "MyQueue";
    String outputQname = "A";
    private int sleepTime;
    static InitialContext jndiContext = null;
    Queue replyQueue=null;
    Hashtable sessions=null;
    static QueueConnection queueConnection = null;
    public static String readFromFile(String fileName) {
    String line = null;
    try {
    FileReader fr = new FileReader(fileName);
    BufferedReader br = new BufferedReader(fr);
    String temp = "";
    line = "";
    while ((temp = br.readLine()) != null) {
    //System.out.println("line is"+line);
    if (temp != null)
    line = line + temp;
    return line;
    } catch (Exception ex) {
    System.out.println("Exception occurred,Ex" + ex);
    return line;
    MessageSenderMultiThread(String strMsg, int sTime, QueueConnection qC, QueueSession qS, Queue q, String name) {
    super(name);
    this.strMessage = strMsg;
    this.sleepTime = sTime;
    this.tempQC = qC;
    this.tempQS = qS;
    this.tempQ = q;
    sessions=new Hashtable();
    System.out.println("Inside Constructior");
    public void run() {
    try {           
    queueSender = tempQS.createSender(tempQ);
    tempQueue = tempQS.createTemporaryQueue();
    queueReceiver = tempQS.createReceiver(tempQueue);
    //queueReceiver = tempQS.createReceiver(replyQueue);
    message = tempQS.createTextMessage();
    message.setText(this.strMessage);
    message.setJMSReplyTo(tempQueue);
    //message.setJMSReplyTo(replyQueue);
    message.setJMSCorrelationID("1234");
    queueSender.send(message);
    System.out.println(message.getText());
    tempQC.start();
    //while (true) {
    Message m = queueReceiver.receive();
    if (m != null) {
    if (m instanceof TextMessage) {
    message = (TextMessage) m;
    if (message != null) {                           
    System.out.println("########################corr id::"+message.getJMSCorrelationID());
    queueReceiver.close();
    //System.out.println("message:: " + message.getText() + "Thread Name " + this.getName());
    } else
    System.out.println("NULL");
    } //else
    //break;
    System.out.println("Exiting !");
    } catch (JMSException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    public static void main(String args[]) {
    String inputQname = "System/RI/ApplicationType/TroubleTicket/Application/1-0;0-0;OSSJTTRI/Comp/MessageQueue";
    QueueConnectionFactory queueConnectionFactory = null;
    QueueSession queueSession = null;
    Queue inputQueue = null;
    try {
    jndiContext = new InitialContext();
    queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup("System/RI/ApplicationType/TroubleTicket/Application/1-0;0-0;OSSJTTRI/Comp/QueueConnectionFactory");
    inputQueue = (Queue) jndiContext.lookup(inputQname);
    queueConnection = queueConnectionFactory.createQueueConnection();
    queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    } catch (JMSException e) {
    e.printStackTrace();
    } catch (Exception e) {
    e.printStackTrace();
    String strRequest = null;
    strRequest = readFromFile("C:/ISM/getTroubleTicketsByKeysRequest.xml");
    new MessageSenderMultiThread(strRequest, 100, queueConnection, queueSession, inputQueue, "Thread1").start();
    strRequest = readFromFile("C:/ISM/getTroubleTicketsByKeysRequest1.xml");
    new MessageSenderMultiThread(strRequest, 100, queueConnection, queueSession, inputQueue,"Thread2").start();
    System.out.println("OVER");
    // System.exit(-1);
    }

    A session is single threaded (so it can not be used by different threads and generate valid behavior). This behavior is covered in @ setion 4.4 of the JMS specification
    If you need multiple threads to process messages you should either:
    * have them share a single session
    * read messages in from the session in a single thread and pass them off to
    other threads processing the message
    On the second option, you must have the "reading" thread also acknowledge the message in client acknowledge (or commit in transactions)

  • Multi Threading..on object locking

    when a synchronised method of an object is invoked by a thread that object gets locked. can another thread invoke unsynchronized method of the same object? howz it possible..if it is possible..pl give the rationale behind this..

    Yes it can. And the reason is part of your homework assignment.

  • Using org.rosuda.JRI.REXP objects with R values

    Hi,
    As JRI and rJava use JNI, I thought I'd try postin this here...
    I'm a bit confused about how REXP and Rengine in org.rosuda.JRI works.
    If I use the example code....
    public REXP getDistance (Rengine re)
             //...open a file and assign some data to 'data'.....then...      
            REXP rexp = re.eval ("dist_out <- data.matrix(data, rownames.force = NA)");
            return rexp;
        }... then the following code knows what 'dist_out' is, that it's of class 'matrix' and works fine...
    public Rengine getNJTree (REXP rexp, Rengine re)
            re.eval ("library (ape)");
            re.eval ("tree_mr <- nj(dist_out)");
            re.eval ("plot(tree_mr)");
            System.out.println ("Exiting getNJTree");
            return re;
        }But, if I use....
    public Rengine getNJTree (REXP rexp, Rengine re)
            re.eval ("library (ape)");
            re.eval ("tree_mr <- nj("+rexp+")");
            re.eval ("plot(tree_mr)");
           return re;
        }...then I get an error - "object tree_mr not found"
    and this is because rexp is not being recognised as the 'dist_out' which was assigned to it earlier.
    If I run the code rexp.getContent(), I get the content as "[D@129b0e1", which I guess is some reference?
    Even if I try....
    {code} public Rengine getNJTree (REXP rexp, Rengine re)
    double[][] matrix = rexp.asDoubleMatrix ();
    re.eval ("library (ape)");
    re.eval ("tree_mr <- nj("+matrix+")");
    re.eval ("plot(tree_mr)");
    return re;
    }{code}
    ....I still get "object tree_mr not found"
    So, I'm obviously doing something wrong here, but I can't figure out for the life of me what it is.
    Any help or explaination would be very welcome.
    Many thanks!

    As JRI and rJava use JNI, I thought I'd try postin this here...I cannot image why. The issue has nothing whatsoever to do with JNI.
    Locking this thread.

  • Do 2 same auth objects with different values bleed together?

    If I had a user who had Auth object F_BKPF_BUK with Activity 01 and Company Code 1200 and also Auth Object F_BKPF_BUK with Activity 03 and Company Code 1300, would the user have 01 and 03 for both Company Code 1200 and 1300 or would the user be restricted to 01 for 1200 and 03 for 1300?

    It depends on the object and how the result of the authority-check is "built".
    For the result of a single authority-check Sanju is correct.
    It would not make sense to attempt to display something (retrieving the value from the record) which has not been created yet (checking the value in the entry screen).
    However the opposite can be true for authority-checks within arguments:
    -  IF weak_check_failed    "user is not authorized...
    -  THEN perform strong_check    "permit everything if passes...
    -  ELSE return_to_...     "Go back to list...
    However, in many cases this weaker : stronger check is against different objects.
    Other transactions will completely bypass the one object and only use a stronger one.
    F_BKPF_BUK should be okay for transactions FB01 and FB03, for example.
    Cheers,
    Julius

  • How to create new record with old values

    Dear all
    i have creation page with 45 fields are there
    user will enter all the fields and save it will call to non editable mode
    if user will click on change button it will call to editable mode
    in that my requirement is user wont change among those ites(45 items)clcik on save again it will call to view mode
    in that user will change any one of the value among 45 items and click on save button i need to create one more record in database
    if user wont edit any one of the field out of 45 items i dont want to create new record in database
    how can we achieve thsi functionality
    Regards
    Sreekanth

    Hi Srikant,
    When user may edit the record, the same row may get updated in vo. Thus over writing existing row instead of creating new row.
    Approach1..
    On the page where user may edit records, instead of presenting records of existing row, present copy of existing row. So
    In AM... (Later on you can put vo logic to its proper place, i.e. vo java file)
    public void viewPageCallSetup()
    Row originalRow=vo.createRow();
    Row dummyRowForEdit=vo.createRow();
    //COPY THE ORIGINAL ROW TO DUMMY ROW. IF THERE IS DIRECT METHOD TO CREATE COPY OF EXISTING ROW, THAT MAY BE MUCH BETTER.
    for(int i=0;i<vo.getAttributeCount()-1; i++)
    dummyRowForEdit.setAttribute(i, originalRow.getAttribute(i));
    vo.insertRow(dummyRowForEdit);
    vo.setNewRowState(Row.STATUS_INITIALIZED);
    vo.setCurrentRow(dummyRowForEdit);
    call this method in contoller's processRequest..
    string oid=pagecontext.getparameter("oid");
    if(pageContext.getparameter("Purpose").equals("Edit")) //Means user clickED the edit button so we need to replicate the row
    am. viewPageCallSetup(oid); //calling this method in am
    else
    In PFR...
    if(pageContext.getparameter("Purpose").equals("Edit"))
    am.xxcostedit(oid); //calling this method in am
    in case user selects "Cancel" on edit form,we need to remove the duplicate row. So in AM write a method to remove the duplicate rowd on click of "Cancel" button on edit form.
    Rest of the logic is same for "Save" button. Just say commit.
    Abdul Wahid

  • Serializing objects with the NIO API

    I try to use the new IO API to implement a non-blocking multi-threaded server that communicates with client applications by exchanging serialized objects. I started from the code in the JavaWorld article at http://www.javaworld.com/javaworld/jw-09-2001/jw-0907-merlin.html .
    With the new features of J2SDK 1.4.0, you don't have to create a separate thread per connected client. That is a big improvement.
    But when I read an object with ObjectInputStream, I get a java.nio.channels.IllegalBlockingModeException.
    Has anybody successfully implemented such a server since the release of the new io API?
    Thanks.
    Jean-Robert

    The ObjectStream code is basically incompatible with non blockin I/O since you must block on the stream until a whole Object is available. You could roll something like this yourself, by reading bytes until there are enough available to build the next object and then getting that Object from the buffer and shipping it to your client thread. All of this is far more trouble than just using the Stream oriented I/O.
    NIO and mutilple threads are a nightmare, the whole idea of non-blocking I/O is to avoid needing multiple threads. If you do use multiple threads you will need queues between them. See the Taming the NIO Circus topic for lots of discussion of NIO and its problems. The system seems more stable in JDK 1.5, but most people haven't even started using 1.4 for production yet.
    Personally I avoid ObjectStreams. They are only useful between Java applications, if I want that I just use RMI and let Java do ALL the hard work. When I write a Socket based app, its probably because the other end is a mainframe of a C program. For that reason I send data as bytes, packaged up in packets, and encode as XML or ASN.1 so the other end can interpret it.

  • Multi Threading in EJB by sending requests to JDBC or JMS queue

    Hi,
    I know that multi-threading is not permitted on EJB, but I'm planning an application which has to send a copule of requests to another system in parallel. So the EJB should be talking to any number of other systems at one time.
    In an application I would simply create some threads, and that's it. With EJB this is not possible, so I've come up with the following idea:
    A Queuing system will be implemented. This can be a simple table in a database or a message bean (JMS-Java Message Service). In both cases request objects have to be serialized into byte streams and stored as a Binary Object (e.g. Oracle BLOB) in the database or attach somehow to the JMS message.
    Some sort of queue processor looks at the queue, deserializes the requests, does something and sends back a response (again by serialization and through db or jms).
    Technically the db solution should work, I've been doing ths (de)serialization of java objects into an oracle blob, and it works. Creating a process which scans a database should also work, and with timestamps I can implement a queue.
    With JMS I'm not that sure, mainly because I'm not familiar with it :-). But as far as I know some JMS vendors (I do not remember who) are using database for messaging anyway.
    Any comments ?
    Thanks

    As I understand JMS, the database is used for persistence of messages before they are acknowledged.
    If persistence is turned on, once a message arrives on the queue, the message object is serialized and stored in the database with an appropriate primary key.
    When the consumer calls the receive() method the Message Object is sent to the consumer, when this acknowledged the corresponding entry is removed from the database.

Maybe you are looking for

  • How to create Purchase group

    Hai Guys, What is the procedure to create my own Purchase group? Kindly let me know the Steps.. Regards Jino.

  • 4507-E LineCards Throughput Division. (URGENT)

    My Company has bought a Modular 4507-E to be implemented in Our Backbone, the Line Cards are as Follows: WS-X4248-FE-SFP    Catalyst 4500 48PT 100Base-X WS-C4507R+E           Catalyst 4500E 7 Slot chassis for 48Gbps/slot WS-X4640-CSFP-E    Catalyst 4

  • Having trouble updating my podcast

    Hello, I created my podcast last week, and the first episode is available since my podcast was verified. But now I added an "item" in my rss feed 5 days ago, and nothing chaged in my podcast. The new episode is available in the rss feed but not on iT

  • Problem with Timeouts with an infopackage

    I have an infopackage that is running a full load.  It's scheduled to run as "Immediate/Start Later in the Background"  However apparently that background task spawns a dialogue task that exceeds the timeout limit set by our BASIS team. What is this

  • HotspotAuthenticationApp

    I have a recurrent message displayed in my console every 10 seconds  ( it's written into the system.log) 04/07/12 19:19:28,400 HotspotAuthenticationApp: kCGErrorInvalidConnection: CGSGetCurrentCursorLocation: Invalid connection 04/07/12 19:19:28,400