comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* Send and retrieve pictures from my computer at home using my cell - 1 
messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6e9842e6a7341b7
* array - 6 messages, 5 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/53af4d09d2b14807
* Let a runtime exception go beyond a Thread? - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cd0b7eae55d576e3
* Sending mail - Created By field contains junk information - 1 messages, 1 
author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f36d7268525953f7
* [J2ME]How to avoid memory fragmentation - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cb6a26addf63af68
* Advanced question about generics - 3 messages, 3 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/70947db3058ccce1
* Correct Semaphore Implementation in Java - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8259aec1ceed4f8f
* Anti-aliasing GIF Images - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2cc5fef6d79db9b7
* JAXB : expecting an automatical control in java source when restrictions are 
specified in XML schema - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/31da199eccd3127
* Configure a singleton - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7e33c5a6bd77128b
* Java and image resize - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4eaffabaf616cdb7
* tricky+frustrating: changing mouse handler while mouse pressed doesn't work - 
1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d860374b64c95232
* best pratices in Exception Handling - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b7f7ffa192845fec
* Array referencing - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1e5bd96d75c26308
* Which is better... performance- and memory-wise? - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bb866c6ac7a64180
* Servlet OutOfMemory on images. Please help me! - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2b54ac9443545bf3
* How to use Transactions in stateless session bean? - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ee73b722c1d5e795

==============================================================================
TOPIC: Send and retrieve pictures from my computer at home using my cell
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6e9842e6a7341b7
==============================================================================

== 1 of 1 ==
Date: Fri, Nov 26 2004 8:09 am
From: Andrew Thompson  

On Thu, 25 Nov 2004 22:40:07 -0800, marcus wrote:

> Java does not run in a sandbox.

Applet, midlet...

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane




==============================================================================
TOPIC: array
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/53af4d09d2b14807
==============================================================================

== 1 of 6 ==
Date: Fri, Nov 26 2004 4:24 pm
From: "nick"  

what is the differnet between

char[][] s;

and

char s[][];

thanks! 





== 2 of 6 ==
Date: Fri, Nov 26 2004 8:54 am
From: Gerard Krupa  

nick wrote:
> what is the differnet between
> 
> char[][] s;
> 
> and
> 
> char s[][];
> 
> thanks! 
> 
> 

There is no difference in the example that you have given.  If you apply 
the array modifier to the type then it will be applied to all variables 
declared on that line.  For example...

   char a[], b, c;

creates one array and three chars but...

   char[] a, b, c;

creates three arrays.  The two forms are additive so...

   char[] a, b[];

produces a one-dimensional array 'a' and a two-dimensional array 'b'.

This is documented at 
http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html#25891

HTH
Gerard



== 3 of 6 ==
Date: Fri, Nov 26 2004 9:47 am
From: Thomas Weidenfeller  

nick wrote:
> what is the differnet between
> 
> char[][] s;
> 
> and
> 
> char s[][];

Non. Some will argue that one is better (better readable, 
understandable, more logical, etc.) than the other.


BTW: Consider to consult your textbook first for such beginner 
questions. If you can't find this in your textbook consider posting 
beginner's questions to comp.lang.java.help.

/Thomas


-- 
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq



== 4 of 6 ==
Date: Fri, Nov 26 2004 9:56 am
From: Michael Borgwardt 
 

nick wrote:

> what is the differnet between
> 
> char[][] s;
> 
> and
> 
> char s[][];

The first is more logical, since it keeps type information together.
But there are no semantic differences at all, both will result in the
same bytecode.



== 5 of 6 ==
Date: Fri, Nov 26 2004 9:53 am
From: "Tony Morris"  

> produces a one-dimensional array 'a' and a two-dimensional array 'b'.

Do not be misled.
Java does not have multi-dimensional arrays.

-- 
Tony Morris
http://xdweb.net/~dibblego/





== 6 of 6 ==
Date: Fri, Nov 26 2004 11:41 am
From: Gerard Krupa  

