Skip to content

Instantly share code, notes, and snippets.

View steppat's full-sized avatar

Nico Steppat steppat

View GitHub Profile
package br.com.caelum.threads;
public class Banheiro {
private boolean sujo = true;
public void fazNumero1() {
String nomeAluno = Thread.currentThread().getName();
System.out.println(nomeAluno + " tentando entrar no banheiro");
jndi.properties
----------------
java.naming.factory.url.pkgs=org.jboss.ejb.client.naming
jboss-ejb-client.properties (Usuario deve ser criado antes através do add-user.sh)
----------------------------
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
package br.com.caelum.camel;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.model.dataformat.XmlJsonDataFormat;
public class TesteRoteamento {
<property name="hibernate.connection.provider_class" value="org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider"/>
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.max_size" value="20" />
<property name="hibernate.c3p0.timeout" value="180" />
<property name="hibernate.c3p0.idle_test_period" value="100" />
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
version="3.1">
<interceptors>
<interceptor>
<interceptor-class>br.com.caelum.financas.interceptor.LogInterceptor</interceptor-class>
</interceptor>
@steppat
steppat / activemq-composite
Last active August 29, 2015 14:11
exemplo composite queues com ActiveMQ
<!-- adicione abaixo do elemento broker -->
<destinationInterceptors>
<virtualDestinationInterceptor>
<virtualDestinations>
<compositeQueue name="COMP.PEDIDOS">
<forwardTo>
<filteredDestination selector="formato = 'ebook'" queue="COMP.GERADOR"/>
<queue physicalName="COMP.FINANCEIRO" />
<topic physicalName="COMP.NOTIFICACOES" />
</forwardTo>
Obs: http://tinyurl.com/oauth2-github
1) Acesse a sua conta no github e registre a aplicacao fj36-livraria, callback é:
http://localhost:8088/fj36-livraria/oauth/callback
------------------------------
2) Baixe o JAR:
http://central.maven.org/maven2/org/scribe/scribe/1.3.5/scribe-1.3.5.jar
@steppat
steppat / hornetq-stomp
Last active August 29, 2015 14:15
HornetQ com Stomp no Wildfly
1) https://github.com/leonardocordeiro/palestra-JMS-node
2) Precisa ter instalado o node.
3) No standalone-full.xml do Wildfly, no elemento <acceptors>:
<acceptor name="stomp-acceptor">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
<param key="protocol" value="STOMP"/>
<param key="port" value="61613"/>
</acceptor>
@steppat
steppat / soap-header.xslt
Last active August 29, 2015 14:16
Template para adicionar cabeçalho na mensgagem SOAP
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<!-- o template abaixo copia o XML inteiro -->
<!-- @* - seleciona todos os atributos -->
<!-- node() - seleciona todos os nodes -->
<xsl:template match="@*|node()">
<xsl:copy>
@steppat
steppat / Autorizador.java
Last active August 29, 2015 14:16
Simple Soap Handler
package br.com.caelum.estoque.ws.handler;
import java.util.Iterator;
import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.soap.Node;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;