This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Modern JavaScript for the Impatient and have Cay Horstmann on-line!
See this thread for details.
Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!

iamiqbal.m Mohiuddin

Greenhorn
+ Follow
since May 11, 2006
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 iamiqbal.m Mohiuddin

Hello All:

I have two set of Images being displayed on ImageButtons and based on timer and random number i am changing the images by setting them dynamically.
but the new/ changed image is not reflected on screen. I believe it has something to do with refreshing the screen after setting the image.
I have looked at API i dont see anything as such. can anyone help me how the image on a imagebutton can be changed dynamically and displayed?

My code is as below:

package com.pkg.rain;

import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;

import com.pkg.rain.R.id;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;

import android.widget.ImageView;

public class Rain extends Activity {

public ImageButton imagebutton1;
public ImageButton imageButton2;
public ImageButton imageButton3;
public ImageButton imageButton4;
public ImageButton imageButton5;
public ImageButton imageButton6;

public Button playButton;

public EditText numberEditText;

Intent intent;
Timer timer;
int randomNumber=0;


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Random randomGenerator = new Random();
int random = randomGenerator.nextInt(6)+1;
randomNumber = random;

setUpViews();
}


private void setUpViews(){

numberEditText = (EditText)findViewById(id.txtScore);

imagebutton1 = (ImageButton)findViewById(R.id.imagebutton1);
imageButton2 = (ImageButton)findViewById(R.id.imagebutton2);
imageButton3 = (ImageButton)findViewById(R.id.imagebutton3);
imageButton4 = (ImageButton)findViewById(R.id.imagebutton4);
imageButton5 = (ImageButton)findViewById(R.id.imagebutton5);
imageButton6 = (ImageButton)findViewById(R.id.imagebutton6);
intent = new Intent(this, Rain.class);

playButton = (Button)findViewById(R.id.play_button);
playButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
startTimer(1);
}
}
);
}

public void startTimer(int seconds){
timer = new Timer();
timer.schedule(new RemindTask(),1000, seconds*1000);

}

class RemindTask extends TimerTask {
public void run() {

setImages();

}
}

public void setImages(){
Random randomGenerator = new Random();
int random = randomGenerator.nextInt(6)+1;
randomNumber = random;

switch (randomNumber){
case 1:
imagebutton1.setImageResource(R.drawable.smileicon2);
imageButton2.setImageResource(R.drawable.icon);
imageButton3.setImageResource(R.drawable.icon);
imageButton4.setImageResource(R.drawable.icon);
imageButton5.setImageResource(R.drawable.icon);
imageButton6.setImageResource(R.drawable.icon);
break;
case 2:
imageButton2.setImageResource(R.drawable.smileicon2);
imagebutton1.setImageResource(R.drawable.icon);
imageButton3.setImageResource(R.drawable.icon);
imageButton4.setImageResource(R.drawable.icon);
imageButton5.setImageResource(R.drawable.icon);
imageButton6.setImageResource(R.drawable.icon);
break;
case 3:
imageButton2.setImageResource(R.drawable.icon);
imagebutton1.setImageResource(R.drawable.icon);
imageButton3.setImageResource(R.drawable.smileicon2);
imageButton4.setImageResource(R.drawable.icon);
imageButton5.setImageResource(R.drawable.icon);
imageButton6.setImageResource(R.drawable.icon);
break;
case 4:
imagebutton1.setImageResource(R.drawable.icon);
imageButton2.setImageResource(R.drawable.icon);
imageButton3.setImageResource(R.drawable.icon);
imageButton4.setImageResource(R.drawable.smileicon2);
imageButton5.setImageResource(R.drawable.icon);
imageButton6.setImageResource(R.drawable.icon);

break;
case 5:
imagebutton1.setImageResource(R.drawable.icon);
imageButton2.setImageResource(R.drawable.icon);
imageButton3.setImageResource(R.drawable.icon);
imageButton4.setImageResource(R.drawable.icon);
imageButton5.setImageResource(R.drawable.smileicon2);
imageButton6.setImageResource(R.drawable.icon);

break;
case 6:
imagebutton1.setImageResource(R.drawable.icon);
imageButton2.setImageResource(R.drawable.icon);
imageButton3.setImageResource(R.drawable.icon);
imageButton4.setImageResource(R.drawable.icon);
imageButton5.setImageResource(R.drawable.icon);
imageButton6.setImageResource(R.drawable.smileicon2);

break;

}
}
9 years ago
Thanks for the reply.

