Thursday, August 27, 2009

Using Weblogic Work Managers

Using Work Managers to Optimize Scheduled Work
http://e-docs.bea.com/wls/docs103/config_wls/self_tuned.html#wp1063790

<work-manager>
<name>stuckthread_workmanager</name>
<work-manager-shutdown-trigger>
<max-stuck-thread-time>30</max-stuck-thread-time>
<stuck-thread-count>2</stuck-thread-count>
</work-manager-shutdown-trigger>
</work-manager>


   <weblogic-enterprise-bean>
<ejb-name>ResourceConstraintEJB</ejb-name>
<jndi-name>core_work_ejb_resource_ResourceConstraintEJB</jndi-name>
<dispatch-policy>stuckthread_workmanager</dispatch-policy>
</weblogic-enterprise-bean>

Connecting to Weblogic using WLST

WebLogic Scripting Tool
http://edocs.bea.com/wls/docs103/config_scripting/index.html

java weblogic.WLST

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

wls:/offline> connect('weblogic','weblogic','t3://localhost:7001')


wls:/UserDomain/serverConfig> ls()



Thursday, August 13, 2009

Using Ant XmlTask to read properties from xml file

xmltask provides the facility for automatically editing XML files as part of an Ant build
http://www.oopsconsultancy.com/software/xmltask/

    <path id="externaltask.ant.classpath">
<pathelement location="./xmltask-v1.15.jar"/>
</path>

<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" classpathref="externaltask.ant.classpath"/>

<xmltask source="config.xml">
<copy path="//deploymentPath/text()" property="deployment"/>
<copy path="//software/beaHome/text()" property="weblogicHome"/>
</xmltask>

Wednesday, August 5, 2009

Using anonymous class in Java

The Java Language Specification, Third Edition
http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html

The Java Tutorials
http://java.sun.com/docs/books/tutorial/index.html

Java in a Nutshell
http://docstore.mik.ua/orelly/java-ent/jnut/ch03_12.htm

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class TestAnonymous {

@SuppressWarnings("serial")
public static void main(String[] args) {

Map<Object, Object> map = new HashMap<Object, Object>() {

@SuppressWarnings("unchecked")
@Override
public Object put(Object key, Object value) {
if (containsKey(key)) {
((List<Object>) get(key)).add(value);
} else {
List<Object> list = new ArrayList<Object>();
list.add(value);
super.put(key, list);
}
return value;
}
};

map.put("k1", 1);
map.put("k1", 2);
map.put("k1", "1");
map.put("k1", "2");

map.put("k2", 1);
map.put("k2", "1");

map.put("k3", 1);

System.out.println(map.toString());


}

}



{k3=[1], k1=[1, 2, 1, 2], k2=[1, 1]}


Anonymous class converted to nested class
private static final class HashMapConvertList extends
HashMap<Object, Object> {
@SuppressWarnings("unchecked")
@Override
public Object put(Object key, Object value) {
if (containsKey(key)) {
((List<Object>) get(key)).add(value);
} else {
List<Object> list = new ArrayList<Object>();
list.add(value);
super.put(key, list);
}
return value;
}
}
...

Map<Object, Object> map = new HashMapConvertList();