[jboss-cvs] JBossAS SVN: r60125 - projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/util.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 30 16:55:14 EST 2007
Author: scott.stark at jboss.org
Date: 2007-01-30 16:55:14 -0500 (Tue, 30 Jan 2007)
New Revision: 60125
Added:
projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/util/ProxyUtils.java
Log:
AOP proxy utils.
Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/util/ProxyUtils.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/util/ProxyUtils.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/util/ProxyUtils.java 2007-01-30 21:55:14 UTC (rev 60125)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.aop.microcontainer.aspects.util;
+
+import org.jboss.aop.proxy.container.AOPProxyFactoryParameters;
+import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
+import org.jboss.logging.Logger;
+
+/**
+ * AOP proxy utils.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ProxyUtils
+{
+ private static Logger log = Logger.getLogger(ProxyUtils.class);
+
+ /**
+ * Create a proxy
+ *
+ * @param <T> the expected type
+ * @param target the target
+ * @param interfaceClass the interface class
+ * @return the proxy
+ */
+ public static <T> T createProxy(T target, Class<T> interfaceClass)
+ {
+ if (target == null)
+ return null;
+
+ GeneratedAOPProxyFactory proxyFactory = new GeneratedAOPProxyFactory();
+ AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+ params.setInterfaces(new Class[] { interfaceClass });
+ params.setObjectAsSuperClass(true);
+ params.setTarget(target);
+ Object proxy = proxyFactory.createAdvisedProxy(params);
+ if( log.isTraceEnabled() )
+ log.trace("Created proxy: "+proxy.getClass()+"@"+System.identityHashCode(proxy)+" target: "+target.getClass());
+ return interfaceClass.cast(proxy);
+ }
+
+}
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/util/ProxyUtils.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list