Clean Java

There is always a bigger game

Posts Tagged ‘java

MongoDB – Add an Element to an Array using Java Driver.

with one comment

post is moved to http://ourownjava.com/mongodb/how-to-add-an-element-to-an-array-type-using-mongodb-java-driver

Advertisements

Written by cleanjava

March 20, 2013 at 12:39 pm

Creating user registration page in ATG using DSPs and Handler.

with 9 comments

How to add users in ATG using ACC?

with 7 comments

On development phase, you may have to set up users with valid credential to do authentication test in your ATG e-commerce web-site. I will explain you every step required to setup user using ATG ACC and how to verify if the user is indeed setup properly.

1. load dynamo admin tool using the below given URI.
http://host-name:port/dyn/admin

2. On the dynamo admin console click on Admin ACC link. (Third one from the top)

3. Click on “Start ACC in Server VM” button.
4. Now you should see a thick GUI written in java swings titled ATG Control Center. Default credential for ATG ACC is admin/admin
5. On the left hand site you should see a collection of menus.
6. Select the first item in left pane named People and Organization.

7. Now you should see six other items under the People and Organization main item
8. Select Users item. (Third one from the top)

9. This should bring up the user window. Punch in all users details and click on OK button.

10. Click on the save icon on the top right side of ACC window.
11. Now you can verify if the user is really added in the database.
12. Select JDBC browser from Dynamo Admin Page. (see the first step to load dyn admin page)
13. Select “Execute Query” under database operations.
14. Write “select * from dps_user” in the query text area and click execute button.
15. You should be able to the user you have added thru the ACC new user window.

How to write ATG includes query (RQL)?

with 12 comments

Wildcard File Filter in java.

with one comment

Splitting tasks among threads.

with 2 comments

Recently in an interview I was asked to write a program which prints running positive numbers, odd number shall be printed by one thread and even number shall be printed by another thread. I thought to share the program with you guys.


package org.sanju;

/**
 *
 * @author sanju.org
 *
 * Example program which prints odd number by one thread
 * and even number by another thread.
 *
 *
 */
public class SplitTaskExample {

	private volatile Integer i = new Integer(0);

	private void printRunningNumbers(){

		//odd thread
		new Thread(new Runnable() {
			public void run() {
				while(true){
					if(i % 2 == 1){
						System.out.println("odd thread :"+i);
						i++;
					}
					try{
						i.wait();
						i.notifyAll();
					}catch (Exception e) {
					}
				}
			}
		}).start();

		//even thread
		new Thread(new Runnable() {

			public void run() {
				while(true){
					if(i % 2 == 0){
						System.out.println("even thread : "+i);
						i++;
					}
					try{
						i.wait();
						i.notifyAll();
					}catch (Exception e) {
					}
				}
			}
		}).start();

	}

	public static void main(String[] args) {
		new SplitTaskExample().printRunningNumbers();
	}

}

/local/opt/java SplitTaskExample

even thread : 0
odd thread :1
even thread : 2
odd thread :3
even thread : 4
odd thread :5

Written by cleanjava

March 21, 2012 at 7:36 pm