Stuck with these methods

Hello everyone.
the reason of this post is that I am a bit stuck with this class where I need to implement two methods and it is not working so far.
The class in question is:
public class MyPuzzle
    public static final int GRIDSIZE = 5;
    private int[][] squares;
    private String[][] rowConstraints;
    private String[][] columnConstraints;
    public MyPuzzle()
        squares = new int[GRIDSIZE][GRIDSIZE];
        rowConstraints = new String[GRIDSIZE][GRIDSIZE - 1];
        columnConstraints = new String[GRIDSIZE][GRIDSIZE - 1];
        for (int row = 0; row < GRIDSIZE; row++) {
            for (int column = 0; column < GRIDSIZE - 1; column++) {
                rowConstraints[row][column] = " ";
        for (int column = 0; column < GRIDSIZE; column++) {
            for (int row = 0; row < GRIDSIZE - 1; row++) {
                columnConstraints[column][row] = " ";
    public void setSquare(int row, int column, int val)
        if ((1 <= val) && (val <= GRIDSIZE)) {
            squares[row][column] = val;
        else {
            System.out.println("Error - Illegal value " + val);
    public void setRowConstraint(int row, int col, String relation)
        if (relation.equals("<") || relation.equals(">")) {
            rowConstraints[row][col] = relation;
    public void setColumnConstraint(int col, int row, String relation)
        if (relation.equals("<") || relation.equals(">")) {
            columnConstraints[col][row] = relation;
    public void fillPuzzle()
       setColumnConstraint(0, 1, ">");
       setRowConstraint(4, 0, "<");
       setRowConstraint(4, 2, "<");
       setColumnConstraint(4, 3, "<");
       setColumnConstraint(4, 2, "<");
       setRowConstraint(3, 1, "<");
       setRowConstraint(1, 3, ">");
       setSquare(4, 0, 4);
    public void printPuzzle()
        for (int row = 0; row < GRIDSIZE - 1; row++) {
            drawRow(row);
            drawColumnConstraints(row);
        drawRow(GRIDSIZE - 1);
    private void printTopBottom()
        for (int col = 0; col < GRIDSIZE; col++) {
            System.out.print("---   ");
        System.out.println();
    private void drawColumnConstraints(int row)
        for (int col = 0; col < GRIDSIZE; col++) {
            String symbol = " ";
            if (columnConstraints[col][row].equals("<")) {
                symbol = "^";
            else if (columnConstraints[col][row].equals(">")) {
                symbol = "V";
            System.out.print(" " + symbol + "    ");
        System.out.println();
    private void drawRow(int row)
        printTopBottom();
        for (int col = 0; col < GRIDSIZE; col++) {
            String symbol;
            if (squares[row][col] > 0) {
                System.out.print("|" + squares[row][col] + "|");
            else {
                System.out.print("| |");
            if (col < GRIDSIZE - 1) {
                System.out.print(" " + rowConstraints[row][col] + " ");
        System.out.println();
        printTopBottom();
[/code]
The two methods I am trying to implement are:
-isLegal should return a boolean value that tells us whether the puzzle configuration is legal or not. That is, if there is a repeated value in any row or column, or if there is an incorrect value (the number 1024 for instance) anywhere, or if any of the constraints is violated isLegal should return false; otherwise it should return true.
-if the puzzle is not legal, getProblems should return a String describing all the things that are wrong with the configuration.
If anyone may help, I will be eternally gratefull.
Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Hello everyone.
the reason of this post is that I am a bit stuck with this class where I need to implement two methods and it is not working so far.
The class in question is:
public class MyPuzzle
public static final int GRIDSIZE = 5;
private int[][] squares;
private String[][] rowConstraints;
private String[][] columnConstraints;
public MyPuzzle()
squares = new int[GRIDSIZE][GRIDSIZE];
rowConstraints = new String[GRIDSIZE][GRIDSIZE - 1];
columnConstraints = new String[GRIDSIZE][GRIDSIZE - 1];
for (int row = 0; row < GRIDSIZE; row++) {
for (int column = 0; column < GRIDSIZE - 1; column++) {
rowConstraints[row][column] = " ";
for (int column = 0; column < GRIDSIZE; column++) {
for (int row = 0; row < GRIDSIZE - 1; row++) {
columnConstraints[column][row] = " ";
public void setSquare(int row, int column, int val)
if ((1 <= val) && (val <= GRIDSIZE)) {
squares[row][column] = val;
else {
System.out.println("Error - Illegal value " + val);
public void setRowConstraint(int row, int col, String relation)
if (relation.equals("<") || relation.equals(">")) {
rowConstraints[row][col] = relation;
public void setColumnConstraint(int col, int row, String relation)
if (relation.equals("<") || relation.equals(">")) {
columnConstraints[col][row] = relation;
public void fillPuzzle()
setColumnConstraint(0, 1, ">");
setRowConstraint(4, 0, "<");
setRowConstraint(4, 2, "<");
setColumnConstraint(4, 3, "<");
setColumnConstraint(4, 2, "<");
setRowConstraint(3, 1, "<");
setRowConstraint(1, 3, ">");
setSquare(4, 0, 4);
public void printPuzzle()
for (int row = 0; row < GRIDSIZE - 1; row++) {
drawRow(row);
drawColumnConstraints(row);
drawRow(GRIDSIZE - 1);
private void printTopBottom()
for (int col = 0; col < GRIDSIZE; col++) {
System.out.print("--- ");
System.out.println();
private void drawColumnConstraints(int row)
for (int col = 0; col < GRIDSIZE; col++) {
String symbol = " ";
if (columnConstraints[col][row].equals("<")) {
symbol = "^";
else if (columnConstraints[col][row].equals(">")) {
symbol = "V";
System.out.print(" " + symbol + " ");
System.out.println();
private void drawRow(int row)
printTopBottom();
for (int col = 0; col < GRIDSIZE; col++) {
String symbol;
if (squares[row][col] > 0) {
System.out.print("|" + squares[row][col] + "|");
else {
System.out.print("| |");
if (col < GRIDSIZE - 1) {
System.out.print(" " + rowConstraints[row][col] + " ");
System.out.println();
printTopBottom();
}The two methods I am trying to implement are:
-isLegal should return a boolean value that tells us whether the puzzle configuration is legal or not. That is, if there is a repeated value in any row or column, or if there is an incorrect value (the number 1024 for instance) anywhere, or if any of the constraints is violated isLegal should return false; otherwise it should return true.
-if the puzzle is not legal, getProblems should return a String describing all the things that are wrong with the configuration.
If anyone may help, I will be eternally gratefull.
Thanks.

Similar Messages

  • Enhanced SAP class with new methods - Not showing these from standard task

    Dear Gurus,
    I have enhanced SAP standard class with new methods. After I have activated my new methods and would like to create a workflow task using these new methods. when I create a task and input object category as "ABAP Class" and object type is SAP enhanced class. When I try to drop down for methods SAP is not showing my new methods. I do not know why. Am I missing any? Any help would be appreciated.
    Note: Remember I am trying to use SAP ABAP class custom methods.
    Thanks,
    GSM

    Hi,
    Your thread has had no response since it's creation over
    2 weeks ago, therefore, I recommend that you either:
    - Rephrase the question.
    - Provide additional Information to prompt a response.
    - Close the thread if the answer is already known.
    Thank you for your compliance in this regard.
    Kind regards,
    Siobhan

  • Stuck with problems and no help

    hi,
    We are stuck with the following set of problems. Repeated entries to this forum have not fetced any response. If anybody can help us on any of these issues, please reply -
    1. We are not able to define any custom validator. We made our own validator that extends CompareValidor, but when we try to apply this rule to an attribute in the validation tab, we get the error - "no properties defined". Do i need to do something else besides creating a new class that extends CompareValidator and then writing my own code in the vlaidate method.
    2. While deploying our jspApplication on java web server, we are getting the message "error - null". The details are as mentioned in the Topic 'can anyone help!!!' that has been posted by Prabhdeep ().
    3. I have two tables, Customer and address. There is no FK between them (there cannot be because address is shared between many entities). In the address, i have 2 fields, BpType and BpId. BpType will contain 'C' to identity that this address is for a customer and id will have the customer id. In jdev 3.1, i have created entity and view objects for the 2 tables. also, i have made a view link. i need to put the condition Address.bpid = customer.customeid and address.bptype = 'c'. but it is not letting me put the second part of the condition. the chk on id works fine. as soon as i add a chk on type and test the application module, then while insertion of address i get the following error - "set method for BpType cannot be resolved".
    4. I have made a jsp appl based on bc4j. now, i need to put a check on any entity in such a manner that if the check fails, my jsp should ask the user that an exception is occuring and does he want to save even with the exceptional data. if he says yes, i want that the same entity should now save the data without giving an exception. How do i achieve this interaction between my entity and my jsp.
    Thanks a lot for any help,
    Aparna.

    I will answer Question #3:
    I'm not sure if I understand exactly what is
    happening. At first I thought you meant that you couldn't even add the second part of the association clause. But, later it sounds like you were able to add the second part of the clause (namely "address.bptype =
    'c'") and that you are experiencing some runtime error.
    Assuming the latter (that it is a RT problem), I take it this
    "...cannot be resolved" error is the error with code 27020.
    Under normal error conditions, you shouldn't get this error. Something "unusual" (or unforeseen by us) is happening if you are getting this error. Anyway, if you wrote your own client code, you should wrap a try/catch block around it, pick out the detail exception, and see what's going
    on. See the example code below:
    try
    ... make call that causes the exception ...
    catch(oracle.jbo.AttrSetValException ex)
    // Print stack trace for the outer ex
    ex.printStackTrace();
    // Get the inner exception
    Object[] details = ex.getDetails();
    if (details.length > 0)
    Exception innerEx = (Exception) details[0];
    // Now, print the inner exception's
    // stack.
    innerEx.printStackTrace();
    This will help shed some light on the exception and the cause of it.
    John - JDeveloper Team

  • Stuck with the basics..

    Hi!
    this is not a programming problem, but it seems that i am stuck with the basic , i am trying to implement my custom  PushBufferDataSource and a PushBufferStream, but i am not able to understand that how the      read(Buffer buffer) method and the transferHandler thing work..(i.e. when they are called and by whom)
    i would be thankful if someone can briefly explain me these things..

    There are 2 functions on a processor, setMediaTime (start time) and setStopTime(end time) that you can use to make a processor play only a portion of a file and then stop. So, if you use those to make a processor only play part of a file, you can make the datasink attached to the processor only save a portion of the file. No special implementations needed.
    Take a look at the API, and play around with it.
    http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/apidocs/
    That should be enough to get you going...

  • My Mac Book Pro suddenly gets stuck with weird horizontal colored lines across the screen, which will only go once I restart the laptop. What can I do?

    Randomly while scrolling, the screen just goes beserk and gets stuck with random colored lines. And, the only way to get rid of this is to restart my entire computer. My laptop is about 3 years old now. Is this a sign of age or what? What can I do to run my laptop smoothly without turning it off and on every time it goes crazy?

    Try resetting PRAM and SMC.
    Reset PRAM.  http://support.apple.com/kb/PH4405   x
    Reset SMC.     http://support.apple.com/kb/HT3964
    Choose the appropriate method.
    "Resetting SMC on portables with a battery you should not remove on your own".

  • Ipod nano stuck with double arrows

    My nano is stuck with the double arrows (rewind) showing in the upper right hand corner. When I press play the song is just stuck with the first note playing over and over

    The first things to try are these basic troubleshooting steps.
    The Five Rs.

  • Stuck with Foreground and Background processing in Workflow

    Hi All,
    I have a BDC that is acting as a method in the Business Object. The requirement is something like this: The scenario is in the Utilities System. When a customer pays a security deposit a PM (Plant Maintanence) Service Order has to get created automatically in the background. I have a BDC for creating the Service Order but the thing is that if I make that task which runs the BDC as foreground and give the agent assignment it works absolutely fine and the service order gets generated, but if I make the same task as background the Service Order does not get created. I am heavily stuck with this issue.
    Has anybody encountered the same issue ?
    Best Regards,
    Sudhi

    Sudhindra,
    Are you checking for errors after the BDC Call Transaction? What I normally do is to use the Messages into option of the BDC call and return the messages to the Task Container in case of errors.
    Reasons why the method does not work in background is possibly due to authorizations or the WF-BATCH user being not known to the PM system. For instance when I create PM notifications in WF in background, I have to translate the WF initiator's user id to their Personnel Number for the Resp. Person field. If in your workflow the prior step to creating order is a dialog step, you can also try the Advance with dialog option on the background step.
    Cheers,
    Ramki Maley.

  • My iMac is stuck with a grey screen with a icon of a lock.

    My iMac is stuck with a grey screen with a icon of a lock.

    You enter Target Disk mode by launching the iMac with the "T" key held down or by the method you used.  It's used so another Mac connected to it can access the files as if it were another external HD.  This document describes the process: Target Disk Mode,  Transferring files between two computers using FireWire

  • Stuck with waiting for changes to be applied to syncing?

    Am stuck with waiting for changes to be applied to syncing?
    what can I do?

    Did yo try all of these:
    SOLUTION: Some Music Won't Play After Upgrading Your iPhone To iOS7
    Red square in red circle cannot play songs
    My iPod isn't playing certain songs. Help?
    Remove Red Circles with Square in middle

  • Inbound Queues stuck with RFC errors

    Hi Experts,
    Greetings for the Day !
    We have BDOC related issue and we need your expert help ASAP in resolving the same.
    We ahev a few BDOCS lying in intermediate state in transaction SMW01, which we found using BDOC monitoring on daily basis. When we check the same in SMQR - inbound queue, we found that the queues are stuck with an RFC error message.
    We are re-activate these queues to actually resolve the intermediate bdocs. But, my query is
    1> The raeson for getting these BDOCS in intermediate state & stuck queues
    2> A permanent resolution for the same.
    Please help and  let us know if you need more details.
    Regards,
    Kanika

    Hi Kanika,
    RFC error can be due to a bad connection as well. If the server is down, there might be a problem in communication with the connected system and the queues will not be processed further. You need to reactivate or unlock to get the queues processed.
    But if there are any specific errors for which the queues are stuck do state the same, so that we can look into an actual resolution.
    Regards,
    Venkat

  • Interface with static methods

    I'm writting a wrapper for exception handling.One of the classes uses log4j to log exceptions.I want to write a interface to generalize loggin.Idealy I should have an interface with certain static methods for loging (i.e logError,logDebugMessage,consoleError,consoleMessage,etc) , but Interface dosent allow that and neither do abstract classes can havstatic method declarations.The implementations of these methods will achieve the hiding of the complexity of using a logging package,log levels etc from the user.
    Let me know how best I can work something out for this.
    Thanks in advance

    Define them once (as final) in an abstract class. Then any subclass can call logError etc.
    Kind regards,
      Levi

  • Problem with getPrimaryKeys method in DatabaseMetaData

    I'm using the above mentioned method to get primary keys from a DB2 database. I estimate that 95% of the time it performs as expected, but there are 7 tables in my database, that as far as I can see, are no different to any others and it fails to work with these. Looking at the tables in the DB2 control centre shows them all having keys, no different to any of the other tables. Also of note is that the tables it fails on are next to each other, it fails on tables 68 and 69, 135 and 136 and 200,201 and 202. Just wondering if anyone else has seen this problem before and if they found any solutions for it?
    Just ran through the program again and it's failed on a completely different set of tables, they're all sequential as well, could this be a problem with my connection to the db?
    Edited by: jnaish on Aug 14, 2008 7:38 AM

    post the ddl and code i guess
    i doubt this is related to your connection
    Also of note is that the tables it fails on are next to each other, i can't imagine that would be a problem, but sounds like it'd be easy for you to prove your theory with a simple test

  • Please help with this method, cant get it to work correctly.

    any suggestions AT ALL please, im really stuck with this.
    im creating a little animation of pacman, just an animation of it moving buy its self. im using the java elements package so this is all being shown in a drawing window.
    ive made it move fine and go round the window abit eating dots but the code is a mess, and i know i could change some of the main part into a few simple methods and have tried but it seems to stop moving when i try
    import element.*;
    import java.awt.Color;
    static DrawingWindow d = new DrawingWindow(500,500);  
       public static void wait1second()
        //  pause for one tenth of a second second
            long now = System.currentTimeMillis();
            long then = now + 100; // 100 milliseconds
            while (System.currentTimeMillis() < then)
        public static void waitNSeconds(int number)
            int i;
            for (i = 0; i < number; i++) //allows you to determine how long to pause for
                wait1second();
    public static void main(String[] args) {
        //  declaring the variables
        int pacsize1 = 50, pacsize2 = 50;
        int pac1x = 20, pac1y = 20;
        int pacmouth1 = 45, pacangle1 = 270;
        int pacmouth2 = 25, pacangle2 = 320;
        int pacmouth3 = 6, pacangle3 = 348;
        int startmv = 0, stopmv = 33;
        d.setForeground(Color.black);
        Rect bkrnd = new Rect(0,0,500,500);     
        d.fill(bkrnd);
       // while loop used to make the pacman shape move right across the screen with its mouth in three different states
    Arc pacarc = new Arc();
         while (startmv++<stopmv)
            pac1x += 4;
            d.setForeground(Color.yellow);
            pacarc = new Arc(pac1x,pac1y,pacsize1,pacsize2,pacmouth1,pacangle1);
            d.fill(pacarc);
            d.setForeground(Color.black);
            waitNSeconds(1);
            d.fill(pacarc);
            pac1x += 4;
            d.setForeground(Color.yellow);
            pacarc = new Arc(pac1x,pac1y,pacsize1,pacsize2,pacmouth2,pacangle2);
            d.fill(pacarc);
            d.setForeground(Color.black);
            waitNSeconds(1);
            d.fill(pacarc);
            pac1x += 4;
            d.setForeground(Color.yellow);
            pacarc = new Arc(pac1x,pac1y,pacsize1,pacsize2,pacmouth3,pacangle3);
            d.fill(pacarc);
            d.setForeground(Color.black);
            waitNSeconds(1);
            d.fill(pacarc);
    }so i tried making a method to make all the stuf in the while loop alot simpler but it just keeps making the pacman not move at all and im not sure why. heres the code i tried for the method:
    public static void pacmve(int pactestx, int pactesty, int pacsizetest1, int pacsizetest2, int pacmouthtest, int pacangletest)
            pactestx += 4;
            Arc pacarc = new Arc();
            d.setForeground(Color.yellow);
            pacarc = new Arc(pactestx,pactesty,pacsizetest1,pacsizetest2,pacmouthtest,pacangletest);
            d.fill(pacarc);
            d.setForeground(Color.black);
            waitNSeconds(1);
            d.fill(pacarc);
            }it had no problems with the code, but it just doesnt seem to do anything when i call it in the while loop. heres how i used it to try and just make it move across with the mouth in one state:
    while (startmv++<stopmv)
    pacmve(20,20,50,50,45,270);
    }any ideas?
    Edited by: jeffsimmo85 on Nov 22, 2007 2:36 AM

    the clock is still ticking while you do this:
    while (System.currentTimeMillis() < then)
    is that method your design? why not just call Thread.sleep()?
    %

  • Iphone stuck with apple symbol and wont start up

    i updated my iphone and when it finished and went to reboot it just stays stuck on the apple symbol it constantly reboots and will never connect to my laptop i dont know what to do if anyone can help please do

    Hi,
    Luca224 & Ingo2711. Thanks for bringing this topic. on 29th Nov. I faced the same problem on my iPhone 3GS 32GB Firmware 3.1.2, iPhone stuck with apple symbol and wont start up. I have tried with 10 Seconds Sleep/wake-up button + home button to reset. But didn't work. Did google about an hour with many blogs. Finally I made a call to 3 iPhone care and spent 30 minutes and explained whatever I have done; iPhone customer care asked me to go to nearby iPhone service center in Sydney. BUT BY LUCK CLICKED ON iTUNE AND GOT THE OPTION FOR ONLINE FORUM FOR APPLE iPHONE. Many many thanks to Ingo2711 who has given the solution link and also thanks to Luca224 , who raised the issue. I feel, this is a common problem with iPhones those who using iPhone 3GS 3.1.2...... but try the link http://support.apple.com/kb/HT1808 and thanks to Luca224 & Ingo2711. PLEASE FOLLOW THE INSTRUCTION CAREFULY:
    1. Verify you have iTunes 7.5 or later. Apple recommends using the latest version of iTunes.
    2. Disconnect the USB cable from the iPhone or iPod touch, but leave the other end of the cable connected to your computer's USB port.
    3. Power off the device (Press and hold the Sleep/Wake button for a few seconds until the red slider appears, then slide the slider. Wait for the the iPhone or iPod touch to turn off. _+(in my case - red slider didn't appear, but i pressed the Sleep/Wake button until the iPhone went off, finally it was just off... i was frustrated... tried 3 times with more patience )+_
    4. Press and hold the Home button while reconnecting the USB cable to iPhone. When you reconnect the USB to iPhone, the device should then power on. +_( Do exactly as it says)_+
    Note: If you see the message "Charging... Please Wait" or you see the screen pictured below, let the device charge for at least 10 minutes to ensure the battery has some charge and then start with step 2 again. +_(True ... for me it happened 3 times)_+
    5. Continue holding the Home button while iPhone starts up. While starting up, you will see the Apple logo. +_( I was nearly frustrated at my 3rd attempet; my thumb was hurting as I was holding the home button for few minutes..... but finally it worked yahooooooooooooooooo...... suddenly changed my decision.... about going to 3/Apple service center)_+
    6. When you see "Connect to iTunes" on the screen, you can release the Home button and iTunes will display the recovery mode message:
    If you don't see the "Connect to iTunes" screen, then disconnect the USB cable from iPhone and repeat steps 3-6.
    Because you must restore iPhone or iPod touch, iTunes will not recover data from the device, but if it was previously synced on the same computer and the same user account, it should restore a backup (if available). See document HT1414, "Updating and Restoring iPhone Software."
    If you are still unable to restore the iPhone using this method, check Apple support for further troubleshooting and/or service options.
    Note: If you sync both an iPhone and an iPod touch to the same computer, make sure you select the correct backup to restore your settings from (don't select an iPhone backup if you have an iPod touch and don't select an iPod touch backup if you have an iPhone).
    **** ( BACKUP FROM YOUR iTUNES : MAC/PC; AS I GOT MY 95% DATA FROM THERE.... GOOD LUCK)******* IF IT WORKS PLEASE POST YOUR EXPERIENCE....*
    THANKS

  • Can I call an object with synchronized methods from an EJB

    I have a need for multiple threads (e.g. Message Driven Beans) to access a shared object, lets say a singleton, I'm aware of the "you can't have a singleton in the EJB world" issues) for read/write operations, so the operations will need to be synchronised.
    I've seen various statements such as you can't use read/write static fields in EJBs and you can't use synchronisation primitives in EJBs but I've also seen statements that say its okay to access utility classes such as Vector (which has synchronised methods) from an EJB.
    Does anyone know if there is a definitive answer on this? What are the implications of accessing a shared object with synchronised methods from multiple EJBs? Is it just that the EJB's thread may block which limits the ability of the container to manage the EJBs? In the Vector example above (from Professional Java Server Programming) did they mean its okay to use these utility classes provided they aren't shared across threads?
    If I can't use a plain old Java Object does anyone know if there are other potential solutions for sharing objects across EJBs?
    In my problem, I have an operation that I want to run in a multi-threaded way. Each thread will add information to the shared object, and this info may be used by the other threads. There's no lengthy blocking as such other than the fact that only one thread can be adding/reading information from the shared object at a time.
    I've trawled through this forum looking for similar questions of which there seem to be many, but there doesn't seem to be any definitive answers (sorry if there was and I missed it).
    Thanks
    Martin

    You can share objects among EJB's or among objects used by one or more EJB's. You can use synchronization primitives - nothing will prevent you from doing that.
    After all, the container classes, JVM-provides classes, JDBC, JCA, JNDI and other such classes do all of this with impunity. You can too. You can use file and socket I/O as well, presuming you configure the security profile to allow it. Should you? Well it depends on what you need to accomplish and if there is another practical alternative.
    Yes the specification warns you not to, but you cannot be responsible for the interior hidden implementation of classes provided to you by the JVM or third parties so you can never truly know if your are breaking these written rules.
    But when you do these things, you are taking over some part of the role of the container. For short running methods that only block while another thread is using the method or code block and no I/O or use of other potentially blocking operations are contained in the method/block, you will be fine. If you don't watch out and create deadlocks, you will harm the container and its managed thread pool.
    You should not define EJB methods as synchronized.
    Also, if you share objects between EJB's, you need to realize that the container is free to isolate pools of your EJB in separate classloaders or JVM's. It's behavior can be influenced by your packaging choices (use of .ear, multiple separate .jar's, etc.) and the configuration of the server esp. use of clustering. This will cause duplicate sets of shared classes - so singletons will not necessarily be singleton across the entire server/cluster, but no single EJB instance will see more than one of them. You design needs to be tolerant of that fact in order to work correctly.
    This isn't the definitive answer you asked for - I'll leave that to the language/spec lawyers out there. But in my experience I have run across a number of occasions where I had to go outside of the written rules and ave yet to be burned for it.
    Chuck

Maybe you are looking for

  • Is there a way to create a year at a glance with detail and print?

    Is there a way to create a year at a glance with detail and print?

  • Wma to mp3 converter

    I downloaded a conversion program "wma to mp3 converter" to be able to listen to wma music files in my computer. However when I click on the file, just the programmers' codes appear, nothing else. How can I activate the converter program? That is, ho

  • Using dbms_xmlgen.convert to capture URL

    I am using a web service that returns XML response (see result below). I need to capture the URL in the 'GetIEPUrlWithAuditResult' tag. I tried this code but get a ORA-30625: method dispatch on NULL SELF argument is disallowed. Is my dbms_xmlgen.conv

  • How do I know if I set up Apple's two factor authentication?

    How can I tell if I ever set up Apple's two factor authentication and should make sure I can find the Recovery Key?

  • Child nodes as document object

    I have a xml document as follows: <Root> <Header><Name></Name></Header> <Message><Type></Type></Message> </Root> I can read entire xml file into document object. Now I want to take only <Message> elements (Including Message child nodes) into document