[infinispan-commits] Infinispan SVN: r102 - trunk/core/src/main/java/org/infinispan/factories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Wed Apr 8 12:41:26 EDT 2009
Author: galder.zamarreno at jboss.com
Date: 2009-04-08 12:41:26 -0400 (Wed, 08 Apr 2009)
New Revision: 102
Added:
trunk/core/src/main/java/org/infinispan/factories/MarshallerFactory.java
Modified:
trunk/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java
trunk/core/src/main/java/org/infinispan/factories/EmptyConstructorFactory.java
Log:
[ISPN-51] (Create a Marshaller component factory) Factory added and registered in ACR; Cleaned up ECF.
Modified: trunk/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java 2009-04-08 16:29:43 UTC (rev 101)
+++ trunk/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java 2009-04-08 16:41:26 UTC (rev 102)
@@ -152,6 +152,7 @@
s.add(DataContainerFactory.class);
s.add(NamedExecutorsFactory.class);
s.add(TransportFactory.class);
+ s.add(MarshallerFactory.class);
return s;
}
Modified: trunk/core/src/main/java/org/infinispan/factories/EmptyConstructorFactory.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/factories/EmptyConstructorFactory.java 2009-04-08 16:29:43 UTC (rev 101)
+++ trunk/core/src/main/java/org/infinispan/factories/EmptyConstructorFactory.java 2009-04-08 16:41:26 UTC (rev 102)
@@ -5,8 +5,6 @@
import org.infinispan.factories.annotations.DefaultFactoryFor;
import org.infinispan.factories.scopes.Scope;
import org.infinispan.factories.scopes.Scopes;
-import org.infinispan.marshall.Marshaller;
-import org.infinispan.marshall.VersionAwareMarshaller;
import org.infinispan.notifications.cachemanagerlistener.CacheManagerNotifier;
import org.infinispan.remoting.InboundInvocationHandler;
@@ -14,21 +12,16 @@
* Factory for building global-scope components which have default empty constructors
*
* @author Manik Surtani
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
* @since 4.0
*/
- at DefaultFactoryFor(classes = {InboundInvocationHandler.class, CacheManagerNotifier.class, Marshaller.class, RemoteCommandFactory.class})
+ at DefaultFactoryFor(classes = {InboundInvocationHandler.class, CacheManagerNotifier.class, RemoteCommandFactory.class})
@Scope(Scopes.GLOBAL)
public class EmptyConstructorFactory extends AbstractComponentFactory implements AutoInstantiableFactory {
public <T> T construct(Class<T> componentType) {
try {
if (componentType.isInterface()) {
- Class componentImpl;
- if (componentType.equals(Marshaller.class)) {
- componentImpl = VersionAwareMarshaller.class;
- } else {
- // add an "Impl" to the end of the class name and try again
- componentImpl = getClass().getClassLoader().loadClass(componentType.getName() + "Impl");
- }
+ Class componentImpl = getClass().getClassLoader().loadClass(componentType.getName() + "Impl");
return componentType.cast(componentImpl.newInstance());
} else {
return componentType.newInstance();
Added: trunk/core/src/main/java/org/infinispan/factories/MarshallerFactory.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/factories/MarshallerFactory.java (rev 0)
+++ trunk/core/src/main/java/org/infinispan/factories/MarshallerFactory.java 2009-04-08 16:41:26 UTC (rev 102)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.infinispan.factories;
+
+import org.infinispan.config.ConfigurationException;
+import org.infinispan.factories.annotations.DefaultFactoryFor;
+import org.infinispan.marshall.Marshaller;
+import org.infinispan.util.Util;
+
+/**
+ * MarshallerFactory.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ * @since 4.0
+ */
+ at DefaultFactoryFor(classes = Marshaller.class)
+public class MarshallerFactory extends EmptyConstructorFactory implements AutoInstantiableFactory {
+ @Override
+ public <T> T construct(Class<T> componentType) {
+ try {
+ return componentType.cast(Util.getInstance(globalConfiguration.getMarshallerClass()));
+ } catch (Exception e) {
+ throw new ConfigurationException("Unable to create component " + componentType, e);
+ }
+ }
+}
More information about the infinispan-commits
mailing list