Tony Morris wrote:
>>produces a one-dimensional array 'a' and a two-dimensional array 'b'.
> 
> 
> Do not be misled.
> Java does not have multi-dimensional arrays.
> 

WMMOWS - Should have said array of arrays, not n-dimensional arrays. 
Reformed C++ developer I'm afraid :)

SFT
Gerard




==============================================================================
TOPIC: Let a runtime exception go beyond a Thread?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cd0b7eae55d576e3
==============================================================================

== 1 of 1 ==
Date: Fri, Nov 26 2004 9:26 am
From: Jaap de Bergen  

On 26 Nov 2004 08:30:10 +0100, Gordon Beaton <[EMAIL PROTECTED]> wrote:

>On Thu, 25 Nov 2004 21:49:04 +0100, Jaap de Bergen wrote:
>> I'm using a O/R framework which throws a runtimeexception when
>> something goes wrong (for example a column is missig from the
>> database).
>
>[...]
>
>> That was a good idea, but it doesn't work. I guess because when i
>> launch a thread:
>
>That's because each thread has its own call stack, and exceptions only
>propagate up the call stack.
>
>> Does anybody know how i can get the runtimeexception reach the root
>> of my application?
>
>There is a way you can be notified of exceptions occurring in other
>threads. Have a look at ThreadGroup.uncaughtException(), or (if you're
>using 1.5) Thread.setUncaughtExceptionHandler(). 
>

Thanks Gordon. The ThreadGroup solution works perfect.

As a side note/joke: i'm wondering where a exception will end when i
throw it in ThreadGroup.uncaughtException(), it seems to disappear
completely ;-)


Jaap




==============================================================================
TOPIC: Sending mail - Created By field contains junk information
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f36d7268525953f7
==============================================================================

== 1 of 1 ==
Date: Fri, Nov 26 2004 9:29 am
From: "Jack Andersson"  

> It looks like it might be the mail server. Do you have an alternative
> SMTP server to test it on?

I've tried to use another mail server with the same result. Even more
strange, the Created By-adress changes only when the sender is in our
company domain, i e

InternetAddress reply[] = new InternetAddress[1];
reply[0] = new InternetAddress("[EMAIL PROTECTED]");

the Created By-field becomes:

"[EMAIL PROTECTED]"[EMAIL PROTECTED]

But if I use

InternetAddress reply[] = new InternetAddress[1];
reply[0] = new InternetAddress("[EMAIL PROTECTED]");

the Created By-field becomes:

[EMAIL PROTECTED]

which is correct.

> Also trying putting Javamail in debug mode and watch what it sends to
> the server. It should show the reply-to being written, so you can see
> if it is going in clean.

No useful information there, I'm afraid.







==============================================================================
TOPIC: [J2ME]How to avoid memory fragmentation
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cb6a26addf63af68
==============================================================================

== 1 of 1 ==
Date: Fri, Nov 26 2004 9:33 am
From: "DNass"  

when I see the content length of the file received and the amount
of free memory (with the method Runtime.getRuntime().freeMemory()) it seems
that
my app can handle the response but then I have the error message.

Thank you JScoobyCed, I am going to try to
obfuscate the app and let you know.


"JScoobyCed" <[EMAIL PROTECTED]> a écrit dans le message de
news:[EMAIL PROTECTED]
> DNass wrote:
>
> > I have this system error message saying "this application is
> > using too much memory", I know that the app uses about 150k of RAM
> > and the mobile has 260 k
>
> If the application has pictures, try to decrease their sizes. This will
> help lowering the app size. Then use an obfuscator to optimize the byte
> code and reduce again the size.
> Now if the file received by HTTP is bigger than the available memory, it
> might crash the app too.
>
> JScoobyCed

DNass






==============================================================================
TOPIC: Advanced question about generics
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/70947db3058ccce1
==============================================================================

