JMS CON GLASSFISH

Posted: lunes, 29 de noviembre de 2010 by Skuarch in Etiquetas: , , , , , ,
0



Requerimientos
Para poder realizar este ejemplo se nececita de las siguientes apis dentro de tu classpath

appserv-rt.jar
appserv-admin.jar
appserv-deployment-client.jar
appserv-ext.jar
javaee.jar
j2ee.jar (glassfish 3)
imqjmsra.jar

Como ide se uso netbeans

Estas apis las puedes encontrar en la carpeta lib de glassfish, por ejemplo /opt/glassfish/lib y tambien nececitamos el servidor de applicaciones Glassfish 3

Java Message Service, es un sistema de mensajes que consite en dejar un mensaje en el servidor para ser consumido por un cliente (o consumidor), el mensaje puede ser consimido instantaneamente o a la hora que sea. La comunicacion que se realiza es asincrona. La siguiente images ilustra un servicio de mensajes para un chat.



En la imagen se puede apreciar (en una vision general) que el mensaje esta en el servidor y varios clientes/consumidores consultan ese mensaje, el mensaje permanece en el servidor el tiempo necesario, esto se puede configurar, por ejemplo el tiempo de vida del mensaje y la cantidad de clientes/consumidores que lo pueden consultar.

Las colas, los mensajes son guardados en colas. Una cola de mensajes es un lugar común donde algunas aplicaciones publican mensajes, que son consumidos por otras. Existen así 4 componentes principales en un sistema de mensajería:

publicador, es decir, quien publica un Mensaje en una Cola
consumidor, quien consume Mensajes de una Cola
mensaje, que tiene algún formato que tanto publicador como consumidor conocen.
cola, que es el lugar donde publicadores y consumidores se conectan y comunican a través de mensajes.
Es importante destacar que es un sistema asíncrono: el publicador y el consumidor no necesitan estar disponibles a la vez, ya que la cola actúa de intermediario, guardando y distribuyendo los mensajes a medida que el consumidor pueda atenderlos. [esta parte fue extraida de Dos ideas JMS]

Tipo Queue (publicadores y consumidores)

Este tipo de cola sigue la filosofia de el primero que entra es el primero en salir, y los mensajes se van guardando si nadie los consume.Queue es del tipo punto a punto.



Tipo Topic (publicador/subscritor)

Este tipo de cola, es muy similar a la subscripcion a una revista, los consumidores (suscritos a la cola) reciben los mensajes del servidor, y cuando se desconectan se pierden los mensajes.



Tipos de mensajes no solo se pueden mandar mensajes de texto TextMessage si no que tambien se pueden mandar MapMessage que son del tipo clave=valor, tambien existen los ObjectMessage para poder enviar objectos a la cola.

Ejemplo usando Queue

Para este ejemplo se utilizo Glassfish 3, y lo primero que vamos a hacer es crear un recurso JMS, accedemos a nuestro glassfish y en la parte de de Resources >> JMS Resources como se muestra en la imagen



connection factory permite a una aplicacion crear objectos JMS programadamente, seleccionamos esa opcion como se muestra en la imagen anterior. Damos click en el boton de new y ponemos los datos que muestra la imagen



Lo que se realizo fue ponerle un nombre al pool (factoryUno) y el typo (javax.jms.QueueConnectionFactory), los demas parametros se dejaron como estaban y presionar el boton de ok.

Para poder acceder a este recurso es necesario ponerle un nombre. Tenemos que crear el Destination Resource poniendole un nombre JNDI, el destino fisico y el tipo.



Damos click en el botn new y colocamos los parametros como muestra la imagen.



Los parametros configurados son: jndi name = jndi/factoryUno, Physical Destination Name = jndi/factoryUno, Resource Type = javax.jms.Queue y damos en el boton ok.

Clase PublicadorQueue

ALTERNATIVAS A JPCAP