I am not sure why its an issue in the constructor of MSTDatExtrachThread class.

If i change tthe spring beans configuration by removing sourceBean as reference proprty and put it as an isolated bean and get that bean through Bean factory
it works without any error.

<bean id="batchProcessor" class="com.mst.batch.BatchProcessor" singleton="false">
<property name="batchInitializer"><ref bean="batchInitializer" /></property>
<property name="sourceBean"><ref bean="sourceBean" /></property> </bean>

and in code:

This works but not the original one which i have posted.

Appreciate if anyone can put some light on this.
10 years ago
Hello All:

I am running into strange problem.






I am getting the above exception. I see i am able to get batchInitializer bean but not the sourceBean.
Any help is highly appreciated.



10 years ago
Thanks Vinod.

I did check your blog.
Do we need sun-jaxws.xml as mentioned in your blog?

Doesn't JAX-WS annotations take care of this and free us from deployment descriptors.

Last when i did was deployment descriptor was getting generated automatically when we deploy on app. server.
I am trying to achieve the same.

Do i need to set something in JBoss server so that it detects wsdl. when i hit http://localhost:port/jbossws
I see page coming up. Thats means JAX-WS is enabled / installed on this server.

Can anyone provide me a working war file which has web service. I just want to deploy that and see whether i can hit the wsdl or not?
Just to rule out one of the possibility that my war file is messed up.

Thanks in advance.
10 years ago
Thanks Ivan.

I have checked the logs i dont see anything in the logs.

My web.xml is

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">;
<display-name>LoggerServiceWS</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>

I am using eclipse ide. I have added jboss server and then added my project.
To my knowledge we dont need any deployment descriptor for jax-ws web service.

Is this all i need or Do i need to specify anything in app server so that it knows about jax-ws?

Appreciate your inputs.


10 years ago
Hello:

I am new to web services.

I have a sample web service as below.
package sample;

import javax.jws.WebMethod;
import javax.jws.WebService;


@WebService(
name="Logger",
serviceName="LoggerServiceWS",
targetNamespace="http://mstdeal/ws";
)
public class MSTDealLoggerWS {
public MSTDealLoggerWS() {}

@WebMethod(operationName="add", action="urn:Add")
public int add(int i, int j) {
int k = i +j ;
System.out.println(i + "+" + j +" = " + k);

return k;
}
}

I was able to generate the other artifacts using wsgen. It has generated wsdl and other bean classes [Add.java, AddResponse.java]
I have created a war file to deploy this webservice in jboss-4.2.2.GA. The structure of my war file is :

LoggerServiceWS.war
|-- WEB-INF
|-- classes [this has sample package and MSTDealLoggerWS]
|-- lib [no jars here]
|--wsdl [generated wsdl]

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions targetNamespace="http://mstdeal/ws"; name="LoggerServiceWS" xmlns:tns="http://mstdeal/ws"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; xmlns="http://schemas.xmlsoap.org/wsdl/">;
<types>
<xsd:schema>
<xsd:import namespace="http://mstdeal/ws"; schemaLocation="LoggerServiceWS_schema1.xsd"/>
</xsd:schema>
</types>
<message name="add">
<part name="parameters" element="tns:add"/>
</message>
<message name="addResponse">
<part name="parameters" element="tns:addResponse"/>
</message>
<portType name="Logger">
<operation name="add">
<input message="tns:add"/>
<output message="tns:addResponse"/>
</operation>
</portType>
<binding name="LoggerPortBinding" type="tns:Logger">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"; style="document"/>
<operation name="add">
<soap:operation soapAction="urn:Add"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="LoggerServiceWS">
<port name="LoggerPort" binding="tns:LoggerPortBinding">
<soap:address location="http://localhost:8080/LoggerServiceWS/LoggerServiceWS"/>;
</port>
</service>
</definitions>


when i deploy this on JBoss 4.2.2 [server-default-deploy folder]
and when i hit http://localhost:8080/LoggerServiceWS/LoggerServiceWS?wsdl

i am not able to see wsdl. It says 404 exception.