== 1 of 3 ==
Date: Fri, Nov 26 2004 12:46 am
From: [EMAIL PROTECTED] (Jesper Nordenberg) 

"Vincent Cantin" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL 
PROTECTED]>...
> Hello,
> 
> I have a class Server<C extends Connection> that accepts some connections 
> are for each of them creates an instance of C.
> 
> Problem : the implementation of the class need to have C.class in order to 
> create its instance but it doesn't know it unless I ask the user of my class 
> to give it in parameter.
> 
> So the user of the class write something like that :
> 
>     Server server = new Server<MyConnection>(MyConnection.class);
> 
> but I would like him to only write something like that :
> 
>     Server server = new Server<MyConnection>();
> 
> Is there something in the language of Java 1.5 that can do implicitly what I 
> want ?

No, not possible because of type erasure. A flexible solution is to
pass a factory object that create the instances, for example:

Server server = new Server<MyConnection>(new Factory<MyConnection>() {
  public MyConnection create() {
    return new MyConnection();
  }
});

public interface Factory<T> {
  T create();
}

This has several advantages over directly calling a constructor using
reflection.

/Jesper Nordenberg



== 2 of 3 ==
Date: Fri, Nov 26 2004 11:15 am
From: Michal Kleczek  

Jesper Nordenberg wrote:
> "Vincent Cantin" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL 
> PROTECTED]>...
> 
>>Hello,
>>
>>I have a class Server<C extends Connection> that accepts some connections 
>>are for each of them creates an instance of C.
>>
>>Problem : the implementation of the class need to have C.class in order to 
>>create its instance but it doesn't know it unless I ask the user of my class 
>>to give it in parameter.
>>
>>So the user of the class write something like that :
>>
>>    Server server = new Server<MyConnection>(MyConnection.class);
>>
>>but I would like him to only write something like that :
>>
>>    Server server = new Server<MyConnection>();
>>
>>Is there something in the language of Java 1.5 that can do implicitly what I 
>>want ?
> 
> 
> No, not possible because of type erasure. A flexible solution is to
> pass a factory object that create the instances, for example:
> 
> Server server = new Server<MyConnection>(new Factory<MyConnection>() {
>   public MyConnection create() {
>     return new MyConnection();
>   }
> });
> 
> public interface Factory<T> {
>   T create();
> }
> 
> This has several advantages over directly calling a constructor using
> reflection.
> 
> /Jesper Nordenberg
Hi,
actually it is the same as the original solution - but more verbose.
To avoid wiriting "MyConnection" twice you should use a static generic 
method:

public class Server<T extends Connection> {

   public static <S> Server<? extends S> create(Class<S> clazz) {
     return new Server<S>(clazz);
   }

   public Server(Class<T> c) {
   //...
   }

}

Client code:

Server<MyConnection> s = Server.create(MyConnection.class);

Cheers,
Michal



== 3 of 3 ==
Date: Fri, Nov 26 2004 4:04 am
From: "Vincent Cantin"  

Thank you for all the answers, it was usefull for me.

Vincent






==============================================================================
TOPIC: Correct Semaphore Implementation in Java
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8259aec1ceed4f8f
==============================================================================

== 1 of 1 ==
Date: Fri, Nov 26 2004 10:13 am
From: Andrea Desole  

Frank Gerlach wrote:
> Andrea Desole <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> 
>>I wouldn't say it's correct. There are two things that don't convince me:
>>1) a thread shouldn't be able to call V without calling P. You can't 
>>release a resource if you don't get it
> 
> That is right. There is nothing in my implementation preventing abuse.
> There should always be something like a P() .. V() brace in the using code.
> 
> 
>>2) notify is not deterministic. It would be better to have a FIFO queue, 
>>or there is a chance, altough small, that a thread will wait forever
> 
> Remote possibility
yes. I can't say how likely it is, but I also think it doesn't happen 
very often. Still, it can happen.

