You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
(544) |
May
(1715) |
Jun
(1059) |
Jul
(886) |
Aug
(1214) |
Sep
(1375) |
Oct
(1664) |
Nov
(1153) |
Dec
(1084) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(1630) |
Feb
(1634) |
Mar
(1979) |
Apr
(1119) |
May
(1850) |
Jun
(1231) |
Jul
(1168) |
Aug
(1840) |
Sep
(1038) |
Oct
(1127) |
Nov
(1458) |
Dec
(854) |
2004 |
Jan
(1145) |
Feb
(1064) |
Mar
(2242) |
Apr
(1728) |
May
(1346) |
Jun
(1280) |
Jul
(1681) |
Aug
(2388) |
Sep
(2233) |
Oct
(3246) |
Nov
(3248) |
Dec
(1775) |
2005 |
Jan
(3407) |
Feb
(3049) |
Mar
(2402) |
Apr
(3687) |
May
(3289) |
Jun
(5731) |
Jul
(3905) |
Aug
(5843) |
Sep
(5149) |
Oct
(6866) |
Nov
(4051) |
Dec
(4646) |
2006 |
Jan
(7356) |
Feb
(4713) |
Mar
(9447) |
Apr
(6553) |
May
(6206) |
Jun
(4301) |
Jul
(1160) |
Aug
(23) |
Sep
(11) |
Oct
(19) |
Nov
(26) |
Dec
(15) |
2007 |
Jan
(28) |
Feb
(24) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Boleslaw D. <bd...@o2...> - 2006-07-07 12:24:07
|
User: bdaw Date: 06/07/07 08:23:49 Added: portlet/src/main/org/jboss/portal/portlet/impl/jsr168/metadata SecurityConstraintMetaData.java Log: - added parsing of "security-constraint" for portlet.xml - hopefully didn't break anything :) - some additional testing for this Revision Changes Path 1.1 date: 2006/07/07 12:23:49; author: bdaw; state: Exp;jboss-portal/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/metadata/SecurityConstraintMetaData.java Index: SecurityConstraintMetaData.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * 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.portal.portlet.impl.jsr168.metadata; import org.jboss.portal.server.util.TransportGuarantee; import java.util.Set; import java.util.HashSet; /** * @author <a href="mailto:bol...@jb...">Boleslaw Dawidowicz</a> * @version $Revision: 1.1 $ */ public class SecurityConstraintMetaData { private Set portlets = new HashSet(); private TransportGuarantee transportGuarantee; public Set getPortlets() { return portlets; } public void addPortlet(String name) { portlets.add(name); } public void setTransportGuarantee(TransportGuarantee guarantee) { transportGuarantee = guarantee; } public TransportGuarantee getTransportGuarantee() { return transportGuarantee; } } |
From: Boleslaw D. <bd...@o2...> - 2006-07-07 12:24:07
|
User: bdaw Date: 06/07/07 08:23:49 Modified: portlet/src/main/org/jboss/portal/portlet/deployment PortletApplicationMetaDataFactory.java Log: - added parsing of "security-constraint" for portlet.xml - hopefully didn't break anything :) - some additional testing for this Revision Changes Path 1.8 +376 -341 jboss-portal/portlet/src/main/org/jboss/portal/portlet/deployment/PortletApplicationMetaDataFactory.java (In the diff below, changes in quantity of whitespace are not shown.) Index: PortletApplicationMetaDataFactory.java =================================================================== RCS file: /cvsroot/jboss/jboss-portal/portlet/src/main/org/jboss/portal/portlet/deployment/PortletApplicationMetaDataFactory.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -b -r1.7 -r1.8 --- PortletApplicationMetaDataFactory.java 18 Jun 2006 03:25:10 -0000 1.7 +++ PortletApplicationMetaDataFactory.java 7 Jul 2006 12:23:49 -0000 1.8 @@ -36,17 +36,21 @@ import org.jboss.portal.portlet.impl.jsr168.metadata.LocalizedValueMetaData; import org.jboss.portal.portlet.impl.jsr168.metadata.DisplayNameMetaData; import org.jboss.portal.portlet.impl.jsr168.metadata.DescriptionMetaData; +import org.jboss.portal.portlet.impl.jsr168.metadata.TransportGuaranteesMetaData; +import org.jboss.portal.portlet.impl.jsr168.metadata.SecurityConstraintMetaData; import org.jboss.portal.common.util.LocaleInfo; import org.jboss.portal.common.util.Tools; import org.jboss.portal.Mode; +import org.jboss.portal.server.util.TransportGuarantee; import org.xml.sax.Attributes; import java.util.Locale; import java.util.List; +import java.util.Iterator; /** * @author <a href="mailto:ju...@jb...">Julien Viet</a> - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ public class PortletApplicationMetaDataFactory implements GenericObjectModelFactory { @@ -87,6 +91,10 @@ { return new UserAttributeMetaData(); } + else if ("security-constraint".equals(localName)) + { + return new SecurityConstraintMetaData(); + } } if (object instanceof PortletMetaData) { @@ -147,6 +155,21 @@ UserAttributeMetaData userAttribute = (UserAttributeMetaData)child; pa.getUserAttributes().put(userAttribute.getName(), userAttribute); } + else if (child instanceof SecurityConstraintMetaData) + { + SecurityConstraintMetaData security = (SecurityConstraintMetaData)child; + for (Iterator i = security.getPortlets().iterator(); i.hasNext();) + { + String portletName = (String)i.next(); + PortletMetaData portlet = pa.getPortlet(portletName); + if (portlet.getTransportGuarantees() == null) + { + portlet.setTransportGuarantees(new TransportGuaranteesMetaData()); + } + portlet.getTransportGuarantees().add(security.getTransportGuarantee()); + } + + } } if (parent instanceof PortletMetaData) { @@ -337,5 +360,17 @@ userAttribute.setName(value); } } + else if (object instanceof SecurityConstraintMetaData) + { + SecurityConstraintMetaData security = (SecurityConstraintMetaData)object; + if ("portlet-name".equals(localName)) + { + security.addPortlet(value); + } + if ("transport-guarantee".equals(localName)) + { + security.setTransportGuarantee(TransportGuarantee.decode(value)); + } + } } } |
From: Boleslaw D. <bd...@o2...> - 2006-07-07 12:24:07
|
User: bdaw Date: 06/07/07 08:23:50 Modified: portlet build.xml Log: - added parsing of "security-constraint" for portlet.xml - hopefully didn't break anything :) - some additional testing for this Revision Changes Path 1.124 +3 -2 jboss-portal/portlet/build.xml (In the diff below, changes in quantity of whitespace are not shown.) Index: build.xml =================================================================== RCS file: /cvsroot/jboss/jboss-portal/portlet/build.xml,v retrieving revision 1.123 retrieving revision 1.124 diff -u -b -r1.123 -r1.124 --- build.xml 2 Jul 2006 17:50:34 -0000 1.123 +++ build.xml 7 Jul 2006 12:23:50 -0000 1.124 @@ -8,7 +8,7 @@ <!ENTITY targets SYSTEM "../tools/etc/buildfragments/targets.ent"> ]> -<!-- $Id: build.xml,v 1.123 2006/07/02 17:50:34 julien Exp $ --> +<!-- $Id: build.xml,v 1.124 2006/07/07 12:23:50 bdaw Exp $ --> <!--+======================================================================+--> <!--| JBoss Portal (The OpenSource Portal) Build File |--> @@ -721,7 +721,7 @@ <sysproperty key="test.root" value="${build.lib}"/> <sysproperty key="test.uri" value="/test/redirect/"/> - <test name="org.jboss.portal.test.portlet.ha.session.SessionTestSuite"/> + <!--<test name="org.jboss.portal.test.portlet.ha.session.SessionTestSuite"/>--> <!--<test name="org.jboss.portal.test.portlet.info.InfoTestSuite"/>--> <!--<test name="org.jboss.portal.test.portlet.session.SessionSynchronizationTestCase"/>--> <!--<test name="org.jboss.portal.test.portlet.PortletRequestDecoderTestCase"/>--> @@ -731,6 +731,7 @@ <!--<test name="org.jboss.portal.test.portlet.jsr168.ext.dispatcher.DispatcherTestSuite"/>--> <!--<test name="org.jboss.portal.test.portlet.info.InfoTestSuite"/>--> + <test name="org.jboss.portal.test.portlet.deployment.UnmarshallerTestCase"/> <classpath> <path refid="oswego.concurrent.classpath"/> |
From: Boleslaw D. <bd...@o2...> - 2006-07-07 12:24:07
|
User: bdaw Date: 06/07/07 08:23:50 Modified: portlet/src/main/org/jboss/portal/test/portlet/info SecurityInfoTest.java Log: - added parsing of "security-constraint" for portlet.xml - hopefully didn't break anything :) - some additional testing for this Revision Changes Path 1.2 +7 -4 jboss-portal/portlet/src/main/org/jboss/portal/test/portlet/info/SecurityInfoTest.java (In the diff below, changes in quantity of whitespace are not shown.) Index: SecurityInfoTest.java =================================================================== RCS file: /cvsroot/jboss/jboss-portal/portlet/src/main/org/jboss/portal/test/portlet/info/SecurityInfoTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- SecurityInfoTest.java 7 Jul 2006 08:45:13 -0000 1.1 +++ SecurityInfoTest.java 7 Jul 2006 12:23:50 -0000 1.2 @@ -33,7 +33,7 @@ /** * @author <a href="mailto:bol...@jb...">Boleslaw Dawidowicz</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class SecurityInfoTest extends AbstractTest { @@ -65,25 +65,28 @@ SecurityInfo secInfo = info.getSecurity(); secInfo = info.getSecurity(); - assertEquals(1, secInfo.getTransportGuarantees().size()); + assertEquals(2, secInfo.getTransportGuarantees().size()); assertTrue(secInfo.containsTransportGuarantee(TransportGuarantee.CONFIDENTIAL)); //assertTrue(secInfo.containsTransportGuarantee(TransportGuarantee.INTEGRAL)); - //assertTrue(secInfo.containsTransportGuarantee(TransportGuarantee.NONE)); + assertTrue(secInfo.containsTransportGuarantee(TransportGuarantee.NONE)); container = (PortletContainer)registry.getPortletContainer("/test-info.SecuredPortlet2"); info = container.getInfo(); secInfo = info.getSecurity(); - assertEquals(1, secInfo.getTransportGuarantees().size()); + assertEquals(3, secInfo.getTransportGuarantees().size()); assertTrue(secInfo.containsTransportGuarantee(TransportGuarantee.INTEGRAL)); + assertTrue(secInfo.containsTransportGuarantee(TransportGuarantee.CONFIDENTIAL)); + assertTrue(secInfo.containsTransportGuarantee(TransportGuarantee.NONE)); container = (PortletContainer)registry.getPortletContainer("/test-info.SecuredPortlet3"); info = container.getInfo(); secInfo = info.getSecurity(); - assertEquals(1, secInfo.getTransportGuarantees().size()); + assertEquals(2, secInfo.getTransportGuarantees().size()); assertTrue(secInfo.containsTransportGuarantee(TransportGuarantee.INTEGRAL)); + assertTrue(secInfo.containsTransportGuarantee(TransportGuarantee.NONE)); |
From: Boleslaw D. <bd...@o2...> - 2006-07-07 12:24:07
|
User: bdaw Date: 06/07/07 08:23:50 Modified: portlet/src/main/org/jboss/portal/test/portlet/deployment UnmarshallerTestCase.java Log: - added parsing of "security-constraint" for portlet.xml - hopefully didn't break anything :) - some additional testing for this Revision Changes Path 1.9 +5 -1 jboss-portal/portlet/src/main/org/jboss/portal/test/portlet/deployment/UnmarshallerTestCase.java (In the diff below, changes in quantity of whitespace are not shown.) Index: UnmarshallerTestCase.java =================================================================== RCS file: /cvsroot/jboss/jboss-portal/portlet/src/main/org/jboss/portal/test/portlet/deployment/UnmarshallerTestCase.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -b -r1.8 -r1.9 --- UnmarshallerTestCase.java 29 May 2006 16:34:46 -0000 1.8 +++ UnmarshallerTestCase.java 7 Jul 2006 12:23:50 -0000 1.9 @@ -36,6 +36,7 @@ import org.jboss.portal.portlet.metadata.JBossApplicationMetaData; import org.jboss.portal.portlet.metadata.JBossPortletMetaData; import org.jboss.portal.portlet.metadata.PolicyPermissionMetaData; +import org.jboss.portal.server.util.TransportGuarantee; import org.jboss.xb.binding.Unmarshaller; import org.jboss.xb.binding.UnmarshallerFactory; @@ -44,7 +45,7 @@ /** * @author <a href="mailto:ju...@jb...">Julien Viet</a> - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ */ public class UnmarshallerTestCase extends TestCase { @@ -186,6 +187,9 @@ assertEquals("ROLE_NAME_WITH_LINK", ((SecurityRoleRefMetaData)portlet1.getSecurityRoleRefs().get(1)).getRoleName()); assertEquals("ROLE_LINK", ((SecurityRoleRefMetaData)portlet1.getSecurityRoleRefs().get(1)).getRoleLink()); + assertTrue(portlet1.getTransportGuarantees().contains(TransportGuarantee.CONFIDENTIAL)); + assertTrue(portlet1.getTransportGuarantees().contains(TransportGuarantee.INTEGRAL)); + // assertNotNull(app.getUserAttributes()); assertEquals(2, app.getUserAttributes().size()); |
From: Boleslaw D. <bd...@o2...> - 2006-07-07 12:24:07
|
User: bdaw Date: 06/07/07 08:23:50 Modified: portlet/src/resources/test/deployment portlet.xml Log: - added parsing of "security-constraint" for portlet.xml - hopefully didn't break anything :) - some additional testing for this Revision Changes Path 1.5 +18 -0 jboss-portal/portlet/src/resources/test/deployment/portlet.xml (In the diff below, changes in quantity of whitespace are not shown.) Index: portlet.xml =================================================================== RCS file: /cvsroot/jboss/jboss-portal/portlet/src/resources/test/deployment/portlet.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- portlet.xml 11 May 2006 19:23:44 -0000 1.4 +++ portlet.xml 7 Jul 2006 12:23:50 -0000 1.5 @@ -241,6 +241,24 @@ </portlet> --> + <security-constraint> + <portlet-collection> + <portlet-name>Portlet1</portlet-name> + </portlet-collection> + <user-data-constraint> + <transport-guarantee>CONFIDENTIAL</transport-guarantee> + </user-data-constraint> + </security-constraint> + <security-constraint> + <portlet-collection> + <portlet-name>Portlet1</portlet-name> + <portlet-name>Portlet4</portlet-name> + </portlet-collection> + <user-data-constraint> + <transport-guarantee>INTEGRAL</transport-guarantee> + </user-data-constraint> + </security-constraint> + <custom-portlet-mode> <description>first mode</description> <description xml:lang="fr">premier mode</description> |
From: Boleslaw D. <bd...@o2...> - 2006-07-07 12:24:07
|
User: bdaw Date: 06/07/07 08:23:50 Modified: portlet/src/resources/test/info/test-info-war/WEB-INF portlet.xml Log: - added parsing of "security-constraint" for portlet.xml - hopefully didn't break anything :) - some additional testing for this Revision Changes Path 1.5 +1 -0 jboss-portal/portlet/src/resources/test/info/test-info-war/WEB-INF/portlet.xml (In the diff below, changes in quantity of whitespace are not shown.) Index: portlet.xml =================================================================== RCS file: /cvsroot/jboss/jboss-portal/portlet/src/resources/test/info/test-info-war/WEB-INF/portlet.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- portlet.xml 7 Jul 2006 08:45:14 -0000 1.4 +++ portlet.xml 7 Jul 2006 12:23:50 -0000 1.5 @@ -234,6 +234,7 @@ <security-constraint> <portlet-collection> <portlet-name>SecuredPortlet1</portlet-name> + <portlet-name>SecuredPortlet2</portlet-name> </portlet-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> |
From: Tom B. <tom...@jb...> - 2006-07-07 12:04:44
|
User: tbaeyens Date: 06/07/07 08:04:41 Log: Directory /cvsroot/jboss/repository.jboss.com/eclipse/sdk/3.2 added to the repository |
From: Manik S. <msu...@jb...> - 2006-07-07 11:11:36
|
User: msurtani Date: 06/07/07 07:11:35 Modified: src/org/jboss/cache/interceptors Tag: Branch_JBossCache_1_3_0 TxInterceptor.java Log: Fixed JBCACHE-668 and JBCACHE-682 Revision Changes Path No revision No revision 1.35.2.5 +19 -6 JBossCache/src/org/jboss/cache/interceptors/TxInterceptor.java (In the diff below, changes in quantity of whitespace are not shown.) Index: TxInterceptor.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/TxInterceptor.java,v retrieving revision 1.35.2.4 retrieving revision 1.35.2.5 diff -u -b -r1.35.2.4 -r1.35.2.5 --- TxInterceptor.java 5 Jul 2006 17:01:18 -0000 1.35.2.4 +++ TxInterceptor.java 7 Jul 2006 11:11:35 -0000 1.35.2.5 @@ -658,9 +658,9 @@ { // set the hasMods flag in the invocation ctx. This should not be replicated, just used locally by the interceptors. getInvocationContext().setTxHasMods( modifications != null && modifications.size() > 0 ); + MethodCall commitMethod; try { - MethodCall commitMethod; if (onePhaseCommit) { // running a 1-phase commit. @@ -688,18 +688,31 @@ } catch (Throwable e) { - log.error("Commit failed. Issuing a commit on the local tx to clear stale locks.", e); + log.warn("Commit failed. Clearing stale locks."); try { - tx.commit(); + cleanupStaleLocks(gtx); } - catch (Exception e2) + catch (Throwable e2) { - log.error("Unable to re-run commit again to clear locks", e2); + log.error("Unable to clear locks", e2); throw new RuntimeException(e2); } - throw new RuntimeException("Commit failed, marking tx to be rolled back.", e); + throw new RuntimeException("Commit failed", e); + } } + + private void cleanupStaleLocks(GlobalTransaction gtx) throws Throwable + { + // try running a 'local' commit only, to clear locks. + MethodCall commitMethod = new MethodCall(TreeCache.commitMethod, new Object[]{gtx}); + // make sure this call does not replicate. + InvocationContext ic = getInvocationContext(); + Option o = ic.getOptionOverrides(); + o.setCacheModeLocal(true); + ic.setOptionOverrides(o); + setInvocationContext(ic); + handleCommitRollback(commitMethod); } /** |
From: Manik S. <msu...@jb...> - 2006-07-07 11:10:15
|
User: msurtani Date: 06/07/07 07:10:12 Modified: src/org/jboss/cache/interceptors Tag: Branch_JBossCache_1_4_0 TxInterceptor.java Log: Better fix for JBCACHE-668 and JBCACHE-682 Revision Changes Path No revision No revision 1.48.2.3 +20 -5 JBossCache/src/org/jboss/cache/interceptors/TxInterceptor.java (In the diff below, changes in quantity of whitespace are not shown.) Index: TxInterceptor.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/TxInterceptor.java,v retrieving revision 1.48.2.2 retrieving revision 1.48.2.3 diff -u -b -r1.48.2.2 -r1.48.2.3 --- TxInterceptor.java 6 Jul 2006 14:33:01 -0000 1.48.2.2 +++ TxInterceptor.java 7 Jul 2006 11:10:12 -0000 1.48.2.3 @@ -703,20 +703,35 @@ } catch (Throwable e) { - log.error("Commit failed. Issuing a commit on the local tx to clear stale locks.", e); + log.warn("Commit failed. Clearing stale locks."); try { - tx.commit(); + cleanupStaleLocks(gtx); } - catch (Exception e2) + catch (Throwable e2) { - log.error("Unable to re-run commit again to clear locks", e2); + log.error("Unable to clear stale locks", e2); throw new RuntimeException(e2); } - throw new RuntimeException("Commit failed, marking tx to be rolled back.", e); + throw new RuntimeException("Commit failed.", e); } } + + private void cleanupStaleLocks(GlobalTransaction gtx) throws Throwable + { + // try running a 'local' commit only, to clear locks. + MethodCall commitMethod = MethodCallFactory.create(MethodDeclarations.commitMethod, new Object[]{gtx}); + // make sure this call does not replicate. + InvocationContext ic = getInvocationContext(); + Option o = ic.getOptionOverrides(); + o.setCacheModeLocal(true); + ic.setOptionOverrides(o); + setInvocationContext(ic); + handleCommitRollback(commitMethod); + } + + /** * creates a rollback() MethodCall and feeds it to handleCommitRollback(); * @param gtx |
From: Ben W. <bw...@jb...> - 2006-07-07 10:38:48
|
User: bwang Date: 06/07/07 06:38:43 Modified: tests-50/functional/org/jboss/cache/pojo TxUndoTest.java Log: Renamed CacheInterceptor to CacheFieldInterceptor Revision Changes Path 1.3 +2 -2 JBossCache/tests-50/functional/org/jboss/cache/pojo/TxUndoTest.java (In the diff below, changes in quantity of whitespace are not shown.) Index: TxUndoTest.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/TxUndoTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- TxUndoTest.java 7 Jul 2006 10:26:47 -0000 1.2 +++ TxUndoTest.java 7 Jul 2006 10:38:43 -0000 1.3 @@ -13,7 +13,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.pojo.test.Person; -import org.jboss.cache.pojo.interceptors.dynamic.CacheInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.CacheFieldInterceptor; import org.jboss.cache.transaction.DummyTransactionManager; import org.jboss.aop.Advised; import org.jboss.aop.advice.Interceptor; @@ -74,7 +74,7 @@ Interceptor[] interceptors = ((Advised)pojo)._getInstanceAdvisor().getInterceptors(); for(int i=0; i < interceptors.length; i++) { - if(interceptors[i] instanceof CacheInterceptor) + if(interceptors[i] instanceof CacheFieldInterceptor) return true; } return false; |
From: Ben W. <bw...@jb...> - 2006-07-07 10:38:44
|
User: bwang Date: 06/07/07 06:38:34 Modified: tests-50/functional/org/jboss/cache/pojo/util MethodCallTest.java Log: Renamed CacheInterceptor to CacheFieldInterceptor Revision Changes Path 1.3 +2 -2 JBossCache/tests-50/functional/org/jboss/cache/pojo/util/MethodCallTest.java (In the diff below, changes in quantity of whitespace are not shown.) Index: MethodCallTest.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/util/MethodCallTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- MethodCallTest.java 7 Jul 2006 10:26:47 -0000 1.2 +++ MethodCallTest.java 7 Jul 2006 10:38:34 -0000 1.3 @@ -15,7 +15,7 @@ import org.jboss.aop.InstanceAdvisor; import org.jboss.aop.ClassInstanceAdvisor; import org.jboss.aop.advice.Interceptor; -import org.jboss.cache.pojo.interceptors.dynamic.CacheInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.CacheFieldInterceptor; import org.jboss.cache.pojo.MethodDeclarations; import org.jboss.cache.pojo.PojoUtil; @@ -53,7 +53,7 @@ log_.info("testUtil() ...."); InstanceAdvisor advisor = new ClassInstanceAdvisor(); - Interceptor interceptor = new CacheInterceptor(); + Interceptor interceptor = new CacheFieldInterceptor(); Method method = MethodDeclarations.undoAttachInterceptor; |
From: Ben W. <bw...@jb...> - 2006-07-07 10:38:35
|
User: bwang Date: 06/07/07 06:38:29 Modified: tests-50/functional/org/jboss/cache/pojo/test Link.java NodeManager.java Person.java Student.java Log: Renamed CacheInterceptor to CacheFieldInterceptor Revision Changes Path 1.3 +2 -2 JBossCache/tests-50/functional/org/jboss/cache/pojo/test/Link.java (In the diff below, changes in quantity of whitespace are not shown.) Index: Link.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/test/Link.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- Link.java 27 Jun 2006 09:19:31 -0000 1.2 +++ Link.java 7 Jul 2006 10:38:28 -0000 1.3 @@ -9,9 +9,9 @@ /** * Test class for PojoCache for circular references. - * Link is a POJO that will be instrumentet with CacheInterceptor + * Link is a POJO that will be instrumentet with CacheFieldInterceptor * - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * <p>Below is the annotation that signifies this class is "prepared" under JBossAop. This is used in * conjunction with a special jboss-aop.xml (supplied by JBossCache). In addition, this is JDK1.4 style, * so a annoc Ant build target is needed to pre-compile it.</p> 1.3 +2 -2 JBossCache/tests-50/functional/org/jboss/cache/pojo/test/NodeManager.java (In the diff below, changes in quantity of whitespace are not shown.) Index: NodeManager.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/test/NodeManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- NodeManager.java 27 Jun 2006 09:19:31 -0000 1.2 +++ NodeManager.java 7 Jul 2006 10:38:28 -0000 1.3 @@ -13,9 +13,9 @@ /** * Test class for PojoCache for circular references. - * Link is a POJO that will be instrumentet with CacheInterceptor + * Link is a POJO that will be instrumentet with CacheFieldInterceptor * - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * <p>Below is the annotation that signifies this class is "prepared" under JBossAop. This is used in * conjunction with a special jboss-aop.xml (supplied by JBossCache). In addition, this is JDK1.4 style, * so a annoc Ant build target is needed to pre-compile it.</p> 1.3 +2 -2 JBossCache/tests-50/functional/org/jboss/cache/pojo/test/Person.java (In the diff below, changes in quantity of whitespace are not shown.) Index: Person.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/test/Person.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- Person.java 27 Jun 2006 09:19:31 -0000 1.2 +++ Person.java 7 Jul 2006 10:38:28 -0000 1.3 @@ -15,9 +15,9 @@ /** * Test class for PojoCache. - * Person is a POJO that will be instrumented with CacheInterceptor + * Person is a POJO that will be instrumented with CacheFieldInterceptor * - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * <p>Below is the annotation that signifies this class is "prepared" under JBossAop. This is used in * conjunction with a special jboss-aop.xml (supplied by PojoCache). In addition, this is JDK1.4 style, * so a annoc Ant build target is needed to pre-compile it.</p> 1.3 +2 -2 JBossCache/tests-50/functional/org/jboss/cache/pojo/test/Student.java (In the diff below, changes in quantity of whitespace are not shown.) Index: Student.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/test/Student.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- Student.java 27 Jun 2006 09:19:31 -0000 1.2 +++ Student.java 7 Jul 2006 10:38:28 -0000 1.3 @@ -9,9 +9,9 @@ /** * Test class for PojoCache. - * Student is a POJO that will be instrumentet with CacheInterceptor + * Student is a POJO that will be instrumentet with CacheFieldInterceptor * - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * No need to declare annotation here since Person is an instanceof already. */ public class Student extends Person |
From: Ben W. <bw...@jb...> - 2006-07-07 10:36:50
|
User: bwang Date: 06/07/07 06:36:44 Modified: src-50/org/jboss/cache/pojo AOPInstance.java ObjectGraphHandler.java TreeCacheAopDelegate.java Log: Renamed CacheInterceptor to CacheFieldInterceptor Revision Changes Path 1.3 +1 -1 JBossCache/src-50/org/jboss/cache/pojo/AOPInstance.java (In the diff below, changes in quantity of whitespace are not shown.) Index: AOPInstance.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/AOPInstance.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- AOPInstance.java 27 Jun 2006 05:25:43 -0000 1.2 +++ AOPInstance.java 7 Jul 2006 10:36:44 -0000 1.3 @@ -14,7 +14,7 @@ /** * Wrapper type for cached AOP instances. - * When an object is looked up or put in TreeCacheAOP, this object will be advised with a CacheInterceptor. + * When an object is looked up or put in TreeCacheAOP, this object will be advised with a CacheFieldInterceptor. * The tree cache stores a reference to this object (for example to update the instance variables, etc.). * Since this reference need to be transactional but never replicated (the reference is only valid within the VM) * this reference is wrapped into an AOPInstance. 1.6 +4 -4 JBossCache/src-50/org/jboss/cache/pojo/ObjectGraphHandler.java (In the diff below, changes in quantity of whitespace are not shown.) Index: ObjectGraphHandler.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/ObjectGraphHandler.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- ObjectGraphHandler.java 7 Jul 2006 10:26:07 -0000 1.5 +++ ObjectGraphHandler.java 7 Jul 2006 10:36:44 -0000 1.6 @@ -17,14 +17,14 @@ import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor; import org.jboss.cache.pojo.util.AopUtil; import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor; -import org.jboss.cache.pojo.interceptors.dynamic.CacheInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.CacheFieldInterceptor; /** * Handle the object graph management. * * @author Ben Wang * Date: Aug 4, 2005 - * @version $Id: ObjectGraphHandler.java,v 1.5 2006/07/07 10:26:07 bwang Exp $ + * @version $Id: ObjectGraphHandler.java,v 1.6 2006/07/07 10:36:44 bwang Exp $ */ class ObjectGraphHandler { @@ -48,7 +48,7 @@ if (refFqn != null) { // this is recursive. Need to obtain the object from parent fqn - // No need to add CacheInterceptor as a result. Everything is re-directed. + // No need to add CacheFieldInterceptor as a result. Everything is re-directed. // In addition, this op will not be recursive. if (log.isDebugEnabled()) { @@ -140,7 +140,7 @@ internal_.relocate(fqn, newFqn); // Reset the fqn in the cache interceptor InstanceAdvisor advisor = ((Advised) pojo)._getInstanceAdvisor(); - CacheInterceptor interceptor = (CacheInterceptor) AopUtil.findCacheInterceptor(advisor); + CacheFieldInterceptor interceptor = (CacheFieldInterceptor) AopUtil.findCacheInterceptor(advisor); if (interceptor == null) throw new IllegalStateException("ObjectGraphHandler.objectGraphRemove(): null interceptor"); interceptor.setFqn(newFqn); 1.8 +6 -6 JBossCache/src-50/org/jboss/cache/pojo/TreeCacheAopDelegate.java (In the diff below, changes in quantity of whitespace are not shown.) Index: TreeCacheAopDelegate.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/TreeCacheAopDelegate.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -b -r1.7 -r1.8 --- TreeCacheAopDelegate.java 7 Jul 2006 10:26:07 -0000 1.7 +++ TreeCacheAopDelegate.java 7 Jul 2006 10:36:44 -0000 1.8 @@ -20,7 +20,7 @@ import org.jboss.cache.pojo.memory.FieldPersistentReference; import org.jboss.cache.pojo.util.AopUtil; import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor; -import org.jboss.cache.pojo.interceptors.dynamic.CacheInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.CacheFieldInterceptor; import java.lang.reflect.Field; import java.util.Collection; @@ -132,7 +132,7 @@ } // Insert interceptor at runtime InstanceAdvisor advisor = ((Advised) obj)._getInstanceAdvisor(); - CacheInterceptor interceptor = new CacheInterceptor(cache_, fqn, type); + CacheFieldInterceptor interceptor = new CacheFieldInterceptor(cache_, fqn, type); interceptor.setAopInstance(aopInstance); util_.attachInterceptor(advisor, interceptor); } else @@ -185,7 +185,7 @@ cache_._removeObject(fqn, true); // remove old value before overwriting it. } - // Remember not to print obj here since it will trigger the CacheInterceptor. + // Remember not to print obj here since it will trigger the CacheFieldInterceptor. if (log.isDebugEnabled()) { log.debug("putObject(): fqn: " + fqn); @@ -417,7 +417,7 @@ // Always initialize the ref count so we can mark this as an AopNode. AOPInstance aopInstance = InternalDelegate.initializeAopInstance(); // Insert interceptor at runtime - CacheInterceptor interceptor = new CacheInterceptor(cache_, fqn, type); + CacheFieldInterceptor interceptor = new CacheFieldInterceptor(cache_, fqn, type); interceptor.setAopInstance(aopInstance); util_.attachInterceptor(advisor, interceptor); @@ -551,7 +551,7 @@ { if (bulkRemove(fqn, result)) { - // Remember not to print obj here since it will trigger the CacheInterceptor. + // Remember not to print obj here since it will trigger the CacheFieldInterceptor. if (log.isDebugEnabled()) { log.debug("_removeObject(): fqn: " + fqn + "removing exisiting object in bulk."); @@ -605,7 +605,7 @@ // Determine if we want to keep the interceptor for later use. if (removeCacheInterceptor) { - CacheInterceptor interceptor = (CacheInterceptor) AopUtil.findCacheInterceptor(advisor); + CacheFieldInterceptor interceptor = (CacheFieldInterceptor) AopUtil.findCacheInterceptor(advisor); // Remember to remove the interceptor from in-memory object but make sure it belongs to me first. if (interceptor != null) { |
From: Ben W. <bw...@jb...> - 2006-07-07 10:36:47
|
User: bwang Date: 06/07/07 06:36:39 Modified: src-50/org/jboss/cache/pojo/util AopUtil.java Log: Renamed CacheInterceptor to CacheFieldInterceptor Revision Changes Path 1.4 +4 -4 JBossCache/src-50/org/jboss/cache/pojo/util/AopUtil.java (In the diff below, changes in quantity of whitespace are not shown.) Index: AopUtil.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/util/AopUtil.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- AopUtil.java 7 Jul 2006 10:26:06 -0000 1.3 +++ AopUtil.java 7 Jul 2006 10:36:39 -0000 1.4 @@ -13,7 +13,7 @@ import org.jboss.aop.advice.Interceptor; import org.jboss.cache.Fqn; import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor; -import org.jboss.cache.pojo.interceptors.dynamic.CacheInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.CacheFieldInterceptor; import java.io.Serializable; @@ -40,9 +40,9 @@ for (int i = 0; i < interceptors.length; i++) { Interceptor interceptor = interceptors[i]; - if (interceptor instanceof CacheInterceptor) + if (interceptor instanceof CacheFieldInterceptor) { - CacheInterceptor inter = (CacheInterceptor) interceptor; + CacheFieldInterceptor inter = (CacheFieldInterceptor) interceptor; if (inter != null && inter.getFqn().equals(fqn)) { return interceptor; @@ -68,7 +68,7 @@ for (int i = 0; i < interceptors.length; i++) { Interceptor interceptor = interceptors[i]; - if (interceptor instanceof CacheInterceptor) + if (interceptor instanceof CacheFieldInterceptor) { return interceptor; } |
From: Ben W. <bw...@jb...> - 2006-07-07 10:36:40
|
User: bwang Date: 06/07/07 06:36:22 Added: src-50/org/jboss/cache/pojo/interceptors/dynamic CacheFieldInterceptor.java Removed: src-50/org/jboss/cache/pojo/interceptors/dynamic CacheInterceptor.java Log: Renamed CacheInterceptor to CacheFieldInterceptor Revision Changes Path 1.1 date: 2006/07/07 10:36:22; author: bwang; state: Exp;JBossCache/src-50/org/jboss/cache/pojo/interceptors/dynamic/CacheFieldInterceptor.java Index: CacheFieldInterceptor.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.cache.pojo.interceptors.dynamic; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.aop.Advised; import org.jboss.aop.Advisor; import org.jboss.aop.InstanceAdvisor; import org.jboss.aop.advice.Interceptor; import org.jboss.aop.joinpoint.FieldInvocation; import org.jboss.aop.joinpoint.FieldReadInvocation; import org.jboss.aop.joinpoint.FieldWriteInvocation; import org.jboss.aop.joinpoint.Invocation; import org.jboss.cache.Fqn; import org.jboss.cache.pojo.memory.FieldPersistentReference; import org.jboss.cache.pojo.util.AopUtil; import org.jboss.cache.pojo.PojoTreeCache; import org.jboss.cache.pojo.CachedType; import org.jboss.cache.pojo.AOPInstance; import org.jboss.cache.pojo.InternalDelegate; import java.lang.reflect.Field; import java.util.Iterator; /** * Main dynamic interceptor to intercept for field replication. * * @author Ben Wang */ public class CacheFieldInterceptor implements BaseInterceptor { private static final Log log_ = LogFactory.getLog(CacheFieldInterceptor.class); private PojoTreeCache cache; private CachedType type; private Fqn fqn; private String name; private AOPInstance aopInstance; public CacheFieldInterceptor(PojoTreeCache cache, Fqn fqn, CachedType type) { this.cache = cache; this.fqn = fqn; this.type = type; } public CacheFieldInterceptor() { } public AOPInstance getAopInstance() { return aopInstance; } public Object clone() { CacheFieldInterceptor interceptor = new CacheFieldInterceptor(); interceptor.setFqn(getFqn()); interceptor.setAopInstance(getAopInstance()); return interceptor; } public void setInterceptor(Interceptor intcptr) { CacheFieldInterceptor interceptor = (CacheFieldInterceptor)intcptr; setFqn(interceptor.getFqn()); setAopInstance(interceptor.getAopInstance()); } public void setAopInstance(AOPInstance aopInstance) { this.aopInstance = aopInstance; } public String getName() { if (name == null) { this.name = "CacheFieldInterceptor on [" + fqn + "]"; } return name; } public Object invoke(Invocation invocation) throws Throwable { // Check if CLASS_INTERNAL exists. If not, that means we are done. We need to remove ourself. // Note that if speed is important, we will need to perform the detach step pro-actively, // that is, use a listener to listen for the removeObject event. if (isPojoDetached(invocation)) { return invocation.invokeNext(); // invoke the in-memory pojo directly } if (invocation instanceof FieldWriteInvocation) { FieldInvocation fieldInvocation = (FieldInvocation) invocation; Advisor advisor = fieldInvocation.getAdvisor(); Field field = fieldInvocation.getField(); // Only if this field is replicatable. static, transient and final are not. CachedType fieldType = cache.getCachedType(field.getType()); CachedType parentType = cache.getCachedType(field.getDeclaringClass()); if (!isNonReplicatable(field, advisor, parentType)) { Object value = ((FieldWriteInvocation) fieldInvocation).getValue(); if (fieldType.isImmediate() || hasSerializableAnnotation(field, advisor, parentType)) { cache.put(fqn, field.getName(), value); } else { //cache.putObject(((Fqn)fqn.clone()).add(field.getName()), value); cache.putObject(new Fqn(fqn, field.getName()), value); } } } else if (invocation instanceof FieldReadInvocation) { FieldInvocation fieldInvocation = (FieldInvocation) invocation; Field field = fieldInvocation.getField(); Advisor advisor = fieldInvocation.getAdvisor(); // Only if this field is replicatable CachedType fieldType = cache.getCachedType(field.getType()); CachedType parentType = cache.getCachedType(field.getDeclaringClass()); if (!isNonReplicatable(field, advisor, parentType)) { Object result; if (fieldType.isImmediate() || hasSerializableAnnotation(field, advisor, parentType)) { result = cache.get(fqn, field.getName()); } else { //result = cache.getObject(((Fqn)fqn.clone()).add(field.getName())); result = cache.getObject(new Fqn(fqn, field.getName())); } // if result is null, we need to make sure the in-memory reference is null // as well. If it is not, then we know this one is null because it has // been evicted. Will need to reconstruct it if (result != null) return result; else { // TODO There is a chance of recursive loop here if caller tries to print out obj that will trigger the fieldRead interception. Object value = invocation.getTargetObject(); if (value == null || field.get(value) == null) // if both are null, we know this is null as well. return null; else { if (log_.isTraceEnabled()) { log_.trace("invoke(): DataNode on fqn: " + fqn + " has obviously been evicted. Will need to reconstruct it"); } cache.putObject(fqn, value); } } } } return invocation.invokeNext(); } /** * See if this field is non-replicatable such as @Transient or transient modifier. */ private static boolean isNonReplicatable(Field field, Advisor advisor, CachedType type) { if (CachedType.hasAnnotation(field.getDeclaringClass(), advisor, type)) { if (CachedType.hasTransientAnnotation(field, advisor)) return true; } if (CachedType.isPrimitiveNonReplicatable(field)) return true; return false; } private static boolean hasSerializableAnnotation(Field field, Advisor advisor, CachedType type) { if (CachedType.hasAnnotation(field.getDeclaringClass(), advisor, type)) { if (CachedType.hasSerializableAnnotation(field, advisor)) return true; } return false; } /** * Check if the pojo is detached already. If it is and we still have the cache interceptor on * this pojo, we will go ahead and remove it since it should not be there in the first place. * * @param invocation */ private boolean isPojoDetached(Invocation invocation) { boolean detached = false; if (!cache.exists(fqn, InternalDelegate.CLASS_INTERNAL)) { detached = true; Object obj = invocation.getTargetObject(); if (! (obj instanceof Advised)) throw new RuntimeException("Interception on non-advised pojo " + obj.toString()); InstanceAdvisor advisor = ((Advised) obj)._getInstanceAdvisor(); CacheFieldInterceptor interceptor = (CacheFieldInterceptor) AopUtil.findCacheInterceptor(advisor); if (interceptor != null) { if (log_.isDebugEnabled()) { log_.debug("isPojoDetached(): removed cache interceptor fqn: " + fqn + " interceptor: " + interceptor); } advisor.removeInterceptor(interceptor.getName()); } } return detached; } protected void checkCacheConsistency() throws Exception { if (this != cache.peek(fqn, AOPInstance.KEY)) { throw new RuntimeException("Cache inconsistency: Outdated AOPInstance"); } } public void beforeSerialization(Object target) throws Exception { // fill objects for (Iterator i = type.getFields().iterator(); i.hasNext();) { Field field = (Field) (((FieldPersistentReference) i.next())).get(); CachedType fieldType = cache.getCachedType(field.getType()); Object value = null; if (fieldType.isImmediate()) { value = cache.get(fqn, field.getName()); } else { // value = removeObject(fqn+TreeCache.SEPARATOR+field.getName()); //value = cache.getObject(((Fqn)fqn.clone()).add(field.getName())); value = cache.getObject(new Fqn(fqn, field.getName())); } // System.out.println("Setting field " + field.getName() + "[" + field.getDeclaringClass() + "] of "+ target.getClass() + " to " + value); field.set(target, value); } } boolean isChildOf(Fqn parentFqn) { return fqn.isChildOf(parentFqn); } // void setFqn(Fqn fqn) // { // this.fqn = fqn; // } public Fqn getFqn() { return fqn; } public void setFqn(Fqn fqn) { this.fqn = fqn; } } |
From: Ben W. <bw...@jb...> - 2006-07-07 10:26:49
|
User: bwang Date: 06/07/07 06:26:47 Modified: tests-50/functional/org/jboss/cache/pojo/util MethodCallTest.java Log: Relocated the dynamic interceptors Revision Changes Path 1.2 +1 -1 JBossCache/tests-50/functional/org/jboss/cache/pojo/util/MethodCallTest.java (In the diff below, changes in quantity of whitespace are not shown.) Index: MethodCallTest.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/util/MethodCallTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- MethodCallTest.java 7 Jul 2006 09:35:23 -0000 1.1 +++ MethodCallTest.java 7 Jul 2006 10:26:47 -0000 1.2 @@ -15,7 +15,7 @@ import org.jboss.aop.InstanceAdvisor; import org.jboss.aop.ClassInstanceAdvisor; import org.jboss.aop.advice.Interceptor; -import org.jboss.cache.pojo.CacheInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.CacheInterceptor; import org.jboss.cache.pojo.MethodDeclarations; import org.jboss.cache.pojo.PojoUtil; |
From: Ben W. <bw...@jb...> - 2006-07-07 10:26:48
|
User: bwang Date: 06/07/07 06:26:47 Modified: tests-50/functional/org/jboss/cache/pojo TxUndoTest.java Log: Relocated the dynamic interceptors Revision Changes Path 1.2 +1 -0 JBossCache/tests-50/functional/org/jboss/cache/pojo/TxUndoTest.java (In the diff below, changes in quantity of whitespace are not shown.) Index: TxUndoTest.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/tests-50/functional/org/jboss/cache/pojo/TxUndoTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- TxUndoTest.java 7 Jul 2006 09:35:23 -0000 1.1 +++ TxUndoTest.java 7 Jul 2006 10:26:47 -0000 1.2 @@ -13,6 +13,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.pojo.test.Person; +import org.jboss.cache.pojo.interceptors.dynamic.CacheInterceptor; import org.jboss.cache.transaction.DummyTransactionManager; import org.jboss.aop.Advised; import org.jboss.aop.advice.Interceptor; |
From: Ben W. <bw...@jb...> - 2006-07-07 10:26:13
|
User: bwang Date: 06/07/07 06:26:07 Modified: src-50/org/jboss/cache/pojo CachedType.java CollectionClassHandler.java ObjectGraphHandler.java TreeCacheAopDelegate.java Removed: src-50/org/jboss/cache/pojo BaseInterceptor.java CacheInterceptor.java Log: Relocated the dynamic interceptors Revision Changes Path 1.3 +5 -5 JBossCache/src-50/org/jboss/cache/pojo/CachedType.java (In the diff below, changes in quantity of whitespace are not shown.) Index: CachedType.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/CachedType.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- CachedType.java 27 Jun 2006 05:25:43 -0000 1.2 +++ CachedType.java 7 Jul 2006 10:26:07 -0000 1.3 @@ -49,7 +49,7 @@ Character.TYPE, Class.class})); - private WeakReference type; + private WeakReference<Class> type; private boolean immutable; private boolean immediate; // This map caches the class that contains no annotation. @@ -66,7 +66,7 @@ public CachedType(Class type) { - this.type = new WeakReference(type); + this.type = new WeakReference<Class>(type); analyze(); } @@ -221,7 +221,7 @@ * We check whether this class has any field annotation declaration. We assume that there is only * one such declaring class per vm and it is static. */ - static boolean hasAnnotation(Class clazz, Advisor advisor, CachedType type) + public static boolean hasAnnotation(Class clazz, Advisor advisor, CachedType type) { // It is ok that we don't synchronize it here. if (CachedClassWithNoAnnotation_.get(clazz) != null) @@ -255,7 +255,7 @@ return false; } - static boolean isPrimitiveNonReplicatable(Field f) + public static boolean isPrimitiveNonReplicatable(Field f) { int mods = f.getModifiers(); /** @@ -293,7 +293,7 @@ return hasTransientAnnotation(field, advisor) || hasSerializableAnnotation(field, advisor); } - static boolean hasTransientAnnotation(Field field, Advisor advisor) + public static boolean hasTransientAnnotation(Field field, Advisor advisor) { Object obj = advisor.resolveAnnotation(field, org.jboss.cache.aop.annotation.Transient.class); if (obj != null) 1.6 +7 -6 JBossCache/src-50/org/jboss/cache/pojo/CollectionClassHandler.java (In the diff below, changes in quantity of whitespace are not shown.) Index: CollectionClassHandler.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/CollectionClassHandler.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- CollectionClassHandler.java 6 Jul 2006 09:25:40 -0000 1.5 +++ CollectionClassHandler.java 7 Jul 2006 10:26:07 -0000 1.6 @@ -13,10 +13,10 @@ import org.jboss.aop.proxy.ClassProxy; import org.jboss.cache.CacheException; import org.jboss.cache.Fqn; -import org.jboss.cache.pojo.collection.AbstractCollectionInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor; import org.jboss.cache.pojo.collection.CollectionInterceptorUtil; +import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor; -import java.lang.reflect.Field; import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -28,7 +28,7 @@ * * @author Ben Wang * Date: Aug 4, 2005 - * @version $Id: CollectionClassHandler.java,v 1.5 2006/07/06 09:25:40 bwang Exp $ + * @version $Id: CollectionClassHandler.java,v 1.6 2006/07/07 10:26:07 bwang Exp $ */ class CollectionClassHandler { @@ -216,14 +216,15 @@ if (isCollection) { // Always initialize the ref count so that we can mark this as an AopNode. - AOPInstance aopInstance = internal_.initializeAopInstance(); + AOPInstance aopInstance = InternalDelegate.initializeAopInstance(); cache_.put(fqn, AOPInstance.KEY, aopInstance); // Attach aopInstance to that interceptor - BaseInterceptor baseInterceptor = (BaseInterceptor) CollectionInterceptorUtil.getInterceptor((ClassProxy) obj); + BaseInterceptor baseInterceptor = (BaseInterceptor) CollectionInterceptorUtil.getInterceptor( + (ClassProxy) obj); baseInterceptor.setAopInstance(aopInstance); - internal_.setPojo(aopInstance, obj); + InternalDelegate.setPojo(aopInstance, obj); } return isCollection; } 1.5 +5 -3 JBossCache/src-50/org/jboss/cache/pojo/ObjectGraphHandler.java (In the diff below, changes in quantity of whitespace are not shown.) Index: ObjectGraphHandler.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/ObjectGraphHandler.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- ObjectGraphHandler.java 6 Jul 2006 09:25:40 -0000 1.4 +++ ObjectGraphHandler.java 7 Jul 2006 10:26:07 -0000 1.5 @@ -14,15 +14,17 @@ import org.jboss.aop.advice.Interceptor; import org.jboss.cache.CacheException; import org.jboss.cache.Fqn; -import org.jboss.cache.pojo.collection.AbstractCollectionInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor; import org.jboss.cache.pojo.util.AopUtil; +import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.CacheInterceptor; /** * Handle the object graph management. * * @author Ben Wang * Date: Aug 4, 2005 - * @version $Id: ObjectGraphHandler.java,v 1.4 2006/07/06 09:25:40 bwang Exp $ + * @version $Id: ObjectGraphHandler.java,v 1.5 2006/07/07 10:26:07 bwang Exp $ */ class ObjectGraphHandler { @@ -206,7 +208,7 @@ aliasFqn = internal_.createIndirectFqn(refFqn.toString()); } else { - aliasFqn = internal_.getIndirectFqn(refFqn.toString()); + aliasFqn = InternalDelegate.getIndirectFqn(refFqn.toString()); } // set the internal fqn in fqn so we can reference it. if (log.isTraceEnabled()) 1.7 +8 -6 JBossCache/src-50/org/jboss/cache/pojo/TreeCacheAopDelegate.java (In the diff below, changes in quantity of whitespace are not shown.) Index: TreeCacheAopDelegate.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/TreeCacheAopDelegate.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- TreeCacheAopDelegate.java 7 Jul 2006 09:34:42 -0000 1.6 +++ TreeCacheAopDelegate.java 7 Jul 2006 10:26:07 -0000 1.7 @@ -16,9 +16,11 @@ import org.jboss.aop.proxy.ClassProxy; import org.jboss.cache.CacheException; import org.jboss.cache.Fqn; -import org.jboss.cache.pojo.collection.AbstractCollectionInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor; import org.jboss.cache.pojo.memory.FieldPersistentReference; import org.jboss.cache.pojo.util.AopUtil; +import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.CacheInterceptor; import java.lang.reflect.Field; import java.util.Collection; @@ -42,7 +44,7 @@ private CollectionClassHandler collectionHandler_; private SerializableObjectHandler serializableHandler_; // Use ThreadLocal to hold a boolean isBulkRemove - private ThreadLocal bulkRemove_ = new ThreadLocal(); + private ThreadLocal<Boolean> bulkRemove_ = new ThreadLocal<Boolean>(); private final String DETACH = "DETACH"; private PojoUtil util_ = new PojoUtil(); @@ -151,7 +153,7 @@ } } - internal_.setPojo(aopInstance, obj); + InternalDelegate.setPojo(aopInstance, obj); return obj; } @@ -413,7 +415,7 @@ // Let's do batch update via Map instead Map map = new HashMap(); // Always initialize the ref count so we can mark this as an AopNode. - AOPInstance aopInstance = internal_.initializeAopInstance(); + AOPInstance aopInstance = InternalDelegate.initializeAopInstance(); // Insert interceptor at runtime CacheInterceptor interceptor = new CacheInterceptor(cache_, fqn, type); interceptor.setAopInstance(aopInstance); @@ -421,7 +423,7 @@ map.put(AOPInstance.KEY, aopInstance); // This is put into map first. - internal_.putAopClazz(type.getType(), map); + InternalDelegate.putAopClazz(type.getType(), map); // we will do it recursively. // Map of sub-objects that are non-primitive Map subPojoMap = new HashMap(); @@ -470,7 +472,7 @@ // Use option to skip locking since we have parent lock already. cache_.put(fqn, map, internal_.getLockOption()); // This is in-memory operation only - internal_.setPojo(aopInstance, obj); + InternalDelegate.setPojo(aopInstance, obj); for (Object o : subPojoMap.keySet()) { |
From: Ben W. <bw...@jb...> - 2006-07-07 10:26:08
|
User: bwang Date: 06/07/07 06:26:06 Modified: src-50/org/jboss/cache/pojo/util AopUtil.java Log: Relocated the dynamic interceptors Revision Changes Path 1.3 +2 -2 JBossCache/src-50/org/jboss/cache/pojo/util/AopUtil.java (In the diff below, changes in quantity of whitespace are not shown.) Index: AopUtil.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/util/AopUtil.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- AopUtil.java 27 Jun 2006 05:25:43 -0000 1.2 +++ AopUtil.java 7 Jul 2006 10:26:06 -0000 1.3 @@ -12,8 +12,8 @@ import org.jboss.aop.InstanceAdvisor; import org.jboss.aop.advice.Interceptor; import org.jboss.cache.Fqn; -import org.jboss.cache.pojo.BaseInterceptor; -import org.jboss.cache.pojo.CacheInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.CacheInterceptor; import java.io.Serializable; |
From: Ben W. <bw...@jb...> - 2006-07-07 10:26:08
|
User: bwang Date: 06/07/07 06:26:04 Added: src-50/org/jboss/cache/pojo/interceptors/dynamic AbstractCollectionInterceptor.java BaseInterceptor.java CacheInterceptor.java CachedListInterceptor.java CachedMapInterceptor.java CachedSetInterceptor.java Log: Relocated the dynamic interceptors Revision Changes Path 1.1 date: 2006/07/07 10:26:04; author: bwang; state: Exp;JBossCache/src-50/org/jboss/cache/pojo/interceptors/dynamic/AbstractCollectionInterceptor.java Index: AbstractCollectionInterceptor.java =================================================================== /* * JBoss, Home of Professional Open Source * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.cache.pojo.interceptors.dynamic; import org.jboss.cache.Fqn; import org.jboss.cache.pojo.AOPInstance; /** * Abstract base class for collection interceptor. * * @author Ben Wang * @version $Id: AbstractCollectionInterceptor.java,v 1.1 2006/07/07 10:26:04 bwang Exp $ */ @SuppressWarnings({"CanBeFinal"}) public abstract class AbstractCollectionInterceptor implements BaseInterceptor { Fqn fqn_; private boolean attached_ = true; private AOPInstance aopInstance_; @SuppressWarnings({"CanBeFinal"}) public Fqn getFqn() { return fqn_; } @SuppressWarnings({"CanBeFinal"}) public void setFqn(Fqn fqn) { this.fqn_ = fqn; } @SuppressWarnings({"CanBeFinal"}) public AOPInstance getAopInstance() { return aopInstance_; } public void setAopInstance(AOPInstance aopInstance) { this.aopInstance_ = aopInstance; } /** * Attaching the Collection to PojoCache. */ public void attach(Fqn fqn, boolean copyToCache) { // This is a hook to allow re-attching the Collection without specifying the fqn. if (fqn != null) { setFqn(fqn); } attached_ = true; // Reattach anything in-memory to cache } public void detach(boolean removeFromCache) { attached_ = false; // Detach by tranferring the cache content to in-memory copy } public boolean isAttached() { return attached_; } abstract void setInMemoryCopy(Object obj); abstract Object getInMemoryCopy(); abstract void setCacheCopy(Object obj); abstract Object getCacheCopy(); abstract void setCurrentCopy(Object obj); abstract Object getCurrecntCopy(); } 1.1 date: 2006/07/07 10:26:04; author: bwang; state: Exp;JBossCache/src-50/org/jboss/cache/pojo/interceptors/dynamic/BaseInterceptor.java Index: BaseInterceptor.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.cache.pojo.interceptors.dynamic; import org.jboss.cache.Fqn; import org.jboss.cache.pojo.AOPInstance; import org.jboss.aop.advice.Interceptor; /** * Base cache interceptor * * @author Ben Wang */ public interface BaseInterceptor extends Interceptor, Cloneable { /** * Get the original fqn that is associated with this interceptor (or advisor). */ Fqn getFqn(); void setFqn(Fqn fqn); AOPInstance getAopInstance(); void setAopInstance(AOPInstance aopInstance); void setInterceptor(Interceptor interceptor); } 1.1 date: 2006/07/07 10:26:04; author: bwang; state: Exp;JBossCache/src-50/org/jboss/cache/pojo/interceptors/dynamic/CacheInterceptor.java Index: CacheInterceptor.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.cache.pojo.interceptors.dynamic; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.aop.Advised; import org.jboss.aop.Advisor; import org.jboss.aop.InstanceAdvisor; import org.jboss.aop.advice.Interceptor; import org.jboss.aop.joinpoint.FieldInvocation; import org.jboss.aop.joinpoint.FieldReadInvocation; import org.jboss.aop.joinpoint.FieldWriteInvocation; import org.jboss.aop.joinpoint.Invocation; import org.jboss.cache.Fqn; import org.jboss.cache.pojo.memory.FieldPersistentReference; import org.jboss.cache.pojo.util.AopUtil; import org.jboss.cache.pojo.PojoTreeCache; import org.jboss.cache.pojo.CachedType; import org.jboss.cache.pojo.AOPInstance; import org.jboss.cache.pojo.InternalDelegate; import java.lang.reflect.Field; import java.util.Iterator; /** * Main dynamic interceptor to intercept for field replication. * * @author Ben Wang */ public class CacheInterceptor implements BaseInterceptor { private static final Log log_ = LogFactory.getLog(CacheInterceptor.class); private PojoTreeCache cache; private CachedType type; private Fqn fqn; private String name; private AOPInstance aopInstance; public CacheInterceptor(PojoTreeCache cache, Fqn fqn, CachedType type) { this.cache = cache; this.fqn = fqn; this.type = type; } public CacheInterceptor() { } public AOPInstance getAopInstance() { return aopInstance; } public Object clone() { CacheInterceptor interceptor = new CacheInterceptor(); interceptor.setFqn(getFqn()); interceptor.setAopInstance(getAopInstance()); return interceptor; } public void setInterceptor(Interceptor intcptr) { CacheInterceptor interceptor = (CacheInterceptor)intcptr; setFqn(interceptor.getFqn()); setAopInstance(interceptor.getAopInstance()); } public void setAopInstance(AOPInstance aopInstance) { this.aopInstance = aopInstance; } public String getName() { if (name == null) { this.name = "CacheInterceptor on [" + fqn + "]"; } return name; } public Object invoke(Invocation invocation) throws Throwable { // Check if CLASS_INTERNAL exists. If not, that means we are done. We need to remove ourself. // Note that if speed is important, we will need to perform the detach step pro-actively, // that is, use a listener to listen for the removeObject event. if (isPojoDetached(invocation)) { return invocation.invokeNext(); // invoke the in-memory pojo directly } if (invocation instanceof FieldWriteInvocation) { FieldInvocation fieldInvocation = (FieldInvocation) invocation; Advisor advisor = fieldInvocation.getAdvisor(); Field field = fieldInvocation.getField(); // Only if this field is replicatable. static, transient and final are not. CachedType fieldType = cache.getCachedType(field.getType()); CachedType parentType = cache.getCachedType(field.getDeclaringClass()); if (!isNonReplicatable(field, advisor, parentType)) { Object value = ((FieldWriteInvocation) fieldInvocation).getValue(); if (fieldType.isImmediate() || hasSerializableAnnotation(field, advisor, parentType)) { cache.put(fqn, field.getName(), value); } else { //cache.putObject(((Fqn)fqn.clone()).add(field.getName()), value); cache.putObject(new Fqn(fqn, field.getName()), value); } } } else if (invocation instanceof FieldReadInvocation) { FieldInvocation fieldInvocation = (FieldInvocation) invocation; Field field = fieldInvocation.getField(); Advisor advisor = fieldInvocation.getAdvisor(); // Only if this field is replicatable CachedType fieldType = cache.getCachedType(field.getType()); CachedType parentType = cache.getCachedType(field.getDeclaringClass()); if (!isNonReplicatable(field, advisor, parentType)) { Object result; if (fieldType.isImmediate() || hasSerializableAnnotation(field, advisor, parentType)) { result = cache.get(fqn, field.getName()); } else { //result = cache.getObject(((Fqn)fqn.clone()).add(field.getName())); result = cache.getObject(new Fqn(fqn, field.getName())); } // if result is null, we need to make sure the in-memory reference is null // as well. If it is not, then we know this one is null because it has // been evicted. Will need to reconstruct it if (result != null) return result; else { // TODO There is a chance of recursive loop here if caller tries to print out obj that will trigger the fieldRead interception. Object value = invocation.getTargetObject(); if (value == null || field.get(value) == null) // if both are null, we know this is null as well. return null; else { if (log_.isTraceEnabled()) { log_.trace("invoke(): DataNode on fqn: " + fqn + " has obviously been evicted. Will need to reconstruct it"); } cache.putObject(fqn, value); } } } } return invocation.invokeNext(); } /** * See if this field is non-replicatable such as @Transient or transient modifier. */ private static boolean isNonReplicatable(Field field, Advisor advisor, CachedType type) { if (CachedType.hasAnnotation(field.getDeclaringClass(), advisor, type)) { if (CachedType.hasTransientAnnotation(field, advisor)) return true; } if (CachedType.isPrimitiveNonReplicatable(field)) return true; return false; } private static boolean hasSerializableAnnotation(Field field, Advisor advisor, CachedType type) { if (CachedType.hasAnnotation(field.getDeclaringClass(), advisor, type)) { if (CachedType.hasSerializableAnnotation(field, advisor)) return true; } return false; } /** * Check if the pojo is detached already. If it is and we still have the cache interceptor on * this pojo, we will go ahead and remove it since it should not be there in the first place. * * @param invocation */ private boolean isPojoDetached(Invocation invocation) { boolean detached = false; if (!cache.exists(fqn, InternalDelegate.CLASS_INTERNAL)) { detached = true; Object obj = invocation.getTargetObject(); if (! (obj instanceof Advised)) throw new RuntimeException("Interception on non-advised pojo " + obj.toString()); InstanceAdvisor advisor = ((Advised) obj)._getInstanceAdvisor(); CacheInterceptor interceptor = (CacheInterceptor) AopUtil.findCacheInterceptor(advisor); if (interceptor != null) { if (log_.isDebugEnabled()) { log_.debug("isPojoDetached(): removed cache interceptor fqn: " + fqn + " interceptor: " + interceptor); } advisor.removeInterceptor(interceptor.getName()); } } return detached; } protected void checkCacheConsistency() throws Exception { if (this != cache.peek(fqn, AOPInstance.KEY)) { throw new RuntimeException("Cache inconsistency: Outdated AOPInstance"); } } public void beforeSerialization(Object target) throws Exception { // fill objects for (Iterator i = type.getFields().iterator(); i.hasNext();) { Field field = (Field) (((FieldPersistentReference) i.next())).get(); CachedType fieldType = cache.getCachedType(field.getType()); Object value = null; if (fieldType.isImmediate()) { value = cache.get(fqn, field.getName()); } else { // value = removeObject(fqn+TreeCache.SEPARATOR+field.getName()); //value = cache.getObject(((Fqn)fqn.clone()).add(field.getName())); value = cache.getObject(new Fqn(fqn, field.getName())); } // System.out.println("Setting field " + field.getName() + "[" + field.getDeclaringClass() + "] of "+ target.getClass() + " to " + value); field.set(target, value); } } boolean isChildOf(Fqn parentFqn) { return fqn.isChildOf(parentFqn); } // void setFqn(Fqn fqn) // { // this.fqn = fqn; // } public Fqn getFqn() { return fqn; } public void setFqn(Fqn fqn) { this.fqn = fqn; } } 1.1 date: 2006/07/07 10:26:04; author: bwang; state: Exp;JBossCache/src-50/org/jboss/cache/pojo/interceptors/dynamic/CachedListInterceptor.java Index: CachedListInterceptor.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.cache.pojo.interceptors.dynamic; import org.jboss.cache.Fqn; import org.jboss.cache.pojo.PojoTreeCache; import org.jboss.cache.pojo.collection.CollectionInterceptorUtil; import org.jboss.cache.pojo.collection.CachedListImpl; import org.jboss.aop.advice.Interceptor; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * List ineterceptor that delegates to underlying implementation. * * @author Ben Wang */ @SuppressWarnings({"CanBeFinal"}) public class CachedListInterceptor extends AbstractCollectionInterceptor { // protected static final Log log_ = LogFactory.getLog(CachedListInterceptor.class); private static final Map managedMethods_ = CollectionInterceptorUtil.getManagedMethods(List.class); private Map methodMap_; // This is the copy in cache store when it is attached. private List cacheImpl_; // This is the copy in-memory when the state is detached. private List inMemImpl_; // Whichever is used now. private List current_; public CachedListInterceptor(PojoTreeCache cache, Fqn fqn, Class clazz, List obj) { this.fqn_ = fqn; methodMap_ = CollectionInterceptorUtil.getMethodMap(clazz); cacheImpl_ = new CachedListImpl(cache, this); inMemImpl_ = obj; // lazy initialization here. current_ = cacheImpl_; } public CachedListInterceptor() {} public Object clone() { CachedListInterceptor interceptor = new CachedListInterceptor(); interceptor.setFqn(getFqn()); interceptor.setAopInstance(getAopInstance()); interceptor.setCurrentCopy(getCurrecntCopy()); interceptor.setInMemoryCopy(getInMemoryCopy()); interceptor.setCacheCopy(getCacheCopy()); return interceptor; } public void setInterceptor(Interceptor intcptr) { CachedListInterceptor interceptor = (CachedListInterceptor)intcptr; setFqn(interceptor.getFqn()); setAopInstance(interceptor.getAopInstance()); setCurrentCopy(interceptor.getCurrecntCopy()); setInMemoryCopy(interceptor.getInMemoryCopy()); setCacheCopy(interceptor.getCacheCopy()); } /** * When we want to associate this proxy with the cache again. We will need to translate the in-memory * content to the cache store first. */ public void attach(Fqn fqn, boolean copyToCache) { super.attach(fqn, copyToCache); if (copyToCache) toCache(); current_ = cacheImpl_; } private void toCache() { if (inMemImpl_ == null) throw new IllegalStateException("CachedListInterceptor.toCache(). inMemImpl is null."); // TODO This may not be optimal List tmpList = new ArrayList(); for (int i = inMemImpl_.size(); i > 0; i--) { Object obj = inMemImpl_.remove(i - 1); tmpList.add(obj); } int size = tmpList.size(); for (int i = 0; i < tmpList.size(); i++) { cacheImpl_.add(tmpList.get(size - i - 1)); } inMemImpl_ = null; // we are done with this. } /** * When we want to separate this proxy from the cache. We will destroy the cache content and copy them to * the in-memory copy. */ public void detach(boolean removeFromCache) { super.detach(removeFromCache); toMemory(removeFromCache); current_ = inMemImpl_; } void setInMemoryCopy(Object obj) { inMemImpl_ = (List)obj; } Object getInMemoryCopy() { return inMemImpl_; } void setCacheCopy(Object obj) { cacheImpl_ = (List)obj; } Object getCacheCopy() { return cacheImpl_; } void setCurrentCopy(Object obj) { current_ = (List)obj; } Object getCurrecntCopy() { return current_; } private void toMemory(boolean removeFromCache) { if (inMemImpl_ == null) { inMemImpl_ = new ArrayList(); } // Optimization since remove from the beginning is very expensive. List tmpList = new ArrayList(); for (int i = cacheImpl_.size(); i > 0; i--) { int j = i - 1; Object obj = null; if (removeFromCache) { obj = cacheImpl_.remove(j); } else { obj = cacheImpl_.get(j); } tmpList.add(obj); } int size = tmpList.size(); inMemImpl_.clear(); for (int i = 0; i < tmpList.size(); i++) { inMemImpl_.add(tmpList.get(size - i - 1)); } } public String getName() { return "CachedListInterceptor"; } public Object invoke(org.jboss.aop.joinpoint.Invocation invocation) throws Throwable { if (current_ == null) throw new IllegalStateException("CachedListInterceptor.invoke(). current_ is null."); return CollectionInterceptorUtil.invoke(invocation, current_, methodMap_, managedMethods_); } } 1.1 date: 2006/07/07 10:26:04; author: bwang; state: Exp;JBossCache/src-50/org/jboss/cache/pojo/interceptors/dynamic/CachedMapInterceptor.java Index: CachedMapInterceptor.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.cache.pojo.interceptors.dynamic; import org.jboss.cache.Fqn; import org.jboss.cache.pojo.PojoTreeCache; import org.jboss.cache.pojo.collection.CollectionInterceptorUtil; import org.jboss.cache.pojo.collection.CachedMapImpl; import org.jboss.aop.advice.Interceptor; import java.util.HashMap; import java.util.Iterator; import java.util.Map; /** * Map interceptor that delegates to the underlying impl. * * @author Ben Wang */ @SuppressWarnings({"CanBeFinal"}) public class CachedMapInterceptor extends AbstractCollectionInterceptor { // protected static final Log log_ = LogFactory.getLog(CachedMapInterceptor.class); private static final Map managedMethods_ = CollectionInterceptorUtil.getManagedMethods(Map.class); private Map methodMap_; private Map cacheImpl_; private Map inMemImpl_; private Map current_; public CachedMapInterceptor(PojoTreeCache cache, Fqn fqn, Class clazz, Map obj) { this.fqn_ = fqn; methodMap_ = CollectionInterceptorUtil.getMethodMap(clazz); cacheImpl_ = new CachedMapImpl(cache, this); inMemImpl_ = obj; current_ = cacheImpl_; } CachedMapInterceptor() {} public Object clone() { CachedListInterceptor interceptor = new CachedListInterceptor(); interceptor.setFqn(getFqn()); interceptor.setAopInstance(getAopInstance()); interceptor.setCurrentCopy(getCurrecntCopy()); interceptor.setInMemoryCopy(getInMemoryCopy()); interceptor.setCacheCopy(getCacheCopy()); return interceptor; } public void setInterceptor(Interceptor intcptr) { CachedListInterceptor interceptor = (CachedListInterceptor)intcptr; setFqn(interceptor.getFqn()); setAopInstance(interceptor.getAopInstance()); setCurrentCopy(interceptor.getCurrecntCopy()); setInMemoryCopy(interceptor.getInMemoryCopy()); setCacheCopy(interceptor.getCacheCopy()); } void setInMemoryCopy(Object obj) { inMemImpl_ = (Map)obj; } Object getInMemoryCopy() { return inMemImpl_; } void setCacheCopy(Object obj) { cacheImpl_ = (Map)obj; } Object getCacheCopy() { return cacheImpl_; } void setCurrentCopy(Object obj) { current_ = (Map)obj; } Object getCurrecntCopy() { return current_; } /** * When we want to associate this proxy with the cache again. We will need to translate the in-memory * content to the cache store first. */ public void attach(Fqn fqn, boolean copyToCache) { super.attach(fqn, copyToCache); if (copyToCache) toCache(); current_ = cacheImpl_; } private void toCache() { if (inMemImpl_ == null) throw new IllegalStateException("CachedMapInterceptor.toCache(). inMemImpl is null."); for (Object key : inMemImpl_.keySet()) { Object val = inMemImpl_.get(key); cacheImpl_.put(key, val); } inMemImpl_.clear(); inMemImpl_ = null; // we are done with this. } /** * When we want to separate this proxy from the cache. We will destroy the cache content and copy them to * the in-memory copy. */ public void detach(boolean removeFromCache) { super.detach(removeFromCache); toMemory(removeFromCache); current_ = inMemImpl_; } private void toMemory(boolean removeFromCache) { if (inMemImpl_ == null) { inMemImpl_ = new HashMap(); } Iterator it = cacheImpl_.keySet().iterator(); inMemImpl_.clear(); while (it.hasNext()) { Object key = it.next(); Object val = null; if (removeFromCache) { val = cacheImpl_.remove(key); } else { val = cacheImpl_.get(key); } inMemImpl_.put(key, val); } } public String getName() { return "CachedMapInterceptor"; } public Object invoke(org.jboss.aop.joinpoint.Invocation invocation) throws Throwable { if (current_ == null) throw new IllegalStateException("CachedMapInterceptor.invoke(). current_ is null."); return CollectionInterceptorUtil.invoke(invocation, current_, methodMap_, managedMethods_); } } 1.1 date: 2006/07/07 10:26:04; author: bwang; state: Exp;JBossCache/src-50/org/jboss/cache/pojo/interceptors/dynamic/CachedSetInterceptor.java Index: CachedSetInterceptor.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.cache.pojo.interceptors.dynamic; import org.jboss.cache.Fqn; import org.jboss.cache.pojo.PojoTreeCache; import org.jboss.cache.pojo.collection.CollectionInterceptorUtil; import org.jboss.cache.pojo.collection.CachedSetImpl; import org.jboss.aop.advice.Interceptor; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * Set interceptor that delegates underlying impl. * * @author Ben Wang */ @SuppressWarnings({"CanBeFinal"}) public class CachedSetInterceptor extends AbstractCollectionInterceptor { // protected static final Log log_=LogFactory.getLog(CachedSetInterceptor.class); private Map methodMap_; private static final Map managedMethods_ = CollectionInterceptorUtil.getManagedMethods(Set.class); private Set cacheImpl_; private Set current_; private Set inMemImpl_; public CachedSetInterceptor(PojoTreeCache cache, Fqn fqn, Class clazz, Set obj) { this.fqn_ = fqn; methodMap_ = CollectionInterceptorUtil.getMethodMap(clazz); cacheImpl_ = new CachedSetImpl(cache, this); inMemImpl_ = obj; current_ = cacheImpl_; } public CachedSetInterceptor() {} public Object clone() { CachedListInterceptor interceptor = new CachedListInterceptor(); interceptor.setFqn(getFqn()); interceptor.setAopInstance(getAopInstance()); interceptor.setCurrentCopy(getCurrecntCopy()); interceptor.setInMemoryCopy(getInMemoryCopy()); interceptor.setCacheCopy(getCacheCopy()); return interceptor; } public void setInterceptor(Interceptor intcptr) { CachedListInterceptor interceptor = (CachedListInterceptor)intcptr; setFqn(interceptor.getFqn()); setAopInstance(interceptor.getAopInstance()); setCurrentCopy(interceptor.getCurrecntCopy()); setInMemoryCopy(interceptor.getInMemoryCopy()); setCacheCopy(interceptor.getCacheCopy()); } void setInMemoryCopy(Object obj) { inMemImpl_ = (Set)obj; } Object getInMemoryCopy() { return inMemImpl_; } void setCacheCopy(Object obj) { cacheImpl_ = (Set)obj; } Object getCacheCopy() { return cacheImpl_; } void setCurrentCopy(Object obj) { current_ = (Set)obj; } Object getCurrecntCopy() { return current_; } /** * When we want to associate this proxy with the cache again. We will need to translate the in-memory * content to the cache store first. */ public void attach(Fqn fqn, boolean copyToCache) { super.attach(fqn, copyToCache); if (copyToCache) toCache(); current_ = cacheImpl_; } private void toCache() { if (inMemImpl_ == null) throw new IllegalStateException("CachedSetInterceptor.toCache(). inMemImpl is null."); for (Iterator it = inMemImpl_.iterator(); it.hasNext();) { Object obj = it.next(); it.remove(); cacheImpl_.add(obj); } inMemImpl_ = null; // we are done with this. } /** * When we want to separate this proxy from the cache. We will destroy the cache content and copy them to * the in-memory copy. */ public void detach(boolean removeFromCache) { super.detach(removeFromCache); toMemory(removeFromCache); current_ = inMemImpl_; } private void toMemory(boolean removeFromCache) { if (inMemImpl_ == null) { inMemImpl_ = new HashSet(); } // TODO. This needs optimization. inMemImpl_.clear(); for (Iterator it = cacheImpl_.iterator(); it.hasNext();) { Object obj = it.next(); if (removeFromCache) it.remove(); inMemImpl_.add(obj); } } public String getName() { return "CachedSetInterceptor"; } public Object invoke(org.jboss.aop.joinpoint.Invocation invocation) throws Throwable { if (current_ == null) throw new IllegalStateException("CachedSetInterceptor.invoke(). current_ is null."); return CollectionInterceptorUtil.invoke(invocation, current_, methodMap_, managedMethods_); } } |
From: Ben W. <bw...@jb...> - 2006-07-07 10:26:07
|
User: bwang Date: 06/07/07 06:26:03 Modified: src-50/org/jboss/cache/pojo/collection CachedListImpl.java CachedMapImpl.java CachedSetImpl.java CollectionInterceptorUtil.java Removed: src-50/org/jboss/cache/pojo/collection AbstractCollectionInterceptor.java CachedListInterceptor.java CachedMapInterceptor.java CachedSetInterceptor.java Log: Relocated the dynamic interceptors Revision Changes Path 1.4 +2 -1 JBossCache/src-50/org/jboss/cache/pojo/collection/CachedListImpl.java (In the diff below, changes in quantity of whitespace are not shown.) Index: CachedListImpl.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/collection/CachedListImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- CachedListImpl.java 27 Jun 2006 06:19:16 -0000 1.3 +++ CachedListImpl.java 7 Jul 2006 10:26:03 -0000 1.4 @@ -11,6 +11,7 @@ import org.jboss.cache.pojo.util.AopUtil; import org.jboss.cache.pojo.util.Null; import org.jboss.cache.pojo.PojoTreeCache; +import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor; import java.util.Iterator; import java.util.LinkedList; @@ -27,7 +28,7 @@ */ @SuppressWarnings({"CanBeFinal"}) -class CachedListImpl extends CachedListAbstract implements List +public class CachedListImpl extends CachedListAbstract implements List { // protected static final Log log_ = LogFactory.getLog(CachedListImpl.class); 1.7 +3 -2 JBossCache/src-50/org/jboss/cache/pojo/collection/CachedMapImpl.java (In the diff below, changes in quantity of whitespace are not shown.) Index: CachedMapImpl.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/collection/CachedMapImpl.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- CachedMapImpl.java 30 Jun 2006 19:11:11 -0000 1.6 +++ CachedMapImpl.java 7 Jul 2006 10:26:03 -0000 1.7 @@ -11,6 +11,7 @@ import org.jboss.cache.Fqn; import org.jboss.cache.pojo.util.Null; import org.jboss.cache.pojo.PojoTreeCache; +import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor; import java.util.AbstractCollection; import java.util.AbstractSet; @@ -30,7 +31,7 @@ * @author Scott Marlow */ @SuppressWarnings({"CanBeFinal"}) -class CachedMapImpl implements Map +public class CachedMapImpl implements Map { // protected static final Log log_ = LogFactory.getLog(CachedMapImpl.class); @@ -38,7 +39,7 @@ private PojoTreeCache cache_; private AbstractCollectionInterceptor interceptor_; - CachedMapImpl(PojoTreeCache cache, AbstractCollectionInterceptor interceptor) + public CachedMapImpl(PojoTreeCache cache, AbstractCollectionInterceptor interceptor) { this.cache_ = cache; interceptor_ = interceptor; 1.4 +2 -1 JBossCache/src-50/org/jboss/cache/pojo/collection/CachedSetImpl.java (In the diff below, changes in quantity of whitespace are not shown.) Index: CachedSetImpl.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/collection/CachedSetImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- CachedSetImpl.java 27 Jun 2006 06:19:16 -0000 1.3 +++ CachedSetImpl.java 7 Jul 2006 10:26:03 -0000 1.4 @@ -12,6 +12,7 @@ import org.jboss.cache.pojo.util.AopUtil; import org.jboss.cache.pojo.util.Null; import org.jboss.cache.pojo.PojoTreeCache; +import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor; import java.util.AbstractSet; import java.util.Collection; @@ -28,7 +29,7 @@ * @author Jussi Pyörre */ @SuppressWarnings({"CanBeFinal"}) -class CachedSetImpl extends AbstractSet +public class CachedSetImpl extends AbstractSet { // protected static final Log log_=LogFactory.getLog(CachedSetImpl.class); 1.4 +4 -0 JBossCache/src-50/org/jboss/cache/pojo/collection/CollectionInterceptorUtil.java (In the diff below, changes in quantity of whitespace are not shown.) Index: CollectionInterceptorUtil.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/collection/CollectionInterceptorUtil.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- CollectionInterceptorUtil.java 27 Jun 2006 06:19:16 -0000 1.3 +++ CollectionInterceptorUtil.java 7 Jul 2006 10:26:03 -0000 1.4 @@ -16,6 +16,10 @@ import org.jboss.aop.util.MethodHashing; import org.jboss.cache.Fqn; import org.jboss.cache.pojo.PojoTreeCache; +import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.CachedListInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.CachedMapInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.CachedSetInterceptor; import org.jboss.cache.pojo.util.AopUtil; import java.lang.reflect.InvocationTargetException; |
From: Kabir K. <kk...@jb...> - 2006-07-07 10:19:05
|
User: kkhan Date: 06/07/07 06:19:04 Modified: src/test/org/jboss/test/aop/memoryleaks MemoryLeakTestCase.java Log: [JBAOP-226] Resolve memory leaks for the generated advisors. Revision Changes Path 1.3 +28 -5 jboss-aop/src/test/org/jboss/test/aop/memoryleaks/MemoryLeakTestCase.java (In the diff below, changes in quantity of whitespace are not shown.) Index: MemoryLeakTestCase.java =================================================================== RCS file: /cvsroot/jboss/jboss-aop/src/test/org/jboss/test/aop/memoryleaks/MemoryLeakTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- MemoryLeakTestCase.java 13 Apr 2006 17:53:29 -0000 1.2 +++ MemoryLeakTestCase.java 7 Jul 2006 10:19:04 -0000 1.3 @@ -30,6 +30,8 @@ import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Enumeration; import java.util.Iterator; @@ -87,6 +89,8 @@ Class aspectManagerClass = loader.loadClass("org.jboss.aop.AspectManager"); assertNotSame(aspectManagerClass.getClassLoader(), this.getClass().getClassLoader()); + System.out.println("oldLoader"); + xmlLoader = loader.loadClass("org.jboss.aop.AspectXmlLoader"); assertNotSame(xmlLoader.getClassLoader(),loader); @@ -111,7 +115,7 @@ Thread.currentThread().setContextClassLoader(oldloader); } - assertEquals(1, countInstances("org.jboss.aop.AspectManager")); + assertEquals(1, countInstances("org.jboss.aop.AspectManager", true)); //checkUnload( weakReferenceOnLoader,"org.jboss.test.aop.memoryleaks.Test"); checkUnload( weakReferenceOnLoader, className); @@ -123,6 +127,8 @@ e.printStackTrace(); throw e; } + + System.out.println("Done!"); } private Object getTestInstance(Class testClass) throws Exception @@ -367,11 +373,20 @@ } } - private int countInstances(String name) + private int countInstances(String name, boolean notSubClasses) { JVMTIInterface jvmti = new JVMTIInterface(); - int i = jvmti.getAllObjects(name).length; - return i; + Object[] objects = jvmti.getAllObjects(name); + int subClasses = 0; + for (int i = 0 ; i < objects.length ; i++) + { + if (!objects[i].getClass().getName().equals(name)) + { + subClasses++; + } + } + + return objects.length - subClasses; } private void unregisterClassLoader(Class aspectManagerClass, ClassLoader loader) throws Exception @@ -438,7 +453,15 @@ private void undeploy(Class xmlLoader) throws Exception { - String strurl = System.getProperty("jboss.aop.path"); + String strurl = (String)AccessController.doPrivileged(new PrivilegedAction(){ + + public Object run() + { + return System.getProperty("jboss.aop.path"); + } + + }); +// String strurl = System.getProperty("jboss.aop.path"); assertNotNull("Property jboss.aop.path should be defined",strurl); strurl = strurl.replace('\\','/'); URL url = new URL("file:/" + strurl); |
From: Kabir K. <kk...@jb...> - 2006-07-07 10:17:43
|
User: kkhan Date: 06/07/07 06:17:41 Modified: src/main/org/jboss/aop/instrument TransformerCommon.java Log: Rename the jboss.aop.debug-classes system property to jboss.aop.debug.classes. If set to true, TransformerCommon will call CtClass.debugWriteFile() to output the contents of the class Revision Changes Path 1.15 +15 -1 jboss-aop/src/main/org/jboss/aop/instrument/TransformerCommon.java (In the diff below, changes in quantity of whitespace are not shown.) Index: TransformerCommon.java =================================================================== RCS file: /cvsroot/jboss/jboss-aop/src/main/org/jboss/aop/instrument/TransformerCommon.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -b -r1.14 -r1.15 --- TransformerCommon.java 29 Jun 2006 15:05:21 -0000 1.14 +++ TransformerCommon.java 7 Jul 2006 10:17:41 -0000 1.15 @@ -32,6 +32,7 @@ import java.security.PrivilegedExceptionAction; import org.jboss.aop.AOPClassPool; +import org.jboss.aop.AspectManager; import org.jboss.aop.standalone.Compiler; import javassist.CannotCompileException; @@ -43,7 +44,7 @@ /** * A few handy methods and common things used by the other Transformers * @author <a href="mailto:kab...@bi...">Kabir Khan</a> - * @version $Revision: 1.14 $ + * @version $Revision: 1.15 $ * */ public class TransformerCommon { @@ -105,6 +106,11 @@ ToClassAction.PRIVILEGED.toClass(newClass, null); } } + + if (AspectManager.debugClasses) + { + newClass.debugWriteFile(); + } } catch (Exception e) { @@ -239,6 +245,10 @@ { public Object run() throws Exception { + if (AspectManager.debugClasses) + { + clazz.debugWriteFile(); + } if (loader != null) { return clazz.toClass(loader); @@ -263,6 +273,10 @@ { public Class toClass(CtClass clazz, ClassLoader loader) throws CannotCompileException { + if (AspectManager.debugClasses) + { + clazz.debugWriteFile(); + } if (loader != null) { return clazz.toClass(loader); |
From: Kabir K. <kk...@jb...> - 2006-07-07 10:17:43
|
User: kkhan Date: 06/07/07 06:17:41 Modified: src/main/org/jboss/aop AspectManager.java Log: Rename the jboss.aop.debug-classes system property to jboss.aop.debug.classes. If set to true, TransformerCommon will call CtClass.debugWriteFile() to output the contents of the class Revision Changes Path 1.163 +4 -4 jboss-aop/src/main/org/jboss/aop/AspectManager.java (In the diff below, changes in quantity of whitespace are not shown.) Index: AspectManager.java =================================================================== RCS file: /cvsroot/jboss/jboss-aop/src/main/org/jboss/aop/AspectManager.java,v retrieving revision 1.162 retrieving revision 1.163 diff -u -b -r1.162 -r1.163 --- AspectManager.java 30 Jun 2006 10:34:42 -0000 1.162 +++ AspectManager.java 7 Jul 2006 10:17:41 -0000 1.163 @@ -90,7 +90,7 @@ * to do that. * * @author <a href="mailto:bi...@jb...">Bill Burke</a> - * @version $Revision: 1.162 $ + * @version $Revision: 1.163 $ */ public class AspectManager implements Translator @@ -319,7 +319,7 @@ String advisorName = System.getProperty("jboss.aop.advisor", null); AdvisorFactory.initialise(advisorName); - String debugClass = System.getProperty("jboss.aop.debug-classes", null); + String debugClass = System.getProperty("jboss.aop.debug.classes", null); if (debugClass != null) { debugClasses = (new Boolean(debugClass)).booleanValue(); @@ -765,11 +765,11 @@ } catch(NoSuchFieldException e) { - System.out.println("[warn] Error unsetting advisor for " + advisedClass.getName() + e); + System.out.println("[warn] Error unsetting advisor for " + advisedClass.getName() + " " + e); } catch(IllegalAccessException e) { - System.out.println("[warn] Error unsetting advisor for " + advisedClass.getName() + e); + System.out.println("[warn] Error unsetting advisor for " + advisedClass.getName() + " " + e); } } } |