This is a very simple example. Highly appreciate if someone can help me why .wsdl is not deployed.

10 years ago
Preview
DB2 callable statement close.
All:

I am running into very strange situation.

I am getting error maximum number of statements exceeded. which is known that the statement / callable statement is not closed somewhere in the code.

which is not the case here in my code. I am closing callable statement.

I have ran two scenarios one worked and another failed.

Scenario one which worked:
I have multithreaded application if i create the connection after i spawn a new thread it works without any error.

pseudo code is as follows
_________________________________________________________________
public class Thread1 implements Runnable{

private DBMgrImpl dbMgrImpl = null;

public Thread1(){
this.dbMgrImpl = new DBMgrImpl(); //creates DB connection
}

public void run(){

dbLoader.insertRecord(dbMgrImpl ); // inserts record by creating callable statement. I have finally block in insertRecord which closes callable statement.

}

}

public class Test{

for(int i<100){
Thread1 thread = new Thread1();
new Thread(thread).start();
}
}

_______________________________________________________________________________________

This above approache works fine with no errors. Though iam not closing connection anywhere in the above. Its just callable statement being closed.

Scenario two which fails:

public class Thread1 implements Runnable{

private DBMgrImpl dbMgrImpl = null;

public Thread1(DBMgrImpl dbMgrImpl ){
this.dbMgrImpl = dbMgrImpl ;
}

public void run(){

dbLoader.insertRecord(dbMgrImpl ); // inserts record by creating callable statement. I have finally block in insertRecord which closes callable statement.

}

}

public class Test{

DBMgrImpl dbMgrImpl = new DBMgrImpl(100); // create 100 connections before spawning any thread

for(int i<100){
Thread1 thread = new Thread1(dbMgrImpl );
new Thread(thread).start();
}
}

This above approache blows with maximum number of statements exceeded.
_____________________________________________________________________

My understanding of what might be happening is when iam creating DBMgrImpl inside the thread as soon as thread completes its getting garbage collected. So connection / callable statements are not available.
whereas in other scenario since DBMgrImpl is created before spawning the thread and is passed to threads each one uses it and DBMgrImpl remains in memory even after thread is completed.

Does anyone of you guys got into this kind of situation. I am using jt400.jar [type 4 driver]. I have read in few forums that we have to explicitly invoke garbage collection for this kind of errors. Wondering is this driver [jt400] issue?

I would appreciate any pointers in this direction.

Thanks,


After reading the message from MQ if insertion fails then message must be rolled back to Queue.
Another possibility is that based on the message the business logic would require to connect to database and get some more fields and then insert into another database. All this happens as a single unit of work.
Let me know is this not distrubuted transactions.
I am looking for both 1) reading from MQ and inserting into DB
2) Reading from DB and inserting into another DB.

Thanks in advance.
11 years ago
I have a scenario where in the java standalone program reads message from MQ queue and inserts into database.
This should happen as a single unit of work.

My question is java standalone supports distributed transaction? [XA etc...]

If anoyone of you have handled this kind of scenario i woud appreciate any pointers in this direction.

Regards,
Iqbal.M

11 years ago
Thanks. I appreciate it.

We dont know the number of threads that are going to be created.
Its dynamic based on number os records returned from the database.

I shall explore more on ThreadPool option.
We have a simple jsp/struts UI.
Using the UI we can start a batch process by clicking on Run button.
The batch process would fetch records from DB and write to MQ.
We have a threshold value of 30000 records.
When the program retrieves 30000 records we spawn a new thread and pass that list of 30000 records to that thread which does
writing to MQ and the retrieval continues. This process repeats everytime counter reaches 30000 mark.
Now on the UI we are going to have Stop button. When user clicks on stop button the execution of that batch should be stopped. (All the threads that might have spawned should be stopped on clicking of stop).

We have layered architecture with UI (jsp and forms / actions (struts)) and jdbc framework in separate packages.

Any pointers would be highly apprecited.

Thanks in advance,
Iqbal
Dear All:

Myself going to travel to US. I have been asked to get hands on Weblogic.
I have been working on J2EE (EJB) for the past 2 & 1/2 years.
I need soome pointers to get started.
Please provide me the names of books, URL's etc..So that i can start learning.
How much time it takes for this?

Thank you very much,
Iqbal.M
14 years ago