Using ThreadPoolExecutor, wish to obtain thread for known runnable object

My problem is this:
I use a ThreadPoolExecutor with default ThreadFactory to create a pair of threads; one operates a live particle simulation, the other mouse interactions with the particles.
I would like to be able to stop one particle simulation (which is a class extending Runnable) and replace it with another. The problem is that I call myRunnableSimulator.stop(), but then I am unable to join() its thread before creating the new particle simulator, because the ThreadPoolExecutor uses a ThreadFactory. And since I have 2 threads running, Thread.currentThread() isn't much use.
ThreadedPoolExecutor.awaitTermination(long duration, TimeUnit unit) doesn't help me either, since it waits for all tasks to terminate. I could set the timeout to some duration that feels safe for the thread I want to die to do so, but it's a bit of a fudge.
Any advice would be much appreciated.

If the tasks you submit to an executor have termination dependencies then you need to explicitly code them into the task based on its state, not the state of the thread executing the task.
Thread.join() is a lazy way to asking "has my task finished execution". And it tells you nothing about the success or failure of that execution. myTask.isDone() is what you need - whether isDone comes from a Future or from your own task implementation.

Similar Messages

  • How to use BAPI_OBJCL* to set classification data for Techn. Objects - PM ?

    Good afternoon !
            I´m working in a project to integrate some legacy system with the ECC 6.0, and I need to do some activities like, create functional locations and equipments in SAP PM, I have done this creating Z RFC modules that call bapis like BAPI_FUNCLOC_CREATE and BAPI_EQUI_CREATE, but these BAPIs doesn´t fill classification data, so, in a first moment, I solved this using BDC, but I would like to solve these needs using standard BAPIs if possible.
            To solve the classification, I tried to do it using the BAPI_OBJCL* BAPIs(BAPI_OBJCL_GET_KEY_OF_OBJECT, BAPI_OBJCL_CREATE_KEY), but I didn´t find any example of using these bapis with technical objects, so I tried to test the BAPI_OBJCL_GET_KEY_OF_OBJECT in a first moment and, when I call it passing '003' as classtype(003 is the classtype for the functional locations), this bapi returns me "Class type 003 requires additional objects"(the same occurs if I try it with 002, for equipment). What means this message ? Need I to do some customization in img/spro, or cannot these bapis be used with PM technical objects ?
            Thank you for your attention,
            Wilson

    Hi all !
            I have found the solution for this problem, I found that I was trying to use the wrong functions for my case, so, to solve my needs here, I will use BAPI_OBJCL_CREATE to set the classification data for Functional Locations and Equipments, and I can use BAPI_OBJCL_GETCLASSES to list all classes assigned for a Technical Object, and BAPI_OBJCL_GETDETAIL to get all characteristics assigned to a Technical Object for a specific class.
            Thank you all for your attention !
            Wilson

  • Which respoitories to use? please see the thread for the scenario!

    Hello Guru's,
    I want to use KM Repositories instead of using the Content Repository which we create in Backend system using OAC0 T.Code.
    The requirement is to store employee photos so that can be linked to Image Container used in Who's Who application of ESS.
    http://www.sd-solutions.com/documents/SDS_Employee_Photos_v4.7.html
    I went through the above link but want to use KM Repository instead.
    Please provide me inputs of what kind of repositories exist in KM and what for those repositories are used and which one to use in our scenario.
    I went through all the help docs, would appreciate if anyone can send step by step config of how to use and which one to use.
    Any inputs are appreciated.
    Thanks in advance for your time.
    Pramod

    HI
    The requirement is to store employee photos so that can be linked to Image Container used in Who's Who application of ESS.
    if u want to make your task simple just use default documents repository a type of cm repository as also said by prem.
    Regards,
    Vijay.

  • Bizarre behavior of a View Criteria for a View Object

    Hey,
    I remarked quite a bizarre behavior of the View criteria that I created for my view object, using bind variables.
    lets say I have the generated query in the View object:
    SELECT Paquet.ID,
    Paquet.WEIGHT,
    Paquet.VALUE,
    Paquet.ORIGIN,
    Paquet.DESTINATION
    FROM PAQUET Paquet
    I want to use the executeWithParams with bind variables for this View object.
    I create a bind variable:p_o
    I create the View Criteria vith the visual editor that generates an additional view clause:
    ( ( ( Paquet.ORIGIN LIKE ('%' || :p_o || '%') ) OR ( :p_o IS NULL ) ) )
    test query works and explain plan as well.
    Now, when I execute the view object on a page with the bind variable properly set, I get the error: java.sql.SQLException: Attempt to set a parameter name that does not occur in the SQL: p_o
    Then I copy the where clause generated by view criteria visual edito directly to the query and delete the View Criteria, and it ALL WORKS FINE
    If has to work like that, then what is the View Criteria useful for? I still think that there is a problem.
    Thanks!
    Taavi

    Hi,
    ViewCriterias are not accessed with ExecuteWith Params. For this the bind variable needs to be in the where clause. Named ViewCriterias are listed separately in the DC list
    Frank

  • Is there support for the GraphicsFmt object in FrameMaker 11 ExtendScript?

    I was reading the FDK documentation for FrameMaker 11 and I see that support has been added for Object formats using FO_GraphicsFmt.
    Is there support for the GraphicsFmt object in FrameMaker 11 ExtendScript?
    If not, when will it be added?
    Another question: Will the ExtendScript documentation ever be improved?

    Stuart,
    I am pretty sure you can use the object from ExtendScript. With the FDK documentation you should be able to guess the property names in ExtendScript, but the easiest way is to use a small test document and write a small script to get at the GraphicsFmt object. Set a breakpoint and use the Data Browser and/or JavaScript Console to see how FM uses the object.
    As for better ExtendScript documentation: I am working on a website (www.progframe.com) that will feature better documentation, combining the current docs with stuff picked up from the FDK reference and test scripts. It will also have tutorials for newbie scripters. If Adobe does not put an effort into the docs, I might as well do it and possibly pick up some scripting jobs that way. I am planning to launch the website early next year and keeping it up to date so that ExtendScript info is immediately available when a new FM version hits the market.
    Kind regards
    Jang

  • How to add timeout for threads which are running  using ThreadPoolExecutor

    I am trying change my existing functionality with ThreadPoolExecutor. I was unable to achieve fully.
    Here is my issue.
    I was creating multiple threads for independent DB update operations. And was calling join with time value on the each thread, for any reason if the db update hangs so that thread should die.
    Now am trying use a nice ThreadPoolExecutor so that it can run and queue the threads nicely. But how do I create the timeout values for the threads which are in the ThreadPool. For any reason if the thread hangs then timeout will take care of killing the thread. When we use execute method submit the runnable task its not guaranteed that thread will run immediately. So when the executor will execute the submitted task is not know.
    Probably I might be wrong some where.
    Thanks.

    Future task = threadPoolExecutor.submit(...);
    //this will block until it finishes or times out.
    task.get(REQUEST_TIMEOUT, TimeUnit.MILLISECONDS);

  • ThreadPoolExecutor and using priority to determine what threads will run

    Hello,
    I am fairly new to Java, so I apologize if there is an obvious answer.
    The ThreadPoolExecutor is a great class for thread management. What I would like to do is have a priority scheme that would determine what thread should be run next. For example, let's say I have 100 threads and a limit of 20 threads. Each thread that is executed should have a mechanism to indicate a priority. When a thread becomes available in the pool, the priority value should be checked to determine which thread to run. This would allow me to get important tasks completed quickly. Right now it appears that there is a FIFO order to threads. I tried wrapping the runnable object in a Thread, but that didn't seem to have an effect.
    I am using a Fixed thread Pool:
          loThreadPoolExecutor = (ThreadPoolExecutor) Executors.newFixedThreadPool(MAXTHREADS); (MAXTHREADS=20)I have tried creating a PriorityBlockingQueue with a comparator that compares the thread priority, but nothing seems to work.
      public Constructor() {
    loThreadPoolExecutor = new ThreadPoolExecutor(MAXTHREADS,MAXTHREADS*2,0,TimeUnit.SECONDS,new PriorityBlockingQueue(11,new PrvComparator()));
        private class PrvComparator implements Comparator  {
              public int compare(Object o1, Object o2) {
                   // TODO Auto-generated method stub
                   Thread t1 = (Thread) o1;
                   Thread t2 = (Thread) o2;
                   System.out.println("P1="+t1.getPriority()+ " P2="+t2.getPriority());
                   if (t1.getPriority()<t2.getPriority()) return -1;
                   if (t1.getPriority()>t2.getPriority()) return 1;
                   else return 0;
                   //PriorityBlockingQueue
              }I would appreciate any help.

    What are you trying to prioritize? The order on which tasks come off the work queue, or the order in which they get completed?
    Doing the first is simple but restricted. Your tasks are Comparable and define their own priority and you use a PriorityBlockingQueue. But you are restricted to using the execute() method with Runnable's that are Comparable. submit() will wrap the task in a FutureTask that isn't Comparable and so will cause a ClassCastException.
    Doing the second is difficult. Even if your threads have different priorities then don't queue for tasks in priority order, so the thread priority when taking a task is irrelevant. You could change the thread priority based on the priority of the task once it starts executing. But Thread priorities are only a hint to the scheduler that you think Thread A is more important than Thread B. On some platforms priorities will have little observable effects - whereas on other it can be drastic if you use priorities that are too high or too low. The mapping from Java priority to OS thread priority is platform specific. See for example http://java.sun.com/javase/6/docs/technotes/guides/vm/thread-priorities.html

  • How is it possible to make sure that LV uses the same thread for several threadsafe DLL calls?

    Hello,
    i have a thread safe DLL and most functions are called from serveral threads from the LV apllication without problems.
    In case of an error i have to call an error handler function in this DLL (like WinAPI: GetLastError()) from the same thread which has called the function that failed before.
    I can't use the user interface execution because some functions need a long execution time and i don't want to balk the user interface.
    All other executions than the user interface execution have more than one thread and in most cases the DLL function calls were executed from different threads - so the error handling doesn't work...
    Any idea?
    Thanks for your help!

    Hmmm....
    How about wrapping all of your dll calls in a single VI (or an Action Engine ) and make sure the VI's thread is NOT set for "Same as caller".
    "Threadconfig.vi" (sp?) will also let you dictate the number of threads associated with an execution system. Set your target thread for "1".
    Not sure on the above.
    Please correct me if this is wrong!
    Ben
    Message Edited by Ben on 07-19-2007 08:26 AM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Is there a separate discussion thread for educators using ibook?

    Many of us in higher education are trying to use ibooks as text or as lab manuals.  Are there discussion threads for the particular ibook issues teachers/instructors/professors might come across?  Thank you.

    No, unless you are into the production of ebooks, then there are forums at
    https://discussions.apple.com/community/books?view=discussions

  • Woes of the Z10, and now i want to use it as a backup phone for my contacts and data. Can I?

    Ok, this has been a real nightmare. I am an extensive user of BB since OS4. Wanted to try the new Z10, so I got myself a spanking new one. With my prior experience in switching devices, it would be a cinch. Transfer device over via blackberry desktop software, change the emails via BIS, and I'm all sorted out. 
    OMG dear blackberry. You made me jump through so many hoops I felt like a circus dog.
    Blacberry desktop doesn't work with the Z10. No one told me. I had to find out the hard way after not being able to detect the phone. wasted half an hour of my life. Downloaded Blackberry link. Transferred my contacts and everything over, couldn't be happier.
    Hurrah, thought the nightmare was done. It was just starting.
    Micro sim. Not everyone has a microsim cutter lying around. Great. Troop off to the shop. Figured after I get the sim cut, I could also transfer the emails via BIS server. So that's what I did. (oh by the way, having to buy a micro SD card was also a pain in the A but still acceptable). The BIS server detected the change in device so it disabled my emails. No problem. Until the technician told me at the store-sorry-BIS DOESNT WORK WITH Z10. Whaaaaat? Come on blackberry! Now its just normal emails, similar to that of iphone and samsung. Emails were your best feature. Ok, this I can stomach. What I cannot stomach is...blackberrry, you just killed your frequent traveller who needs international roaming. BIS emails and BBM was wonderful. I could get by travelling from country to country on 50mb a month unlimited. Apparently not anymore. I need a full fledged international roaming plan that will cost me an arm and a leg. This is insane. 
    Finally I had the Z10 working. I manually entered all my emails. ( i have 9 emails. Thank god they are all gmail based, especially for work, if not I would have ripped all my hair out). For the whole 2 hours, I looked at it and hated it. It was hard to use, I had to keep swiping up and to the right, sometimes it wouldn't swipe well, sometimes I couldn't tell if it was swiping or not. Neither did it help that Whatsapp hasn't even been sorted out on the Z10. Whatsapp is my life. My family's on it. My friends are on it. My suppliers and my customers are on it. Oh wait. Z10-well, you can download it from the appworld, but it doesn't install. Thinking it was a problem with the downloads, I kept at it..only to have the technician tell me, "sorry, Whatsapp not working on Z10, too bad"...anyway I made up my mind to go back to the Torch. So thinking it would be as simple as changing the hub ID on the Z10 and then reactivating the Torch. All will be well. Wrong. 
    I had to run to another tel shop to beg for a spare sim shell so I could stick the micro sim into it and have it back as a normal sim. Another 2 hours of my life later, I realise-changing the hub ID on the Z10 doesn't change anything. It doesn't mean you can just use the original hub Id and all systems are go on the first phone. Changing the hub ID means changing the original one. Argh. This was so frustrating especially when the BIS server refused to switch back to the old device. Ever clicked on detect device 200 times? Well that would be me. Eventually I figured it out. Change back to the old hub ID, security wipe the horrible thing, log in with the original hub ID and reset the device via BIS server. Finally, order is restored.
    Which leads me to my question. I am thinking of porting over my contact list and data to the Z10, and using it as another phone in another country. However I want to use a different Id from my Torch since it is considered a different device but with the same data. Will blackberry link allow me to do this, or will it only switch the data provided the hub ID is the same?
    Blackberry, hand over heart, I'll use the Torch till it dies ( I just changed out the nav pad cause it was completely worn out and would act wonky in sunlight- I call it the blackberry vampire version) and after that I'm off to another smart phone platform. You've made my life miserable. It was great while it lasted, but I'm going to be migrating to another platform eventually. Thanks for the memories.

    Hello,
    BlackBerry 10 has always been advertised as a revolutionary change from prior...not an evolution. And you have both now learned the hard way just how detailed that change is. As with so many things, the assumptions made from past experience with BB are not useful for this very significant change. Rather, research done prior to purchase is the most useful activity one can undertake.
    For BB10, BIS is not required. Indeed, on some carriers, having BIS on the account actually impedes some services for BB10. BB10 uses a full on-device ActiveSync client for email now. BIS-handled email is gone...as are "hosted" email accounts (though you can get 1-year of forwarding).
    Migrating of data from old to new involves many choices before beginning. For example, if you are not afraid of placing your Calendar and Contact data "into the cloud", the Z10 can excellently synchronize that against many different providers (many more than BIS ever could). Done correctly, one can attain full end-to-end OTA synchronization of Calendar/Contact data between Outlook desktop client (and perhaps others, though I've not tested), a Z10, a PlayBook, and more (for me, I've got 2 Outlook client instances, one Z10, one PB, and one Droid...all working beautifully OTA).
    Traveling is no more challenging than in the past...your specific device must be able to function on the networks upon which you wish to roam...this is no different from before (e.g., a GSM-only device simply cannot roam on a CDMA network). To compare specifics, I've found this useful:
    http://www.bbin.in/en/2013/03/03/4-types-blackberry-z10-models-fits-better/?utm_campaign=4-types-of-...
    There are many other differences...but please try to let go of what was before, for pretty much none of it applies anymore. BB10 is revolutionarily different from before.
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Problem when using ThreadPoolExecutor under Linux

    I am writing a multithreading web page fetcher under windows with jdk1.5.0-09. I have a task dispatcher like this:
    public void run() {
         while (true) {
              try {
               if(_fetcherPool.getActiveCount()<_config.numThreads){
                   _fetcherPool.execute(new RobotstxtFetcher(_crawler, getURLQueue().take()));
                } else {
                   Thread.sleep(someDelay);
              } catch (InterruptedException e) {
                   log.error("Dispatcher.run", e);
    }Everything works fine as expected, 500 threads are generated, and new tasks will be submitted to the pool. I got performance of finishing 20 tasks per second.
    But when I moved this program to Redhat Enterprise Linux with jdk1.5.0_09, the behavior changed completely. 500 threads are still generated. But they are not processing anything for about 60 seconds, but then suddenly finished about 300 tasks in 1-2 seconds. Then the program will wait for another 60 seconds and then finish 300 tasks in 1-2 seconds again.
    So I tried to test it with multithread without using threadpoolexecutor. I generated 500 threads, and each thread get tasks from the queue directly without thread pooling. It works fine just as under windows.
    Can anyone tell me why?
    BTW, I suspect the creation of the thread pool may be an issue. Here's my code:
    ThreadPoolExecutor _fetcherPool = new ThreadPoolExecutor(
         500, 500+20, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>() );Please help. Thanks.
    Message was edited by:
    okss

    I can't see the picture. Maybe host somewhere else and post a link?

  • How to use ThreadPoolExecutor / ArrayBlockingQueue with event objects

    I am having some trouble figuring out how to use the new java.util.concurrent library for a simple thread pool that has custom threads pulling off event objects from a queue.
    I started with this kind of code below, which I know is not right but am having trouble seeing the correct approach. Any help is appreciated. Thank You!
    -Paul
    public class testThreadPool {
    public static void main( String [] args ) {
    //work queue actaully only takes runnables,
    //but I need to add my event objects to this queue ??
    ArrayBlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<Runnable>(20);
    ThreadPoolExecutor pool = new ThreadPoolExecutor(10,//pool size
    20,//max pool size
    1,
    TimeUnit.SECONDS,
    workQueue);//the work queue
    //this will ensure that the pool executor creates worker
    //threads of type MyThreadWorker
    pool.setThreadFactory(new MyThreadFactory());
    pool.prestartAllCoreThreads();
    //throw some events on the queue and let the pool workers
    //start to execute with the given event object
    workQueue.add(MyEvent);
    workQueue.add(AnotherEvent);
    class MyThreadFactory implements ThreadFactory {
    public Thread newThread(Runnable runnable) {
    return new (Thread)MyThreadWorker();
    class MyThreadWorker implements Runnable {
    private boolean m_run = true;
    public void run(){
    Object obj;
    while (m_run) {
    obj = null;
    //get the event object from the blocking queue
    try {
    obj = workQueue.take();
    } catch (InterruptedException e) {
    if ( obj == null ) continue;
    if ( obj == null ) continue;
    if (obj instanceof MyEvent) {
    //do this
    } else if (obj instanceof AnotherEvent) {
    //do this
    public void stopRunning(){
    m_run = false;
    this.interrupt();
    }

    What database and connection type are you using? Are you connecting the report directly to the database, or trying to assign the datasource to object data?
    It sounds like you might be trying to use a linked list, collection or other C# construct to pass your data in. This currently isn't supported by the Crystal Reports SDK. You can use a DataSet or a DataTable, and possibly also an IDataReader depending on which version of Crystal Reports you're referencing in your project. Of course you can also connect directly to the database, even if the database isn't on the same machine as the application.
    The way to show master records with detail information is through the use of subreports and linked subreport parameters. Linked subreports take their parameter value from a record in the main report, so that only the data appropriate to that master record is displayed. The guys over in the [report design|SAP Crystal Reports; forum can help you out with this if you have questions on the specifics.

  • Which List should be used, to remove in a thread safe way?

    Hello all,
    I plan to have a List, where n number of Threads will accessing the List.
    When two or more thread trying to remove an equals items from the List, only one of the thread will remove successfully (i,e, remove(Object o) will return true). The rest of the threads will realize remove(Object o) returns false
    I wish to achieve this. I know that I can achieve by using :
    Collections.synchronizedList(new ArrayList(...))However, I afraid having the synchronized block will slow down my execution speed. Is there other way, that I achieve the same objective with faster speed? For example, using CopyOnWriteArrayList?
    Thanks!

    Sorry,
    I said "badly" because it is synchornized by putting "synchronized" keyword on most of the methods prototypes.
    Which equals to synchronizing on "this".
    In my opinion, one problem of this implementation is that 2 calls to a get() method will be synchronized wherever they dont need to. (As get() does not modify the vector). [See Edit]
    One other is you can synchronize on the Vector's mutex (itself) outside of the Vector's code.
    And at last, as synchronizedList is not implemented by a Vector and is more recent than the Vector implementation...
    I guess they implemented it in another way for many good reasons...
    [Edit]
    As i can see in Collections, the synchronizedList is implemented in the same way.
    BUT, as the synchronized keyword is not in the method's prototype, we can expect the implementation to be changed a day...
    And vector is a kind of old object kept for backward compatibility i guess. (someone can confirm ?). ("As of the Java 2 platform v1.2, this class has been retrofitted to implement List, so that it becomes a part of Java's collection framework.")
    @KwangHooi
    You can write your own implementation of a List which will not synchronize on the same token for both read/write operations. (but, i guess it could be hard to avoid deadlocks)

  • How can I use a Selector in a thread safe way?

    Hello,
    I'm using a server socket with a java.nio.channels.Selector contemporarily by 3 different threads (this number may change in the future).
    From the javadoc: Selectors are themselves safe for use by multiple concurrent threads; their key sets, however, are not.
    Following this advise, I wrote code in this way:
             List keys = new LinkedList(); //private key list for each thread
             while (true) {
              keys.clear();
              synchronized(selector) {
                  int num = selector.select();
                  if (num == 0)
                   continue;
                  Set selectedKeys = selector.selectedKeys();
                  //I expected this code to produce disjoint key sets on each thread...
                  keys.addAll(selectedKeys);
                  selectedKeys.clear();
              Iterator it = keys.iterator();
              while (it.hasNext()) {
                  SelectionKey key = (SelectionKey) it.next();
                  if ((key.readyOps() & SelectionKey.OP_ACCEPT) == SelectionKey.OP_ACCEPT) {
                   Socket s = serverSocket.accept();
                   SocketChannel sc = s.getChannel();
                   sc.configureBlocking( false );
                   sc.register( selector, SelectionKey.OP_READ );
                  } else if ((key.readyOps() & SelectionKey.OP_READ) == SelectionKey.OP_READ) {
    //.....Unfortunately synchronizing on the selector didn't have the effect I expected. When another thread select()s, it sees the same key list as the other thread that select()ed previously. When control arrives to serverSocket.accept(), one thread goes ahead and the other two catch an IllegalBlockingModeException.
    I'm not willing to handle this exception, the right thing to do is giving disjoint key sets to each thread. How can I achieve this goal?
    Thanks in advance

    A single thread won't be enough cause after reading data from the socket I do some processing on it that may take long.So despatch that processing to a separate thread.
    Most of this processing is I/O boundI/O bound on the socket? or something else? If it's I/O bound on the socket that's even more of a reason to use a single thread.
    Anyway I think I'll use a single thread with the selector, put incoming data in a queue and let other 2 or 3 threads read from it.Precisely. Ditto outbound data.
    Thanks for your replies. But I'm still curious: why is a selector thread safe if it can't be used with multiple threads because of it's semantics?It can, but there are synchronization issues to overcome (with Selector.wakeup()), and generally the cost of solving these is much higher than the cost of a single-threaded selector solution with worker threads for the application processing.

  • How can I use JavaScript extention functions with Xalan for transforming XML with XSL

    While transforming standart XML and XSL files to HTML with this servlet:
    package mypackage1;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import java.net.URL;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.StreamSource;
    import javax.xml.transform.stream.StreamResult;
    import org.mozilla.javascript;
    public class Servlet2 extends HttpServlet
    private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
    try
    response.setContentType(CONTENT_TYPE);
    PrintWriter out = response.getWriter();
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Source xmlSource = new StreamSource(new FileReader("c:/aaa.xml"));
    Source xslSource = new StreamSource(new FileReader("c:/bbb.xsl"));
    Transformer transformer = tFactory.newTransformer(xslSource);
    transformer.transform (xmlSource, new StreamResult(out));
    catch (Exception e)
    e.printStackTrace();
    everything is going ok,
    but when try to use javascript function in XSL file, for example like in this:
    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:lxslt="http://xml.apache.org/xslt" xmlns:my-ext="ext1"
    extension-element-prefixes="my-ext">
    <lxslt:component prefix="my-ext"
    functions="getdate">
    <lxslt:script lang="javascript">
    function getdate() {
    var d = new Date();
    return d.toUTCString();
    </lxslt:script>
    </lxslt:component>
    <xsl:template match="/">
    <p><xsl:copy-of select="my-ext:getdate()"/></p>
    </xsl:template>
    </xsl:stylesheet>
    recieve error-message:
    XSL-1000: (Fatal Error) Error while parsing XSL file (Extension function namespace should start with 'http://www.oracle.com/XSL/Transform/java/'.).
    What kind of namespace I should specify?

    Hello, Paul.
    I'm sure you may not use JavaScript as a language for creating XSLT extention functions with Oracle XDK Parser. This is since parser might have JavaScript interpreter to work with JavaScript, but it has not.
    If you need to build any XSLT extention functions you must build them as Java class' static methods.
    After that, you define the usage of the class by mean of namespace declaration as:
    xmlns:your-ns="http://www.oracle.com/XSL/Transform/java/yourpackage.Yourclass"
    (Prefix "http://www.oracle.com/XSL/Transform/java/" may differs if you use non-Oracle XML parser)
    and use class' static method in XSLT:
    <xsl:value-of select="your-ns.staticMethodName(paramsIfAny)"/>
    In your case you may wish to use standard Date class:
    xmlns:date="http://www.oracle.com/XSL/Transform/java/java.util.Date"
    <xsl:value-of select="date:toString(date:new)"/>

Maybe you are looking for

  • ADOBE, please fix CC application, it's broken beyond repair.

    Just look at the list of people have problems with CC application.  It's so bad that if you do a google search on the problem there will be 100+ pages of hits on the problems with CC from professionals to the hobbiest. I want to stay with Adobe produ

  • Looking for Orchestral music tutorials

    I am a starting Logic 8 express user and compose mainly classical orchestral music. Are there video tutorials that teach especially orchestral editing? I really would like to learn how to make a good recording of my music, professional spaced etc.

  • Problem with HTTP load balancing

    Hello Experts I have a problem when i do loadbalancing for links like http://1.1.1.1/site/home where 1.1.1.1 is the VIP address (i got http not found), while it is working fine when the link is http://1.1.1.1, the link is working fine on the real ser

  • 我在执行T_code:ppome的时候的错误,请问怎么解决?

    Runtime Errors CREATE_DATA_UNKNOWN_TYPE Except. CX_SY_CREATE_DATA_ERROR Date and Time 2009-01-13 10:59:08 Short text CREATE DATA: The specified type "HRP1654" is no valid data type. What happened? Error in the ABAP Application Program The current ABA

  • Query Related Collection Report

    Hi, I have created a report using Collection. How can i change the element width of Report Column In collection. Thanks Nisha