Skip to content

Instantly share code, notes, and snippets.

View jyeary's full-sized avatar
🐝
in the hive mind

John Yeary jyeary

🐝
in the hive mind
View GitHub Profile
/*
* Copyright 2013-2017 John Yeary <jyeary@bluelotussoftware.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
package com.bluelotussoftware.io;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
/**
*
package com.bluelotussoftware.example.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
@PersistenceUnit(unitName="SamplePersistenceWebPU")
EntityManagerFactory emf;
public Customer[] getCustomers() {
EntityManager em = emf.createEntityManager();
Query q = em.createQuery("SELECT c FROM Customer c");
List list = q.getResultList();
return list.toArray(new Customer[list.size()]);
}
package com.bluelotussoftware;
import com.sun.faces.application.view.ViewScopeManager;
import java.util.Collections;
import java.util.Map;
import javax.faces.component.TransientStateHelper;
import javax.faces.component.UIViewRoot;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
package com.bluelotussoftware.example.filter;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:w="http://www.sun.com/webui/webuijsf">
<body>
<ui:composition template="/template-client.xhtml">
<ui:define name="title">
package com.bluelotussoftware.commons.io;
import java.io.File;
import java.util.Date;
import org.apache.commons.io.monitor.FileAlterationListener;
import org.apache.commons.io.monitor.FileAlterationObserver;
/**
*
* @author John Yeary
package com.bluelotussoftware.example.richfaces;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URLDecoder;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
//Substitute your target web application below.
ServletContext sc = request.getServletContext().getContext("/EnterpriseApplication1-war"); 
//An example of what you can see to prove a point
Map<String, ? extends ServletRegistration> map = sc.getServletRegistrations(); 
for (String key : map.keySet()) {    
sc.log("Registration " + map.get(key).getName());      
Map<String, String> params = sc.getServletRegistration(map.get(key).getName()).getInitParameters();    
for (String k : params.keySet()) {        
sc.log("\t" + k + " --> " + params.get(k));
}