> 
>>I also know that some JVMs don't work as they should, and in some cases 
>>a waiting thread can wake up without notify being called.
> 
> Hmm. Can you elaborate on this ?
not really. It's something that someone showed me on a book (for more 
information look on "Effective Java", by Joshua Bloch, item 50). It just 
says that in many JVM implementations, apparently because of something 
related to the Posix standard, this problem can occur. They are called 
spurious wakeups. I think this is what Matt Humphrey in this thread 
calls spurious notify. In fact, both Matt and the book are suggesting to 
use a loop.




==============================================================================
TOPIC: Anti-aliasing GIF Images
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2cc5fef6d79db9b7
==============================================================================

== 1 of 2 ==
Date: Fri, Nov 26 2004 1:17 am
From: [EMAIL PROTECTED] (Kevin Bertman) 

I have created a Java Dodgems game at
http://www.kevinbertman.co.uk/japan/dodgemsRules.shtml

Each dodgem is a gif image. Since the applet often rotates each
dodgem, is there a way that I can use anti-aliasing to reduce the
jagged edges? Or can anti-aliasing only be applied to things 'drawn'
like drawLine, fillRect, or drawString?



== 2 of 2 ==
Date: Fri, Nov 26 2004 11:36 am
From: Thomas Weidenfeller  

Kevin Bertman wrote:
> Each dodgem is a gif image. Since the applet often rotates each
> dodgem, is there a way that I can use anti-aliasing to reduce the
> jagged edges? Or can anti-aliasing only be applied to things 'drawn'
> like drawLine, fillRect, or drawString?

Anitaliasing is indeed best done during rasterisation (what you call 
'drawing'). Which means, when some data with (theoretically) infinite 
resolution is fitted into the discrete raster of which e.g. a gif image 
consists of.

There are other techniques to reduce the effect in images. Essentially 
these are image filter. Typically a filter, like a bilinear filter, is 
applied to a super-sampled version of the image (an image e.g. 
originally created twice as large as needed) during downscaling. The 
results is a (hopefully only) slightly blurred image. It depends very 
much on the contents of the image, and the type of filtering if such an 
image is perceived as better or worse than the original. java.awt.image 
provides a few filters, you just have to try what works best for you.

/Thomas

PS: comp.lang.java.gui is next door.

-- 
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq




==============================================================================
TOPIC: JAXB : expecting an automatical control in java source when restrictions 
are specified in XML schema
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/31da199eccd3127
==============================================================================

== 1 of 1 ==
Date: Fri, Nov 26 2004 1:19 am
From: [EMAIL PROTECTED] (Jean-Marie Condom) 

yes i had forgotten to write this in my email ;
the pb was coming from the fact that i wasn't
using Ant so the grammar wasn't used since
file bgm.ser was absent
now all is ok !

jean-marie

> Perhaps:
> 
> <xsd:complexType name="Connexion">
>    <xsd:attribute name="reconnexion" type="ZeroOrOne" />
> </xsd:complexType>




==============================================================================
TOPIC: Configure a singleton
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7e33c5a6bd77128b
==============================================================================

== 1 of 1 ==
Date: Fri, Nov 26 2004 9:37 am
From: "ShadowMan"  

"Ferenc Hechler" <[EMAIL PROTECTED]> ha scritto nel messaggio
news:[EMAIL PROTECTED]
> OK,
> my first answer did not match your question: How to pass some
> config-file-data to a class containing a singleton.
> For example Log4J uses a default-configuration file
> "log4j.properties" or so, which is searched in the classpath.
> But you can change the configuration by explicitly setting the
> properties from another configuration file (PropertyConfigurator).
>
> I think this is a flexible way. Add a method setConfig(...) which
> overwrites some defaults which are used otherwise.

perfect...so this method should be static!
-- 
ShadowMan






==============================================================================
TOPIC: Java and image resize
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4eaffabaf616cdb7
==============================================================================

== 1 of 1 ==
Date: Fri, Nov 26 2004 9:30 am
From: Nigel Wade  

hopkins wrote:

