 |
 |
Index ‹ java-programmer
|
- Previous
- 2
- .ear files in Sun Java StudioHi all,
I am not sure if this is the right newsgroup for this question. But I just
thought that some of you may be able to help me out; that's why I am asking
you all this question.
I have a .ear file and I just downloaded Sun Java Studio Enterprise 8. May
I ask how can I import this .ear file in Sun Java Studio Enterprise 8? Can
someone point me to the right direction?
Thanks in advance,
Monte
--
---------------------------------------------
"Whatever my lot, thou has taught me to say, 'it is well; it is well with my
soul.'" -- Lyrics of It is well, it is well with my soul.
- 3
- Freelance programmer / developerHello,
I am software developer looking for freelance or Full Time work, do you
have any work that need to done.. buzz me at johnleox @ gmail.com
my skill sets:
VB,
ASP (VBScript & Javascript),
SQL Server,
Access (VBA),
Excel (VBA),
.NET(ASP.NET / C#)
Oracle &
Crystal Reports
I can work on migration projects, supporting exsisting project and
looking out for new project.
If location or place of work is not important for you then buzz..
waiting for your work.
johnleox @ gmail.com
- 3
- Can't read JAAS config from JARWe have an application that uses JAAS for security.
Until now the JAAS config file was in a folder (conf/) and the
application just ran fine.
To prepare for the deployment of the application with Webstart I packed
the folder with the config file in the application's JAR. Now JAAS
can't seem to find the file anymore.
Working:
|--application.jar
|--conf/
|--auth.conf
Failing:
|--application.jar
|--conf/
|--auth.conf
Both have the same manifest:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_04-b05 (Sun Microsystems Inc.)
Main-Class: com.fpc.nokeos.core.client.launch.Launcher
Class-Path: . conf
I also tried expliciitely adding "conf/auth.conf" to manifest but it
didn't work either.
The stacktrace I get is
08:57:42,250 - ERROR: [NokeosClientSecurity] Could not connect to the
server.
Please check your network connection.
java.lang.SecurityException: conf/auth.conf (No such file or directory)
at
com.sun.security.auth.login.ConfigFile.<init>(ConfigFile.java:97)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at
java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at
javax.security.auth.login.Configuration$3.run(Configuration.java:216)
at java.security.AccessController.doPrivileged(Native Method)
at
javax.security.auth.login.Configuration.getConfiguration(Configuration.java:210)
at
javax.security.auth.login.LoginContext$1.run(LoginContext.java:237)
at java.security.AccessController.doPrivileged(Native Method)
at
javax.security.auth.login.LoginContext.init(LoginContext.java:234)
at
javax.security.auth.login.LoginContext.<init>(LoginContext.java:403)
at
com.fpc.nokeos.core.client.security.NokeosClientSecurity.login(NokeosClientSecurity.java:46)
at
com.fpc.nokeos.core.client.launch.Launcher.checkLogin(Launcher.java:89)
at
com.fpc.nokeos.core.client.launch.Launcher.main(Launcher.java:66)
Caused by: java.io.IOException: conf/auth.conf (No such file or
directory)
at
com.sun.security.auth.login.ConfigFile.init(ConfigFile.java:157)
at
com.sun.security.auth.login.ConfigFile.<init>(ConfigFile.java:95)
... 16 more
How can I make it work?
- 4
- Efficient polling of a flatfileJust looking for feedback on what you might consider the most efficient
means to poll a flat file.
I need to have my app look at a flat file, say, every second or so, and read
any data that may have been appended to it.
Wondering what others might consider an efficient means of doing this in
Java. Would it be wise to merely look at the file size everysecond or so,
and, if that has changed, to then read it, starting from that byte which was
the previous size of the file on the previous polling a second ago?
Is there a more efficent way to do this? Thanks, Ike
- 4
- Important and UrgentHi all,
Please read on:
We are doing a survey to collect information on middleware usage
and some features of the middleware. Through the survey data as one
source of information, we can do research on middleware, and software
engineering trend analysis and prediction.
Please take out some minutes to fill in this survey. Please this is
really important survey.
Suvey link:
http://swtech.njit.edu/middlewaresurvey/
As this group includes Students/Faculties as well as Professionals,
please fill up the Individual survey and other corresponding surveys.
I am sure you guys will take part and will help this research.
Give little time to make this survey successful.
Your efforts are appreciated.
Thank you all
Purvi
- 8
- Jmatlink help pleasei can use jmatlink to open matlab but I can't
get it to open an m files and therefore run a functions using thev
arrays. How do I get
it to open a certain m file, I have tried to set the path in matlab
but that doesn't work.
Please help.
--
Message posted via http://www.javakb.com
- 8
- setFont() on solarisHi,
In one of my methods, I have a call like:
label.setFont(new Font("Arial", Font.PLAIN, 9));
This call works fine on windows but not on solaris. Moreover, the
label's text gets truncated when it shows up ("Applications" shows as
"Applicati") I iterated through the fonts via
GraphicsEnvironment.getAllFonts() and Arial seems to be available to
the java graphics environment on solaris.
How do I get arial font on solaris and not cause the truncation? Any
suggestions?
Thanks.
- 10
- Get IP tomcat serverHi !
I am using Tomcat and i would like to get the host IP from the
servletContext object. Does anybody know how to get it ?
Thank you for your help
Best regards
Sylvain Caillet
- 12
- Designation standard output as File type I have a method (fragment below) that takes a File type "outFile"
as the output file. However, if the user of this method specifies
"null" for that parameter, I want to make the output go to standard
output instead of a file.
My question: To what do I set outFile (File type) to make the
output go to standard output (display)? System.out is of a type
PrintStream.
Thanks, Alan
public static void printData(File dir, File outFile)
{
try
{
if (outFile == null)
{
outFile = ?????; // Default is standard output (System.out)
}
. . .
- 12
- 12
- JLint port
--=-hJb57ejBSXdHWUZd6IhV
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi there,
I've been looking at the JLint port (java/jlint). This port is flagged
as BROKEN in FreeBSD 5.x. Looking at the JLint homepage I see that
version 3.0 is current (the port is 2.3). I have easily managed to
compile and install JLint 3.0, only a minimal patch is required (to
disable the bool->int mapping in types.hh). Would someone mind upgrading
this port? I send an upgraded port with this email. Please have a look
at it, comment it and check it in if you like.
Best regards, Roman
--=-hJb57ejBSXdHWUZd6IhV
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"
--=-hJb57ejBSXdHWUZd6IhV--
- 12
- Xdoclet JBossHi all,
I am new to xdoclet and would like to convert my existing EJB source
files to xdoclet embedded tags and ultimately generating deploy
descriptors for JBoss.(4.0)
My current application server is Pramati and i am migrating to
JBoss(4.04GA) using xdoclet(1.2.3) as the EJB (Spec 2.0) deployment
automation tool. I have the ejb.jar and other descriptors which are
specific to Pramati Application server. I would like to generate the
appropriate interfaces (Remote, Home etc) and JBoss specific
descriptors for each EJB. I goggled but didnt find a complete example
using xdoclet. The information seems to be scattered.
I would like to know the steps for the following ( For eg I have a
MyXYZBean.java )
1) Adding appropriate xdoclet tags(Jboss specific) to this source file
(MyXYZBean.java)
2) Steps to generate the Remote, home etc interface source files ( Eg
MyXYZRemote.java, MyXYZHome.java etc)
3) Steps to generate JBoss specific descriptors (jboss.xml, ejb.jar
etc)
4) A task to be included in my build.xml which takes care of steps 1) ,
2) and 3) appropriately.
Many thanks,
Santosh
- 12
- JDBC Thin driver for Oracle doesnt loadI'm using Oracle's JDeveloper 10g so the driver should exist. however this
code raises the ClassNotFoundException. so my questions
1. Whats the simplest way to tell if the thin driver for oracle ( or any
other JDBC driver ) exists?
2. If it does not exist where can I download it and where should I put it?
3. If it exists then why doesn't this code run? I've even tried to register
with the DriverManager but the same error.
thx.
import java.sql.*;
public class JDBCThin
{
public static void main(String[] args)
{
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch ( ClassNotFoundException e )
{
System.out.println(e.getMessage()) ;
}
}
}
- 14
- 16
|
| Author |
Message |
Timo Nentwig

