Skip to content

Instantly share code, notes, and snippets.

Brett C. bmchild

Block or report user

Report or block bmchild

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ToStringUtil.java
package com.mypackage;
import java.lang.reflect.Method;
import java.util.Enumeration;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
public class ToStringUtil {
View log4j.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<!-- Pattern to output the caller's file name and line number -->
<param name="ConversionPattern" value="%d{ISO8601} [%p] %m [(%M)%c]%n" />
</layout>
View cluster-config.xml
<Cluster channelSendOptions="8" className="org.apache.catalina.ha.tcp.SimpleTcpCluster">
<Manager className="org.apache.catalina.ha.session.DeltaManager" expireSessionsOnShutdown="false" domainReplication="true" notifyListenersOnReplication="true" />
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender" />
</Sender>
@bmchild
bmchild / applicationContext.xml
Created Nov 16, 2011
maven-war-plugin using environments
View applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
@bmchild
bmchild / context.xml
Created Nov 17, 2011
Context.xml example with Connecter J PLugin
View context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<!-- maxActive: Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to -1 for no limit.
-->
<!-- maxIdle: Maximum number of idle dB connections to retain in pool.
Set to -1 for no limit. See also the DBCP documentation on this
@bmchild
bmchild / CustomMethodSecurityExpressionHandler.java
Created Jan 19, 2012
Custom regex lookup access Expression with Spring Security 3.1. The lookup, hasRegexRole, is available on the JSP or on the method.
View CustomMethodSecurityExpressionHandler.java
package com.bmchild.security.access.expression;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.log4j.Logger;
import org.springframework.security.access.expression.SecurityExpressionRoot;
import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
import org.springframework.security.core.Authentication;
/**
* @author bchild
@bmchild
bmchild / springRepoTest.java
Created Mar 1, 2012
An example of using @configuration for testing spring repositories
View springRepoTest.java
package com.bmchild.repository;
/*imports
*.
*.
*.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader=AnnotationConfigContextLoader.class)
@bmchild
bmchild / CallingMyCollectionsUtil.java
Created Mar 16, 2012
Join a Collection on any POJO with a Data Extractor
View CallingMyCollectionsUtil.java
com.bmchild;
//imports
public class CallingMyCollectionsUtil {
private class Pojo {
private String field;
public String getField() {
@bmchild
bmchild / file.java
Created Apr 9, 2012
Get Entity Class from spring JpaRepository
View file.java
@SuppressWarnings("rawtypes")
public static Class<?> getEntity(JpaRepository repo) {
Type clazzes = getGenericType(repo.getClass())[0];
Type[] jpaClass = getGenericType(getClass(clazzes));
return getClass( ((ParameterizedType)jpaClass[0]).getActualTypeArguments()[0]);
}
public static Type[] getGenericType(Class<?> target) {
if (target == null)
return new Type[0];
View org.springframework.ide.eclipse.core.springbuilder.launch
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.springframework.ide.eclipse.core.springbuilder"/>
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>
You can’t perform that action at this time.