| implement writeObject how? serializable singleton how? |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- Finding BCC receipientsIs there a way to see if a user (having sent you an email) has bcc'd
that email to anyone else? Sun Java WebMail is being used.
Mark
******
- 2
- EJB Deploy issues in RAD 6 I get the following exception while trying to deploy a EJB project in
my test environment
com.ibm.etools.rmic.RMICException: RMIC Command returns RC = 1.
at com.ibm.etools.rmic.RMICOperation.invokeCommandLine(Unknown Source)
at com.ibm.etools.rmic.RMICOperation.rmic(Unknown Source)
at com.ibm.etools.rmic.RMICOperation.generateStubs(Unknown Source)
at com.ibm.etools.rmic.UIRMICBeansOperation.generateStubs(Unknown
Source)
at com.ibm.etools.rmic.RMICOperation.run(Unknown Source)
at com.ibm.etools.ejbdeploy.EJBDeployer.visit(Unknown Source)
at com.ibm.etools.ejbdeploy.EJBDeployer.doExecute(Unknown Source)
at com.ibm.etools.ejbdeploy.EJBDeployer.execute(Unknown Source)
at com.ibm.wtp.j2ee.deploy.J2EEDeployOperation.deploy(Unknown Source)
at com.ibm.wtp.j2ee.deploy.J2EEDeployOperation.execute(Unknown Source)
at com.ibm.wtp.common.operation.WTPOperation.doRun(Unknown Source)
at com.ibm.wtp.common.operation.WTPOperation$1.run(Unknown Source)
at org.eclipse.core.internal.resources.Workspace.run(Unknown Source)
at org.eclipse.core.internal.resources.Workspace.run(Unknown Source)
at com.ibm.wtp.common.operation.WTPOperation.run(Unknown Source)
at com.ibm.wtp.common.operation.WTPOperationJobAdapter.run(Unknown
Source)
at org.eclipse.core.internal.jobs.Worker.run(Unknown Source)
Any idea why this happens?
- 2
- Need to create custom taglib similar to bean:messageFirst off let me just say that while I know "java" pretty well from
about 3-4 years ago, but I am not really up to speed on all the JSP and
Struts things going on but I'm learning as fast as possible :-)
That being said, I have been thrown feet first into a new project and
have been asked to do this.
So anyway I am using resource.properties files to store all of our
strings and I have been adding them to our JSP's using the bean:message
taglib.
This works great and I have no problem creating different property
files for multiple languages using localization.
My problem is that the app we are writing is for one company that
operates in different states (OH, IN, etc...) The business logic for
each company is very similar but sometimes the language needs to change
between states. Further confusing the issue is that this one company
has sub companies which operate in multiple states and each company is
very similar. So I have come up with the idea that I would like to use
the "key" element of bean:message to try to create a sort of
localization scheme for the companies and states.
Here is is my idea. I would like to create a taglib that works exactly
like the bean:message taglib except that you pass in key names that are
like "promptname.company.state". The taglib will look for a key named
"promptname.company.state" and if it exists it will return it, if not
it looks for generic key for that company "promptname.company" if that
does not exist it looks for "promptname". If that key does not exist
it returns error or ???key?? as normal.
The idea is that we create a generic base for the application and
customize the prompts from the differences. Seems like a good idea to
me, heck, there may even already be a taglib out there that does this?
My problem is that I don't know where to start with extending the
bean:message tag. Theoretically it wouldn't be a problem to just keep
sending requests and stripping off .company and .state until you found
one.
Can someone point me in the right direction for doing this? This would
really save me some time.
Jason Stiles
email***@***.com
- 5
- JDBC to MS AccessHello,
I have just wanted to use such line to add one field into ms access
database:
st.executeUpdate("INSERT INTO DateTable (Date) VALUES (#2006-09-06#)");
Table DateTable has two fields: DateID (autoincrement) & Date
(date/time type). Compiling it I got an error:
"[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO
statement."
So it seems that my insert is not well formulated. Ok, but when I copy
it to MS Access I have no problems with running it (i.e. I get no
errors and a new row is added). Could you tell me what is going on?!?
Regards, mark
- 5
- McNealy gives it away``McNealy gives it away
``[...] McNealy?s intimates might provide the real clues as
to what it means. Jon Feiber, a Sun manager from 1983 to
1991, says in High Noon, a book about McNealy, that ?if
Scott blinks at all, Microsoft will eat his lunch.
Anything other than absolute conviction and unbelievable
maniacal desire to compete with Microsoft is going to
lose. You?re not going to beat Bill Gates by being
conciliatory or compromising.?
This deal looks like a loss. [...]''
--
__________
|im |yler http://timtyler.org/ email***@***.com Remove lock to reply.
- 5
- Swing design, components vs. containersHi,
Can anyone explain me (or guess on) the motivation for why the Swing
developers decided to let JComponent extend the AWT Container class and
not the AWT Component class?
I find it strange that Swing does not seperate containers from
components in the class hierarchy (ie. you can add buttons to buttons etc.).
Any comments on this issue would be appreciated.
--
Martin - http://925.dk
"Shoot for the moon, even if you miss, you'll land among the stars."
- 8
- fix horizontal sizeI have a JFrame that I'd like to fix so it is resizable vertically, but not
horizontally. I can't seem to come up with any simple way of doing this, but
it doesn't sound like it should be too difficult.
Can anybody help. If I need to make it a JWindow, or something else, that
shouldn't be a problem.
Cheers
Scott
- 9
- Bug#388596: gcj-4.1: CharsetEncoder.canEncode() gives different results than Sun versionPackage: gcj-4.1
Version: 4.1.1-13
Severity: normal
The following test program gives different results with gcj and Sun JDK:
// A.java
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
public class A {
public static void main(String[] args) throws java.io.IOException
{
CharsetEncoder enc = Charset.forName("US-ASCII").newEncoder();
System.out.println(enc.canEncode('\u00e4'));
}
}
// end
$ javac A.java
$ /usr/lib/jvm/java-1.5.0-sun/bin/java A
false
$ /usr/lib/jvm/java-gcj/bin/java A
true
The Sun version seems to return something like (c > 31 && c < 127),
which makes sense, whereas gcj always gives true.
This breaks lots of code, such as Apache JaxMe 2 version 0.51
(specifically the MarshallerTest in the test suite, which generated
invalid XML with gcj).
-- System Information:
Debian Release: testing/unstable
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17-1-686
Locale: LANG=sv_SE.UTF-8, LC_CTYPE=sv_SE.UTF-8 (charmap=UTF-8)
Versions of packages gcj-4.1 depends on:
ii gcc-4.1 4.1.1-13 The GNU C compiler
ii gcj-4.1-base 4.1.1-13 The GNU Compiler Collection (gcj b
ii gij-4.1 4.1.1-13 The GNU Java bytecode interpreter
ii java-common 0.25 Base of all Java packages
ii libc6 2.3.6.ds1-4 GNU C Library: Shared libraries
ii libc6-dev 2.3.6.ds1-4 GNU C Library: Development Librari
ii libgcc1 1:4.1.1-13 GCC support library
ii libgcj7-dev 4.1.1-13 Java development headers and stati
ii libgcj7-jar 4.1.1-13 Java runtime library for use with
ii zlib1g 1:1.2.3-13 compression library - runtime
Versions of packages gcj-4.1 recommends:
ii fastjar 1:4.1.1-13 Jar creation utility
-- no debconf information
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
- 9
- in jvm, how do you leap?hi ..
can anyone please help me answer this questions..
i'm totally lost.. i dont know what leap really
means in this context.. and i dont know
how you would do that unknown thing in JVM..
any help is appreciated!!
thanks
- 11
- Struts and mapped propertyHi
I'm using Struts with DynaActionForm wich as 3 to 8 Map as property, so I'm
using mapped property.
When I put them into HTML form it result in INPUT fields having names like
'map1(property1)' this leads to problems in writing Javascript.
Can I use another format in mapped property names?!
thanx
--
ShadowMan
- 11
- 12
- newInstance() with generics howto?How could we 'clean up'(no ct error, no ct warning, no rt error nor
exception)
the following code? I tried everything conceivable and failed in all of
them.
------------------
import java.util.*;
import java.lang.reflect.*;
public class GetMethod{
public static void main(String[] args) {
Object obj = null;
Class<Hashtable> clazz = Hashtable.class;
Class<Class> claxx = Class.class;
try {
Method method = claxx.getMethod("newInstance");
obj = method.invoke(clazz);
}
catch (Exception e) {
e.printStackTrace();
}
Hashtable<String,String> ht = (Hashtable<String,String>)obj;
ht.put("foo", "bar");
System.out.println(ht.get("foo"));
}
}
-----------------------------------------------------------------------
- 13
- java to java networkingI have not written any socket code before or done any RMI.
I'd like to do the developer certification and also I have my own project
waiting in the wings that would benefit from this. The latter is my primary
concern.
I have a distibuted java application (is this the right term?) that exists
on many users PCs on a network. This is essentially just gui code. I then
have a central java 'server' application that applies the model & all the
business rules.
The view application needs to deal just with the business app, which in turn
deals with the data layer, MySQL, Flatfile or whatever. I think this is
pretty standard practice?
My basic understanding so far is that I should define the interface by which
the protocol operates. I'm not entirely sure how to do this and what else I
need to do, though I imagine proper threading will form a crucial aspect of
this.
Can anyone recommend a good book that assumes half decent OO & java skills,
and that I can apply to the developer certification. I've got the Sybex
book 'complete java2 certification' but it glosses over a great deal of
networking.
Does anyone know of anything online that would help me?
Perhaps people could profer a Joshua Bloch style list of networking does and
don'ts?
TIA
--
Mike W
- 13
- Terminate a process treeHi group,
I'm new here, so apologies if I ask this in the wrong way.
I have been programming in java for about 2 months, and am currently trying
to control an external application that I start using:
Process proc;
Runtime rt;
proc = rt.exec("java.exe -cp ... etc.. something");
Then I capture the input/output & error streams and thread them off.
The problem I have, is that I need to architect for the eventuality of the
external process locking up and not responding to requests. I have the
whole capturing of streams in a timeout, so I can tell when the external
program has not responded within a reasonable time, however when I issue the
proc.destroy() method, the java.exe process takes up almost 100% cpu and
never stops. I have to use operating system tools to perform a manual kill
of the process.
I can only assume that the proc.destroy() doesnt kill the entire process
tree, and because the command line starts off java.exe, which runs the
something.class file, a process is orphaned somewhere.
Any help would be much appreciated.
Thanks
Wayne
- 13
- JAXB 2.0 Question?Hi,
I have created Java classes from an XSD using IntelliJ 6 and JAXB 2.0
plugin. I have populated the object and when I try to marshal the
object, I am getting ns2 appended to my root (default) element. I have
added a XmlRootElement tag to my root element. For the sake of
simplicity, I tried to unmarshal an XML file and then marshal it again
(without doing anything in between) as seen next:
My original XML file looks like the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><MSG
xmlns="http://xxx.yyy.com/"><ACKNOWLEDGEMENT>Success</
ACKNOWLEDGEMENT></MSG>
When I unmarshal it and marshal it again (doing nothing in between), I
get:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><MSG
xmlns:ns2="http://xxx.yyy.com/"><ns2:ACKNOWLEDGEMENT>Success</
ns2:ACKNOWLEDGEMENT></MSG>
I have used the same techniques before and they worked successfully. I
do not think the problem is with the XSD. Could you please tell me why
am I getting ns2 appended to my root element? and how can I get rid of
it?
Thanks in advance
|
| Author |
Message |
Frank Fredstone

|
Posted: 2007-1-17 13:35:00 |
Top |
java-programmer, implement writeObject how? serializable singleton how?
I have code that I want to execute only once ever, as a side-effect of
constructing an object. I have put this in a static initializer. But,
if I want to allow the object to be serialized I seem to be stuck,
since the initializer is executed during deserialization.
In the java developer's almanac:
http://www.exampledepot.com/egs/java.io/DeserSingle.html
There's an example of a serializable singleton:
public class MySingleton implements Serializable {
static MySingleton singleton = new MySingleton();
private MySingleton() {
}
// This method is called immediately after an object of this
// class is deserialized.
// This method returns the singleton instance.
protected Object readResolve() {
return singleton;
}
}
If I add code to the constructor, it executes during
deserialization, so that doesn't work for me.
Is there someway to determine within a static initializer or
constructor that this object is being constructed and not being
deserialized? If there were I could execute code only during the one
construction of the object, and not again.
I was thinking that I could implement readObject/writeObject. But, how can
I implement writeObject? How do you represent the fields?
In the oreilly RMI book there is an example of a writeObject method,
but it doesn't explain how you are supposed to represent fields of the
object. I've looked around a bit and found nothing.
|
| |
|
| |
 |
Tom Hawtin

|
Posted: 2007-1-17 16:04:00 |
Top |
java-programmer >> implement writeObject how? serializable singleton how?
Frank Fredstone wrote:
>
> public class MySingleton implements Serializable {
> static MySingleton singleton = new MySingleton();
^private final
>
> private MySingleton() {
> }
>
> // This method is called immediately after an object of this
> // class is deserialized.
> // This method returns the singleton instance.
> protected Object readResolve() {
^^^^^^^^^private
> return singleton;
> }
> }
>
> If I add code to the constructor, it executes during
> deserialization, so that doesn't work for me.
It shouldn't do. readObject (or a call to
ObjectInputStream.defaultReadObject) takes the place of the constructor.
For this sort of class, it doesn't really matter what the fields are set
to as you are going to dump the deserialised object.
> Is there someway to determine within a static initializer or
> constructor that this object is being constructed and not being
> deserialized? If there were I could execute code only during the one
> construction of the object, and not again.
>
> I was thinking that I could implement readObject/writeObject. But, how can
> I implement writeObject? How do you represent the fields?
Keep the readResolve (only make it private) and make any instance fields
transient (there is no point serialising them).
> In the oreilly RMI book there is an example of a writeObject method,
> but it doesn't explain how you are supposed to represent fields of the
> object. I've looked around a bit and found nothing.
You aren't interested in the fields.
(take the bit about singletons being evil as read)
Tom Hawtin
|
| |
|
| |
 |