Posted: domingo, 3 de octubre de 2010 by Skuarch in Etiquetas: , , ,
0



Como ya lo saben jpcap es una api para poder capturar los datos que pasan sobre las interfaces de red, pues aqui les muestro algunas alternativas:

jnetpcap http://jnetpcap.com/
JNetDev http://netdev.it.rit.edu/
JNetStream http://jnetstream.com/
jpckt32 http://sourceforge.net/projects/jpckt32/

PROCESOS EN PARALELO EN UBUNTU

Posted: martes, 6 de julio de 2010 by Skuarch in Etiquetas: ,
2



Si tienes una computadora con mas de un nucleo esto te puede servir para inicial aplicaciones en paralelo.

sudo update-bootsystem-insserv && sudo sed -i 's/CONCURRENCY=none/CONCURRENCY=startpar/g' etc/init.d/rc && sudo sh -c "echo 'CONCURRENCY=startpar' >> /etc/default/rcS"


espero que te sirva!!!!

CAMBIAR EL COLOR DE TR CON JQUERY

Posted: lunes, 28 de junio de 2010 by Skuarch in Etiquetas: , , , , ,
0



Para no utlizar funciones de javascript y cada vez que se quiera cambiar el color de un tr de una tabla se puede utilizar esto.


$(document).ready(function() {
$(function() {
$('.actionRow').hover(function() {
$(this).css('background-color', '#FFFF99');
},
function() {
$(this).css('background-color', '#FFFFFF');
});
});
});


obviamente agregas jquery a la pagina

LEER ARCHIVOS DE UNA CARPETA CON JAVA

Posted: viernes, 4 de junio de 2010 by Skuarch in Etiquetas: , ,
0



Lectura de archivos de una carpeta


import java.io.File;
import java.io.FilenameFilter;

public class FileFilterTest {

public static void main(String[] args) {

FilenameFilter filter=new FilenameFilter(){
public boolean accept(File dir, String fileName) {
return fileName.endsWith("java");
}
};

File f=new File("D:/Programs/Code");
String [] fileList=f.list(filter);
for (int i=0; i < fileList.length; i++){
System.out.println(fileList[i]);
}
}

}

COMPENDIO DE APIS

Posted: jueves, 3 de junio de 2010 by Skuarch in Etiquetas: , , , ,
0

El objetivo de este post es juntar todas las apis, bibliotecas, frameworks, plug ins y herramientas para que las podamos consultar en un futuro, espero que me puedan ayudar para que la lista crezca. GRACIAS !!

Loggers


log4j http://logging.apache.org/log4j/1.2/ [libreria]
SLF4J http://www.slf4j.org/ [libreria]
commons-logging http://commons.apache.org/logging/ [libreria]
logback http://logback.qos.ch/ [libreria]
Craftsman Spy http://zer0.free.fr/craftsman/spy.php [libreria] logger para jdbc
Houston http://ajax.sourceforge.net/houston/ [libreria]
jLo http://jlo.jzonic.org/ [framework]
jMyra http://www.jmyra.com/ [libreria]
JTraceDump http://jtracedump.sourceforge.net/ [libreria] provides a facility to keep a history of application processing steps in memory and dump it in case of an error. It is not a replacement, but an addition to trace- or debug-loggin
just4log http://just4log.sourceforge.net/ [libreria] Just4Log is a library to enhance dynamically the performance of various logging systems inside a java application
Limpid Log http://www.acelet.com/limpidlog/index.html [libreria] you can register a class of interest and the system will log all important information about the class
Logging Toolkit for Java http://www.alphaworks.ibm.com/tech/loggingtoolkit4j [libreria]
monolog http://monolog.ow2.org/ [libreria]
ObjectGuy http://www.theobjectguy.com/javalog/ [framework]
protomatter http://protomatter.sourceforge.net/ [libreria] includes a logging library that supports logging to the standard syslog UNIX daemon
simple-log https://simple-log.dev.java.net/ [libreria] is a small and simple logging library and requires you to do almost nothing (other than actually logging) to get log output happening.

