[jboss-cvs] JBossAS SVN: r67629 - trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Nov 29 16:16:11 EST 2007
Author: ALRubinger
Date: 2007-11-29 16:16:11 -0500 (Thu, 29 Nov 2007)
New Revision: 67629
Added:
trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactoryNotRegisteredException.java
trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactoryRegistry.java
Log:
[EJBTHREE-1134] Added PersistenceManagerFactory to get around @PersistenceManager(Class) leak
Added: trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactory.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactory.java 2007-11-29 21:16:11 UTC (rev 67629)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.cache.persistence;
+
+import org.jboss.ejb3.cache.simple.StatefulSessionPersistenceManager;
+
+/**
+ * Defines contract for an EJB3 Persistence Manager Factory
+ *
+ * @author <a href="mailto:andrew.rubinger at redhat.com">ALR</a>
+ * @version $Revision: $
+ */
+public interface PersistenceManagerFactory
+{
+ StatefulSessionPersistenceManager createPersistenceManager();
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactoryNotRegisteredException.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactoryNotRegisteredException.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactoryNotRegisteredException.java 2007-11-29 21:16:11 UTC (rev 67629)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.cache.persistence;
+
+/**
+ * PoolFactoryNotRegisteredException
+ *
+ * Thrown when attempting to retrieve a pool factory with
+ * unrecognized name from the registry
+ *
+ * @author <a href="mailto:andrew.rubinger at redhat.com">ALR</a>
+ * @version $Revision: $
+ */
+public class PersistenceManagerFactoryNotRegisteredException extends Exception
+{
+
+ // Class Members
+ private static final long serialVersionUID = -881723607135494483L;
+
+ // Constructors
+
+ public PersistenceManagerFactoryNotRegisteredException()
+ {
+ super();
+ }
+
+ public PersistenceManagerFactoryNotRegisteredException(String message)
+ {
+ super(message);
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactoryNotRegisteredException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactoryRegistry.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactoryRegistry.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactoryRegistry.java 2007-11-29 21:16:11 UTC (rev 67629)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.cache.persistence;
+
+import java.util.Map;
+
+/**
+ * Registry for all configured PersistenceManager Factory implementations
+ *
+ * @author <a href="mailto:andrew.rubinger at redhat.com">ALR</a>
+ * @version $Revision: $
+ */
+public class PersistenceManagerFactoryRegistry
+{
+ // Instance Members
+ private Map<String, Class<? extends PersistenceManagerFactory>> factories;
+
+ // Accessors / Mutators
+
+ public Map<String, Class<? extends PersistenceManagerFactory>> getFactories()
+ {
+ return factories;
+ }
+
+ public void setFactories(Map<String, Class<? extends PersistenceManagerFactory>> factories)
+ {
+ this.factories = factories;
+ }
+
+ // Functional Methods
+
+ /**
+ * Obtains the Persistence Manager Factory with the specified registered name
+ *
+ * @param name The registered name of the factory to retrieve
+ * @return The Persistence Manager Factory
+ */
+ public PersistenceManagerFactory getPersistenceManagerFactory(String name) throws PersistenceManagerFactoryNotRegisteredException
+ {
+ // Obtain cache factory
+ Class<? extends PersistenceManagerFactory> persistenceManagerFactory = this.factories.get(name);
+
+ // Ensure registered
+ if (persistenceManagerFactory == null)
+ {
+ throw new PersistenceManagerFactoryNotRegisteredException("PersistenceManager Factory with name " + name + " is not registered.");
+ }
+
+ try
+ {
+ // Return
+ return persistenceManagerFactory.newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new RuntimeException("Error in instanciating persistence manager factory " + persistenceManagerFactory.getName(), e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/cache/persistence/PersistenceManagerFactoryRegistry.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the jboss-cvs-commits
mailing list