Frank Fredstone

|
Posted: 2007-1-18 2:48:00 |
Top |
java-programmer >> implement writeObject how? serializable singleton how?
Tom Hawtin <email***@***.com> writes:
> Frank Fredstone wrote:
>>
>> public class MySingleton implements Serializable {
>> static MySingleton singleton = new MySingleton();
> ^private final
>> private MySingleton() {
>> }
>> // This method is called immediately after an object of
>> this // class is deserialized.
>> // This method returns the singleton instance.
>> protected Object readResolve() {
> ^^^^^^^^^private
>> return singleton;
>> }
>> }
>>
>> If I add code to the constructor, it executes during
>> deserialization, so that doesn't work for me.
>
> It shouldn't do. readObject (or a call to
> ObjectInputStream.defaultReadObject) takes the place of the
> constructor. For this sort of class, it doesn't really matter what the
> fields are set to as you are going to dump the deserialised object.
The constructor is called during deserialization, maybe because of the
assignment to the field singleton. If I put a print statement in the
constructor, it executes during deserialization. If I use the
supposedly redundant "transient static" the constructor is still
called during deserialization. If I use transient only the constructor
is called during deserialization. If I use static final, the
constructor is called during deserialization.
>> Is there someway to determine within a static initializer or
>> constructor that this object is being constructed and not being
>> deserialized? If there were I could execute code only during the one
>> construction of the object, and not again.
>>
>> I was thinking that I could implement readObject/writeObject. But, how can
>> I implement writeObject? How do you represent the fields?
>
> Keep the readResolve (only make it private) and make any instance
> fields transient (there is no point serialising them).
There is no change. The constructor is still called during deserialization.
>> In the oreilly RMI book there is an example of a writeObject method,
>> but it doesn't explain how you are supposed to represent fields of the
>> object. I've looked around a bit and found nothing.
>
> You aren't interested in the fields.
>
> (take the bit about singletons being evil as read)
I did read that article, but I'm not sure how it applies to what I'm
trying to do.
For my purposes, the singleton means "cause a side-effect only
once". I'm trying to find a way to have that behavior survive
deserialization.
The field "singleton" was important because witthout
serialization/deserialization it represents the one and only instance
of the object.(and the one and only time that the constructor was
called).
Any scheme I can think of so far to indicate to the class that it is
being constructed rather than deserialized is executed during
deserializaion also, so I can't distinguish between the two.
What about readObject/writeObject. I think I could get around the
problem by implementing writeObject. How should a writeObject method
represent the state of an object?
|
| |
|
| |
 |