> I want to automate the process of uploading photos to my web site.
> What I want java to be able to do is take a directory of photos,
> resize them appropriately, create and XML file based on their names,
> then FTP the whole lot.
> 
> My question is how well does java support jpeg resizing and whats
> java's ftp access like. I could probably do this task in PHP, but I
> thought I'll try java first.
> 
> Thanks!

There's probably no need to reinvent the wheel. Take a look at JAlbum
(http://jalbum.net/) and see if it meets your requirements.

-- 
Nigel Wade, System Administrator, Space Plasma Physics Group,
            University of Leicester, Leicester, LE1 7RH, UK 
E-mail :    [EMAIL PROTECTED] 
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555




==============================================================================
TOPIC: tricky+frustrating: changing mouse handler while mouse pressed doesn't 
work
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d860374b64c95232
==============================================================================

== 1 of 1 ==
Date: Fri, Nov 26 2004 10:40 am
From: Claus Atzenbeck  

Hi,

to summarize my previous mail:

How can I completely ignore incomming mouse events (basically mouseDragged)
from the "real" mouse in order to call:

        java.awt.Robot robot = new robot();
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        robot.mousePress(InputEvent.BUTTON1_MASK);

Any hint is appreciated!

Claus




==============================================================================
TOPIC: best pratices in Exception Handling
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b7f7ffa192845fec
==============================================================================

== 1 of 1 ==
Date: Fri, Nov 26 2004 1:42 am
From: [EMAIL PROTECTED] 

Hi

I am a rookie Java developer.
I am looking for a guide on design and architecture in Exception
generation and handling.

I have found a lot of tutorial on the syntax, but not one on how to
actually design a sensible Exception handling.

<rant>
( the 'think in Java' book is a farce, it should be named 'write the
correct syntax in Java', for instance...)
</rant>

anyone can direct me to a good tutorial ?
TIA,
--philippe





==============================================================================
TOPIC: Array referencing
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1e5bd96d75c26308
==============================================================================

== 1 of 1 ==
Date: Fri, Nov 26 2004 9:46 am
From: Nigel Wade  

[EMAIL PROTECTED] wrote:

> Hi,
> 
> Here is my routine. It is not working. Anyone see the problem?
> 
> public void  test ()
> {
> 
>     String[][] data_1 = {
>         { "AA_1",                   "Hello world" },
>         { "AA_2",                   "123456789" }
>         };
>     String[][] data_2 = {
>         { "BB_1",                   "Bla Bla" },
>         { "BB_1",                   "222222222" },
>         };
>     String[][] data_3 = {
>         { "CC_1",                   "Happy New Year" },
>         { "CC_1",                   "333333333" },
>         };
> 
>     for(int i=1; i <=3; i++){
> // following line is wrong. Anyone know how to do it??
>        String data_name[][] = "data_"+i;  
>        System_out_println(" first   = "+data_name[j][0];
>        System_out_println(" second  = "+data_name[j][1];
>     }
> }
> 
> Thank you!
> 
> Anders

Off the top of my head, one way to do this is to use a HashMap:

    HashMap dataMap = new HashMap();
...
    dataMap.put("data_1",data_1);
    dataMap.put("data_2",data_2);
    dataMap.put("data_3",data_3);
    for(int i=1; i <=3; i++){
       String[][] data_name = (String[][]) dataMap.get("data_"+i);  

This isn't a general solution to this type of problem, but for this specific
case it gets the job done, and it's pretty simple. 

-- 
Nigel Wade, System Administrator, Space Plasma Physics Group,
            University of Leicester, Leicester, LE1 7RH, UK 
E-mail :    [EMAIL PROTECTED] 
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555




==============================================================================
TOPIC: Which is better... performance- and memory-wise?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bb866c6ac7a64180
==============================================================================

== 1 of 1 ==
Date: Fri, Nov 26 2004 10:20 am
From: "Chris Uppal"  

Daniel Sjöblom wrote:

> I created a little test class, and ran it through a little JVMTI agent
> that dumps the JIT-generated native code, and I can confirm that at
> least on the client 1.5.0 JVM on x86 linux, the explicit assignment was
> not removed in the JIT-ed code. That was the only difference between the
> compiled code of the two different approaches.
>
> The server VM on the same JVM did generate equivalent code for both
> approaches. I suspect the client VM does not do any dead code elimination.

Interesting.  Thank you.

    -- chris






==============================================================================
TOPIC: Servlet OutOfMemory on images. Please help me!
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2b54ac9443545bf3
==============================================================================

== 1 of 1 ==
Date: Fri, Nov 26 2004 11:52 am
From: Michael Borgwardt 
 

Animanera wrote:
> BUT if 7 users CONCURRENTLY access to the servlet and execute the same 
> code, the 7 images are *contemporarily* in memory, saturating it.
> 
> My (ugly) idea on catching OOME was "if a user try to execute the 
> resizing and this operation throw an OOME, it means that too user are 
> executing this code, therefore for THIS user I sleep for a while loop 
> since the operation doesn't throw an OOME".

Very ugly.

> Simpler (and, maybe, better) solution should be declaring the resize 
> method as SYNCHRONIZED therefore only ONE user at a time can execute the 
> method (is it right, also if the method is static?). = no possibilities 
> to saturate the memory;

Should work, but limits your throughput more than necessary.

A clean alternative would be to keep count on how many calls are inside
the method at any one time and permit only a limited number (e.g. 5).

java.util.concurrent.Semaphore does exactly that, but is available only
in Java 1.5, or you can use the package it was based on:
http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html




==============================================================================
TOPIC: How to use Transactions in stateless session bean?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ee73b722c1d5e795
==============================================================================

== 1 of 1 ==
Date: Fri, Nov 26 2004 12:00 pm
From: "harry"  

Thanks Sudsy, I understand that bit but am still confused as to how to use
transaction in stateless session beans? i.e how to start, rollback & commit
them in my code?

cheers

harry


"Sudsy" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> harry wrote:
> <snip>
> > Do I have to create another session bean, this time make it stateful &
put
> > all methods that require transactions in there? or can I still achieve
this
> > using a stateless bean?
> >
> > Many thanks - appologies if not correct wording but a bit new to this!
>
> Look at the container-transaction element nested within the
> assembly-descriptor element which is nested in the ejb-jar
> element. Here's a brief outline of an ejb-jar.xml file:
>
> <?xml version="1.0"?>
> <!DOCTYPE ejb-jar PUBLIC
>    "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
>    "http://java.sun.com/dtd/ejb-jar_2_0.dtd";>
> <ejb-jar>
>    <enterprise-beans>
>      <session>
>        <ejb-name>MyBean</ejb-name>
>        <home>com.mine.MyBeanHome</home>
>        <remote>com.mine.MyBean</remote>
>        <ejb-class>com.mine.MyBean</ejb-class>
>        <session-type>Stateless</session-type>
>        <transaction-type>Container</transaction-type>
>      </session>
>    </enterprise-beans>
>    <assembly-descriptor>
>      <container-transaction>
>        <method>
>          <ejb-name>MyBean</ejb-name>
>          <method-name>*</method-name>
>        </method>
>        <trans-attribute>Required</trans-attribute>
>      </container-transaction>
>    </assembly-descriptor>
> </ejb-jar>
>
> Looks like you have some reading ahead of you!  ;-)
>
> --
> Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development.
>





==============================================================================

You received this message because you are subscribed to the Google
Groups "comp.lang.java.programmer" group.

To post to this group, send email to [EMAIL PROTECTED] or
visit http://groups-beta.google.com/group/comp.lang.java.programmer

To unsubscribe from this group, send email to
[EMAIL PROTECTED]

To change the way you get mail from this group, visit:
http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

To report abuse, send email explaining the problem to [EMAIL PROTECTED]

==============================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to