Chat


jml http://sourceforge.net/apps/trac/java-jml [libreria]
jymsg http://sourceforge.net/apps/trac/java-jml [libreria]

Graficas


jfreeChart http://www.jfree.org/jfreechart/ [libreria]
ChartDirector http://www.advsofteng.com/ [libreria]
jChart http://jcharts.sourceforge.net/ http://www.jchart.com/ [libreria]

XML


jDom http://www.jdom.org/ [libreria]
Sax http://www.saxproject.org/ [libreria]
Castor http://www.castor.org/ [framework]
XMLBeans http://xmlbeans.apache.org/ [libreria]
XStream http://xstream.codehaus.org/ [libreria]
xerces http://xerces.apache.org/xerces-j/ [libreria]
xPath http://www.ibm.com/developerworks/library/x-javaxpathapi.html [libreria]

Redes


RockSaw http://www.savarese.org/software/rocksaw/ [libreria]
commons net http://commons.apache.org/net/ [libreria]
jsch http://www.jcraft.com/jsch/ [libreria]
jpcap http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/ [libreria]
jrtp https://jrtp.dev.java.net/ [libreria]
jperf http://sourceforge.net/projects/jperf/ [libreria]
JCIFS http://jcifs.samba.org/ [libreria]
j8583 http://j8583.sourceforge.net/ [libreria]
mina http://mina.apache.org/ [libreria]

Testing


jUnit http://www.junit.org/ [libreria]
jUnitEE http://www.junitee.org/ [libreria]
testNG http://testng.org/doc/index.html [framework]
jMeter http://projects.apache.org/projects/jakarta_jmeter.html [libreria]

Herramientas


find bugs http://findbugs.sourceforge.net/ [herramienta]
PMD http://pmd.sourceforge.net/ [libreria]
EasyPMD http://gianlucacosta.altervista.org/software/easypmd2/index.php [pluging netbeans]
hudson http://hudson-ci.org/ [herramienta]
Subclipse http://subclipse.tigris.org/ [plug ing para eclipse]
SVN http://subversion.tigris.org/ [herramienta] para el control de versiones
TraceTool http://tracetool.sourceforge.net/ [herramienta] is a logging library and viewer application for different programming environments, including Java.
Drools http://www.jboss.org/drools [herramienta]

WEB


struts http://struts.apache.org/ [framework]
Cobra http://lobobrowser.org/cobra.jsp [libreria]
Play http://www.playframework.org/ [framework]
Spring http://www.springsource.org/ [framework]
Tapestry http://tapestry.apache.org/ [framework]
WebWork http://www.opensymphony.com/webwork/ [framework]
JMesa http://code.google.com/p/jmesa/ [libreria]
Display tag http://www.displaytag.org/1.2/ [libreria]
facelets http://java.net/projects/facelets/ [framework]
myFaces http://projects.apache.org/projects/myfaces.html [framework]
Apache Wicket http://projects.apache.org/projects/wicket.html [framework]
Google web Toolkit http://code.google.com/intl/es-ES/webtoolkit/ [framework]
Smart Gwt http://code.google.com/p/smartgwt/ [framework]
Ext Gwt http://www.sencha.com/products/gwt/ [framework]
JBoss Seam http://seamframework.org/ [framework]
Vaadin http://vaadin.com/home [framework]
Wicket http://wicket.apache.org/ [framework]
icefaces http://www.icefaces.org/main/home/ [framework]
richfaces http://www.jboss.org/richfaces [framework]
primeFaces http://www.primefaces.org/ [framework]
Cocoon http://cocoon.apache.org/ [framework]
Turbine http://java-source.net/open-source/web-frameworks [framework]
Makumba http://www.makumba.org/ [framework]
Stripes http://www.stripesframework.org/display/stripes/Home [framework]
JPublish http://www.josso.org/confluence/display/JOSSO1/JOSSO [framework]
Streak http://strecks.sourceforge.net/ [framework-extension]
AribaWeb http://aribaweb.org/ [framework]
Avil http://njet.org/ [framework]
WebOnSwing http://webonswing.sourceforge.net/xoops.htm [framework]
ThinWire http://www.thinwire.com/ [framework]
Pustefix http://pustefix-framework.org/ [framework]
Vroom http://sourceforge.net/projects/vroom/ [framework]
Induction http://www.inductionframework.org/ [framework]
Chrysalis http://chrysalis.sourceforge.net/ [framework]
Jzeno http://jzeno.org/joomla/ [framework]
Sombrero http://www.sombrerosoft.de/ [framework]
JVx http://www.sibvisions.com/jvx [framework]
Maverick http://mav.sourceforge.net/ [framework]
Sofia http://www.salmonllc.com/sofia [framework]
jaffa http://jaffa.sourceforge.net/ [framework]