Chris Uppal

|
Posted: 2007-1-18 3:42:00 |
Top |
java-programmer >> implement writeObject how? serializable singleton how?
Frank Fredstone wrote:
> The constructor is called during deserialization, maybe because of the
> assignment to the field singleton.
Did the singleton instance exist before you started deserialising ? I.e. was
the class MySingleton already loaded ? If not then it'll be loaded as a result
of seeing that class mentioned in the data, and the singleton instance will be
constructed at that time, and so your print() statements would be misleading.
-- chris
|
| |
|
| |
 |
Tom Hawtin

|
Posted: 2007-1-18 3:48:00 |
Top |
java-programmer >> implement writeObject how? serializable singleton how?
Frank Fredstone wrote:
> Tom Hawtin <email***@***.com> writes:
>
>> Frank Fredstone wrote:
>>> If I add code to the constructor, it executes during
>>> deserialization, so that doesn't work for me.
>> It shouldn't do. readObject (or a call to
>> ObjectInputStream.defaultReadObject) takes the place of the
>> constructor. For this sort of class, it doesn't really matter what the
>> fields are set to as you are going to dump the deserialised object.
>
> The constructor is called during deserialization, maybe because of the
> assignment to the field singleton. If I put a print statement in the
> constructor, it executes during deserialization. If I use the
> supposedly redundant "transient static" the constructor is still
> called during deserialization. If I use transient only the constructor
> is called during deserialization. If I use static final, the
> constructor is called during deserialization.
Perhaps you are seeing the construction during static (class)
initialisation. When an object is deserialised the constructor of the
most derived non-serialisable class (possibly Object) is invoked by the
serialisation mechanism.
"transient static" doesn't make any sense, as static (class) data is not
serialised.
>>> In the oreilly RMI book there is an example of a writeObject method,
>>> but it doesn't explain how you are supposed to represent fields of the
>>> object. I've looked around a bit and found nothing.
>> You aren't interested in the fields.
>>
>> (take the bit about singletons being evil as read)
>
> I did read that article, but I'm not sure how it applies to what I'm
> trying to do.
>
> For my purposes, the singleton means "cause a side-effect only
> once". I'm trying to find a way to have that behavior survive
> deserialization.
Are you trying to store the state of the object? That doesn't really
make any sense. You are making and reading a copy of the singleton
state, so there is more than one of the singletons in existence.
> The field "singleton" was important because witthout
> serialization/deserialization it represents the one and only instance
> of the object.(and the one and only time that the constructor was
> called).
That's a static, not an instance, field.
> Any scheme I can think of so far to indicate to the class that it is
> being constructed rather than deserialized is executed during
> deserializaion also, so I can't distinguish between the two.
readResolve is called after an object is constructed through
deserialisation.
> What about readObject/writeObject. I think I could get around the
> problem by implementing writeObject. How should a writeObject method
> represent the state of an object?
Not having writeObject is equivalent to having a writeObject that just
calls ObjectOutputStream.defaultWriteFields. It just writes the
non-transient field data out in a nice fashion. The only interesting
piece of data of a singleton to be serialised is its identity (i.e. its
class).
Tom Hawtin
|
| |
|
| |
 |
