Aboo Bolaky

Greenhorn
+ Follow
since Apr 02, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Aboo Bolaky

hi Steve..
Ive done a project using the EJB Timer Service...let me tell u whats its like...although being an addition to the EJB specs..it performs the basic things that u need to launch a process or even trigger an event when the timer expires...it all depends on the nature of the application that ure developing..and bear in mind that u cant use the Timer Service with stateless beans (which is quite a bit of a drawback)
at a first glance, its fair enough to use it for an application that has a specific functionality...but if ure gonna build something thats later going to expand or would demand scalability and other features, u might look at the Quartz Crystal API ..the flexibility that it gives you is far much better than timer service in EJB.
Job Scheduling in Java by Bosanac, D.

Best Regards
Aboo
the class String already implements the interface Serializable and therefore you should be able to send an Arr of Strings over RMI..
The other mechanism as Rajan pointed out is Log4J..
have a look at Vikram Goyal's introductory explanation
hi ya...
yeah ure right...the EJB specs specifically says that EJBS cannot perform file i/o. if u need to log messages or access files, you must find another mechanism...
nope..the spec is not wrong...u should be careful to note that there are two types of session beans,..
1: Stateless Session beans..
these beans MUST HAVE only one create method and that method takes no parameters..
2: StateFull Session Beans
these beans can have more than 1 create method and can take as many parameters as you like..
for more information about connection factories and destinations visit Sun's JMS tutorial

connection factories and destinations are created with the J2EE admin console and are best managed adminitratively rather than programmatically..
administered objects with reference to JMS are ConnectionFactories and destinations. these are looked up via JNDI...and are both managed by the J2EE server...
try this

import java.util.Collection;

Collection accounts=new HashSet();
accounts=home.findall();
sorry what i meant for <resource -env entry> is actually meant for <env entry>..
the real defn for resource env refs is that they provide a way of accessing, via JNDI lookups, administered objects associated with a resource. For example, an application may need to access a JMS Destination object. The <resource-env-ref> element, defined in the standard deployment descriptors lets applications declare the resource requirements.

The main difference between <resource-env-ref> and <resource-ref> element is the absence of specific resource authentication requirement; both these elements have to be backed up by a resource factory descriptor.

resource-env-ref>
<description> My Topic </description>
<res-env-ref-name> jms/MyTopic </res-ref-name>
<res-env-ref-type> javax.jms.Topic </res-type>
</resource-env-ref>

in order these resource-env-ref variables to work, the administrators will have to make target resource factories available at run-time.
hello..
<resource-refs> may be any resource being used/referenced by the bean..like a connection pool or a topicconnection/queueconnection factory
on the other hand..
<resource env ref> can be any string or data format that u look up via jndi context ...like a string u place in the java:comp/env/ namespace
this occurs when u would like to create a well known string with a given value and then look up that value from ur bean....instaed of declaring it inside ur code, u look it up from JNDI...
hope it helps..
:roll:
JMS
hi ya...if u implement messagedriven beans...then these beans actually run on the server side and cant write to standard output..u will actually see the output in the server log file..
however one way to get arnd this problem is to create Message Listeners on the client side...instead of using MEssage driven beans,..this will do the task of message driven beans.ie. assynchronously listening to msg.. Check out this code snippet...

import javax.jms.*;
public class client implements MessageListener{

//any instance variables and methods that u like...
//its imperative to have this function
public void onMessage(Message msg){
if (msg instance of TextMessage)
System.out.println("Received text msg..");
}

likewise the msg can be printed to standard output..
be careful to note that when u deploy the application, the application client must be bound to the appropriate message Destination...these are done manually when u deploy the application.. if these settings are not present, then the client will have to way to listen to msgs...koz the message destination is not defined...
hope ive cleared out ur doubts!!!


:roll:
Hello all..
Im so desperate..Can anyone of u help me sort this problem..i have a bean that uses the timer service.on the ejbtimeout..i create a topic publisher and send a message to a topic.(topic name and connection factory have been successfully looked up).im using a message selector (userID) on the message im sending. Only users that have that id are supposed to receive the message.

On my client,it implements the messagelistener interface..the users logs with his/her userID.
Even that, a user with a different id receives the message�..

Hope the code will stretch the picture out..


BEAN (omitting exceptions)

Public void ejbtimeout(Timer timer){

String id=�03048660�
outputMessage=getAlertMessage(id);
System.out.println("The message is:"+outputMessage);


//topicConnectionFactory = new com.sun.messaging.TopicConnectionFactory();

Context ctx=new InitialContext();
topic=(Topic) ctx.lookup("java:comp/env/jms/TopicName");


topicConnectionFactory=(TopicConnectionFactory) ctx.lookup("java:comp/env/jms/MyConnectionFactory");

/* Create the connection.../
topicConnection = topicConnectionFactory.createTopicConnection();
/* Not transacted Auto acknowledegement */

topicSession = topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);


topicPublisher = topicSession.createPublisher(topic);
/*
* Non persistent delivery
*/
topicPublisher.setDeliveryMode(DeliveryMode.NON_PERSISTENT);


TextMessage msg=topicSession.createTextMessage();
msg.setText(outputMessage);
msg.setStringProperty("USERID",id);
topicConnection.start();

topicPublisher.publish(msg);

}