Web Services


Axis2 http://projects.apache.org/projects/axis2.html [libreria]
xFire http://xfire.codehaus.org/ [framework]

Criptografia


not-yet-commons-ssl http://juliusdavies.ca/commons-ssl/ [libreria]
BouncyCastle http://www.bouncycastle.org/java.html [libreria]
OpenSSL http://sourceforge.net/projects/openssl-java/ [libreria]

Object-Relational Mapping


hibernate http://www.hibernate.org/ [framework]
OpenJPA http://openjpa.apache.org/ [framework]
JDO http://db.apache.org/jdo/index.html [framework]
eclipselink http://www.eclipse.org/eclipselink/ [framework]
iBatis http://ibatis.apache.org/ [framework]
myBatis http://code.google.com/p/mybatis/ [framework]
Siena http://www.sienaproject.com/index.html [libreria]
Cayenne http://cayenne.apache.org/ [libreria]

JDBC


Connector/J http://www.mysql.com/downloads/connector/j/ [libreria]
sqljdbc http://msdn.microsoft.com/es-es/library/ms378749(v=SQL.90).aspx [libreria]
jtds http://jtds.sourceforge.net/ [libreria]

Pool de conexiones


commons-dbcp http://commons.apache.org/dbcp/ [libreria]
boneCP http://jolbox.com/ [libreria]
c3p0 http://sourceforge.net/projects/c3p0/ [libreria]

Otros


jAlarms http://sourceforge.net/projects/jalarms/ [libreria]
java.util http://www.ifs.tuwien.ac.at/ifs/lehre/eprog/javadoc/jdk/docs/api/java/util/package-summary.html [paquete]
JBPM http://www.jboss.org/jbpm [herramienta]
spy memcached client http://code.google.com/p/spymemcached/ [herramienta]
eric's console http://cs.roosevelt.edu/eric/console.html [libreria]
apache tika http://projects.apache.org/projects/tika.html [libreria]
JYaml http://jyaml.sourceforge.net/ [libreria] serializacion
JRebel http://www.zeroturnaround.com/jrebel/ [libreria] is a plugin for the Java Virtual Machine that enables on-the-fly reloading of changes made to Java class files
JCS http://jakarta.apache.org/jcs/ [libreria] JCS is a distributed caching system written in java. It is intended to speed up applications by providing a means to manage cached data of various dynamic natures.
archiva http://archiva.apache.org/ [libreria]
velocity http://velocity.apache.org/engine/index.html [libreria]
EJB http://download.oracle.com/javaee/6/tutorial/doc/ [framework]
openEJB http://velocity.apache.org/engine/index.html [framework]
apache lucene http://lucene.apache.org/java/docs/index.html [herramienta]

Informes y Documentos de Oficina