Frank Fredstone

|
Posted: 2007-1-18 5:30:00 |
Top |
java-programmer >> implement writeObject how? serializable singleton how?
Tom Hawtin <email***@***.com> writes:
> Frank Fredstone wrote:
>> Tom Hawtin <email***@***.com> writes:
>>
>>> Frank Fredstone wrote:
>
>>>> If I add code to the constructor, it executes during
>>>> deserialization, so that doesn't work for me.
>>> It shouldn't do. readObject (or a call to
>>> ObjectInputStream.defaultReadObject) takes the place of the
>>> constructor. For this sort of class, it doesn't really matter what the
>>> fields are set to as you are going to dump the deserialised object.
>>
>> The constructor is called during deserialization, maybe because of the
>> assignment to the field singleton. If I put a print statement in the
>> constructor, it executes during deserialization. If I use the
>> supposedly redundant "transient static" the constructor is still
>> called during deserialization. If I use transient only the constructor
>> is called during deserialization. If I use static final, the
>> constructor is called during deserialization.
>
> Perhaps you are seeing the construction during static (class)
> initialisation. When an object is deserialised the constructor of the
> most derived non-serialisable class (possibly Object) is invoked by
> the serialisation mechanism.
So, you and Chris Uppal's post as well, are agreeing that the
constructor is called during deserialization.
>> For my purposes, the singleton means "cause a side-effect only
>> once". I'm trying to find a way to have that behavior survive
>> deserialization.
>
> Are you trying to store the state of the object? That doesn't really
> make any sense. You are making and reading a copy of the singleton
> state, so there is more than one of the singletons in existence.
I want an object that has a state that is initialized only once, as a
result of an external side-effect. I also want it to be possible for
that state to be serialized, without the state being "reinitialized"
(in the sense of being intitialized again by a specific block of code)
during deserialization. I want the state (the field values) restored,
without the code that initializes them during construction being
called.
In any case, I found information about writeObject in:
http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/examples.doc1.html
Based on that, I have this mutation of the java developer almanac
serializable singleton that seems to survive deserialization. The
external side-effect is represented by retrieving a system property.
The one instance of the class would be normally be referenced using:
MySingleton.instance();
If it were deserialized, the reference would be faked using:
(MySingleton) objectInputStream.readObject();
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamField;
import java.io.Serializable;
public class MySingleton implements Serializable {
private static final ObjectStreamField[] serialPersistentFields = {
new ObjectStreamField("instance", MySingleton.class),
new ObjectStreamField("value", String.class)
};
private static MySingleton instance = null;
private String value = null;
private MySingleton() {
System.out.println("Constructing MySingleton");
}
private MySingleton(boolean f) {
System.out.println("Constructing MySingleton f");
System.out.println("Setting value to " +
System.getProperty("abc"));
value = System.getProperty("abc");
}
public String value() { return value; }
public static MySingleton instance() {
if (instance == null) {
instance = new MySingleton(true);
}
return instance;
}
private void writeObject(ObjectOutputStream s) throws IOException {
ObjectOutputStream.PutField fields = s.putFields();
fields.put("instance", instance);
fields.put("value", value);
s.writeFields();
}
private void readObject(ObjectInputStream s) throws IOException {
try {
ObjectInputStream.GetField fields = s.readFields();
instance = (MySingleton) fields.get("instance", null);
value = (String) fields.get("value", null);
} catch (ClassNotFoundException cnfe) {
throw new IOException("" + cnfe);
}
}
}
|
| |
|
| |
 |
Tom Hawtin

