sexta-feira, junho 25, 2004

Eclipse rc1 ... - LOMBOZ pré compilados

E alguns pré-compilados:

http://www.finalize.de/eclipse/lomboz-cvs-for-3.0-rc1.tgz
http://rainbow.mimuw.edu.pl/~po189428/lomboz-cvs-for-3.0-rc1.tgz
http://adam.kruszewski.name/static/lomboz-cvs-for-3.0-rc1.tgz

X11 (Xserver) + Java workarounds

Muito boas dicas para quem precisa utilizar implicitamente o X11 do linux ou qq outro ambiente como solaris por exemplo ... implicito diga-se de passagem usar um java.awt.Font por exemplo.
Fonte do artigo
Several workarounds are known:

1) X Virtual Frame Buffer (Xvfb)
2) Pure Java AWT (PJA)
3) Virtual Network Computing (VNC)

On WinNT and Win2K with JRE 1.3.1, logging onto the console instantiates the window system and the BufferedImage creation succeeds. You must be logged is as the same user that instantiates the servlet container. Installing VNC and running tomcat as a service allows normal operation even when logged out.

On Mac OS X 10.1.4, the OS creates an anonymous instance of the JRE. This fails if the machine enters "sleep" mode, but it works during normal screen-saver operation. I haven't tried VNC in this environemnt.

Under Solaris 2.7 with JRE 1.2.2, VNC allows correct operation as long as the same user starts both tomcat and VNC.

Under RedHat linux 7.1, JRE 1.3.1 and tomcat 4.0.3, vnc-server-3.3.3r2-28 allows correct operation as long as the same user starts both tomcat and VNC. Edit the file /etc/tomcat4/conf/tomcat4.conf to set the DISPLAY variable to the same virtual X session created in /etc/sysconfig/vncservers. You may need to start VNC before starting tomcat.

Under JRE 1.4, setting the "headless" property to true allows JFreeChart to render in the absence of an X11 instance. Ray Mercer reports success on RedHat Linux 7.1, 7.1j & 7.2. I have verified correct operation on Solaris 2.7.20:

System.setProperty("java.awt.headless","true");

For servlets, you can use set the property in the command line that invokes the servlet container:

java -Djava.awt.headless=true ...

In tomcat 4, the catalina.sh script can use an environment setting:

setenv CATALINA_OPTS -Djava.awt.headless=true

quinta-feira, junho 24, 2004

Job Sheduler - OpenSymphony - Quartz

OpenSymphony - Quartz - Documentation
Parece ter bastante features legais esse scheduler, vale a pena conferir!

Sample uses of job scheduling with Quartz:

- Driving Workflow: As a new order is initially placed, schedule a Job to fire in exactly 2 hours, that will check the status of that order, and trigger a warning notification if an order confirmation message has not yet been received for the order, as well as changing the order's status to 'awaiting intervention'.

- System Maintenance: Schedule a job to dump the contents of a database into an XML file every business day (all weekdays except holidays) at 11:30 PM.

segunda-feira, junho 21, 2004

webwork - Iteration Tags

http://wiki.opensymphony.com/display/WW/Iteration+Tags


Simples

<ww:iterator value="employees">
    <ww:property value="name"/> is the <ww:property value="jobTitle"/><br>
</ww:iterator>

Mais complexo

<webwork:iterator value="groupDao.groups" status="groupStatus">
    <tr class="<webwork:if test="#groupStatus.odd == true ">odd</webwork:if><webwork:else>even</webwork:else>">
        <td><webwork:property value="name" /></td>
        <td><webwork:property value="description" /></td>
        <td>
            <webwork:iterator value="users" status="userStatus">
                <webwork:property value="fullName" /><webwork:if test="!#userStatus.last">,</webwork:if>               
            </webwork:iterator>
        </td>
    </tr>
</webwork:iterator>

Um viajante ...

<ww:iterator value="countries">
    <ww:iterator value="cities">
        <ww:property value="name"/>, <ww:property value="[1].name"/><br>
    </ww:iterator>
</ww:iterator>

resultado será :

Wellington, New Zealand
Auckland, New Zealand
Moscow, Russia
Glasgow, Scotland
Edinburgh, Scotland
Stockholm, Sweden

webwork - Using WebWork2 and XWork1 with JSP 2.0 and JSTL 1.1

Confluence - Using WebWork2 and XWork1 with JSP 2.0 and JSTL 1.1
Outro exemplo interessante que não usa c:out mto legal ...

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
<title>Info about ${user.firstName}</title>
</head>
<body>
<h1>Info about ${user.firstName} ${user.lastName} [OS:ID=${user.id}]</h1>
<table border="1" cellspacing="0" cellpadding="2" width="90%" >
<tr>
<th>Name</th> <td>${user.firstName} ${user.lastName}</td>
</tr>
<tr>
<th>Created</th> <td><fmt:formatDate value="${user.date}" pattern="yyyy-MM-dd HH:mm"/></td>
</tr>
<tr>
<th>Email</th> <td>${user.email}</td>
</tr>
<tr>
<th>Address</th> <td>${user.street} ${user.zip} ${fn:toUpperCase(user.city)}</td>
</tr>
</table>
</body>
</html>