JasperReport http://jasperforge.org/projects/jasperreports [libreria]
iReport http://jasperforge.org/projects/ireport [libreria]
POI http://poi.apache.org/ [libreria]
iText http://itextpdf.com/ [libreria]
Pentaho reports http://reporting.pentaho.com/ [libreria]
apache PDFBox http://pdfbox.apache.org/ [libreria]

Compilación


Maven http://maven.apache.org/ [framework]
Ant http://ant.apache.org/ [libreria]
Gradle http://gradle.org/index.php [libreria]
Ivy http://ant.apache.org/ivy/index.html [libreria]

Interoperabilidad


Thrift http://thrift.apache.org/ [framework]

Administracion de Contenidos


Alfresco http://wiki.alfresco.com/wiki/Main_Page [herramienta]
Lenya http://projects.apache.org/projects/lenya.html [herramienta]
KENAI http://kenai.com/ [herramienta]
Riot http://www.riotfamily.org/index.html [herramienta]
Magnolia http://www.magnolia-cms.com [herramienta]

Interfaz Grafica de Usuario


Swing Application Framework https://appframework.dev.java.net/ [framework]
java Foundation Classes http://java.sun.com/products/jfc/download.html [libreria]
Better Swing Application Framework http://kenai.com/projects/bsaf/pages/Home [framework]
GUTS - Guice Utilities & Tools Set http://kenai.com/projects/guts/pages/Home [libreria]

Extenciones de la plataforma


Jython http://www.jython.org/ [lenguaje]
Scala http://www.scala-lang.org/ [lenguaje]
Groovy http://groovy.codehaus.org/ [lenguaje]
AspectJ http://www.eclipse.org/aspectj/ [lenguaje]
Clojure http://clojure.org/ [lenguaje]
ColdFusion http://www.adobe.com/products/coldfusion/ [lenguaje]
Gosu http://gosu-lang.org/ [lenguaje]
JRuby http://jruby.org/ [lenguaje]
Rhino http://www.mozilla.org/rhino/ [lenguaje]

UBUNTU BOTONES DE LADO DERECHO

Posted: miércoles, 2 de junio de 2010 by Skuarch in
0



Para poner los botones del lado derecho en las ventanas, se escribe esto en una terminal


$ gconftool-2 --type string --set /apps/metacity/general/button_layout "menu:maximize,minimize,close"


para regrearlo a su estado normal, osea del lado izquierdo


$ gconftool-2 --type string --set /apps/metacity/general/button_layout "maximize,minimize,close:menu"

CARGAR LIBRERIAS DLL EN JAVA

Posted: jueves, 20 de mayo de 2010 by Skuarch in Etiquetas: , , , , ,
0



Para poder cargar dll's en java se puede tener varios caminos como puede ser

System.loadLibrary("d:\\directoryX\\subDirY\\MyDll.dll")

ó

System.load("d:\\directoryX\\subDirY\\MyDll.dll");


utilizando la clase Runtime
Runtime.getRuntime().load("d:/directoryX/subDirY/MyDll.dll");


especificando a la jvm
java -Djava.library.path=c:/temp JNIJavaHowTo



y la exception que se lanza es java.lang.UnsatisfiedLinkError

fuente
http://www.rgagnon.com/javadetails/java-0318.html

COMANDO PARA BAJAR LA GAMMA EN UBUNTU

Posted: martes, 18 de mayo de 2010 by Skuarch in
0



Asi de facil, con este comando puedes bajar la gamma del monitor

xgamma -gamma 0.75


donde 0.75 es el nivel de gamma que quieres cambiar

BARRA DE DIRECCIONES EN NAUTILUS

Posted: lunes, 17 de mayo de 2010 by Skuarch in Etiquetas: , ,
0



para poder mostrar la barra de direcciones en ubuntu 10.04 se abre una terminal si se coloca el siguiente codigo

gconftool-2 --type=Boolean --set /apps/nautilus/preferences/always_use_location_entry true


para regresarla a la normalidad

gconftool-2 --type=Boolean --set /apps/nautilus/preferences/always_use_location_entry false