|
Posted: 2005-1-13 18:20:00 |
Top |
java-programmer, EJB: removing local TOs
Hi!
This applies to WebLogic 7 but probably is generally the case.
I have a Collection of Local objects which I want to remove(). So I thought
collection.clear() would be sufficient and the container would do the job.
But it doesn't.
So, I iterate thru the Collection and call remove() on each Local object.
This throws a ConcurrentModificationException because the container does
remove the element from the Collection when calling remove() on the Local
object.
The only solution seems to iterate over the collection, put the objects to
be deleted in another collection, iterating over that collection and
calling remove() there on any Local object.
Well, there must be something I misunderstood about EJB, right?
|
| |
|
| |
 |
Collin VanDyck

|
Posted: 2005-1-13 22:06:00 |
Top |
java-programmer >> EJB: removing local TOs
Timo Nentwig wrote:
> Hi!
>
> This applies to WebLogic 7 but probably is generally the case.
>
> I have a Collection of Local objects which I want to remove(). So I thought
> collection.clear() would be sufficient and the container would do the job.
> But it doesn't.
>
> So, I iterate thru the Collection and call remove() on each Local object.
> This throws a ConcurrentModificationException because the container does
> remove the element from the Collection when calling remove() on the Local
> object.
>
> The only solution seems to iterate over the collection, put the objects to
> be deleted in another collection, iterating over that collection and
> calling remove() there on any Local object.
>
> Well, there must be something I misunderstood about EJB, right?
>
Try this and see what happens:
Collection localObjects = objectHome.findSomeToDelete();
for (Iterator objIter = localObjects.iterator(); objIter.hasNext();)
{
LocalObject obj = (LocalObject)objIter.next();
objIter.remove();
obj.remove();
}
|
| |
|
| |
 |
