raghu mrvreddy

Greenhorn
+ Follow
since Nov 24, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by raghu mrvreddy

Can you try changing the name of service to HTTPConnector2 or something else. As far as I see, its not able to start the mule because it is finding two HTTPConnectors.

Let me know if this helps else can you paste your mule-config file.

Thank you,
mrvreddy
15 years ago
I am not sure how you are keep tracking of the threads for each user but its always better to maintain a thread pool and assign a thread for each request of user when he starts a thread..


Here is a sample program which starts a thread running indefinitely and i stop the thread from main thread --- code might use some deprecated methods but it works

Copy and paste it and it should work... I used some existing code from internet.... @http://nadeausoftware.com/articles/2008/04/java_tip_how_list_and_find_threads_and_thread_groups

import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;


public class TestClass {
public static void main(String[] s){
TestClass t = new TestClass();
t.xxx();
}

public void xxx(){
Thread t1 = new Thread(new Runnable() {
public void run() {
for(;;){
try {
System.out.println("got in");
//Thread.sleep(1000);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
},"one");

t1.start();
System.out.println("Getting thread Info");
Thread t = getThread("one");
System.out.println(t);
//changing the flag
//comment and uncomment the t.stop() which is another thread i started
t.stop();

}

Thread getThread( final String name ) {
if ( name == null )
throw new NullPointerException( "Null name" );
final Thread[] threads = getAllThreads( );
for ( Thread thread : threads )
if ( thread.getName( ).equals( name ) )
return thread;
return null;
}

Thread[] getAllThreads( final Thread.State state ) {
final Thread[] allThreads = getAllThreads( );
final Thread[] found = new Thread[allThreads.length];
int nFound = 0;
for ( Thread thread : allThreads )
if ( thread.getState( ) == state )
found[nFound++] = thread;
return java.util.Arrays.copyOf( found, nFound );
}

Thread[] getAllThreads( ) {
final ThreadGroup root = getRootThreadGroup( );
final ThreadMXBean thbean = ManagementFactory.getThreadMXBean( );
int nAlloc = thbean.getThreadCount( );
int n = 0;
Thread[] threads;
do {
nAlloc *= 2;
threads = new Thread[ nAlloc ];
n = root.enumerate( threads, true );
} while ( n == nAlloc );
return java.util.Arrays.copyOf( threads, n );
}

ThreadGroup getThreadGroup( final String name ) {
if ( name == null )
throw new NullPointerException( "Null name" );
final ThreadGroup[] groups = getAllThreadGroups( );
for ( ThreadGroup group : groups )
if ( group.getName( ).equals( name ) )
return group;
return null;
}

ThreadGroup[] getAllThreadGroups( ) {
final ThreadGroup root = getRootThreadGroup( );
int nAlloc = root.activeGroupCount( );
int n = 0;
ThreadGroup[] groups;
do {
nAlloc *= 2;
groups = new ThreadGroup[ nAlloc ];
n = root.enumerate( groups, true );
} while ( n == nAlloc );

ThreadGroup[] allGroups = new ThreadGroup[n+1];
allGroups[0] = root;
System.arraycopy( groups, 0, allGroups, 1, n );
return allGroups;
}

ThreadGroup rootThreadGroup = null;

ThreadGroup getRootThreadGroup( ) {
if ( rootThreadGroup != null )
return rootThreadGroup;
ThreadGroup tg = Thread.currentThread( ).getThreadGroup( );
ThreadGroup ptg;
while ( (ptg = tg.getParent( )) != null )
tg = ptg;
return tg;
}
}

Hope this helps... I might me completely wrong too...








public class Main {

public static void main(String[] args) throws Exception {
Animal be = new Beagle();

FileOutputStream f_out = new FileOutputStream( "myobject.data" );

// Write object with ObjectOutputStream
ObjectOutputStream obj_out = new ObjectOutputStream( f_out );

// Write object out to disk
obj_out.writeObject( be );

FileInputStream f_in = new FileInputStream( "myobject.data" );

// Read object using ObjectInputStream
ObjectInputStream obj_in = new ObjectInputStream( f_in );

// Read an object
Object obj = obj_in.readObject();
System.out.println( obj );
}

}

class Animal {

int i = 10;

Animal() {
System.out.print( "a" );
}

@Override
public String toString() {
return "i=" + this.i;
}
}

class Dog extends Animal implements Serializable {

int j = 11;

Dog() {
System.out.print( "d" );
}

@Override
public String toString() {

return super.toString() + "j=" + this.j;
}
}

class Beagle extends Dog {

int k = 12;

@Override
public String toString() {

return super.toString() + "j=" + this.j;
}
}

Check out...
I am not sure why you cant do it if you can do it with normal controller, after all MultiActionController allows you to aggregate multiple actions into one controller.
15 years ago
As far as I know SAX parser is best suited for loading configuration files. DOM would create a object-oriented hierarchical representation of the xml file which we generally doesn't need for configuration files.

Sax parser is generally used for configuration file loading in most of the frameworks.

Even for key value pair, SAX would be the better option.

However depending on your requirements, check the advantages of SAX and DOM, pick the best suited one.

Raghu
15 years ago
hi
My friend was asked a question in google about private access modifiers.

question was :

if you have setters and getters methods for accessing private variables, how are you providing security for private variables if the client can set the private variable value using setter methods

in advance
Thanks
18 years ago
Iam having a file where one java program updates the file and the other java program will be invoked when this file is updated.

Is there an event that can be thrown when a file is updated?

Thanks
18 years ago