webwork - Iteration Tags

Confluence - Iteration Tags
Confluence - Iterator tag examples
--
Integaringo e obtendo status da lista

<ww:bean name="com.opensymphony.webwork.example.IteratorExample" id="it">
<ww:param name="day" value="'foo'"/>
<ww:param name="day" value="'bar'"/>
</ww:bean>

<table border="0" cellspacing="0" cellpadding="1">
<tr>
<th>Days of the week</th>
</tr>

<ww:iterator value="#it.days" status="rowstatus">
<tr>
<ww:if test="#rowstatus.odd == true">
<td style="background: grey"><ww:property/></td>
</ww:if>
<ww:else>
<td><ww:property/></td>
</ww:else>
</tr>
</ww:iterator>
</table>
--
Interagindo numa lista de objetos
<ww:iterator value="employees"> <ww:property value="name"/> is the <ww:property value="jobTitle"/><br> </ww:iterator>

--

<ww:iterator value="countries"> <ww:iterator value="cities"> <ww:property value="name"/>, <ww:property value="[1].name"/><br> </ww:iterator> </ww:iterator>

Resultado será algo como:

Wellington, New Zealand
Auckland, New Zealand
Moscow, Russia
Glasgow, Scotland
Edinburgh, Scotland
Stockholm, Sweden

TheServerSide.com - Review of Covert Java

TheServerSide.com - Review of Covert Java
Parece mto bom trata de tecnicar pra decompilação e engenharia reversa...

Iniciar o tomcat em modo de debug

Para iniciar o tomcat em modo de debug, apenas criei um arquivo no diretório bin do tomcat chamado debug.bat com o seguinte conteudo:
--
@echo off
SET CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compiler=NONE -Duser.language="en_US" -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000

call startup.bat
--
Vale resaltar que o modo de debug faz com que a jvm ouve em uma porta (no caso 8000) e vc com sua ide se conecta nessa porta e "avisa" a jvm que se encontrar algo aonde esteja sei break point ele manda a requisição pra ide

domingo, junho 20, 2004

terça-feira, junho 15, 2004

Shell para iniciar um app java


Abaixo um pequeno shell para init.d / rc3.d / rc5.d para iniciar um programa em java, inclui start/stop
###############################################
#!/bin/sh
######## OPTIONALLY MODIFY THE VALUES OF THESE VARIABLES #########

#YOURPROGRAMHOME=//YourHome; export YOURPROGRAMHOME
#JAVA_HOME=/; export JAVA_HOME
#LD_LIBRARY_PATH=$YOURPROGRAMHOME/lib:$YOURPROGRAMHOME/bin; export LD_LIBRARY_PATH
#LIBPATH=$YOURPROGRAMHOME/lib:$YOURPROGRAMHOME/bin:/usr/lib:/lib; export LIBPATH
#CLASSPATH=$YOURPROGRAMHOME:.; export CLASSPATH
#MAINCLASS=java.util.String; export MAINCLASS
#PARAMS=; export PARAMS
#LOGFILE=app_log.log; export LOGFILE
#THISFILENAME=start.java; export THISFILENAME
###################################################################


killproc() { # kill the named process(es)

# get the script file pid from the "ps -ef" line, if there is one.
script_pid=`ps -ef | grep "$1" | grep -v grep | awk '{print $2}'`

if [ "$script_pid" != "" ]
then

# Get the child pid (if any); it's the associated java process
child_pid=`ps -ef | grep " $script_pid " | grep -v grep | grep -v "$1" | awk '{print $2}'`

# Kill the child process, if any, and the script process
# Note; must do child first or else it's "parent" may change
if [ "$child_pid" != "" ]
then
echo Stopping pid $child_pid
kill $child_pid 2> /dev/null
fi
echo Stopping pid $script_pid
kill $script_pid 2> /dev/null
fi
}


#
# Make sure this is not being run as root.
#
tmp_account=`id | cut -f2 -d\( | cut -f1 -d\)`

if [ "$tmp_account" = "root" ]
then
echo "* ERROR: This script should not be run as root."
exit 1
fi

#
# Make sure the needed environment variables are set.
#
if [ "$YOURPROGRAMHOME" = "" ]
then
echo ""
echo "** YOURPROGRAMHOME must be defined"
exit 1
elif [ "$JAVA_HOME" = "" ]
then
echo ""
echo "** JAVA_HOME must be defined"
exit 1
fi

#
# Determine platform.
#
PLATFORM=`uname -a | cut -f1 -d" "`; export PLATFORM

#
# Start your program
#


case "$1" in
'start')
echo "Starting the Application ..."
if [ "$PLATFORM" = "AIX" ]
then
java_options="-Djava.compiler=NONE"
else
java_options=""
fi
$JAVA_HOME/bin/java $java_options -Xms128m -Xmx128m -cp $CLASSPATH $MAINCLASS $PARAMS > $LOGFILE 2>&1
;;

#
# When the system is shutting down, stop the App
#

'stop')
echo "Stopping the Application ..."
killproc "$THISFILENAME start" 2> /dev/null
;;
*)
echo "Usage: $0 { start | stop }"
exit 1
;;
esac
exit 0
###############################################