John C. Bollinger

|
Posted: 2005-1-13 23:07:00 |
Top |
java-programmer >> EJB: removing local TOs
Timo Nentwig wrote:
> Hi!
>
> This applies to WebLogic 7 but probably is generally the case.
>
> I have a Collection of Local objects which I want to remove(). So I thought
> collection.clear() would be sufficient and the container would do the job.
> But it doesn't.
>
> So, I iterate thru the Collection and call remove() on each Local object.
> This throws a ConcurrentModificationException because the container does
> remove the element from the Collection when calling remove() on the Local
> object.
>
> The only solution seems to iterate over the collection, put the objects to
> be deleted in another collection, iterating over that collection and
> calling remove() there on any Local object.
>
> Well, there must be something I misunderstood about EJB, right?
It sounds like the Collection in question is the representation of one
of an entity bean's container-managed relationships. In that case, yes,
there is something you do not understand: modifying the collection
affects the _relationships_ defined for the entity from which you
obtained the collection, not (directly) the other entities themselves.
When you remove an entity from the collection in any way, you clear the
relationship without destroying the entity. If you remove() the entity
then the Collection is automatically updated because the source entity
cannot have a relationship with a non-existent entity. This all is
generally a good thing, but it does present a minor problem for the
scenario you describe.
You must either
1) clear each relationship while retaining a handle on the related
entity, then remove the entity, or
2) remove the entities without worrying explicitly about the relationships.
Your proposed solution is a variation on (2); if I did it this way,
however, I would not explicitly iterate over the Collection you already
have, but instead use
List toRemove = new ArrayList(entityCollection);
then iterate over toRemove and invoke remove() on each element.
Collin's suggested solution is a variation on (1).
Which is preferrable is a matter of taste and style; performance
probably is not a factor unless you have truly massive collections.
John Bollinger
email***@***.com
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- What is the difference between a BMP EntityBean and a DAO ?As I read in a couple of articles a BMP (Bean Managed Persistence is an EntityBean
where the programmer has to care about the SQL statements.
On the other side a DAO implements the direct access to an SQL database.
But isn't that the same?
What are the differences ?
Lars
- 2
- java graph theoryi am a student tryingto write a progamme that will use graphs as their
starting point but dont know where to start. i have a small amount of
code to get me started but not much help.
If anyone can help me in anyway woulf be helpful.( places to look/
tips/ people to speak to/ books to look @ etc..)
- 3
- Panel text not showing in JFrameI have a JFrame to display after a button is clicked. The following
JFrame appears, but the label text does not appear until the thread is
completed. Any advise:
public void run(){
JPanel panel = new JPanel(); // create pane content object
JLabel prompt = new JLabel("Processing log files");
panel.add(prompt);
Container contentPane = myFrame.getContentPane();
contentPane.add(panel);
myFrame.setTitle("Processing logs...Please Wait");
myFrame.setBounds(100,100,350,75); // position frame
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.toFront();
panel.add(prompt);
myFrame.setVisible(true);
myFrame.pack();
System.out.println ("pack1 done");
myFrame.repaint();
myFrame.pack();
}
- 4
- TCP client application does detect network failureHi,
This is a behavior of the TCP socket in Java I dont' understand:.
Let say we have a simple client/server application running on TWO different
machines.
The client send bytes to the server.
The server recieved the bytes and wait for about X sec.
During this waiting time, we disconnect the server from the network (just by
unplugging the server network cable).
After the waiting time the server is aware of the network failure (a
SocketException is thrown : connection reset, because it is trying to send
the response)
But on the client side it is still stuck on a "rcv =
commandInput.readLine();" statement (see after for the complete code), it
will never be aware of the network failure !!! Even after one hour the
client is still waiting to read something on closed socket. Is this the
normal behavior ?
In reality we are dealing with an application that use the FTP server to
server mode (we are controlling only the command socket, the data transfer
is made by the servers). We have to transfer huge file, thus we can not set
up a time out. If the last scenario occurs, some of our transfers are stuck
and it is not possible for us to detect the failure. The client will wait
for ever the response.
Does anybody have already deal with that ?
Below is the simple client and server I made in order to make my experiment.
The client just read the keyboard input and send it to the server; the
server just echo the request except if the request
is 'wait X', in this case it will wait for X sec before responding.
Thanks by advance,
Olivier MERIGON
CLIENT:
----------------------------------------------------------------------------
-------
package com.iratensolutions.test.ftp;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
/**
* A Client/Server application to test the network failure behavior with TCP.
* This the client part. It just sends the keyboard input to the server.
* @author Olivier MERIGON
*/
public class TestNetworkFailureClient {
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("usage: java
com.iratensolutions.test.ftp.TestNetworkFailureClient serverAdress");
}
Socket commandSocket = null;
BufferedReader commandInput;
BufferedReader keyboardInput;
PrintWriter commandOutput;
try {
commandSocket = new Socket(args[0], 666);
commandInput = new BufferedReader(new
InputStreamReader(commandSocket.getInputStream()));
keyboardInput = new BufferedReader(new InputStreamReader(System.in));
commandOutput = new PrintWriter(new
OutputStreamWriter(commandSocket.getOutputStream()));
} catch (Exception e) {
e.printStackTrace();
return;
}
System.out.println("CLIENT STARTED");
String snd;
String rcv = null;
try {
do {
System.out.print("KEYBOARD: ");
snd = keyboardInput.readLine();
if (snd != null) {
commandOutput.println(snd);
commandOutput.flush();
System.out.println("SND: " + snd);
rcv = commandInput.readLine();
System.out.println("RCV: " + rcv);
}
} while (rcv != null);
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
--------------------------------------------------------------------------
SERVER
----------------------------------------------------------------------
package com.iratensolutions.test.ftp;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
/**
* A Client/Server application to test the network failure behavior with TCP.
* This the server part. The server can wait X second after responding to a
request.
* If a wait request is received, the server just answer the time waited
after
* the requested wait time, otherwise it respond immediatly the request
number.
* usage: wait intNbSec | any text
* @author Olivier MERIGON
*/
public class TestNetworkFailureServer {
public static void main(String args[]) {
ServerSocket echoServer = null;
String line;
DataInputStream is;
PrintStream os;
Socket clientSocket = null;
try {
echoServer = new ServerSocket(666);
System.out.println("SERVER STARTED");
} catch (IOException e) {
System.out.println(e);
}
while (true) {
try {
clientSocket = echoServer.accept();
System.out.println("Handling new client...");
is = new DataInputStream(clientSocket.getInputStream());
os = new PrintStream(clientSocket.getOutputStream());
int loopId = 0;
do {
line = is.readLine();
System.out.println("RCV: " + line);
//Handle "Wait" command
if (line.trim().startsWith("wait")) {
String[] tab = line.split("\\s");
boolean ok = false;
try {
int nbSec = Integer.parseInt(tab[1]);
System.out.println("...waiting for " + nbSec + " sec.");
try {
Thread.sleep(nbSec * 1000);
} catch (InterruptedException e1) {
}
String resp = "...end of wainting periode of " + nbSec + " sec.";
os.println(resp);
System.out.println("SND: " + resp);
ok = true;
} catch (Exception e) {
ok = false;
}
if (!ok) {
String resp = "usage: wait intNbSec | any text";
os.println(resp);
System.out.println("SND: " + resp);
}
//Handle "normal" action
} else {
os.println("# " + loopId);
System.out.println("SND: # " + loopId);
}
loopId++;
} while (line != null);
} catch (IOException e) {
System.out.println(e);
}
}
}
}
- 5
- DND using XML Hi,
I want to transfer a block of XML between 2 DND objects in java
What's the best way to do this?
steve
- 6
- AWT Cursor in vista problemHi,
i have an applet with a black background.
when i set the Cursor to Cursor.TEXT_CURSOR in Vista the cursor is
displayed also in black, and it is not seen.
any idea???
- 7
- 8
- using ClassDep to reduce rt.jari have been trying to use the JINI tool ClassDep to create a list of the
dependencies of a program i have written, but have been unsuccessful. when
i run it i output a list of classes that ClassDeps says my program needs,
but when i create an rt.jar file containing only those classes (yes, in the
appropriate package directories) i get the following:
NoClassDefFoundError: java.lang.ArrayStoreException.
i figured maybe it was a fluke, and just manually included the class.
after doing so i got the following, more confusing error:
error: java.lang.Error: java.io.UnsupportedEncodingException: Cp1252
Cp1252 is not something i specifically make reference to in my program, and
have only a nebulous idea of what it even is/does.
anyway, though, that's beside the point: i would really like to make a
slimmed down version of rt.jar to fit my specific needs according to the
classes that are needed by my app.
is there any way to do this that works, or am i just using ClassDep
incorrectly?
Please Help!
Thank You!
-Voltaic
- 9
- Java Swing font anti-aliasing w/o desktop environmentHello all,
With the newer versions of Java your Swing apps can look extra pretty
thanks to font smoothing. When using Ubuntu (as I am) the builtin
desktop environment configurations set this up for you - when running
GNOME, KDE, or XFCE it looks great. But I choose to run my .xsession
file instead, which loads FVWM. And somewhere along the line something
isn't set right and I don't get pretty smoothed fonts in my Swing apps.
I checked environment variables and I can't see it there, so I'm
thinking it may be an X resource? I don't know; if anybody has any
ideas on which knob I can twiddle to get the pretty fonts back, I'd
greatly appreciate it!
Best regards.
--
Taylor Venable
email***@***.com
http://real.metasyntax.net:2357/
- 10
- Compile error help (linking a class library)Hi,
I set the CLASSPATH correctly but still get the following compile error. I
also tried the "-classpath" alternative and get the same error message.
/home/yao/eh/jython-20.class(org/python/core/PyInteger.java):4:
class PyInteger is public, should be declared in a file named
PyInteger.java
(source unavailable)
But the class PyInteger is in a file PyInteger.java, just it is in the
class jython-20.class but no a .java source file. I use to do things like
this (linking with a class library and use the classes provided in it) a
lol before. But why this time, it's not working? Did I missing something?
Thanks,
Stan
- 11
- dynamic instanciation of a generic classHi,
I've a question about Tiger (Java 5), genercity and dynamic instanciation
of class.
I can't found tutorial or sample via the Net.
By exemple :
public class A<T>
{
private T v;
public A(T v)
{
this.v=v;
}
public void test()
{
System.out.println(v.getClass().getName());
}
}
I'd like instanciate the A class with something like that : Class.forName
("A").... but why can I specified T parameter ?
Please, send me some sample or URL.
Thanks,
Arnaud.
- 12
- How to place a window in the center of the screen ?I would like to open a window and to placed it at a certain position on a screen
(e.g. in the center).
How do I do this? My (simplified) current code looks like:
public class testGBL extends JFrame implements ActionListener {
JLabel lab1;
....
JButton butBack;
public testGBL() {
...
Container contentPane = getContentPane();
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
contentPane.setLayout(gridbag);
c.fill = GridBagConstraints.HORIZONTAL;
butBack = new JButton("Back");
c.gridx = 0;
c.gridy = 0;
c.weightx = 1.0;
c.gridwidth = 2;
gridbag.setConstraints(butBack, c);
butBack.setEnabled(false);
butBack.addActionListener(this);
contentPane.add(butBack);
....
}
public static void main(String args[]) {
testGBL window = new testGBL();
window.setTitle("test");
window.pack();
window.setVisible(true); }
}
- 13
- How does one combine the Adapter and Factory design patterns in a memory efficient way?I'm using the adapter pattern, and I've got a factory to generate adapters
for passed in adaptees. Let's call the class of the objects getting adapted
"Foo", and the Adapter class itself "Bar".
So here are some details specific to my situation:
1) the constructor for Bar is private and visible to the factory (Bar is
acting as its own factory), so I can completely control when and how Bar
gets instantiated.
2) If an existing adapter for a given instance of Foo doesn't exist yet,
I'll want to create a new Bar which matches with it.
3) If there already is a adapter h for Foo, I have to return that existing
match, and NOT generate a new one.
4) upon a request for an adapter for null, I return null.
This is relatively easy to do if I have infinite memory. I just create a
Map<Foo,Bar>, like so:
<code>
public class Bar {
private final Foo f;
private Bar(Foo f) {
this.f = f;
}
private final static Map<Foo,Bar> mapping = new
ConcurrentHashMap<Foo,Bar>();
public static Bar make(Foo f) {
if (impl == null) {
return null;
}
synchronized (mapping) {
if (!mapping.containsKey(f)) {
mapping.put(f, new Bar(f));
}
Bar b = mapping.get(f);
assert returnValue != null;
return returnValue;
}
}
public void newInterfaceWhichModifiesState() {
this.f.oldInterfaceWhichModifiesState();
}
public int newInterfaceWhichGetsState() {
return this.f.oldInterfaceWhichGetsState();
}
}
</code>
However, it's possible that the calling code is generating billions and
billions of instances of Foo, and then throwing them away after their first
use. My Map would prevent the garbage collector from being able to reclaim
those instances. I can safely delete those "throwaway Foos" and their
matches from my Map, because if there doesn't exist a reference to some
instance of Foo anywhere else in the JVM, then it can't possibly ever occur
that that instance will ever get passed into my make(Foo) method, in which
case, I would never need to return its corresponding Bar.
The two potential-solutions I looked at, Maps of WeakReferences and
WeakHashMap, turned out not to satisfy my requirements.
If instead of a Map<Foo,Bar>, I had a Map<Foo,WeakReference<Bar>>, then it's
possible that the matching Bar would get garbage collected, but the instance
of Foo would get passed in again, and there's no way for me to recover its
matching pair, thus violating condition (3) mentioned above.
If I replace Map<Foo,Bar> with WeakHashMap<Foo,Bar>, none of the keys will
get GCed, because instances of Bar contain a strong reference to Foo, via
the private field f. If I change that field to a weak reference, then it's
possible the instance of Foo that's being adapted will get GCed while the
corresponding adapter is still in use, resulting in the newInterface()
method failing.
I think what I need is some sort of special PairOfWeakReference class such
that if there are any references to either an instance of Foo or its
corresponding Bar, then BOTH remain uncollectable. However, once there do
not exist any strong references to either instances, then the pair become
collectable simultaneously.
Using a pair class, as in:
<code>
public class Pair<A,B> {
public final A a;
public final B b;
public Pair(A a, B b) {
this.a = a;
this.b = b;
}
}
</code>
WeakReference<Pair<Foo,Bar>> won't work either, because the WeakReference
class is checking against references to instances of the Pair class, rather
than references to the instances of Foo and Bar.
This adapter-factory combination doesn't sound like something that unusual
or obscure, so I figure I must be missing something simple from effectively
implementing it. Can anyone tell me what that is?
- Oliver
- 14
- JFace getting startedHi
I try to run a simple SWT/Jface example. I am running this from inside
eclipse 3.2.0 and I have included the following in my classpath:
swt.jar - Taken from swt-3.3M3-win32-win32-x86.zip
jface.jar - Taken from program files\eclipse\plugins and Renamed from
org.eclipse.jface_3.2.0.I20060605-1400.jar
Here is the class:
import org.eclipse.jface.window.*;
import org.eclipse.swt.widgets.*;
public class MyJFaceExample1 extends Window {
public MyJFaceExample1() {
// super(null); //Wont compile with null as the beginner example says
it should
super(new Shell()); //Compiles
}
public static void main(String[] args) {
MyJFaceExample1 demo = new MyJFaceExample1();
demo.setBlockOnOpen(true);
demo.open();
Display.getCurrent().dispose();
}
------------------------------------------------------------
This compiles fine but when I try to run this I get:
java.lang.NoClassDefFoundError:
org/eclipse/core/commands/common/EventManager
I then copy c:\program
files\eclipse\plugins\org.eclipse.core.commands_3.2.0.I20060605-1400.jar
and rename it to core.jar.
I then get the following error: java.lang.NoClassDefFoundError:
org/eclipse/core/runtime/ListenerList
Then I am stuck.
Please help me with getting started with JFace.
- 15
- sending a message from jboss to all java-clientsHi
I'm building a j2ee Application on top of j2ee and JBoss 4.0.
The Clients connected to JBoss are non-web Swing Clients.
If One Clients changes the data on a bean/in the db, all the other clients
connected to the jboss have to be informed about the change, so they can
update der UI.
On a standalone Java-App i would use listeners to solve this, but as im new
to j2ee i have no idea how to realize this with j2ee and jboss.
It would be great to get some ideas on how to solve this problem.
greets from Germany
Johannes Hermen
|
|
|