Skip to content

Instantly share code, notes, and snippets.

Avatar

David Blevins dblevins

View GitHub Profile
View gist:127606
import java.io.IOException;
import java.io.InputStream;
import java.io.ByteArrayOutputStream;
import java.net.URL;
/**
* @version $Revision$ $Date$
*/
public class Utils {
View persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="scrumtoysPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>jsf2.demo.scrum.model.entities.Project</class>
<class>jsf2.demo.scrum.model.entities.Sprint</class>
<class>jsf2.demo.scrum.model.entities.Story</class>
<class>jsf2.demo.scrum.model.entities.Task</class>
View persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="scrumtoysPU" transaction-type="JTA">
<class>jsf2.demo.scrum.model.entities.Project</class>
<class>jsf2.demo.scrum.model.entities.Sprint</class>
<class>jsf2.demo.scrum.model.entities.Story</class>
<class>jsf2.demo.scrum.model.entities.Task</class>
<properties>
View gist:134229
Properties p = new Properties();
p.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "http://127.0.0.1:8080/openejb/ejb");
// user and pass optional
p.put("java.naming.security.principal", "myuser");
p.put("java.naming.security.credentials", "mypass");
InitialContext ctx = new InitialContext(p);
View gist:141846
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
View gist:142433
Index: container/openejb-core/src/main/java/org/apache/openejb/core/CoreContainerSystem.java
===================================================================
--- container/openejb-core/src/main/java/org/apache/openejb/core/CoreContainerSystem.java (revision 785410)
+++ container/openejb-core/src/main/java/org/apache/openejb/core/CoreContainerSystem.java (working copy)
@@ -21,6 +21,7 @@
import org.apache.openejb.core.ivm.naming.IvmContext;
import org.apache.openejb.loader.SystemInstance;
+import javax.naming.Context;
import java.util.Map;
View gist:143371
ConfigurationFactory config = new ConfigurationFactory();
Assembler assembler = new Assembler();
SystemInstance.get().setProperty("openejb.strict.interface.declaration", "true");
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(OrangeBean.class));
View which.pl
#!/usr/bin/env perl
sub which {
my $cmd = shift;
if (eval "require File::Which; 1") {
return File::Which::which($cmd);
} else {
return `which $cmd`;
}
View preview.cgi
#!/usr/bin/env perl
use strict;
use warnings;
use LWP;
my $user = 'test';
my $site = 'http://blogs.apache.org';
open(C, "< .$user") or die "Unable to open handle to .$user: $!\n";