How to call GET_SEARCH_RESULTS from Filter Class

Hi All,
I want to call GET_SEARCH_RESULTS from Filter Class. How can we do? Any sample code.

Hi Mohan,
I am using "preComputeDocName"
public int doFilter(Workspace ws, DataBinder binder, ExecutionContext cxt)
throws DataException, ServiceException
  String dType=binder.getLocal(UCMConstants.dDocType);
  if(dType.equals("CIDTest"))
   if(binder.getLocal("IdcService").equals("CHECKIN_NEW"))
    String filename=binder.getLocal(UCMConstants.primaryFile);
    originalFileName=filename.substring(filename.lastIndexOf("\\")+1);
    SystemUtils.trace(trace_checkin, "org::"+originalFileName);
    DataBinder newDB = ucmUtils.getNewBinder(binder);
    newDB.putLocal("IdcService", "GET_SEARCH_RESULTS");
    newDB.putLocal("QueryText","dDocType <starts> `"+dType+"` <AND> xcidfilename <starts> `"+originalFileName+"`");
    ucmUtils.executeService(ws, newDB, true);
    DataResultSet docInfoDrs = null;
    docInfoDrs = (DataResultSet) newDB.getResultSet("SearchResults");
    if(docInfoDrs.getNumRows()!=0){
     throw new ServiceException("file is not unique");
    binder.putLocal("xcidfilename", originalFileName);
    return CONTINUE;
return CONTINUE;

Similar Messages

  • Is possible to call procedure from vorowimpl class

    Hi,
    please tell me how to call procedure from vorowimpl class.
    Thanks in advance,
    SAN

    Hi cruz,
    Thanks for your reply.
    I checked that link and they given for controller.
    But i want to call that from the vorowimpl class. but i tried similar like calling in the controller.
    here my code, please correct it if it is mistake.
    public AssessmentsAMImpl xxam;
    public String getXXCompName() {
    //return (String) getAttributeInternal(XXCOMPNAME);
    OADBTransaction txn=(OADBTransaction)xxam.getDBTransaction();
    String compName=getCompName();
    String xxName="";
    CallableStatement cs=txn.createCallableStatement("DECLARE OUTPARAM VARCHAR2(100);begin apps.XX_COMP_ELEMENTSVO_PROC(:1,:2);end;",0);
    try{
    cs.setString(1,compName);
    cs.registerOutParameter(2,OracleTypes.VARCHAR,0);
    cs.execute();
    xxName=cs.getString(1);
    catch(Exception e){
    try{
    cs.close();
    catch(Exception e){
    return xxName;
    }

  • Calling method from another class problem

    hi,
    i am having problem with my code. When i call the method from the other class, it does not function correctly?
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Dice extends JComponent
        private static final int SPOT_DIAM = 9; 
        private int faceValue;   
        public Dice()
            setPreferredSize(new Dimension(60,60));
            roll(); 
        public int roll()
            int val = (int)(6*Math.random() + 1);  
            setValue(val);
            return val;
        public int getValue()
            return faceValue;
        public void setValue(int spots)
            faceValue = spots;
            repaint();   
        @Override public void paintComponent(Graphics g) {
            int w = getWidth(); 
            int h = getHeight();
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setColor(Color.WHITE);
            g2.fillRect(0, 0, w, h);
            g2.setColor(Color.BLACK);
            g2.drawRect(0, 0, w-1, h-1); 
            switch (faceValue)
                case 1:
                    drawSpot(g2, w/2, h/2);
                    break;
                case 3:
                    drawSpot(g2, w/2, h/2);
                case 2:
                    drawSpot(g2, w/4, h/4);
                    drawSpot(g2, 3*w/4, 3*h/4);
                    break;
                case 5:
                    drawSpot(g2, w/2, h/2);
                case 4:
                    drawSpot(g2, w/4, h/4);
                    drawSpot(g2, 3*w/4, 3*h/4);
                    drawSpot(g2, 3*w/4, h/4);
                    drawSpot(g2, w/4, 3*h/4);
                    break;
                case 6:
                    drawSpot(g2, w/4, h/4);
                    drawSpot(g2, 3*w/4, 3*h/4);
                    drawSpot(g2, 3*w/4, h/4);
                    drawSpot(g2, w/4, 3*h/4);
                    drawSpot(g2, w/4, h/2);
                    drawSpot(g2, 3*w/4, h/2);
                    break;
        private void drawSpot(Graphics2D g2, int x, int y)
            g2.fillOval(x-SPOT_DIAM/2, y-SPOT_DIAM/2, SPOT_DIAM, SPOT_DIAM);
    }in another class A (the main class where i run everything) i created a new instance of dice and added it onto a JPanel.Also a JButton is created called roll, which i added a actionListener.........rollButton.addActionListener(B); (B is instance of class B)
    In Class B in implements actionlistener and when the roll button is clicked it should call "roll()" from Dice class
    Dice d = new Dice();
    d.roll();
    it works but it does not repaint the graphics for the dice? the roll method will get a random number but then it will call the method to repaint()???
    Edited by: AceOfSpades on Mar 5, 2008 2:41 PM
    Edited by: AceOfSpades on Mar 5, 2008 2:42 PM

    One way:
    class Flintstone
        private String name;
        public Flintstone(String name)
            this.name = name;
        public String toString()
            return name;
        public static void useFlintstoneWithReference(Flintstone fu2)
            System.out.println(fu2);
        public static void useFlintstoneWithOutReference()
            Flintstone barney = new Flintstone("Barney");
            System.out.println(barney);
        public static void main(String[] args)
            Flintstone fred = new Flintstone("Fred");
            useFlintstoneWithReference(fred); // fred's the reference I"m passing to the method
            useFlintstoneWithOutReference();
    {code}
    can also be done with action listener
    {code}    private class MyActionListener implements ActionListener
            private Flintstone flintstone;
            public MyActionListener(Flintstone flintstone)
                this.flintstone = flintstone;
            public void actionPerformed(ActionEvent arg0)
                //do whatever using flinstone
                System.out.println(flintstone);
        }{code}
    Edited by: Encephalopathic on Mar 5, 2008 3:06 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to call the PS filter in my own MFC PlugIn

    There are several filters in PS that I use frequently.But it's so trouble to find them one by one.I want to write a plugin so that I can see all the filters I want in the same interface.I try it.But when I called filter in my plugin,it always told me that something was wrong and the plugin can't do anything.Can anybody tell me how to call the PS filter in MFC Plugin.My codes that called filter was in the follow.I don't know where is wrong.(ps:My english is so poor.....I don't know whether there are some syntax error.Sorry.)
    PIActionDescriptor test = NULL;
      SPErr error = kSPNoError;
      PIActionDescriptor result = NULL;
      error = sPSActionDescriptor->Make(&test);
      sPSActionDescriptor->PutEnumerated(test,'GEfk','GEft','PstE');
      sPSActionDescriptor->PutInteger(test,keyEdgeThickness,2);
      sPSActionDescriptor->PutInteger(test,keyEdgeIntensity,6);
      sPSActionDescriptor->PutInteger(test,keyPosterization,2);
      error = sPSActionControl->Play(&result,eventPosterEdges,test,plugInDialogSilent);

    I'm sorry. But how can I selected the pixel layer in MFC. I use the codes in the follow. And it work excellent in the automation plugin. But it doesn't work in MFC plugin. How can I change it? Can you give me some advices?
    PIActionDescriptor desc00000000000000F8 = NULL;
    error = sPSActionDescriptor->Make(&desc00000000000000F8);
    if (error) goto returnError;
    PIActionReference ref0000000000000038 = NULL;
    error = sPSActionReference->Make(&ref0000000000000038);
    if (error) goto returnError;
    error = sPSActionReference->PutName(ref0000000000000038, classLayer, "Background");
    if (error) goto returnError;
    error = sPSActionDescriptor->PutReference(desc00000000000000F8, keyNull, ref0000000000000038);
    if (error) goto returnError;
    error = sPSActionDescriptor->PutBoolean(desc00000000000000F8, keyMakeVisible, false);
    if (error) goto returnError;
    error = sPSActionControl->Play(&result, eventSelect, desc00000000000000F8, plugInDialogSilent);
    if (error) goto returnError;

  • Related documents or links on how to call webservices from WDJ

    Hi all
    i need documents & links on how to call webservices from Webdynpro for Java.
    if anybody send the documents on sample scenarios on the same then it is the great help to me...
    Thanks
    Sunil

    Hi Sunil,
    May these links help you.
    http://help.sap.com/saphelp_nw04/helpdata/en/f7/f289c67c759a41b570890c62a03519/frameset.htm
    http://help.sap.com/saphelp_nwce10/helpdata/en/64/0e0ffd314e44a593ec8b885a753d30/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/d2/0357425e060d53e10000000a155106/frameset.htm
    and  the below thread to call weservices in java.
    Re: How to call a web service from Java
    Regards,
    Supraja

  • Is it possible to call methods from another class from within an abstract c

    Is it possible to call methods from another class from within an abstract class ?

    I found an example in teh JDK 131 JFC that may help you. I t is using swing interface and JTable
    If you can not use Swing, then you may want to do digging or try out with the idea presented here in example 3
    Notice that one should refine the abstract table model and you may want to create a method for something like
    public Object getValuesAtRow(int row) { return data[row;}
    to give the desired row and leave the method for
    getValuesAt alone for getting valued of particaular row and column.
    So Once you got the seelcted row index, idxSelctd, from your table
    you can get the row or set the row in your table model
    public TableExample3() {
    JFrame frame = new JFrame("Table");
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {System.exit(0);}});
    // Take the dummy data from SwingSet.
    final String[] names = {"First Name", "Last Name", "Favorite Color",
    "Favorite Number", "Vegetarian"};
    final Object[][] data = {
         {"Mark", "Andrews", "Red", new Integer(2), new Boolean(true)},
         {"Tom", "Ball", "Blue", new Integer(99), new Boolean(false)},
         {"Alan", "Chung", "Green", new Integer(838), new Boolean(false)},
         {"Jeff", "Dinkins", "Turquois", new Integer(8), new Boolean(true)},
         {"Amy", "Fowler", "Yellow", new Integer(3), new Boolean(false)},
         {"Brian", "Gerhold", "Green", new Integer(0), new Boolean(false)},
         {"James", "Gosling", "Pink", new Integer(21), new Boolean(false)},
         {"David", "Karlton", "Red", new Integer(1), new Boolean(false)},
         {"Dave", "Kloba", "Yellow", new Integer(14), new Boolean(false)},
         {"Peter", "Korn", "Purple", new Integer(12), new Boolean(false)},
         {"Phil", "Milne", "Purple", new Integer(3), new Boolean(false)},
         {"Dave", "Moore", "Green", new Integer(88), new Boolean(false)},
         {"Hans", "Muller", "Maroon", new Integer(5), new Boolean(false)},
         {"Rick", "Levenson", "Blue", new Integer(2), new Boolean(false)},
         {"Tim", "Prinzing", "Blue", new Integer(22), new Boolean(false)},
         {"Chester", "Rose", "Black", new Integer(0), new Boolean(false)},
         {"Ray", "Ryan", "Gray", new Integer(77), new Boolean(false)},
         {"Georges", "Saab", "Red", new Integer(4), new Boolean(false)},
         {"Willie", "Walker", "Phthalo Blue", new Integer(4), new Boolean(false)},
         {"Kathy", "Walrath", "Blue", new Integer(8), new Boolean(false)},
         {"Arnaud", "Weber", "Green", new Integer(44), new Boolean(false)}
    // Create a model of the data.
    TableModel dataModel = new AbstractTableModel() {
    // These methods always need to be implemented.
    public int getColumnCount() { return names.length; }
    public int getRowCount() { return data.length;}
    public Object getValueAt(int row, int col) {return data[row][col];}
    // The default implementations of these methods in
    // AbstractTableModel would work, but we can refine them.
    public String getColumnName(int column) {return names[column];}
    public Class getColumnClass(int col) {return getValueAt(0,col).getClass();}
    public boolean isCellEditable(int row, int col) {return (col==4);}
    public void setValueAt(Object aValue, int row, int column) {
    data[row][column] = aValue;
    };

  • How to call GET_SEARCH_RESULTS service in filter

    Hi Experts,
    I wrote a custom filter and in filter i am calling GET_SEARCH_RESULTS service. But i am getting following error :
    intradoc.data.DataException: !csNoServiceDefined,GET_SEARCH_RESULTS
         at test.notification.ExpirationNotification.executeService(ExpirationNotification.java:195)
         at test.notification.ExpirationNotification.doCustomDailyEvent(ExpirationNotification.java:112)
         at test.notification.ExpirationNotification.doFilter(ExpirationNotification.java:51)
         at intradoc.shared.PluginFilters.filter(PluginFilters.java:92)
         at intradoc.server.ScheduledSystemEvents.checkScheduledEvents(ScheduledSystemEvents.java:161)
         at intradoc.server.IdcSystemLoader$13.handleManagerEvent(IdcSystemLoader.java:2411)
         at intradoc.server.SubjectManager$1.run(SubjectManager.java:92)
    Here is the code :
    public class ExpirationNotification implements FilterImplementor
         public int doFilter(Workspace ws, DataBinder eventData, ExecutionContext cxt)
              throws DataException, ServiceException
              try{
              String action = eventData.getLocal("action");
              if (action!=null && action.equals("CustomExpNotifyEvent"))
                   doCustomDailyEvent(ws, eventData, cxt);
                   return CONTINUE;
         }catch(Exception e){e.printStackTrace();}
              return CONTINUE;
         protected void doCustomDailyEvent(Workspace ws, DataBinder eventData,
              ExecutionContext cxt) throws DataException, ServiceException
              update("CustomExpNotifyEvent", "CustomExpNotifyEvent event started...", ws);
              try
                   DataBinder serviceBinder = new DataBinder();
                   serviceBinder.putLocal("QueryText", "dOutDate > `<$dateCurrent()$>` <AND> dOutDate < `<$dateCurrent(30)$>`");
                   serviceBinder.putLocal("IdcService", "GET_SEARCH_RESULTS");
                        executeService(serviceBinder,"sysadmin",false);
                        ResultSet results= serviceBinder.getResultSet("SearchResults");
              } catch(Exception e){e.printStackTrace();}
              update("CustomExpNotifyEvent", "CustomExpNotifyEvent finished successfully", ws);
         protected void update(String action, String msg, Workspace workspace) throws ServiceException, DataException
              long curTime = System.currentTimeMillis();
              ScheduledSystemEvents sse = IdcSystemLoader.getOrCreateScheduledSystemEvents(workspace);
              sse.updateEventState(action, msg, curTime);
         protected void trace(String str)
              SystemUtils.trace("scheduledevents", "- custom - " + str);
         public static Workspace getSystemWorkspace() {
              Workspace workspace = null;
              Provider wsProvider = Providers.getProvider("SystemDatabase");
              if (wsProvider != null)
                   workspace = (Workspace) wsProvider.getProvider();
              return workspace;
         * Obtain information about a user. Only the 'userName' parameter must be
         * non-null.
         public static UserData getFullUserData(String userName, ExecutionContext cxt,
                   Workspace ws) throws DataException, ServiceException {
              if (ws == null)
                   ws = getSystemWorkspace();
              UserData userData = UserStorage.retrieveUserDatabaseProfileDataFull(userName, ws, null, cxt, true, true);
              return userData;
         public void executeService(DataBinder binder, String userName,
                   boolean suppressServiceError) throws DataException,
                   ServiceException {
              // obtain a connection to the database
              Workspace workspace = getSystemWorkspace();
              // check for an IdcService value
              String cmd = binder.getLocal("IdcService");
                   if (cmd == null)
                   throw new DataException("!csIdcServiceMissing");
              // obtain the service definition
              ServiceData serviceData = ServiceManager.getFullService(cmd);
              System.out.println(cmd+".....serviceData-------------"+serviceData);
              if (serviceData == null)
                   throw new DataException(LocaleUtils.encodeMessage(
                             "!csNoServiceDefined", null, cmd));
              // create the service object for this service
              Service service = ServiceManager.createService(serviceData.m_classID,workspace, null, binder, serviceData);
              // obtain the full user data for this user
              //if(service.getCachedObject("propFile")==null){
              UserData fullUserData = getFullUserData(userName, service, workspace);
              service.setUserData(fullUserData);
              binder.m_environment.put("REMOTE_USER", userName);
              ServiceException error = null;
              try {
                   // init the service to not send HTML back
                   service.setSendFlags(true, true);
                   // create all the ServiceHandlers and implementors
                   service.initDelegatedObjects();
                   // do a security check
                   service.globalSecurityCheck();
                   // prepare for the service
                   service.preActions();
                   // execute the service
                   service.doActions();
                   // do any cleanup
                   service.postActions();
                   // store any new personalization data
                   service.updateSubjectInformation(true);
                   service.updateTopicInformation(binder);
              } catch (ServiceException e) {
                   error = e;
              } finally {
                   // Remove all the temp files.
                   service.cleanUp(true);
                   workspace.releaseConnection();
              // handle any error
              if (error != null) {
                   if (suppressServiceError) {
                        error.printStackTrace();
                        if (binder.getLocal("StatusCode") == null) {
                             binder.putLocal("StatusCode", String
                                       .valueOf(error.m_errorCode));
                             binder.putLocal("StatusMessage", error.getMessage());
                   } else {
                        throw new ServiceException(error.m_errorCode, error
                                  .getMessage());
    Edited by: user4884609 on Nov 5, 2012 5:05 PM

    The error you get tells you that the server cannot find the service GET_SEARCH_RESULTS.
    I checked the documentation (http://download.oracle.com/docs/cd/E17904_01/doc.1111/e11011/c05_core.htm#BABJBFFD) and this service is defined as a subservice - therefore, you might call it only within other service and (most likely) not directly from java.
    I guess that you use a filter because you use some standard hooks (like check-in ones). Therefore, you might not be able to call subservice prior to calling the filter. I'd suggest you to write what you are trying to achieve - it seems to me a bit strange that as a result of a filter you want to nothing else but fill-in a search result set.

  • How to call a ABAP proxy class from a BADI? Please help!

    hi Experts,
        I have a scenario where I have to call a ABAP proxy class from a BADI. How can I do this? Does anybody has sample code for the same?
    Please help.
    Thanks
    Gopal

    Hi Gopal,
    Check this out
    DATA: ref_obj    TYPE REF TO zmfg_production_ord.----> BADI
    * Instantiate the proxy class
        CREATE OBJECT ref_obj.
        TRY.
            CALL METHOD ref_obj->execute_asynchronous
              EXPORTING
                output = it_output.     "Output Structure
            COMMIT WORK.
          CATCH cx_ai_system_fault INTO ref_sysexception.
        ENDTRY.
        IF  ref_sysexception IS INITIAL.
          WRITE : / 'Error Message'.
        ENDIF.
    Edited by: Raj on May 28, 2008 4:52 PM

  • How to load function from derived class from dll

    Dear all,
    how to access extra function from derived class.
    for Example
    //==========================MyIShape.h
    class CMyIShape
    public:
    CMyIShape(){};
    virtual ~CMyIShape(){};
    virtual void Fn_DrawMe(){};
    // =========== this is ShapRectangle.dll
    //==========================ShapRectangle .h
    #include "MyIShape.h"
    class DLL_API ShapRectangle :public CMyIShape
    public:
    ShapRectangle(){};
    virtual ~ShapRectangle(){};
    virtual void Fn_DrawMe(){/*something here */};
    virtual void Fn_ChangeMe(){/*something here */};
    __declspec (dllexport) CMyIShape* CreateShape()
    // call the constructor of the actual implementation
    CMyIShape * m_Obj = new ShapRectangle();
    // return the created function
    return m_Obj;
    // =========== this is ShapCircle .dll
    //==========================ShapCircle .h
    #include "MyIShape.h"
    class DLL_API ShapCircle :public CMyIShape
    public:
    ShapCircle(){};
    virtual ~ShapCircle(){};
    virtual void Fn_DrawMe(){/*something here */};
    virtual void Fn_GetRadious(){/*something here */};
    __declspec (dllexport) CMyIShape* CreateShape()
    // call the constructor of the actual implementation
    CMyIShape * m_Obj = new ShapCircle();
    // return the created function
    return m_Obj;
    in exe there is no include header of of ShapCircle and ShapRectangle 
    and from the exe i use LoadLibrary and GetProcAddress .
    typedef CMyIShape* (*CREATE_OBJECT) ();
    CMyIShape*xCls ;
    //===================== from ShapeCircle.Dll
    pReg=  (CREATE_OBJECT)GetProcAddress (hInst ,"CreateShape");
    xCls = pReg();
    now xCls give all access of base class. but how to get pointer of funciton Fn_GetRadious() or how to get access.
    thanks in advance.

    could you please tell me in detail. why so. or any reference for it. i love to read.
    i don't know this is bad way.. but how? i would like to know.
    I indicated in the second sentence. Classes can be implemented differently by different compilers. For example, the alignment of member variables may differ. Also there is the pitfall that a class may be allocated within the DLL but deallocated in the client
    code. But the allocation/deallocation algorithms may differ across different compilers, and certainly between DEBUG and RELEASE mode. This means that you must ensure that if the DLL is compiled in Visual Studio 2010 / Debug mode, that the client code is also
    compiled in Visual Studio 2010 / Debug mode. Otherwise your program will be subject to mysterious crashes.
    is there any other way to archive same goal?
    Of course. DLL functionality should be exposed as a set of functions that accept and return POD data types. "POD" means "plain-ole-data" such as long, wchar_t*, bool, etc. Don't pass pointers to classes. 
    Obviously classes can be implemented within the DLL but they should be kept completely contained within the DLL. You might, for example, expose a function to allocate a class internally to the DLL and another function that can be called by the client code
    to free the class. And of course you can define other functions that can be used by the client code to indirectly call the class's methods.
    and why i need to give header file of ShapCircle and shapRectangle class, even i am not using in exe too. i though it is enough to give only MyIShape.h so with this any one can make new object.
    Indeed you don't have to, if you only want to call the public properties and methods that are defined within MyIShape.h.

  • How to call methods from within run()

    Seems like this must be a common question, but I cannot for the life of me, find the appropriate topic. So apologies ahead of time if this is a repeat.
    I have code like the following:
    public class MainClass implements Runnable {
    public static void main(String args[]) {
    Thread t = new Thread(new MainClass());
    t.start();
    public void run() {
    if (condition)
    doSomethingIntensive();
    else
    doSomethingElseIntensive();
    System.out.println("I want this to print ONLY AFTER the method call finishes, but I'm printed before either 'Intensive' method call completes.");
    private void doSomethingIntensive() {
    System.out.println("I'm never printed because run() ends before execution gets here.");
    return;
    private void doSomethingElseIntensive() {
    System.out.println("I'm never printed because run() ends before execution gets here.");
    return;
    }Question: how do you call methods from within run() and still have it be sequential execution? It seems that a method call within run() creates a new thread just for the method. BUT, this isn't true, because the Thread.currentThread().getName() names are the same instead run() and the "intensive" methods. So, it's not like I can pause one until the method completes because they're the same thread! (I've tried this.)
    So, moral of the story, is there no breaking down a thread's execution into methods? Does all your thread code have to be within the run() method, even if it's 1000 lines? Seems like this wouldn't be the case, but can't get it to work otherwise.
    Thanks all!!!

    I (think I) understand the basics.. what I'm confused
    about is whether the methods are synced on the class
    type or a class instance?The short answer is; the instance for non-static methods, and the class for static methods, although it would be more accurate to say against the instance of the Class for static methods.
    The locking associated with the "sychronized" keyword is all based around an entity called a "monitor". Whenever a thread wants to enter a synchronized method or block, if it doesn't already "own" the monitor, it will try to take it. If the monitor is owned by another thread, then the current thread will block until the other thread releases the monitor. Once the synchronized block is complete, the monitor is released by the thread that owns it.
    So your question boils down to; where does this monitor come from? Every instance of every Object has a monitor associated with it, and any synchronized method or synchonized block is going to take the monitor associated with the instance. The following:
      synchronized void myMethod() {...is equivalent to:
      void myMethod() {
        synchronized(this) {
      ...Keep in mind, though, that every Class has an instance too. You can call "this.getClass()" to get that instance, or you can get the instance for a specific class, say String, with "String.class". Whenever you declare a static method as synchronized, or put a synchronized block inside a static method, the monitor taken will be the one associated with the instance of the class in which the method was declared. In other words this:
      public class Foo {
        synchronized static void myMethod() {...is equivalent to:
      public class Foo{
        static void myMethod() {
          synchronized(Foo.class) {...The problem here is that the instance of the Foo class is being locked. If we declare a subclass of Foo, and then declare a synchronized static method in the subclass, it will lock on the subclass and not on Foo. This is OK, but you have to be aware of it. If you try to declare a static resource of some sort inside Foo, it's best to make it private instead of protected, because subclasses can't really lock on the parent class (well, at least, not without doing something ugly like "synchronized(Foo.class)", which isn't terribly maintainable).
    Doing something like "synchronized(this.getClass())" is a really bad idea. Each subclass is going to take a different monitor, so you can have as many threads in your synchronized block as you have subclasses, and I can't think of a time I'd want that.
    There's also another, equivalent aproach you can take, if this makes more sense to you:
      static final Object lock = new Object();
      void myMethod() {
        synchronized(lock) {
          // Stuff in here is synchronized against the lock's monitor
      }This will take the monitor of the instance referenced by "lock". Since lock is a static variable, only one thread at a time will be able to get into myMethod(), even if the threads are calling into different instances.

  • Call method from another class instance

    Forgive me if I don't make sense, I'm relatively new to Java and still not up on all the lingo.
    So here's what I want to do... This is probably easier explained with code:
    ParentClass.java
    public class ParentClass {
         public static void main(String[] args)
              ChildClass1 child1 = new ChildClass1();
              ChildClass2 child2 = new ChildClass2();
              System.out.println("ParentClass");
              System.out.println(child1.getText());
              System.out.println(child2.getText());
    ChildClass1.javapublic class ChildClass1 {
         private String text = "ChildClass1";
         public ChildClass1()
              System.out.println("ChildClass1 Constructor");
         public String getText()
         { return text; }
    }ChildClass2.java is identical to ChildClass1, except the 1's replaced with 2's etc.
    I need to be able to call getText() in ChildClass1 from ChildClass2, and eventually methods in the ParentClass class.
    As I understand, if I make the ChildClass's extend the ParentClass, every new instance of the ChildClass will create a new instance of the ParentClass. What I need though, is one instance of ParentClass with it's eventual variables etc. set, and then have the two classes defined within, able to talk to each other and the methods in the ParentClass.
    How does one go about doing this? Does that even make sense?
    Thanks, Savage

    You may need to read thru the information provided on this page to understand how to create objects: http://java.sun.com/docs/books/tutorial/java/data/objectcreation.html
    I'd also suggest you read the tutorial available at: http://java.sun.com/docs/books/tutorial/java/index.html
    Regarding how you call a method belonging to another class you could do it in the foll. ways depending on whether the method is static or not - a static method may be called using the class name followed by a dot and the static method name while a non-static method would require you to create an instance of the class and then use that instance name followed by a dot and the method name. All said and done i'd still suggest you read thru the complete Java programming tutorial to get a good grounding on all these concepts and fundamentals of the language if you are looking to master the technology.
    Thanks
    John Morrison

  • Call repaint() from any class?

    I have a class where I have put a JButton. When I press the button I want to
    call repaint() to update an Image object on a JPanel in a totally different class.
    Unfortunately the Image object has to reside in the JPanel class and therefore I thought
    I cound call an static method from the class with the JButton. Doesn't work.
    Hence, how do I call repaint() for a JPanel from another class?

    You can try comething like this ... quick and dirty (All caveats apply; use code at your own risk):
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    class BJCan  extends Canvas {
      private int width, height;
      private Color color;
      public BJCan() {
        setBackground(Color.black);
        color = Color.red;
      public void repaintCan(Color c) {
        color = c;
        repaint();
      public void paint(Graphics g) {
        width  = (int) getSize().getWidth();
        height = (int) getSize().getHeight();
        g.setColor(color);
        g.drawRect(10,10,width-20,height-20);
    class BJPaintCan  extends JFrame {
      private int width, height;
      private JPanel bjp;
      private BJCan bjc;
      public BJPaintCan() {
        super("BJPaintCan");
        bjp = new JPanel();
        bjc = new BJCan();
        bjp.add(bjc);
        getContentPane().add(bjp);
        setBounds(50,50,300,300);
        width  = (int) getSize().getWidth();
        height = (int) getSize().getHeight();
        bjc.setSize(width-75, height-75);
        setVisible(true);
      public void repaint(Color c) {
        bjc.repaintCan(c);
    public class BJPaint  extends JFrame {
      private boolean boo;
      private BJPaintCan bjpp;
      public BJPaint() {
        super("BJPaint");
        bjpp = new BJPaintCan();
        JButton hitIt = new JButton("Hit It!");
        hitIt.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            if ( boo ) {
              bjpp.repaint(Color.blue);
              boo = false;
            else {
              bjpp.repaint(Color.yellow);
              boo = true;
        JPanel jp = new JPanel();
        jp.setLayout(new FlowLayout(FlowLayout.CENTER));
        jp.add(hitIt);
        getContentPane().add(jp);
        setBounds(375,255,300,200);
        setVisible(true);
      public static void main(String[] argv) {
        new BJPaint();
    }~Bill

  • How to call xsl from java?

    Hi All,
    My main java class 'OrderCustomerEntry' is located in package 'Order.Profiles.Customer'
    I have my xml input stored in a String object. Now I have stored a xsl in the same package 'Order.Profiles.Customer'.
    I make certain updations to my xml. After that, I have to call a xsl, which will finally do some transformations on my xml.
    Kindly tell me how to call this xsl file from java.
    Thanks,
    Sabarisri. N
    Edited by: Sabarisri N on Oct 11, 2011 11:15 AM

    This can be complicated with many factors coming into play. Suppose everything is set up in good order, if the xsl is stored in the jar containing the package Order.Profiles.Customer at its root. That means, the jar has some structure like this:
    Order/Profiles/CustomerOrderCustomerEntry.class
    META-INF/...
    xyz.xsl
    etcYou may try this when load it up.
    String xslFile="xyz.xsl";
    //tf being the factory
    Transformer transformer = tf.newTransformer(new StreamSource(ClassLoader.getSystemResourceAsStream(xslFile)));The change with respect to the case where the xslFile is in the current directory is the ClassLoader part.
    Suppose it is stored in a resource directory say "res".
    Order/Profiles/CustomerOrderCustomerEntry.class
    META-INF/...
    res/xyz.xsl
    etcThe corresponding lines would look like this.
    String xslFile="res/xyz.xsl";
    //tf being the factory
    Transformer transformer = tf.newTransformer(new StreamSource(ClassLoader.getSystemResourceAsStream(xslFile)));Hopefully, this may be enough to get you going...
    ps: Although no one should force anyone on the way to name packages, the majority in the industry uses all lowercase characters whenever possible.

  • How to call LSMW from a Report program

    Hi,
    I have a requirment of extending vendor master data (Companycode data and Purchasing Organization data ) through Tcode XK02 using LSMW.Also I need to generate an error log file for validating the data from flat file and  must have an export option of the error log file.
    Can you help me how to proceed on this in steps.
    Also pls let me know how to call LSMW transaction through a Report.
    Based on the selection criteria I need to maintain two source structues,one for companycode data and the other for Purchasing Orgnization data for uploading  data thru LSMW.How to do this?
    pls respond ASAP,
    Thanks,
    Nagendra

    Hi,
    create 2 LSMW object (under same project and subproject)..
    one for extended vendor master data for company code data and other for  extended purchase organization data for company code data.
    Now check the radio buttons and based on that populate ur LSMW object.
    Store project
      project = < >.
    Store subproject
      subproj = < >.
    Store object
      object  = '6GSC022_TS3'.
    if r_ccode = 'X'.
    Store object
      object  = < >.
    else.
    Store object
      object  = < >.
    endif.
    Call the function module to display object (LSMW) maintenance screen
      CALL FUNCTION '/SAPDMC/LSM_OBJ_STARTER'
        EXPORTING
          project        = project
          subproj        = subproj
          object         = object
        EXCEPTIONS
          no_such_object = 1
          OTHERS         = 2.
    Generating error log:
    After the checking the field if u think for this u need to generate error message then In the Maintain Field Mapping and Conversion Rules option under the required field write the following code:
    data: v_msgtxt(100) type c.
    message  <msg ID>    <message type>   <message no>
                     with   <var1>  <var2>
                     into v_msgtxt.
    write v_msgtxt.
    Follow the next step in LSMW object till you reach the option  Convert Data.
    After you execute this option you will get the desired message here.
    Regards,
    Joy.

  • How to call BAPI from ABAP Inbound Proxy

    Hi All
    Can some one provide/giude  a sample code on how to call a BAPI from generated Method (Inbound Proxy) and how are the table parameters passed from Proxy to BAPI.
    Thanks
    Ravi/

    Hello Ravi,
    In the proxy before calling the BAPI, construct the table, fill it with the appropiate values by lopping over the proxy request object. Now use this table for calling BAPI
    Cheers,
    Naveen

Maybe you are looking for

  • Regrding upgradation from sap r/3 4.6 to ECC 6.0

    Hi Friends, We want to upgrade from 4.6C to ECC6.0 . Pls can any one suggest me which tool i have to use . Possible pls send me some docs on this one. Thanks & Regards, Ramnaresh.P

  • Error message in BAPI_REQUISITION_CHANGE

    Hi  gurus . I've got an error message : Runtime Errors         CALL_FUNCTION_UC_STRUCT Exception              CX_SY_DYN_CALL_ILLEGAL_TYPE   The reason for the exception is:   In the function "BAPI_REQUISITION_CHANGE", the STRUCTURE parameter    "REQU

  • Music transfer from iPhone 4 to iPhone 4s?

    I'm having trouble transferring my music from the iPhone 4 to the iPhone 4s.  Here's what I tried.  I backed up the iPhone 4 and then plugged in the newly activated iPhone 4s and restored it as a backup.  When the iPhone 4s finished restoring, only p

  • How do I download games into my iphone?

    Hi All, Please help...Ever since the new IOS I have been unable to work the itunes, meaning I dont know how to download games from my pc into my iphone...Although my phone shows the icons but it is not downloading. One more thing I need advise in: ho

  • Map programe for valuation

    dear gurus yesterday i faced a problem with material stock valuation with ref. to that i got on replay ple check map program ple tell me about that tahnk u prakash