CLIENT:


Public class client extends MessageListener{

InitialContext ctx=new InitialContext();
topic=(Topic) ctx.lookup("java:comp/env/jms/TopicName");


TopicConnectionFactory=(TopicConnectionFactory) ctx.lookup("java:comp/env/jms/MyConnectionFactory");

topicConnection = topicConnectionFactory.createTopicConnection();
topicSession = topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
String filterProperty="USERID like '03048660' ";

topicSubscriber = topicSession.createSubscriber(topic,filterProperty,false);

topicSubscriber.setMessageListener(this);

topicConnection.start();



public void onMessage(Message message){
TextMessage msg=null;

try{
if (message instanceof TextMessage)
{
msg=(TextMessage)message;
System.out.println("Got Message:" + msg.getText());
JOptionPane.showMessageDialog(getContentPane(),msg.getText(),"Alert Service",JOptionPane.INFORMATION_MESSAGE);

}

}

catch(Throwable te){
te.printStackTrace();
}

}


}

When I run the program with ID :03048660, the expected output is obtained. the user receives the message.
But when I run (side by side) another instance of the same program with a different id, that user also receives the message..(although he is not supposed to receive it koz his ID is not 03048660)

Isnt the message filter working???plz help me
Hello all..
Im so desperate..Can anyone of u help me sort this problem..i have a bean that uses the timer service.on the ejbtimeout..i create a topic publisher and send a message to a topic.(topic name and connection factory have been successfully looked up).im using a message selector (userID) on the message im sending. Only users that have that id are supposed to receive the message.

On my client,it implements the messagelistener interface..the users logs with his/her userID.
Even that, a user with a different id receives the message�..

Hope the code will stretch the picture out..


BEAN (omitting exceptions)

Public void ejbtimeout(Timer timer){

String id=�03048660�
outputMessage=getAlertMessage(id);
System.out.println("The message is:"+outputMessage);


//topicConnectionFactory = new com.sun.messaging.TopicConnectionFactory();

Context ctx=new InitialContext();
topic=(Topic) ctx.lookup("java:comp/env/jms/TopicName");


topicConnectionFactory=(TopicConnectionFactory) ctx.lookup("java:comp/env/jms/MyConnectionFactory");

/* Create the connection.../
topicConnection = topicConnectionFactory.createTopicConnection();
/* Not transacted Auto acknowledegement */

topicSession = topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);


topicPublisher = topicSession.createPublisher(topic);
/*
* Non persistent delivery
*/
topicPublisher.setDeliveryMode(DeliveryMode.NON_PERSISTENT);


TextMessage msg=topicSession.createTextMessage();
msg.setText(outputMessage);
msg.setStringProperty("USERID",id);
topicConnection.start();

topicPublisher.publish(msg);

}


CLIENT:


Public class client extends MessageListener{

InitialContext ctx=new InitialContext();
topic=(Topic) ctx.lookup("java:comp/env/jms/TopicName");


TopicConnectionFactory=(TopicConnectionFactory) ctx.lookup("java:comp/env/jms/MyConnectionFactory");

topicConnection = topicConnectionFactory.createTopicConnection();
topicSession = topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
String filterProperty="USERID like '03048660' ";

topicSubscriber = topicSession.createSubscriber(topic,filterProperty,false);

topicSubscriber.setMessageListener(this);

topicConnection.start();



public void onMessage(Message message){
TextMessage msg=null;

try{
if (message instanceof TextMessage)
{
msg=(TextMessage)message;
System.out.println("Got Message:" + msg.getText());
JOptionPane.showMessageDialog(getContentPane(),msg.getText(),"Alert Service",JOptionPane.INFORMATION_MESSAGE);

}

}

catch(Throwable te){
te.printStackTrace();
}

}


}

When I run the program with ID :03048660, the expected output is obtained. the user receives the message.
But when I run (side by side) another instance of the same program with a different id, that user also receives the message..(although he is not supposed to receive it koz his ID is not 03048660)

Isnt the message filter working???plz help me
thnks..
didnt think it would be that easy...was struggling with type casting!!..
17 years ago
hello...im building a SWING login interface with the JPasswordField Component. To obtain the unmasked password i use
char password[]=txtPassword.getPassword();

the function getPassword returns an array of chars...but i need the result as simply of type String.
i tried the type casting several times but im not having the hang of it...can anyone help me plz?
thanks in advance,
Drftwy
17 years ago