|
Posted: 2007-1-18 5:59:00 |
Top |
java-programmer >> implement writeObject how? serializable singleton how?
Frank Fredstone wrote:
> Tom Hawtin <email***@***.com> writes:
>
>> Perhaps you are seeing the construction during static (class)
>> initialisation. When an object is deserialised the constructor of the
>> most derived non-serialisable class (possibly Object) is invoked by
>> the serialisation mechanism.
>
> So, you and Chris Uppal's post as well, are agreeing that the
> constructor is called during deserialization.
The constructor is not called for the deserialised copy. It is called
for the singleton copy.
> I want an object that has a state that is initialized only once, as a
> result of an external side-effect. I also want it to be possible for
> that state to be serialized, without the state being "reinitialized"
> (in the sense of being intitialized again by a specific block of code)
> during deserialization. I want the state (the field values) restored,
> without the code that initializes them during construction being
> called.
> private static MySingleton instance = null;
> public static MySingleton instance() {
> if (instance == null) {
> instance = new MySingleton(true);
> }
> return instance;
> }
This is not thread safe.
> private void readObject(ObjectInputStream s) throws IOException {
> try {
> ObjectInputStream.GetField fields = s.readFields();
> instance = (MySingleton) fields.get("instance", null);
But that doesn't change any current instance of MySingleton to the new
singleton. I suspect that a singleton is really not what you want (it
almost never is).
Anyway, proceeding on with deserialisation mutates the singleton, I
suggest just updating the actual singleton instance, and replacing
references to it in other deserialised object to the real version.
public class MySingleton implements java.io.Serializable {
private static final MySingleton INSTANCE = new MyInstance();
public static getInstance() {
return INSTANCE;
}
private String value;
private MySingleton() {
System.out.println("Constructing MySingleton");
}
public synchronized String getValue() {
return value;
}
public synchronized void setValue(String value) {
this.value = value;
}
private Object readResolve(java.io.ObjectInputStream s) {
// Copy data into real instance.
synchronized (INSTANCE) {
INSTANCE.value = this.value;
}
// Replace serial instance with the real one.
return INSTANCE;
}
}
|
| |
|
| |
 |
Frank Fredstone

|
Posted: 2007-1-18 6:51:00 |
Top |
java-programmer >> implement writeObject how? serializable singleton how?
Tom Hawtin <email***@***.com> writes:
> Frank Fredstone wrote:
>> Tom Hawtin <email***@***.com> writes:
>>
>>> Perhaps you are seeing the construction during static (class)
>>> initialisation. When an object is deserialised the constructor of the
>>> most derived non-serialisable class (possibly Object) is invoked by
>>> the serialisation mechanism.
>>
>> So, you and Chris Uppal's post as well, are agreeing that the
>> constructor is called during deserialization.
>
> The constructor is not called for the deserialised copy. It is called
> for the singleton copy.
If I don't implement readObject/writeObject:
MySingleton ms = (MySingleton) objectInputStream.readObject();
System.out.println("After deserialization");
prints
Constructing MySingleton
After deserialization
then after:
ms.instance();
it does not print "Constructing MySingleton".
That makes me think that the constructor is being called when it's
deserialized.
I'm not sure if I understand the distinction you are making between
the deserialized copy and the singleton copy.
>> I want an object that has a state that is initialized only once, as a
>> result of an external side-effect. I also want it to be possible for
>> that state to be serialized, without the state being "reinitialized"
>> (in the sense of being intitialized again by a specific block of code)
>> during deserialization. I want the state (the field values) restored,
>> without the code that initializes them during construction being
>> called.
>
>> private static MySingleton instance = null;
>
>> public static MySingleton instance() {
>> if (instance == null) {
>> instance = new MySingleton(true);
>> }
>> return instance;
>> }
> This is not thread safe.
I should have used:
public static synchronized MySingleton instance() {
...
}
>
>> private void readObject(ObjectInputStream s) throws IOException {
>> try {
>> ObjectInputStream.GetField fields = s.readFields();
>> instance = (MySingleton) fields.get("instance", null);
>
> But that doesn't change any current instance of MySingleton to the new
> singleton. I suspect that a singleton is really not what you want (it
> almost never is).
Is there a way to avoid the possibility of their being multiple copies
of an object due to deserialization?
I should also add a clone method that throws an exception
I'm treating serialization as some ugliness that allows you to violate
the interface of a class, and I want to do my best to make my class
survive that ugliness.
> Anyway, proceeding on with deserialisation mutates the singleton, I
> suggest just updating the actual singleton instance, and replacing
> references to it in other deserialised object to the real version.
>
> public class MySingleton implements java.io.Serializable {
> private static final MySingleton INSTANCE = new MyInstance();
> public static getInstance() {
> return INSTANCE;
> }
>
> private String value;
> private MySingleton() {
> System.out.println("Constructing MySingleton");
> }
> public synchronized String getValue() {
> return value;
> }
> public synchronized void setValue(String value) {
> this.value = value;
> }
> private Object readResolve(java.io.ObjectInputStream s) {
> // Copy data into real instance.
> synchronized (INSTANCE) {
> INSTANCE.value = this.value;
> }
>
> // Replace serial instance with the real one.
> return INSTANCE;
> }
> }
That class does not contain constant values as it's "state" and is not
initialized by a side-effect that must be used to inititialize the
state once and only once, which is what I need.
|
| |
|
| |
 |
Tom Hawtin

|
Posted: 2007-1-18 22:34:00 |
Top |
java-programmer >> implement writeObject how? serializable singleton how?
Frank Fredstone wrote:
> That makes me think that the constructor is being called when it's
> deserialized.
The constructor of a different object is called during deserialisation.
It doesn't make sense to deserialise a singleton. What you can do is
replace references to a singleton in a serial stream with the real
singleton instance.
> Is there a way to avoid the possibility of their being multiple copies
> of an object due to deserialization?
Implement readResolve to switch to another copy. (Although this can in
general be hacked to get at the original object.)
> I should also add a clone method that throws an exception
Object.clone is protected. So long as the class does not make clone
public, does not implement Cloneable and is unsubclassable, then there
is not a problem. Of course to usefully subclass the singleton, you'd
have to be able to create a copy of it anyway.
> I'm treating serialization as some ugliness that allows you to violate
> the interface of a class, and I want to do my best to make my class
> survive that ugliness.
Serialisation effectively provides a second interface[1] to your class.
It should be quite independent of the normal class' API.
Tom Hawtin
[1] interface as a generic term, not the Java keyword "interface".
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- measuring signal strength in javahello
i am writing a java program for locating a wireless device within an
office environment. i want to use the signal strengths of the
surrounding base stations (access points) to estimate the current
location of the device.
does anybody have an idea how to get the strength of a signal sent by
a base station in java?
thank you,
dominik
- 2
- Java Threads - Get running threadsHy there,
I'm building an application that creates a thread. This thread creates
other threads to perform several tasks.
My question is simple. Being this main thread created in a JSP page,
and still running after the user logs out, how can i get the current
status of the thread? I would like for the user, when he logs on the
application, to verify if the thread is active, that is, the current
status.
I can't seem to be able to get the thread once it is initialized.
Thanks in advance for any help.
Regards
Pedro Pinto
- 3
- Dual JTree interaction
Hi guys
I have 2 jTree controls on a jFrame ,
And when I try to make the second jTree to react on the first jTree clicks ,
What is the correct OOP way to do it ?
- 4
- REALLY CHEAP computer programming ebook libraries just follow any of the links below REALLY CHEAP computer programming eBook Libraries just follow any of the links below
Super Visual Basic eBook Library only ?!
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=2779152882&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=2779152862&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=3652441341&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=3578838387&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=2779152820&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=3652441295&ssPageName=ADME:B:LC:UK:1
Incredible A+ Certification eBook CD-ROM only ?!
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=3578838127&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=3578838127&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=2779152561&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=3652441071&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=2779152536&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=2779152520&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=3578838040&ssPageName=ADME:B:LC:UK:1
Brilliant C/C++ eBook Library only ?!
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=2779152433&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=3578837936&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=3652440934&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=3578837915&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=2779152379&ssPageName=ADME:B:LC:UK:1
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=2779152365&ssPageName=ADME:B:LC:UK:1
- 5
- GIS application programI am developing a GIS java server and is now trying to write 2 modules
one is about the algorithm to find the shortest route for a journey
second one is the billing system used to support the billing service to
count the number of bytes transferred in each process
Do anyone have any reference and similar for my reference ..
Thousands Thanx
- 6
- Program can't count argumentsHi,
I have written a .java file with below source code.
public class getargs {
public static void main (String [] args) {
System.out.println(args.length);
}
}
Compilation succeeded. But when I ran the program with below
parameters:
java getargs abc
or
java getargs "abc"
the program returned 0 in both cases. If I don't intertpret wrongly,
args.length should contain the count of program arguments. Why would I
get the result as I ran this program ?
I run java SDK 1.4.1.
- 7
- Re:Clearlooks is unsupported??Hi,
I am using RePast simulation package with Java 1.5 on Fedora Core 4.
When I run the model (see below), I get the following message. The
program works, but it generates pretty ugly interface.
Could anyone please let me know how to solve this problem??
Thank you.
-----------------------------------------------------------------
[jonghook@localhost GayModel]$ java -cp .:${REPASTJ}/repast.jar
GayModel
/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:49: Engine "clearlooks" is
unsupported, ignoring
-------------------------------------------------------
- 8
- UI Painting Problems -Upgrade from JDK1.3-JDK1.4Hi,
I have some UIs in my application. Today I was upgrading the code from
JDK1.3.1 to JDK1.4.2 WindowsXP.
Some How the UI hangs and painting does not happen properly. Does any
body have any solution
Any solutions is helpfull....
All compilation went through fine...
When I generate the JVM dump.. I get the following errpr
Full thread dump Java HotSpot(TM) Client VM (1.4.2_03-b02 mixed mode):
"DestroyJavaVM" prio=5 tid=0x000352b8 nid=0x8ac waiting on condition
[0..7fad8]
"TimerQueue" daemon prio=5 tid=0x03164d28 nid=0xe84 in Object.wait()
[76cf000..7
6cfd8c]
at java.lang.Object.wait(Native Method)
- waiting on <0x10e54ce8> (a javax.swing.TimerQueue)
at javax.swing.TimerQueue.run(TimerQueue.java:231)
- locked <0x10e54ce8> (a javax.swing.TimerQueue)
at java.lang.Thread.run(Thread.java:534)
"Java2D Disposer" daemon prio=10 tid=0x030c2f10 nid=0x99c in
Object.wait() [760f
000..760fd8c]
at java.lang.Object.wait(Native Method)
- waiting on <0x10d6d850> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
- locked <0x10d6d850> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
at sun.java2d.Disposer.run(Disposer.java:100)
at java.lang.Thread.run(Thread.java:534)
"AWT-EventQueue-0" prio=7 tid=0x030bd818 nid=0x95c waiting on
condition [758e000
..758fd8c]
at sun.java2d.pipe.PixelToShapeConverter.fillRect(PixelToShapeConverter.
java:44)
at sun.java2d.pipe.ValidatePipe.fillRect(ValidatePipe.java:46)
at sun.java2d.SunGraphics2D.fillRect(SunGraphics2D.java:2066)
at com.kbs.vide.util.gui.DynamicKuberreButton.drawPixel(DynamicKuberreBu
tton.java:314)
at com.kbs.vide.util.gui.DynamicKuberreButton.paintBackground(DynamicKub
erreButton.java:140)
at com.kbs.vide.util.gui.DynamicKuberreButton.paintButton(DynamicKuberre
Button.java:250)
at com.kbs.vide.util.gui.ImageButton.paintComponent(ImageButton.java:229
)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
- locked <0x10cb9ab0> (a java.awt.Component$AWTTreeLock)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at javax.swing.JComponent._paintImmediately(JComponent.java:4685)
at javax.swing.JComponent.paintImmediately(JComponent.java:4488)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System
EventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:151)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:141)
at java.awt.Dialog$1.run(Dialog.java:540)
at java.awt.Dialog.show(Dialog.java:561)
at java.awt.Component.show(Component.java:1133)
at java.awt.Component.setVisible(Component.java:1088)
at com.kbs.vide.util.gui.KuberreDialog.setVisible(KuberreDialog.java:283
)
at com.kbs.vide.client.gui.MainAdapter.actionPerformed(MainAdapter.java:
68)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
86)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1839)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
)
at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1
113)
at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseRelease
d(BasicMenuItemUI.java:943)
at java.awt.Component.processMouseEvent(Component.java:5100)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
"AWT-Windows" daemon prio=7 tid=0x030ae538 nid=0x870 runnable
[754f000..754fd8c]
at sun.awt.windows.WToolkit.eventLoop(Native Method)
at sun.awt.windows.WToolkit.run(WToolkit.java:262)
at java.lang.Thread.run(Thread.java:534)
"AWT-Shutdown" prio=5 tid=0x0309a950 nid=0xb44 in Object.wait()
[750f000..750fd8
c]
at java.lang.Object.wait(Native Method)
- waiting on <0x10cc1dc0> (a java.lang.Object)
at java.lang.Object.wait(Object.java:429)
at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:259)
- locked <0x10cc1dc0> (a java.lang.Object)
at java.lang.Thread.run(Thread.java:534)
"Signal Dispatcher" daemon prio=10 tid=0x009c29f8 nid=0x314 waiting on
condition
[0..0]
"Finalizer" daemon prio=9 tid=0x009c0130 nid=0x7bc in Object.wait()
[2baf000..2b
afd8c]
at java.lang.Object.wait(Native Method)
- waiting on <0x10cb8cc0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
- locked <0x10cb8cc0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
"Reference Handler" daemon prio=10 tid=0x009bed00 nid=0x284 in
Object.wait() [2b
6f000..2b6fd8c]
at java.lang.Object.wait(Native Method)
- waiting on <0x10cb8d28> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:429)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:115)
- locked <0x10cb8d28> (a java.lang.ref.Reference$Lock)
"VM Thread" prio=5 tid=0x009fb640 nid=0xf4 runnable
"VM Periodic Task Thread" prio=10 tid=0x0003f9a8 nid=0x4a8 waiting on
condition
"Suspend Checker Thread" prio=10 tid=0x009c2470 nid=0x2d0 runnable
Thanks
SubbaRao
- 9
- Any available Web-based Calendar module written in JSPHi,
I wonder if there is any available Web-based Calendar module that
allows users to enter/edit event, set repeating frequency and reminder
of the event. I need something written in JSP.
Thanks in advance.
Tung Chau
- 10
- jdk1.4.2p5 build error
--=-QXgBEaZzAqtsE+sUalvG
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi,
I am having a problem building jdk1.4.2p5. I already have jdk-1.3.1p7_2
installed from my installation of OpenOffice1.03
Do I have to first remove jdk1.3.1 before I install jdk1.4.2 ?
I am in the process of upgrading OO1.03 to 1.1, attached is my error
message.
Any help would be appreciated.
Thanks,
Nelis
--=-QXgBEaZzAqtsE+sUalvG
Content-Disposition: attachment; filename=debug_jdk.txt
Content-Type: text/plain; name=debug_jdk.txt; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
# Start of jdk build
bsd i586 1.4.2-p5 build started: 03-11-12 12:22
if [ -r ./../../deploy/make/Makefile ]; then \
( cd ./../../deploy/make; gmake sanity EXTERNALSANITYCONTROL=true CONTROL_TOPDIR=/usr/ports/java/jdk14/work/control CONTROL_TOPDIR_NAME=control ALT_OUTPUTDIR=/usr/ports/java/jdk14/work/control/build/bsd-i586 ARCH_DATA_MODEL=32 MILESTONE=p5 BUILD_NUMBER=nelis_12_nov_2003_12_22 ; ); \
fi
gmake[1]: Entering directory `/usr/ports/java/jdk14/work/deploy/make'
gmake[1]: Leaving directory `/usr/ports/java/jdk14/work/deploy/make'
gmake[1]: Entering directory `/usr/ports/java/jdk14/work/j2se/make'
gmake[1]: Leaving directory `/usr/ports/java/jdk14/work/j2se/make'
Build Machine Information:
build machine =
Build Directory Structure:
CWD = /usr/ports/java/jdk14/work/control/make
TOPDIR = ./../..
CONTROL_TOPDIR = ./../../control
GENERICS_TOPDIR = ./../../generics
HOTSPOT_TOPDIR = ./../../hotspot
J2SE_TOPDIR = ./../../j2se
MOTIF_TOPDIR = ./../../motif
Hotspot Settings:
HOTSPOT_BUILD_JOBS =
Bootstrap Settings:
JAVAWS_BOOTDIR = /java/re/j2se/1.4.1/archive/fcs/binaries/bsd-i586
BOOTSTRAP J2SDK VERSION:
OUTPUTDIR = /usr/ports/java/jdk14/work/control/build/bsd-i586
Build Tool Settings:
UNIXCOMMAND_PATH = /bin/
COMPILER_PATH = /usr/bin/
DEVTOOLS_PATH = /usr/local/bin/
USRBIN_PATH = /usr/bin/
GCC32_COMPILER_PATH = /java/devtools/bsd/gcc3.2/
MOZILLA_PATH =
MOZILLA_HEADERS_PATH =
MOZILLA_LIBS_PATH =
CC_VER = 2.95.4
PATH = /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
Build Directives:
PEDANTIC =
INSANE =
Build Platform Settings:
PLATFORM = bsd
ARCH = i586
LIBARCH = i386
ARCH_FAMILY = i586
ARCH_DATA_MODEL = 32
OS_VERSION = 4.9-STABLE
TRUE_PLATFORM = FreeBSD (4.x STABLE way)
FREE_SPACE = 44495664
GNU Make Settings:
MAKE = gmake
MAKE VERSION =
MAKECMDGOALS = sanity
MAKEFLAGS = w -- BUILD_NUMBER=nelis_12_nov_2003_12_22 MILESTONE=p5 ARCH_DATA_MODEL=32 ALT_OUTPUTDIR=/usr/ports/java/jdk14/work/control/build/bsd-i586 CONTROL_TOPDIR_NAME=control CONTROL_TOPDIR=/usr/ports/java/jdk14/work/control EXTERNALSANITYCONTROL=true
SHELL = /bin/sh
Target Build Versions:
JAVAWS_VERSION = 1.4.2
MILESTONE = p5
BUILD_NUMBER = nelis_12_nov_2003_12_22
Bootstrap Settings:
BOOTDIR = /java/re/j2se/1.4.1/archive/fcs/binaries/bsd-i586
BOOTSTRAP J2SDK VERSION:
OUTPUTDIR = /usr/ports/java/jdk14/work/control/build/bsd-i586
Build Tool Settings:
UNIXCOMMAND_PATH = /bin/
COMPILER_PATH = /usr/bin/
DEVTOOLS_PATH = /usr/local/bin/
USRBIN_PATH = /usr/bin/
MOTIF_DIR = /usr/X11R6
CC_VER = 2.95.4
ZIP_VER = 2.3
PATH = /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
Build Directives:
USE_ONLY_BOOTDIR_TOOLS =
USE_HOTSPOT_INTERPRETER_MODE =
PEDANTIC =
DEV_ONLY = YES
J2RE_ONLY =
NO_DOCS =
NO_IMAGES =
TOOLS_ONLY = true
INSANE =
Build Platform Settings:
PLATFORM = bsd
ARCH = i586
LIBARCH = i386
ARCH_FAMILY = i586
ARCH_DATA_MODEL = 32
OS_VERSION = 4.9-STABLE
TRUE_PLATFORM = FreeBSD (4.x STABLE way)
FREE_SPACE = 44495648
GNU Make Settings:
MAKE = gmake
MAKE VERSION =
MAKECMDGOALS = sanity
MAKEFLAGS =
SHELL = /bin/sh
Target Build Versions:
JDK_VERSION = 1.4.2
MILESTONE = p5
BUILD_NUMBER = nelis_12_nov_2003_12_22
External File/Binary Locations:
HOTSPOT_SERVER_PATH = /usr/ports/java/jdk14/work/control/build/bsd-i586/hotspot-i586/server
HOTSPOT_CLIENT_PATH = /usr/ports/java/jdk14/work/control/build/bsd-i586/hotspot-i586/client
MOTIF_DIR = /usr/X11R6
CACERTS_FILE = ./../src/share/lib/security/cacerts
WARNING: Your build environment has the variable DEV_ONLY
defined. This will result in a development-only
build of the J2SE workspace, lacking the documentation
build and installation bundles.
ERROR: JAVAWS_BOOTDIR does not point to a valid Java 2 SDK
Check that you have access to
/java/re/j2se/1.4.1/archive/fcs/binaries/bsd-i586/bin/java
and/or check your value of ALT_JAVAWS_BOOTDIR.
ERROR: BOOTDIR does not point to a valid Java 2 SDK
Check that you have access to
/java/re/j2se/1.4.1/archive/fcs/binaries/bsd-i586/bin/java
and/or check your value of ALT_BOOTDIR.
Exiting because of the above error(s).
gmake: *** [post-sanity] Error 1
*** Error code 2
Stop in /usr/ports/java/jdk14.
enigma#
--=-QXgBEaZzAqtsE+sUalvG
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
--=-QXgBEaZzAqtsE+sUalvG--
- 11
- escape meta for Pattern?On
http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
it says:
> The string literal "\(hello\)" is illegal and leads to a compile-time error; in order to match the string (hello) the string literal "\\(hello\\)" must be used.
Now, if I read my input strings from a file I have to convert my
strings in order to match them against a pattern. How do I do that?
Is there a predefined method to do it? Like quotemeta in perl?
Thanks!
Markus
- 12
- Java Gurus Help!Yep, shall do i use limewire but you didn't no I typed that....... ;)
cheers Steve
- 13
- HTTP Persistent connections on Apache web-serverHi,
I need to implement a solution which needs a HTTP persistent connection
from the client( any browser ) to the webserver ( Apache here )
This is how I am trying to acheive the persistent connection:
For every user logging on to the webserver, the browser sends a HTTP
request to the webserver which is being handled by a servlet on the
webserver. The servlet then creates a thread which holds the response
object and waits for some asynchronous data coming from a diff backend
sever.
As soon as some data is posted on to this thread, this thread sends
back the data to the clent on the response object that it has been
holding as a java-script object.
This thread is terminated only when the user logs out od the webserver.
Now, I have a few questions on this part:
1) I find that it is not an appropriate solution, given the fact that
the webserver needs to cater to 20-30k users at a time and creating a
thread per user on the webserver would really not solve the purpose. Am
I right ? ( The webserver would die is n't it?..)
2) Also, is there any limitation on the time that the thread can hold
the response object? like if the thread doesn't get any data posted on
to it from a diff backend sever, will the client( here IE or mozilla )
close the underlying socket connection ?
3)Any limitation on the scalability of this approach ( I want to know
to how many users will this approach solve )?
4) Now given my inner feeling that this approach won't work well, what
is the best way to implement a lonf-lived HTTP persistenet connection
from my browser to the webserver.
(Please note that the webserver need to push some asynchronous data to
the client as long as the user is logged on the webserver ..no refresh
mechanism please )
Apprecaite if reponded well!!!
Thanks in advance to ALL
"webdev50"
- 14
- 15
|
|
|