diff --git a/.gitignore b/.gitignore
index ca1375d78..100f9fe0b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,3 +43,5 @@ target/
# Misc
*.swp
+*.log
+*.epoch
diff --git a/exo.kernel.commons/pom.xml b/exo.kernel.commons/pom.xml
index b0643c815..89e74cc05 100644
--- a/exo.kernel.commons/pom.xml
+++ b/exo.kernel.commons/pom.xml
@@ -58,16 +58,6 @@
-
- org.ogce
- xpp3
-
-
- junit
- junit
-
-
-
org.slf4j
@@ -98,7 +88,7 @@
maven-surefire-plugin
- @{argLine} ${env.MAVEN_OPTS} -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy
+ @{argLine} -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy
diff --git a/exo.kernel.commons/src/main/java/org/exoplatform/commons/xml/ExoXMLSerializer.java b/exo.kernel.commons/src/main/java/org/exoplatform/commons/xml/ExoXMLSerializer.java
deleted file mode 100644
index b905c18d3..000000000
--- a/exo.kernel.commons/src/main/java/org/exoplatform/commons/xml/ExoXMLSerializer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.commons.xml;
-
-import org.xmlpull.mxp1_serializer.MXSerializer;
-
-/**
- * Jul 8, 2004
- *
- * @author Tuan Nguyen
- * @version $Id: ExoXMLSerializer.java,v 1.1 2004/07/08 19:24:47 tuan08 Exp $
- */
-public class ExoXMLSerializer extends MXSerializer
-{
- final static public String INDENTATION = "http://xmlpull.org/v1/doc/properties.html#serializer-indentation";
-
- final static public String LINE_SEPARATOR = "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator";
-
- public void element(String ns, String tag, String text) throws Exception
- {
- if (text == null)
- return;
- startTag(ns, tag);
- text(text);
- endTag(ns, tag);
- }
-
- static public ExoXMLSerializer getInstance()
- {
- ExoXMLSerializer ser = new ExoXMLSerializer();
- ser.setProperty(ExoXMLSerializer.INDENTATION, " ");
- ser.setProperty(ExoXMLSerializer.LINE_SEPARATOR, "\n");
- return ser;
- }
-}
diff --git a/exo.kernel.commons/src/main/java/org/exoplatform/commons/xml/ExoXPPParser.java b/exo.kernel.commons/src/main/java/org/exoplatform/commons/xml/ExoXPPParser.java
deleted file mode 100644
index 09dc47e1d..000000000
--- a/exo.kernel.commons/src/main/java/org/exoplatform/commons/xml/ExoXPPParser.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.commons.xml;
-
-import org.xmlpull.mxp1.MXParserCachingStrings;
-import org.xmlpull.v1.XmlPullParser;
-
-/**
- * Jul 8, 2004
- *
- * @author Tuan Nguyen
- * @version $Id: ExoXPPParser.java,v 1.4 2004/10/20 20:58:27 tuan08 Exp $
- */
-public class ExoXPPParser extends MXParserCachingStrings
-{
- private String[] nodeAttributeName_ = new String[20];
-
- private String[] nodeAttributeValue_ = new String[20];
-
- private int nodeAttributeCount_;
-
- public boolean node(String name) throws Exception
- {
- if (this.eventType == XmlPullParser.END_DOCUMENT)
- return false;
- while (this.eventType != XmlPullParser.START_TAG)
- {
- next();
- if (this.eventType == XmlPullParser.END_DOCUMENT)
- return false;
- }
- if (getName().equals(name))
- {
- copyAttributes();
- next();
- return true;
- }
- return false;
- }
-
- public String nodeContent(String name) throws Exception
- {
- if (node(name))
- return getContent();
- return null;
- }
-
- public void endNode(String name) throws Exception
- {
- while (!(this.eventType == XmlPullParser.END_TAG && name.equals(getName())))
- {
- nextTag();
- }
- }
-
- public void mandatoryNode(String name) throws Exception
- {
- if (this.eventType == XmlPullParser.END_DOCUMENT)
- {
- throw new Exception("expect tag name " + name + ", but end of document");
- }
- while (this.eventType != XmlPullParser.START_TAG)
- {
- next();
- if (this.eventType == XmlPullParser.END_DOCUMENT)
- {
- throw new Exception("expect tag name " + name + ", but end of document");
- }
- }
- if (!getName().equals(name))
- {
- throw new Exception("expect tag name " + name + ", but find " + getName());
- }
- copyAttributes();
- next();
- }
-
- public String mandatoryNodeContent(String name) throws Exception
- {
- mandatoryNode(name);
- return getContent();
- }
-
- public String getContent() throws Exception
- {
- if (this.eventType != TEXT)
- {
- return null; // throw new Exception("Not a text node, name : " +
- // getName()) ;
- }
- return this.getText();
- }
-
- public String getNodeAttributeValue(String name)
- {
- for (int i = 0; i < nodeAttributeCount_; i++)
- {
- if (name.equals(nodeAttributeName_[i]))
- return nodeAttributeValue_[i];
- }
- return null;
- }
-
- private void copyAttributes()
- {
- for (int i = 0; i < this.attributeCount; i++)
- {
- nodeAttributeName_[i] = this.attributeName[i];
- nodeAttributeValue_[i] = this.attributeValue[i];
- }
- nodeAttributeCount_ = this.attributeCount;
- }
-
- static public ExoXPPParser getInstance() throws Exception
- {
- return new ExoXPPParser();
- }
-}
diff --git a/exo.kernel.component.cache/pom.xml b/exo.kernel.component.cache/pom.xml
index 5147f7b21..d5ca63141 100644
--- a/exo.kernel.component.cache/pom.xml
+++ b/exo.kernel.component.cache/pom.xml
@@ -64,7 +64,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- @{argLine} ${env.MAVEN_OPTS} -Djava.net.preferIPv4Stack=true -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy
+ @{argLine} -Djava.net.preferIPv4Stack=true -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy
diff --git a/exo.kernel.component.command/pom.xml b/exo.kernel.component.command/pom.xml
index bdabe39a7..48b3a525d 100644
--- a/exo.kernel.component.command/pom.xml
+++ b/exo.kernel.component.command/pom.xml
@@ -75,7 +75,7 @@
maven-antrun-plugin
- ${env.MAVEN_OPTS} -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy
+ @{argLine} -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy
diff --git a/exo.kernel.component.common/pom.xml b/exo.kernel.component.common/pom.xml
index 212f674ce..448de64b1 100644
--- a/exo.kernel.component.common/pom.xml
+++ b/exo.kernel.component.common/pom.xml
@@ -150,7 +150,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- @{argLine} ${env.MAVEN_OPTS} -Djava.net.preferIPv4Stack=true -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy
+ @{argLine} -Djava.net.preferIPv4Stack=true -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy
diff --git a/exo.kernel.component.ext.cache.impl.infinispan.v8/pom.xml b/exo.kernel.component.ext.cache.impl.infinispan.v8/pom.xml
index fd72630dc..cf4145410 100644
--- a/exo.kernel.component.ext.cache.impl.infinispan.v8/pom.xml
+++ b/exo.kernel.component.ext.cache.impl.infinispan.v8/pom.xml
@@ -99,7 +99,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- @{argLine} ${env.MAVEN_OPTS} --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED -Djava.net.preferIPv4Stack=true -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy
+ @{argLine} --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED -Djava.net.preferIPv4Stack=true -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy
diff --git a/exo.kernel.component.ext.cache.impl.memcached.v1/pom.xml b/exo.kernel.component.ext.cache.impl.memcached.v1/pom.xml
deleted file mode 100644
index 5e09005a9..000000000
--- a/exo.kernel.component.ext.cache.impl.memcached.v1/pom.xml
+++ /dev/null
@@ -1,130 +0,0 @@
-
-
-
-
- 4.0.0
-
- org.exoplatform.kernel
- kernel-parent
- 6.5.x-SNAPSHOT
-
- exo.kernel.component.ext.cache.impl.memcached.v1
- eXo PLF:: Kernel :: Cache Extension :: Memcached Implementation
- Memcached Implementation of Cache Service for Exoplatform SAS 'eXo Kernel' project.
-
-
- true
- 127.0.0.1:11211
-
-
-
- org.exoplatform.kernel
- exo.kernel.commons.test
- test
-
-
- org.exoplatform.kernel
- exo.kernel.container
-
-
- org.exoplatform.kernel
- exo.kernel.component.cache
-
-
- net.spy
- spymemcached
-
-
- org.apache.ws.commons
- ws-commons-util
-
-
- xml-apis
- xml-apis
-
-
- junit
- junit
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- @{argLine} ${env.MAVEN_OPTS} -Djava.net.preferIPv4Stack=true -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy
-
-
- memcached.locations
- ${memcached.locations}
-
-
-
-
-
- maven-antrun-plugin
-
-
- prepare-test-policy
- process-test-resources
-
-
- Creating Access Policy for tests
-
-
-
-
-
-
-
-
-
-
-
-
-
- run
-
-
-
-
-
- ant
- ant-optional
- 1.5.3-1
-
-
-
-
-
-
-
- test
-
- false
-
-
-
-
diff --git a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/BinaryConnectionFactoryCreator.java b/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/BinaryConnectionFactoryCreator.java
deleted file mode 100644
index de8e2b459..000000000
--- a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/BinaryConnectionFactoryCreator.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2013 eXo Platform SAS.
- *
- * 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.exoplatform.services.cache.impl.memcached;
-
-import net.spy.memcached.BinaryConnectionFactory;
-import net.spy.memcached.ConnectionFactory;
-import net.spy.memcached.DefaultConnectionFactory;
-import net.spy.memcached.DefaultHashAlgorithm;
-
-/**
- * The {@link ConnectionFactoryCreator} that will create {@link BinaryConnectionFactory} instances
- *
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public class BinaryConnectionFactoryCreator implements ConnectionFactoryCreator
-{
- /**
- * The length of the queue
- */
- protected int queueLength = DefaultConnectionFactory.DEFAULT_OP_QUEUE_LEN;
-
- /**
- * The buffer size
- */
- protected int bufferSize = DefaultConnectionFactory.DEFAULT_READ_BUFFER_SIZE;
-
- /**
- * The algorithm to use for hashing
- */
- protected String hash;
-
- /**
- * {@inheritDoc}
- */
- public ConnectionFactory create()
- {
- return new BinaryConnectionFactory(queueLength, bufferSize, hash == null ? DefaultConnectionFactory.DEFAULT_HASH
- : DefaultHashAlgorithm.valueOf(hash));
- }
-}
diff --git a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/ConnectionFactoryCreator.java b/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/ConnectionFactoryCreator.java
deleted file mode 100644
index 687b0af20..000000000
--- a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/ConnectionFactoryCreator.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2013 eXo Platform SAS.
- *
- * 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.exoplatform.services.cache.impl.memcached;
-
-import net.spy.memcached.ConnectionFactory;
-
-/**
- * This defines a creator of {@link ConnectionFactory}
- *
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public interface ConnectionFactoryCreator
-{
- /**
- * Creates an instance of a {@link ConnectionFactory}
- * @return a new instance of a {@link ConnectionFactory}
- */
- ConnectionFactory create();
-}
diff --git a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/ExoCacheFactoryConfigPlugin.java b/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/ExoCacheFactoryConfigPlugin.java
deleted file mode 100644
index acc85b110..000000000
--- a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/ExoCacheFactoryConfigPlugin.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.services.cache.impl.memcached;
-
-import org.exoplatform.container.component.BaseComponentPlugin;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.ValueParam;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * This class is used to define custom configurations
- *
- * Created by The eXo Platform SAS
- * Author : eXoPlatform
- * exo@exoplatform.com
- * 23 juil. 2009
- */
-public class ExoCacheFactoryConfigPlugin extends BaseComponentPlugin
-{
-
- /**
- * The map of all the creators defined for this ComponentPlugin
- */
- private final Map configs;
-
- public ExoCacheFactoryConfigPlugin(InitParams params)
- {
- configs = new HashMap();
- for (Iterator iterator = params.getValueParamIterator(); iterator.hasNext();)
- {
- ValueParam vParam = iterator.next();
- configs.put(vParam.getName(), vParam.getValue());
- }
- }
-
- /**
- * Returns all the configurations defined for this ComponentPlugin
- */
- public Map getConfigs()
- {
- return configs;
- }
-}
diff --git a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/ExoCacheFactoryImpl.java b/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/ExoCacheFactoryImpl.java
deleted file mode 100644
index 902aa4481..000000000
--- a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/ExoCacheFactoryImpl.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.services.cache.impl.memcached;
-
-import net.spy.memcached.AddrUtil;
-import net.spy.memcached.BinaryConnectionFactory;
-import net.spy.memcached.MemcachedClient;
-
-import org.exoplatform.commons.utils.SecurityHelper;
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.ObjectParameter;
-import org.exoplatform.container.xml.ValueParam;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.exoplatform.services.cache.ExoCacheFactory;
-import org.exoplatform.services.cache.ExoCacheInitException;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.picocontainer.Startable;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.security.PrivilegedExceptionAction;
-import java.util.List;
-
-/**
- * This class is the Memcached implementation of the {@link org.exoplatform.services.cache.ExoCacheFactory}
- *
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public class ExoCacheFactoryImpl implements ExoCacheFactory, Startable
-{
-
- /**
- * The logger
- */
- private static final Log LOG = ExoLogger
- .getLogger("exo.kernel.component.ext.cache.impl.memcached.v1.ExoCacheFactoryImpl");
-
- /**
- * The parameter key that defines the {@link ConnectionFactoryCreator}
- */
- public static final String CONNECTION_FACTORY_CREATOR = "connection.factory.creator";
-
- /**
- * The parameter key that defines the memcache locations
- */
- public static final String MEMCACHED_LOCATIONS = "memcached.locations";
-
- /**
- * The parameter key that defines the default expiration timeout
- */
- public static final String DEFAULT_EXPIRATION_TIMEOUT = "default.expiration.timeout";
-
- /**
- * The default expiration timeout, set to 15 minutes
- */
- public static final long DEFAULT_EXPIRATION_TIMEOUT_VALUE = 15 * 60 * 1000L;
-
- /**
- * The current {@link ExoContainerContext}
- */
- private final ExoContainerContext ctx;
-
- /**
- * The memcached client
- */
- private final MemcachedClient cache;
-
- /**
- * The cache creator
- */
- private final MCExoCacheCreator cacheCreator;
-
- /**
- * The default constructor
- */
- public ExoCacheFactoryImpl(ExoContainerContext ctx, final InitParams params) throws IOException
- {
- this.ctx = ctx;
- ValueParam locations;
- if (params == null || (locations = params.getValueParam(MEMCACHED_LOCATIONS)) == null
- || locations.getValue() == null || locations.getValue().isEmpty())
- {
- throw new IllegalArgumentException("The parameter '" + MEMCACHED_LOCATIONS + "' cannot be null or empty");
- }
- final List isaLocations = AddrUtil.getAddresses(locations.getValue());
- this.cache = SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction()
- {
- public MemcachedClient run() throws IOException
- {
- ObjectParameter op = params.getObjectParam(CONNECTION_FACTORY_CREATOR);
- if (op == null || op.getObject() == null)
- {
- LOG.debug("No connection factory creator has been defined, "
- + "so we will use the BinaryConnectionFactory by default");
- return new MemcachedClient(new BinaryConnectionFactory(), isaLocations);
- }
- else if (!(op.getObject() instanceof ConnectionFactoryCreator))
- {
- throw new IllegalArgumentException("The parameter '" + CONNECTION_FACTORY_CREATOR
- + "' must refer to a ConnectionFactoryCreator.");
- }
- else
- {
- return new MemcachedClient(((ConnectionFactoryCreator)op.getObject()).create(), isaLocations);
- }
- }
- });
-
- ValueParam vp = params.getValueParam(DEFAULT_EXPIRATION_TIMEOUT);
- if (vp == null || vp.getValue() == null || vp.getValue().isEmpty())
- {
- LOG.debug("No default expiration timeout has been defined");
- this.cacheCreator = new MCExoCacheCreator(DEFAULT_EXPIRATION_TIMEOUT_VALUE);
- }
- else
- {
- this.cacheCreator = new MCExoCacheCreator(Long.parseLong(vp.getValue()));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("rawtypes")
- public ExoCache createCache(ExoCacheConfig config) throws ExoCacheInitException
- {
- return cacheCreator.create(ctx, config, cache);
- }
-
- /**
- * {@inheritDoc}
- */
- public void start()
- {
- }
-
- /**
- * {@inheritDoc}
- */
- public void stop()
- {
- cache.shutdown();
- }
-}
diff --git a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/MCExoCache.java b/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/MCExoCache.java
deleted file mode 100644
index cfb303818..000000000
--- a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/MCExoCache.java
+++ /dev/null
@@ -1,790 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.services.cache.impl.memcached;
-
-import net.spy.memcached.CASValue;
-import net.spy.memcached.MemcachedClient;
-import net.spy.memcached.internal.OperationFuture;
-
-import org.apache.ws.commons.util.Base64;
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.management.annotations.Managed;
-import org.exoplatform.management.annotations.ManagedDescription;
-import org.exoplatform.management.annotations.ManagedName;
-import org.exoplatform.services.cache.CacheInfo;
-import org.exoplatform.services.cache.CacheListener;
-import org.exoplatform.services.cache.CacheListenerContext;
-import org.exoplatform.services.cache.CachedObjectSelector;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
- * An {@link org.exoplatform.services.cache.ExoCache} implementation based on spymemcached.
- *
- * @author Nicolas Filotto
- * @version $Id$
- */
-public class MCExoCache implements ExoCache
-{
-
- /**
- * Logger.
- */
- private static final Log LOG = ExoLogger//NOSONAR
- .getLogger("exo.kernel.component.ext.cache.impl.memcached.v1.AbstractExoCache");//NOSONAR
-
- private final AtomicInteger hits = new AtomicInteger(0);
-
- private final AtomicInteger misses = new AtomicInteger(0);
-
- private final AtomicInteger count = new AtomicInteger(0);
-
- private final AtomicReference lastNamespace = new AtomicReference();
-
- private String label;
-
- private String name;
-
- private final String fullName;
-
- private boolean distributed;
-
- private boolean replicated;
-
- private boolean logEnabled;
-
- private int expirationTimeout;
-
- protected final MemcachedClient cache;
-
- @SuppressWarnings("rawtypes")
- private static final ConcurrentMap> ALL_LISTENERS =
- new ConcurrentHashMap>();
-
- public MCExoCache(ExoContainerContext ctx, ExoCacheConfig config, MemcachedClient cache, long expirationTimeout)
- {
- this.fullName = ctx.getName() + "-" + config.getName();
- this.cache = cache;
- this.expirationTimeout = (int)(expirationTimeout / 1000L);
- setDistributed(config.isDistributed());
- setLabel(config.getLabel());
- setName(config.getName());
- setLogEnabled(config.isLogEnabled());
- setReplicated(config.isRepicated());
- }
-
- /**
- * @return the fullName
- */
- String getFullName()
- {
- return fullName;
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("rawtypes")
- public void addCacheListener(CacheListener super K, ? super V> listener)
- {
- if (listener == null)
- {
- throw new IllegalArgumentException("The listener cannot be null");
- }
- List lListeners = getOrCreateListeners();
- lListeners.add(new ListenerContext(listener, this));
- }
-
- @SuppressWarnings("rawtypes")
- private List getOrCreateListeners()
- {
- List lListeners = getListeners();
- if (lListeners == null)
- {
- lListeners = new CopyOnWriteArrayList();
- List oldValue = ALL_LISTENERS.putIfAbsent(fullName, lListeners);
- if (oldValue != null)
- {
- lListeners = oldValue;
- }
- }
- return lListeners;
- }
-
- @SuppressWarnings("rawtypes")
- private List getListeners()
- {
- return ALL_LISTENERS.get(fullName);
- }
-
- /**
- * Tries at worse 3 times to get the namespace
- * @return
- */
- private String getNamespace()
- {
- return getNamespace(3);
- }
-
- /**
- * Gives the namespace to use as prefix for our key in order to allow invalidation of a cache
- * @param triesLeft the total amount of tries left in case of a failure
- * @return the namespace
- */
- private String getNamespace(int triesLeft)
- {
- String oldNamespace = lastNamespace.get();
- CASValue casValue = cache.getAndTouch(fullName, expirationTimeout);
- String value;
- if (casValue == null || casValue.getValue() == null)
- {
- value = UUID.randomUUID().toString();
- OperationFuture resp = cache.add(fullName, expirationTimeout, value);
- Boolean result = null;
- try
- {
- result = resp.get();
- }
- catch (InterruptedException e)
- {
- LOG.error("Could not get the namespace", e);
- }
- catch (ExecutionException e)
- {
- LOG.error("Could not get the namespace", e);
- }
- if (result == null || !result.booleanValue())
- {
- if (result == null && triesLeft == 0)
- {
- throw new RuntimeException("The namespace could not be found");
- }
- LOG.debug("Could not get the namespace, so we need to retry");
- return getNamespace(triesLeft - 1);
- }
- }
- else
- {
- value = (String)casValue.getValue();
- }
- if (lastNamespace.compareAndSet(oldNamespace, value) && oldNamespace != null && !oldNamespace.equals(value))
- {
- // The namespace has changed so we reset the counter as it could be due to
- // a remote clear cache
- count.set(0);
- }
- return value;
- }
-
- /**
- * Gives the name of the key with the prefix
- * @param name the name of the key without the prefix
- * @return the full name of the key
- */
- private String getKeyFullName(Serializable name)
- {
- return getKeyFullName(getNamespace(), name);
- }
-
- /**
- * Gives the name of the key with the prefix
- *
- * @param namespace the namespace to use
- * @param name the name of the key without the prefix
- * @return the full name of the key
- */
- private String getKeyFullName(String namespace, Serializable name)
- {
- StringBuilder sb = new StringBuilder();
- sb.append(namespace);
- sb.append(':');
- sb.append(toString(name));
- return sb.toString();
- }
-
- /**
- * Used to serialize the key
- * @param key the key to serialize
- * @return the value of the key serialized in Base64
- */
- private static String toString(Serializable key)
- {
- if (key instanceof String)
- return (String)key;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = null;
- try
- {
- oos = new ObjectOutputStream(baos);
- oos.writeObject(key);
- }
- catch (IOException e)
- {
- throw new RuntimeException("Could not serialize the key " + key, e);
- }
- finally
- {
- if (oos != null)
- {
- try
- {
- oos.close();
- }
- catch (IOException e)
- {
- LOG.trace("Could not close the object output stream", e);
- }
- }
- }
- return Base64.encode(baos.toByteArray());
- }
-
- /**
- * {@inheritDoc}
- */
- public void clearCache()
- {
- // As it is not possible to clear a particular cache, we simply change the namespace as
- // described in the doc https://code.google.com/p/memcached/wiki/NewProgrammingTricks#Namespacing
- String namespace = UUID.randomUUID().toString();
- String oldNamespace = lastNamespace.get();
- OperationFuture resp = cache.set(fullName, expirationTimeout, namespace);
- Boolean result;
- try
- {
- result = resp.get();
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not clear the cache ", e);
- }
- if (result != null && result.booleanValue())
- {
- lastNamespace.compareAndSet(oldNamespace, namespace);
- count.set(0);
- onClearCache();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public V get(Serializable name)
- {
- if (name == null)
- {
- return null;
- }
- CASValue casValue = cache.getAndTouch(getKeyFullName(name), expirationTimeout);
- V result = casValue == null ? null : (V)casValue.getValue();
- if (result == null)
- {
- misses.incrementAndGet();
- }
- else
- {
- hits.incrementAndGet();
- }
- onGet((K)name, result);
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getCacheHit()
- {
- return hits.get();
- }
-
- /**
- * {@inheritDoc}
- */
- public int getCacheMiss()
- {
- return misses.get();
- }
-
- /**
- * {@inheritDoc}
- */
- @Managed
- @ManagedName("Size")
- @ManagedDescription("The local cache size as it is not possible to get the global cache size")
- public int getCacheSize()
- {
- return count.get();
- }
-
- /**
- * {@inheritDoc}
- */
- public List getCachedObjects()
- {
- throw new UnsupportedOperationException("Cannot get the cached objects");
- }
-
- /**
- * {@inheritDoc}
- */
- public String getLabel()
- {
- return label;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isDistributed()
- {
- return distributed;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isLogEnabled()
- {
- return logEnabled;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isReplicated()
- {
- return replicated;
- }
-
- /**
- * {@inheritDoc}
- */
- public void put(final K key, final V value) throws IllegalArgumentException
- {
- if (key == null)
- {
- throw new IllegalArgumentException("No null cache key accepted");
- }
- else if (value == null)
- {
- // ignore null values
- return;
- }
- putOnly(getNamespace(), key, value);
- onPut(key, value);
- }
-
- /**
- * Only puts the data into the cache nothing more
- */
- protected void putOnly(String namespace, K key, V value)
- {
- OperationFuture resp = cache.add(getKeyFullName(namespace, key), expirationTimeout, value);
- Boolean result;
- try
- {
- result = resp.get();
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not add the new value for the key " + key, e);
- }
- if (result == null || !result.booleanValue())
- {
- // The value already exists in the cache so we simply replace it
- resp = cache.replace(getKeyFullName(namespace, key), expirationTimeout, value);
- try
- {
- result = resp.get();
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not replace the old value of the key " + key, e);
- }
- if (result == null || !result.booleanValue())
- {
- // we try again
- putOnly(namespace, key, value);
- }
- }
- else if (namespace.equals(lastNamespace.get()))
- {
- // A new value has been added and the namespace has not been modified during the process
- count.incrementAndGet();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void putMap(final Map extends K, ? extends V> objs) throws IllegalArgumentException
- {
- if (objs == null)
- {
- throw new IllegalArgumentException("No null map accepted");
- }
- for (Serializable name : objs.keySet())
- {
- if (name == null)
- {
- throw new IllegalArgumentException("No null cache key accepted");
- }
- }
- try
- {
- String namespace = getNamespace();
- for (Map.Entry extends K, ? extends V> entry : objs.entrySet())
- {
- putOnly(namespace, entry.getKey(), entry.getValue());
- onPut(entry.getKey(), entry.getValue());
- }
- }
- catch (Exception e)//NOSONAR
- {
- LOG.warn("An error occurs while executing the putMap method", e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public V remove(Serializable name) throws IllegalArgumentException
- {
- if (name == null)
- {
- throw new IllegalArgumentException("No null cache key accepted");
- }
- String namespace = getNamespace();
- V value = (V)cache.get(getKeyFullName(namespace, name));
- OperationFuture resp = cache.delete(getKeyFullName(namespace, name));
- Boolean result;
- try
- {
- result = resp.get();
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not remove the value for the key " + name, e);
- }
- if (result != null && result.booleanValue())
- {
- if (namespace.equals(lastNamespace.get()))
- {
- // The value has been removed successfully and the namespace has not been modified during the process
- count.decrementAndGet();
- }
- onRemove((K)name, value);
- }
- return value;
- }
-
- /**
- * {@inheritDoc}
- */
- public List removeCachedObjects()
- {
- final List list = getCachedObjects();
- clearCache();
- return list;
- }
-
- /**
- * {@inheritDoc}
- */
- public void select(CachedObjectSelector super K, ? super V> selector) throws Exception
- {
- throw new UnsupportedOperationException("Cannot select a sub part of the cache dynamically");
- }
-
- /**
- * {@inheritDoc}
- */
- public void setDistributed(boolean distributed)
- {
- this.distributed = distributed;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setLabel(String label)
- {
- this.label = label;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setLogEnabled(boolean logEnabled)
- {
- this.logEnabled = logEnabled;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setName(String name)
- {
- this.name = name;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setReplicated(boolean replicated)
- {
- this.replicated = replicated;
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- public void onExpire(K key, V obj)
- {
- List listeners = getListeners();
- if (listeners == null || listeners.isEmpty())
- {
- return;
- }
- for (ListenerContext context : listeners)
- {
- try
- {
- context.onExpire(key, obj);
- }
- catch (Exception e)//NOSONAR
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- public void onRemove(K key, V obj)
- {
- List listeners = getListeners();
- if (listeners == null || listeners.isEmpty())
- {
- return;
- }
- for (ListenerContext context : listeners)
- {
- try
- {
- context.onRemove(key, obj);
- }
- catch (Exception e)//NOSONAR
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- public void onPut(K key, V obj)
- {
- List listeners = getListeners();
- if (listeners == null || listeners.isEmpty())
- {
- return;
- }
- for (ListenerContext context : listeners)
- {
- try
- {
- context.onPut(key, obj);
- }
- catch (Exception e)//NOSONAR
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- public void onGet(K key, V obj)
- {
- List listeners = getListeners();
- if (listeners == null || listeners.isEmpty())
- {
- return;
- }
- for (ListenerContext context : listeners)
- {
- try
- {
- context.onGet(key, obj);
- }
- catch (Exception e)//NOSONAR
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
- }
-
- @SuppressWarnings("rawtypes")
- public void onClearCache()
- {
- List listeners = getListeners();
- if (listeners == null || listeners.isEmpty())
- {
- return;
- }
- for (ListenerContext context : listeners)
- {
- try
- {
- context.onClearCache();
- }
- catch (Exception e)//NOSONAR
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
- }
-
- private static class ListenerContext implements CacheListenerContext, CacheInfo
- {
-
- /** . */
- private final ExoCache cache;
-
- /** . */
- final CacheListener super K, ? super V> listener;
-
- public ListenerContext(CacheListener super K, ? super V> listener, ExoCache cache)
- {
- this.listener = listener;
- this.cache = cache;
- }
-
- public CacheInfo getCacheInfo()
- {
- return this;
- }
-
- public String getName()
- {
- return cache.getName();
- }
-
- public int getMaxSize()
- {
- return cache.getMaxSize();
- }
-
- public long getLiveTime()
- {
- return cache.getLiveTime();
- }
-
- public int getSize()
- {
- return cache.getCacheSize();
- }
-
- void onExpire(K key, V obj) throws Exception
- {
- listener.onExpire(this, key, obj);
- }
-
- void onRemove(K key, V obj) throws Exception
- {
- listener.onRemove(this, key, obj);
- }
-
- void onPut(K key, V obj) throws Exception
- {
- listener.onPut(this, key, obj);
- }
-
- void onGet(K key, V obj) throws Exception
- {
- listener.onGet(this, key, obj);
- }
-
- void onClearCache() throws Exception
- {
- listener.onClearCache(this);
- }
- }
-
- @Managed
- @ManagedName("ExpirationTimeout")
- @ManagedDescription("This is the timeout after which the cache entry must be evicted.")
- public long getExpirationTimeout()
- {
- return expirationTimeout;
- }
-
- @Managed
- public void setExpirationTimeout(long expirationTimeout)
- {
- this.expirationTimeout = (int)(expirationTimeout / 1000L);
- }
-
- public void setMaxSize(int max)
- {
- throw new UnsupportedOperationException("The max size cannot be modified");
- }
-
- public void setLiveTime(long period)
- {
- this.expirationTimeout = (int)period;
- }
-
- public int getMaxSize()
- {
- return -1;
- }
-
- public long getLiveTime()
- {
- return expirationTimeout;
- }
-}
diff --git a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/MCExoCacheConfig.java b/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/MCExoCacheConfig.java
deleted file mode 100644
index 4b50ab5d2..000000000
--- a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/MCExoCacheConfig.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2003-2010 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.cache.impl.memcached;
-
-/**
- * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the LRU expiration algorithm
- * implementation
- *
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public class MCExoCacheConfig extends org.exoplatform.services.cache.ExoCacheConfig
-{
-
- private long expirationTimeout;
-
- public long getExpirationTimeout()
- {
- return expirationTimeout;
- }
-
- public void setExpirationTimeout(long expirationTimeout)
- {
- this.expirationTimeout = expirationTimeout;
- }
-}
diff --git a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/MCExoCacheCreator.java b/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/MCExoCacheCreator.java
deleted file mode 100644
index 26d46b20b..000000000
--- a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/java/org/exoplatform/services/cache/impl/memcached/MCExoCacheCreator.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2003-2010 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.cache.impl.memcached;
-
-import net.spy.memcached.MemcachedClient;
-
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.exoplatform.services.cache.ExoCacheInitException;
-
-import java.io.Serializable;
-
-/**
- * The implementation of an ExoCacheCreator based on the LRU expiration algorithm
- *
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public class MCExoCacheCreator
-{
-
- /**
- * The default value for the parameter expirationTimeout
- */
- private final long defaultExpirationTimeout;
-
- public MCExoCacheCreator(long defaultExpirationTimeout)
- {
- this.defaultExpirationTimeout = defaultExpirationTimeout;
- }
-
- /**
- * {@inheritDoc}
- */
- public ExoCache create(ExoContainerContext ctx, ExoCacheConfig config, MemcachedClient cache)
- throws ExoCacheInitException
- {
- if (config instanceof MCExoCacheConfig)
- {
- final MCExoCacheConfig eaConfig = (MCExoCacheConfig)config;
- return create(ctx, config, cache, eaConfig.getExpirationTimeout());
- }
- else
- {
- final long period = config.getLiveTime();
- return create(ctx, config, cache, period > 0 ? period * 1000 : defaultExpirationTimeout);
- }
- }
-
- /**
- * Creates a new ExoCache instance with the relevant parameters
- */
- private ExoCache create(ExoContainerContext ctx, ExoCacheConfig config, MemcachedClient cache,
- long expirationTimeout) throws ExoCacheInitException
- {
- return new MCExoCache(ctx, config, cache, expirationTimeout);
- }
-}
diff --git a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/resources/conf/portal/configuration.xml b/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/resources/conf/portal/configuration.xml
deleted file mode 100644
index cef883f7a..000000000
--- a/exo.kernel.component.ext.cache.impl.memcached.v1/src/main/resources/conf/portal/configuration.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
- org.exoplatform.services.cache.ExoCacheFactory
- org.exoplatform.services.cache.impl.memcached.ExoCacheFactoryImpl
-
-
- memcached.locations
- ${memcached.locations:127.0.0.1:11211}
-
-
-
-
diff --git a/exo.kernel.component.ext.cache.impl.memcached.v1/src/test/java/org/exoplatform/services/cache/impl/memcached/TestExoCacheFactoryImpl.java b/exo.kernel.component.ext.cache.impl.memcached.v1/src/test/java/org/exoplatform/services/cache/impl/memcached/TestExoCacheFactoryImpl.java
deleted file mode 100644
index 554eb3e2f..000000000
--- a/exo.kernel.component.ext.cache.impl.memcached.v1/src/test/java/org/exoplatform/services/cache/impl/memcached/TestExoCacheFactoryImpl.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.services.cache.impl.memcached;
-
-import junit.framework.TestCase;
-
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.ObjectParameter;
-import org.exoplatform.container.xml.ValueParam;
-import org.exoplatform.services.cache.CacheService;
-import org.exoplatform.services.cache.ExoCache;
-
-/**
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public class TestExoCacheFactoryImpl extends TestCase
-{
- private PortalContainer pc;
-
- @Override
- protected void setUp() throws Exception
- {
- pc = PortalContainer.getInstance();
- }
-
- public void testArguments() throws Exception
- {
- try
- {
- new ExoCacheFactoryImpl(pc.getContext(), null);
- fail("An IllegalArgumentException should occur");
- }
- catch (IllegalArgumentException e)
- {
- // OK
- }
- try
- {
- new ExoCacheFactoryImpl(pc.getContext(), new InitParams());
- fail("An IllegalArgumentException should occur");
- }
- catch (IllegalArgumentException e)
- {
- // OK
- }
- InitParams params;
- try
- {
- params = new InitParams();
- ValueParam vp = new ValueParam();
- vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
- params.addParam(vp);
- new ExoCacheFactoryImpl(pc.getContext(), params);
- fail("An IllegalArgumentException should occur");
- }
- catch (IllegalArgumentException e)
- {
- // OK
- }
- try
- {
- params = new InitParams();
- ValueParam vp = new ValueParam();
- vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
- vp.setValue("");
- params.addParam(vp);
- new ExoCacheFactoryImpl(pc.getContext(), params);
- fail("An IllegalArgumentException should occur");
- }
- catch (IllegalArgumentException e)
- {
- // OK
- }
- try
- {
- params = new InitParams();
- ValueParam vp = new ValueParam();
- vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
- vp.setValue("localhost:11211");
- params.addParam(vp);
- new ExoCacheFactoryImpl(pc.getContext(), params);
- }
- catch (Exception e)
- {
- fail("No exception was expected");
- }
- try
- {
- params = new InitParams();
- ValueParam vp = new ValueParam();
- vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
- vp.setValue("localhost:11211");
- params.addParam(vp);
- ObjectParameter op = new ObjectParameter();
- op.setName(ExoCacheFactoryImpl.CONNECTION_FACTORY_CREATOR);
- op.setObject(new Object());
- params.addParam(op);
- new ExoCacheFactoryImpl(pc.getContext(), params);
- fail("An IllegalArgumentException should occur");
- }
- catch (IllegalArgumentException e)
- {
- // OK
- }
- try
- {
- params = new InitParams();
- ValueParam vp = new ValueParam();
- vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
- vp.setValue("localhost:11211");
- params.addParam(vp);
- ObjectParameter op = new ObjectParameter();
- op.setName(ExoCacheFactoryImpl.CONNECTION_FACTORY_CREATOR);
- op.setObject(new BinaryConnectionFactoryCreator());
- params.addParam(op);
- new ExoCacheFactoryImpl(pc.getContext(), params);
- }
- catch (Exception e)
- {
- fail("No exception was expected");
- }
- try
- {
- params = new InitParams();
- ValueParam vp = new ValueParam();
- vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
- vp.setValue("localhost:11211");
- params.addParam(vp);
- ObjectParameter op = new ObjectParameter();
- op.setName(ExoCacheFactoryImpl.CONNECTION_FACTORY_CREATOR);
- op.setObject(new BinaryConnectionFactoryCreator());
- params.addParam(op);
- ValueParam vp2 = new ValueParam();
- vp2.setName(ExoCacheFactoryImpl.DEFAULT_EXPIRATION_TIMEOUT);
- vp2.setValue("foo");
- params.addParam(vp2);
- new ExoCacheFactoryImpl(pc.getContext(), params);
- fail("An exception was expected");
- }
- catch (Exception e)
- {
- //OK
- }
- try
- {
- params = new InitParams();
- ValueParam vp = new ValueParam();
- vp.setName(ExoCacheFactoryImpl.MEMCACHED_LOCATIONS);
- vp.setValue("localhost:11211");
- params.addParam(vp);
- ObjectParameter op = new ObjectParameter();
- op.setName(ExoCacheFactoryImpl.CONNECTION_FACTORY_CREATOR);
- op.setObject(new BinaryConnectionFactoryCreator());
- params.addParam(op);
- ValueParam vp2 = new ValueParam();
- vp2.setName(ExoCacheFactoryImpl.DEFAULT_EXPIRATION_TIMEOUT);
- vp2.setValue("1000");
- params.addParam(vp2);
- new ExoCacheFactoryImpl(pc.getContext(), params);
- }
- catch (Exception e)
- {
- fail("No exception was expected");
- }
- }
-
- public void testCacheFactory()
- {
- CacheService service_ =
- (CacheService)pc.getComponentInstanceOfType(CacheService.class);
- @SuppressWarnings("rawtypes")
- ExoCache cache = service_.getCacheInstance("myCache");
- assertTrue("expect an instance of MCExoCache but was " + cache, cache instanceof MCExoCache);
- }
-}
diff --git a/exo.kernel.component.ext.cache.impl.memcached.v1/src/test/java/org/exoplatform/services/cache/impl/memcached/TestMCExoCache.java b/exo.kernel.component.ext.cache.impl.memcached.v1/src/test/java/org/exoplatform/services/cache/impl/memcached/TestMCExoCache.java
deleted file mode 100644
index 8e1cd7f00..000000000
--- a/exo.kernel.component.ext.cache.impl.memcached.v1/src/test/java/org/exoplatform/services/cache/impl/memcached/TestMCExoCache.java
+++ /dev/null
@@ -1,539 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.services.cache.impl.memcached;
-
-import junit.framework.TestCase;
-
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.services.cache.CacheListener;
-import org.exoplatform.services.cache.CacheListenerContext;
-import org.exoplatform.services.cache.CacheService;
-import org.exoplatform.services.cache.CachedObjectSelector;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheFactory;
-import org.exoplatform.services.cache.ObjectCacheInfo;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public class TestMCExoCache extends TestCase
-{
-
- CacheService service;
-
- MCExoCache cache;
-
- ExoCacheFactory factory;
-
- MyCacheListener listener;
-
- public TestMCExoCache(String name)
- {
- super(name);
- }
-
- public void setUp() throws Exception
- {
- this.service = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
- this.cache = (MCExoCache)service.getCacheInstance("myCache");
- this.factory = (ExoCacheFactory)PortalContainer.getInstance().getComponentInstanceOfType(ExoCacheFactory.class);
- listener = new MyCacheListener();
- cache.addCacheListener(listener);
- }
-
- protected void tearDown() throws Exception
- {
- cache.clearCache();
- }
-
- public void testPut() throws Exception
- {
- assertEquals(0, listener.put);
- cache.put(new MyKey("a"), "a");
- cache.put(new MyKey("b"), "b");
- cache.put(new MyKey("c"), "c");
- cache.put(new MyKey("d"), null);
- assertEquals(3, listener.put);
- assertEquals(3, cache.getCacheSize());
- assertEquals("a", cache.get(new MyKey("a")));
- cache.put(new MyKey("a"), "c");
- assertEquals(4, listener.put);
- assertEquals(3, cache.getCacheSize());
- assertEquals("c", cache.get(new MyKey("a")));
- cache.put(new MyKey("d"), "c");
- assertEquals(5, listener.put);
- assertEquals(4, cache.getCacheSize());
- }
-
- public void testClearCache() throws Exception
- {
- cache.put(new MyKey("a"), "a");
- cache.put(new MyKey("b"), "b");
- cache.put(new MyKey("c"), "c");
- assertEquals("a", cache.get(new MyKey("a")));
- assertTrue(cache.getCacheSize() > 0);
- assertEquals(0, listener.clearCache);
- cache.clearCache();
- assertEquals(1, listener.clearCache);
- assertTrue(cache.getCacheSize() == 0);
- assertNull(cache.get(new MyKey("a")));
- }
-
- public void testGet() throws Exception
- {
- assertEquals(0, cache.getCacheSize());
- cache.put(new MyKey("a"), "a");
- assertEquals(1, cache.getCacheSize());
- assertEquals(0, listener.get);
- assertEquals("a", cache.get(new MyKey("a")));
- assertEquals(1, listener.get);
- cache.put(new MyKey("a"), "c");
- assertEquals(1, cache.getCacheSize());
- assertEquals("c", cache.get(new MyKey("a")));
- assertEquals(2, listener.get);
- cache.remove(new MyKey("a"));
- assertEquals(0, cache.getCacheSize());
- assertNull(cache.get(new MyKey("a")));
- assertNull(cache.get(new MyKey("x")));
- assertEquals(4, listener.get);
- }
-
- public void testRemove() throws Exception
- {
- cache.put(new MyKey("a"), 1);
- cache.put(new MyKey("b"), 2);
- cache.put(new MyKey("c"), 3);
- assertEquals(3, cache.getCacheSize());
- assertEquals(0, listener.remove);
- assertEquals(1, cache.remove(new MyKey("a")));
- assertEquals(1, listener.remove);
- assertEquals(2, cache.getCacheSize());
- assertEquals(2, cache.remove(new MyKey("b")));
- assertEquals(2, listener.remove);
- assertEquals(1, cache.getCacheSize());
- assertNull(cache.remove(new MyKey("x")));
- assertEquals(2, listener.remove);
- assertEquals(1, cache.getCacheSize());
- }
-
- public void testPutMap() throws Exception
- {
- Map values = new HashMap();
- values.put(new MyKey("a"), "a");
- values.put(new MyKey("b"), "b");
- assertEquals(0, listener.put);
- assertEquals(0, cache.getCacheSize());
- cache.putMap(values);
- assertEquals(2, listener.put);
- assertEquals(2, cache.getCacheSize());
- values = new HashMap()
- {
- private static final long serialVersionUID = 1L;
-
- public Set> entrySet()
- {
- Set> set = new LinkedHashSet>(super.entrySet());
- set.add(new Entry()
- {
-
- public Object setValue(Object paramV)
- {
- return null;
- }
-
- public Object getValue()
- {
- throw new RuntimeException("An exception");
- }
-
- public Serializable getKey()
- {
- return "c";
- }
- });
- return set;
- }
- };
- values.put(new MyKey("e"), "e");
- values.put(new MyKey("d"), "d");
- cache.putMap(values);
- assertEquals(4, listener.put);
- assertEquals(4, cache.getCacheSize());
- }
-
- public void testGetCachedObjects() throws Exception
- {
- cache.put(new MyKey("a"), "a");
- cache.put(new MyKey("b"), "b");
- cache.put(new MyKey("c"), "c");
- cache.put(new MyKey("d"), null);
- assertEquals(3, cache.getCacheSize());
- try
- {
- List values = cache.getCachedObjects();
- assertEquals(3, values.size());
- assertTrue(values.contains("a"));
- assertTrue(values.contains("b"));
- assertTrue(values.contains("c"));
- }
- catch (UnsupportedOperationException e)
- {
- // OK
- }
- }
-
- public void testRemoveCachedObjects() throws Exception
- {
- cache.put(new MyKey("a"), "a");
- cache.put(new MyKey("b"), "b");
- cache.put(new MyKey("c"), "c");
- cache.put(new MyKey("d"), null);
- assertEquals(3, cache.getCacheSize());
- try
- {
- List values = cache.removeCachedObjects();
- assertEquals(3, values.size());
- assertTrue(values.contains("a"));
- assertTrue(values.contains("b"));
- assertTrue(values.contains("c"));
- assertEquals(0, cache.getCacheSize());
- }
- catch (UnsupportedOperationException e)
- {
- // OK
- }
- }
-
- public void testSelect() throws Exception
- {
- cache.put(new MyKey("a"), 1);
- cache.put(new MyKey("b"), 2);
- cache.put(new MyKey("c"), 3);
- final AtomicInteger count = new AtomicInteger();
- CachedObjectSelector selector = new CachedObjectSelector()
- {
-
- public void onSelect(ExoCache extends Serializable, ? extends Object> cache, Serializable key,
- ObjectCacheInfo extends Object> ocinfo) throws Exception
- {
- assertTrue(key.equals(new MyKey("a")) || key.equals(new MyKey("b")) || key.equals(new MyKey("c")));
- assertTrue(ocinfo.get().equals(1) || ocinfo.get().equals(2) || ocinfo.get().equals(3));
- count.incrementAndGet();
- }
-
- public boolean select(Serializable key, ObjectCacheInfo extends Object> ocinfo)
- {
- return true;
- }
- };
- try
- {
- cache.select(selector);
- assertEquals(3, count.intValue());
- }
- catch (UnsupportedOperationException e)
- {
- // OK
- }
- }
-
- public void testGetHitsNMisses() throws Exception
- {
- int hits = cache.getCacheHit();
- int misses = cache.getCacheMiss();
- cache.put(new MyKey("a"), "a");
- cache.get(new MyKey("a"));
- cache.remove(new MyKey("a"));
- cache.get(new MyKey("a"));
- cache.get(new MyKey("z"));
- assertEquals(1, cache.getCacheHit() - hits);
- assertEquals(2, cache.getCacheMiss() - misses);
- }
-
- public void testMultiThreading() throws Exception
- {
- final ExoCache cache = service.getCacheInstance("test-multi-threading");
- final int totalElement = 100;
- final int totalTimes = 20;
- int reader = 20;
- int writer = 10;
- int remover = 5;
- int cleaner = 1;
- final CountDownLatch startSignalWriter = new CountDownLatch(1);
- final CountDownLatch startSignalOthers = new CountDownLatch(1);
- final CountDownLatch doneSignal = new CountDownLatch(reader + writer + remover);
- final List errors = Collections.synchronizedList(new ArrayList());
- for (int i = 0; i < writer; i++)
- {
- final int index = i;
- Thread thread = new Thread()
- {
- public void run()
- {
- try
- {
- startSignalWriter.await();
- for (int j = 0; j < totalTimes; j++)
- {
- for (int i = 0; i < totalElement; i++)
- {
- cache.put(new MyKey("key" + i), "value" + i);
- }
- if (index == 0 && j == 0)
- {
- // The cache is full, we can launch the others
- startSignalOthers.countDown();
- }
- sleep(50);
- }
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- finally
- {
- doneSignal.countDown();
- }
- }
- };
- thread.start();
- }
- startSignalWriter.countDown();
- for (int i = 0; i < reader; i++)
- {
- Thread thread = new Thread()
- {
- public void run()
- {
- try
- {
- startSignalOthers.await();
- for (int j = 0; j < totalTimes; j++)
- {
- for (int i = 0; i < totalElement; i++)
- {
- cache.get(new MyKey("key" + i));
- }
- sleep(50);
- }
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- finally
- {
- doneSignal.countDown();
- }
- }
- };
- thread.start();
- }
- for (int i = 0; i < remover; i++)
- {
- Thread thread = new Thread()
- {
- public void run()
- {
- try
- {
- startSignalOthers.await();
- for (int j = 0; j < totalTimes; j++)
- {
- for (int i = 0; i < totalElement; i++)
- {
- cache.remove(new MyKey("key" + i));
- }
- sleep(50);
- }
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- finally
- {
- doneSignal.countDown();
- }
- }
- };
- thread.start();
- }
- doneSignal.await();
- for (int i = 0; i < totalElement; i++)
- {
- cache.put(new MyKey("key" + i), "value" + i);
- }
- assertEquals(totalElement, cache.getCacheSize());
- final CountDownLatch startSignal = new CountDownLatch(1);
- final CountDownLatch doneSignal2 = new CountDownLatch(writer + cleaner);
- for (int i = 0; i < writer; i++)
- {
- Thread thread = new Thread()
- {
- public void run()
- {
- try
- {
- startSignal.await();
- for (int j = 0; j < totalTimes; j++)
- {
- for (int i = 0; i < totalElement; i++)
- {
- cache.put(new MyKey("key" + i), "value" + i);
- }
- sleep(50);
- }
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- finally
- {
- doneSignal2.countDown();
- }
- }
- };
- thread.start();
- }
- for (int i = 0; i < cleaner; i++)
- {
- Thread thread = new Thread()
- {
- public void run()
- {
- try
- {
- startSignal.await();
- for (int j = 0; j < totalTimes; j++)
- {
- sleep(150);
- cache.clearCache();
- }
- }
- catch (Exception e)
- {
- errors.add(e);
- }
- finally
- {
- doneSignal2.countDown();
- }
- }
- };
- thread.start();
- }
- assertTrue(cache.getCacheSize() > 0);
- cache.clearCache();
- assertEquals(0, cache.getCacheSize());
- if (!errors.isEmpty())
- {
- for (Exception e : errors)
- {
- e.printStackTrace();
- }
- throw errors.get(0);
- }
- }
-
- public static class MyCacheListener implements CacheListener
- {
-
- public int clearCache;
-
- public int expire;
-
- public int get;
-
- public int put;
-
- public int remove;
-
- public void onClearCache(CacheListenerContext context) throws Exception
- {
- clearCache++;
- }
-
- public void onExpire(CacheListenerContext context, Serializable key, T obj) throws Exception
- {
- expire++;
- }
-
- public void onGet(CacheListenerContext context, Serializable key, T obj) throws Exception
- {
- get++;
- }
-
- public void onPut(CacheListenerContext context, Serializable key, T obj) throws Exception
- {
- put++;
- }
-
- public void onRemove(CacheListenerContext context, Serializable key, T obj) throws Exception
- {
- remove++;
- }
- }
-
- public static class MyKey implements Serializable
- {
- private static final long serialVersionUID = 1L;
-
- public String value;
-
- public MyKey(String value)
- {
- this.value = value;
- }
-
- @Override
- public boolean equals(Object paramObject)
- {
- return paramObject instanceof MyKey && ((MyKey)paramObject).value.equals(value);
- }
-
- @Override
- public int hashCode()
- {
- return value.hashCode();
- }
-
- @Override
- public String toString()
- {
- return value;
- }
- }
-}
diff --git a/exo.kernel.component.ext.cache.impl.memcached.v1/src/test/resources/conf/portal/test-configuration.xml b/exo.kernel.component.ext.cache.impl.memcached.v1/src/test/resources/conf/portal/test-configuration.xml
deleted file mode 100644
index 40b87bfa3..000000000
--- a/exo.kernel.component.ext.cache.impl.memcached.v1/src/test/resources/conf/portal/test-configuration.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-
- org.exoplatform.services.cache.CacheService
- org.exoplatform.services.cache.impl.CacheServiceImpl
-
-
-
- cache.config.default
- The default cache configuration
-
-
- default
-
-
- 5
-
-
- 20
-
-
-
-
- test-lru-with-old-config
- The default cache configuration
-
-
- test-lru-with-old-config
-
-
- 5
-
-
- 2
-
-
-
-
- test-lru
- The default cache configuration
-
-
- test-lru
-
-
- 5
-
-
- 2000
-
-
-
-
-
-
diff --git a/exo.kernel.component.ext.cache.impl.memcached.v1/src/test/resources/test.policy b/exo.kernel.component.ext.cache.impl.memcached.v1/src/test/resources/test.policy
deleted file mode 100644
index fc563387a..000000000
--- a/exo.kernel.component.ext.cache.impl.memcached.v1/src/test/resources/test.policy
+++ /dev/null
@@ -1,26 +0,0 @@
-grant codeBase "@MAVEN_REPO@-"{
- permission java.security.AllPermission;
-};
-
-grant codeBase "@MAIN_CLASSES@-"{
- permission java.security.AllPermission;
-};
-
-grant codeBase "@TEST_CLASSES@-"{
-};
-
-grant codeBase "@MAIN_CLASSES@../../../exo.kernel.commons.test/-"{
- permission java.security.AllPermission;
-};
-
-grant codeBase "@MAIN_CLASSES@../../../exo.kernel.commons/-"{
- permission java.security.AllPermission;
-};
-
-grant codeBase "@MAIN_CLASSES@../../../exo.kernel.container/-"{
- permission java.security.AllPermission;
-};
-
-grant codeBase "@MAIN_CLASSES@../../../exo.kernel.component.cache/-"{
- permission java.security.AllPermission;
-};
diff --git a/exo.kernel.container.ext.provider.impl.guice.v3/pom.xml b/exo.kernel.container.ext.provider.impl.guice.v3/pom.xml
deleted file mode 100644
index 30eed0e47..000000000
--- a/exo.kernel.container.ext.provider.impl.guice.v3/pom.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
- 4.0.0
-
- org.exoplatform.kernel
- kernel-parent
- 6.5.x-SNAPSHOT
-
- exo.kernel.container.ext.provider.impl.guice.v3
- eXo PLF:: Kernel :: Container Extension :: Guice Implementation
- A component provider based on Guice.
-
- 0.8
-
-
-
- org.exoplatform.kernel
- exo.kernel.container
-
-
- org.exoplatform.kernel
- exo.kernel.container
- test-jar
- test
-
-
- com.google.inject
- guice
-
-
- org.exoplatform.kernel
- exo.kernel.commons.test
- test
-
-
-
-
-
- maven-surefire-plugin
-
- @{argLine} ${env.MAVEN_OPTS} --add-opens=java.base/java.lang=ALL-UNNAMED -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy
-
-
-
- maven-antrun-plugin
-
-
- prepare-test-policy
- process-test-resources
-
-
- Creating Access Policy for tests
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- run
-
-
-
-
-
- ant
- ant-optional
- 1.5.3-1
-
-
-
-
-
-
diff --git a/exo.kernel.container.ext.provider.impl.guice.v3/src/main/java/org/exoplatform/container/guice/GuiceContainer.java b/exo.kernel.container.ext.provider.impl.guice.v3/src/main/java/org/exoplatform/container/guice/GuiceContainer.java
deleted file mode 100644
index 92e17b275..000000000
--- a/exo.kernel.container.ext.provider.impl.guice.v3/src/main/java/org/exoplatform/container/guice/GuiceContainer.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Copyright (C) 2013 eXo Platform SAS.
- *
- * 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.exoplatform.container.guice;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Binder;
-import com.google.inject.Binding;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.Provider;
-import com.google.inject.name.Names;
-
-import org.exoplatform.container.AbstractComponentAdapter;
-import org.exoplatform.container.AbstractInterceptor;
-import org.exoplatform.container.configuration.ConfigurationManager;
-import org.exoplatform.container.spi.ComponentAdapter;
-import org.exoplatform.container.spi.ContainerException;
-import org.exoplatform.container.spi.Interceptor;
-import org.exoplatform.container.xml.Component;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * The implementation of an {@link Interceptor} allowing eXo Kernel to interact with a Google Guice container
- *
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public class GuiceContainer extends AbstractInterceptor
-{
-
- /**
- * The serial version UID
- */
- private static final long serialVersionUID = -6662420267945445921L;
-
- /**
- * The logger
- */
- private static final Log LOG = ExoLogger.getLogger("exo.kernel.container.ext.provider.impl.guice.v3.GuiceContainer");
-
- /**
- * The Google Guice injector
- */
- private Injector injector;
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- @Override
- public T getComponentInstance(Object componentKey, Class bindType, boolean autoRegistration)
- {
- T result = super.getComponentInstance(componentKey, bindType, autoRegistration);
- if (result == null && injector != null)
- {
- final Binding> binding;
- if (componentKey instanceof Class> && !((Class>)componentKey).isAnnotation())
- {
- binding = injector.getExistingBinding(Key.get((Class>)componentKey));
- }
- else
- {
- if (componentKey instanceof String)
- {
- binding = injector.getExistingBinding(Key.get(bindType, Names.named((String)componentKey)));
- }
- else if (componentKey instanceof Class>)
- {
- binding = injector.getExistingBinding(Key.get(bindType, (Class extends Annotation>)componentKey));
- }
- else
- {
- return null;
- }
- }
- if (binding == null || binding.getProvider().toString().startsWith(ComponentAdapterProvider.class.getName()))
- {
- return null;
- }
- result = bindType.cast(binding.getProvider().get());
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public T getComponentInstanceOfType(Class componentType, boolean autoRegistration)
- {
- T result = super.getComponentInstanceOfType(componentType, autoRegistration);
- if (result == null && injector != null)
- {
- Binding> binding = injector.getExistingBinding(Key.get(componentType));
- if (binding == null || binding.getProvider().toString().startsWith(ComponentAdapterProvider.class.getName()))
- {
- return null;
- }
- result = componentType.cast(binding.getProvider().get());
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- @Override
- public ComponentAdapter getComponentAdapter(Object componentKey, Class bindType, boolean autoRegistration)
- {
- ComponentAdapter result = super.getComponentAdapter(componentKey, bindType, autoRegistration);
- if (result == null && injector != null)
- {
- final Binding> binding;
- if (componentKey instanceof Class> && !((Class>)componentKey).isAnnotation())
- {
- binding = injector.getExistingBinding(Key.get((Class>)componentKey));
- }
- else
- {
- if (componentKey instanceof String)
- {
- binding = injector.getExistingBinding(Key.get(bindType, Names.named((String)componentKey)));
- }
- else if (componentKey instanceof Class>)
- {
- binding = injector.getExistingBinding(Key.get(bindType, (Class extends Annotation>)componentKey));
- }
- else
- {
- return null;
- }
- }
- if (binding == null || binding.getProvider().toString().startsWith(ComponentAdapterProvider.class.getName()))
- {
- return null;
- }
- result = createComponentAdapter(bindType, binding);
- }
- return result;
- }
-
- private ComponentAdapter createComponentAdapter(final Class type, final Binding> binding)
- {
- return new AbstractComponentAdapter(type, type)
- {
- /**
- * The serial UID
- */
- private static final long serialVersionUID = 4241559622835718141L;
-
- public T getComponentInstance() throws ContainerException
- {
- return type.cast(binding.getProvider().get());
- }
-
- public boolean isSingleton()
- {
- return false;
- }
- };
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ComponentAdapter getComponentAdapterOfType(Class componentType, boolean autoRegistration)
- {
- ComponentAdapter result = super.getComponentAdapterOfType(componentType, autoRegistration);
- if (result == null && injector != null)
- {
- final Binding> binding = injector.getExistingBinding(Key.get(componentType));
- if (binding == null || binding.getProvider().toString().startsWith(ComponentAdapterProvider.class.getName()))
- {
- return null;
- }
- result = createComponentAdapter(componentType, binding);
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- @Override
- public List> getComponentAdaptersOfType(Class componentType)
- {
- List> result = super.getComponentAdaptersOfType(componentType);
- if (injector != null)
- {
- result = new ArrayList>(result);
- for (Binding> b : injector.getAllBindings().values())
- {
- if (b.getProvider().toString().startsWith(ComponentAdapterProvider.class.getName()))
- {
- continue;
- }
- else if (componentType.isAssignableFrom(b.getKey().getTypeLiteral().getRawType()))
- {
- result.add((ComponentAdapter)createComponentAdapter(b.getKey().getTypeLiteral().getRawType(), b));
- }
- }
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List getComponentInstancesOfType(Class componentType) throws ContainerException
- {
- List result = super.getComponentInstancesOfType(componentType);
- if (injector != null)
- {
- result = new ArrayList(result);
- for (Binding> b : injector.getAllBindings().values())
- {
- if (b.getProvider().toString().startsWith(ComponentAdapterProvider.class.getName()))
- {
- continue;
- }
- else if (componentType.isAssignableFrom(b.getKey().getTypeLiteral().getRawType()))
- {
- result.add(componentType.cast(b.getProvider().get()));
- }
- }
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void start()
- {
- ConfigurationManager cm = super.getComponentInstanceOfType(ConfigurationManager.class, false);
- // We check if the component has been defined in the configuration of the current container
- // The goal is to enable the GuicegContainer only if it is needed
- Component component = cm.getComponent(ModuleProvider.class);
- if (component == null)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug("No ModuleProvider has been defined, thus the GuiceContainer will be disabled."
- + " To enable the Guice Integration please define a ModuleProvider");
- }
- }
- else
- {
- ModuleProvider provider = super.getComponentInstanceOfType(ModuleProvider.class, false);
- injector = Guice.createInjector(provider.getModule(), new AbstractModule()
- {
- @SuppressWarnings({"unchecked", "rawtypes"})
- @Override
- protected void configure()
- {
- Collection> adapters = delegate.getComponentAdapters();
- Binder binder = binder();
- for (ComponentAdapter> adapter : adapters)
- {
- Object key = adapter.getComponentKey();
- Class> type;
- Annotation annotation = null;
- Class extends Annotation> annotationType = null;
- if (key instanceof Class> && !((Class>)key).isAnnotation())
- {
- type = (Class>)key;
- }
- else
- {
- if (key instanceof String)
- {
- annotation = Names.named((String)key);
- }
- else if (key instanceof Class>)
- {
- annotationType = (Class extends Annotation>)key;
- }
- type = adapter.getComponentImplementation();
- }
- if (annotation == null && annotationType == null)
- {
- binder.bind(type).toProvider(new ComponentAdapterProvider(type, adapter));
- }
- else
- {
- // As we don't know the type, we will bind it for each super classes and interfaces too
- ComponentAdapterProvider provider = new ComponentAdapterProvider(type, adapter);
- bindAll(binder, type, provider, annotation, annotationType);
- }
- }
- }
- });
- LOG.info("A GuiceContainer has been enabled using the ModuleProvider " + provider.getClass());
- }
- super.start();
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- private static void bindAll(Binder binder, Class> clazz, ComponentAdapterProvider provider, Annotation annotation,
- Class extends Annotation> annotationType)
- {
- if (clazz == null || clazz.equals(Object.class))
- return;
- if (annotation == null)
- {
- binder.bind(clazz).annotatedWith(annotationType).toProvider(provider);
- }
- else
- {
- binder.bind(clazz).annotatedWith(annotation).toProvider(provider);
- }
- for (Class> c : clazz.getInterfaces())
- {
- bindAll(binder, c, provider, annotation, annotationType);
- }
- bindAll(binder, clazz.getSuperclass(), provider, annotation, annotationType);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void stop()
- {
- super.stop();
- injector = null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getId()
- {
- return "GuiceIntegration";
- }
-
- private static class ComponentAdapterProvider implements Provider
- {
-
- private final Class type;
-
- private final ComponentAdapter adapter;
-
- private ComponentAdapterProvider(Class type, ComponentAdapter adapter)
- {
- this.type = type;
- this.adapter = adapter;
- }
-
- /**
- * {@inheritDoc}
- */
- public T get()
- {
- return type.cast(adapter.getComponentInstance());
- }
- }
-}
diff --git a/exo.kernel.container.ext.provider.impl.guice.v3/src/main/java/org/exoplatform/container/guice/ModuleProvider.java b/exo.kernel.container.ext.provider.impl.guice.v3/src/main/java/org/exoplatform/container/guice/ModuleProvider.java
deleted file mode 100644
index c022b31a6..000000000
--- a/exo.kernel.container.ext.provider.impl.guice.v3/src/main/java/org/exoplatform/container/guice/ModuleProvider.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2013 eXo Platform SAS.
- *
- * 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.exoplatform.container.guice;
-
-import com.google.inject.Module;
-
-/**
- * The main purpose of this interface is to provide the {@link Module} in which all the components that
- * we would like to expose to eXo kernel are already binded. This is required to prevent Google Guice to try
- * to create unexpected components.
- *
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public interface ModuleProvider
-{
- /**
- * Gives the {@link Module} in which all the components are already binded.
- */
- Module getModule();
-}
diff --git a/exo.kernel.container.ext.provider.impl.guice.v3/src/main/resources/META-INF/services/org.exoplatform.container.spi.Interceptor b/exo.kernel.container.ext.provider.impl.guice.v3/src/main/resources/META-INF/services/org.exoplatform.container.spi.Interceptor
deleted file mode 100644
index 8a77a68ac..000000000
--- a/exo.kernel.container.ext.provider.impl.guice.v3/src/main/resources/META-INF/services/org.exoplatform.container.spi.Interceptor
+++ /dev/null
@@ -1 +0,0 @@
-org.exoplatform.container.guice.GuiceContainer
\ No newline at end of file
diff --git a/exo.kernel.container.ext.provider.impl.guice.v3/src/test/java/org/exoplatform/container/guice/TestGuiceContainer.java b/exo.kernel.container.ext.provider.impl.guice.v3/src/test/java/org/exoplatform/container/guice/TestGuiceContainer.java
deleted file mode 100644
index 0c60dc6ce..000000000
--- a/exo.kernel.container.ext.provider.impl.guice.v3/src/test/java/org/exoplatform/container/guice/TestGuiceContainer.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Copyright (C) 2013 eXo Platform SAS.
- *
- * 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.exoplatform.container.guice;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Module;
-import com.google.inject.name.Names;
-
-import org.exoplatform.container.ContainerBuilder;
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.container.RootContainer;
-import org.exoplatform.container.jmx.AbstractTestContainer;
-import org.exoplatform.container.spi.ComponentAdapter;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.net.URL;
-import java.util.List;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Provider;
-import javax.inject.Qualifier;
-import javax.inject.Singleton;
-
-/**
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public class TestGuiceContainer extends AbstractTestContainer
-{
-
- public void testIntegration()
- {
- URL rootURL = getClass().getResource("test-exo-container.xml");
- URL portalURL = getClass().getResource("test-exo-container2.xml");
- assertNotNull(rootURL);
- assertNotNull(portalURL);
- //
- new ContainerBuilder().withRoot(rootURL).withPortal(portalURL).build();
- RootContainer root = RootContainer.getInstance();
- testIntegration(root);
- ComponentAdapter adapterH = root.getComponentAdapterOfType(H.class);
- assertNull(adapterH);
- PortalContainer portal = PortalContainer.getInstance();
- adapterH = portal.getComponentAdapterOfType(H.class);
- assertNotNull(adapterH);
- H h = root.getComponentInstanceOfType(H.class);
- assertNull(h);
- h = portal.getComponentInstanceOfType(H.class);
- assertNotNull(h);
- assertSame(h, portal.getComponentInstanceOfType(H.class));
- assertSame(h, adapterH.getComponentInstance());
- List> adapters = root.getComponentAdaptersOfType(H.class);
- assertTrue(adapters == null || adapters.isEmpty());
- adapters = portal.getComponentAdaptersOfType(H.class);
- assertNotNull(adapters);
- assertEquals(1, adapters.size());
- assertSame(h, adapters.get(0).getComponentInstance());
- List allH = root.getComponentInstancesOfType(H.class);
- assertTrue(allH == null || allH.isEmpty());
- allH = portal.getComponentInstancesOfType(H.class);
- assertNotNull(allH);
- assertEquals(1, allH.size());
- assertSame(h, allH.get(0));
- }
-
- @SuppressWarnings("unchecked")
- private void testIntegration(RootContainer container)
- {
- assertNotNull(container);
- ComponentAdapter adapterA = container.getComponentAdapterOfType(A.class);
- assertNotNull(adapterA);
- assertSame(adapterA, container.getComponentAdapterOfType(A.class));
- ComponentAdapter adapterB = container.getComponentAdapterOfType(B.class);
- assertNotNull(adapterB);
- ComponentAdapter adapterC = container.getComponentAdapterOfType(C.class);
- assertNotNull(adapterC);
- ComponentAdapter adapterD = container.getComponentAdapterOfType(D.class);
- assertNotNull(adapterD);
- assertSame(adapterD, container.getComponentAdapterOfType(D.class));
- ComponentAdapter adapterE = container.getComponentAdapterOfType(E.class);
- assertNotNull(adapterE);
- adapterE = (ComponentAdapter)container.getComponentAdapter("MyClassE");
- assertNotNull(adapterE);
- assertSame(adapterE, container.getComponentAdapter("MyClassE"));
- ComponentAdapter adapterF = container.getComponentAdapterOfType(F.class);
- assertNotNull(adapterF);
- ComponentAdapter adapterG = container.getComponentAdapterOfType(G.class);
- assertNotNull(adapterG);
- A a = container.getComponentInstanceOfType(A.class);
- assertNotNull(a);
- assertSame(a, container.getComponentInstanceOfType(A.class));
- assertSame(a, adapterA.getComponentInstance());
- B b = container.getComponentInstanceOfType(B.class);
- assertNotNull(b);
- assertSame(b, container.getComponentInstanceOfType(B.class));
- assertSame(b, adapterB.getComponentInstance());
- C c = container.getComponentInstanceOfType(C.class);
- assertNotNull(c);
- assertNotSame(c, container.getComponentInstanceOfType(C.class));
- assertNotSame(c, adapterC.getComponentInstance());
- assertSame(a, c.a);
- assertSame(b, c.b);
- assertSame(a, ((C)adapterC.getComponentInstance()).a);
- assertSame(b, ((C)adapterC.getComponentInstance()).b);
- assertSame(a, container.getComponentInstanceOfType(C.class).a);
- assertSame(b, container.getComponentInstanceOfType(C.class).b);
- assertNotNull(c.a2);
- assertNotNull(c.a2_2);
- assertNotSame(c.a2, c.a2_2);
- assertNotNull(c.d);
- assertSame(c.d, c.d2);
- D d = container.getComponentInstanceOfType(D.class);
- assertNotNull(d);
- assertSame(d, container.getComponentInstanceOfType(D.class));
- assertSame(d, adapterD.getComponentInstance());
- assertSame(a, d.a);
- assertSame(b, d.b);
- assertTrue(d.g instanceof G1);
- assertTrue(d.g2 instanceof G2);
- assertTrue(d.g3.get() instanceof G3);
- E e = (E)container.getComponentInstance("MyClassE");
- assertNotNull(a);
- assertSame(e, container.getComponentInstance("MyClassE"));
- assertSame(e, adapterE.getComponentInstance());
- F f = container.getComponentInstanceOfType(F.class);
- assertNotNull(f);
- assertSame(f, container.getComponentInstanceOfType(F.class));
- assertSame(f, adapterF.getComponentInstance());
- assertSame(e, f.e);
- assertTrue(f.e instanceof E1);
- assertTrue(f.m instanceof E1);
- assertTrue(f.e2 instanceof E2);
- assertNotNull(f.e3.get());
- assertTrue(f.e3.get() instanceof E);
- assertFalse(f.e3.get() instanceof E1);
- assertFalse(f.e3.get() instanceof E2);
- G g = container.getComponentInstanceOfType(G.class);
- assertNotNull(g);
- assertSame(g, container.getComponentInstanceOfType(G.class));
- assertSame(g, adapterG.getComponentInstance());
- List> adapters = container.getComponentAdaptersOfType(Marker.class);
- assertNotNull(adapters);
- assertEquals(4, adapters.size());
- boolean foundE = false, foundF = false, foundE1 = false, foundE2 = false;
- for (ComponentAdapter adapter : adapters)
- {
- if (adapter.getComponentImplementation().equals(E1.class))
- {
- foundE1 = true;
- assertSame(e, adapter.getComponentInstance());
- }
- else if (adapter.getComponentImplementation().equals(E2.class))
- {
- foundE2 = true;
- assertSame(f.e2, adapter.getComponentInstance());
- }
- else if (adapter.getComponentImplementation().equals(E.class))
- {
- foundE = true;
- assertSame(f.e3.get(), adapter.getComponentInstance());
- }
- else if (adapter.getComponentImplementation().equals(F.class))
- {
- foundF = true;
- assertSame(f, adapter.getComponentInstance());
- }
- }
- assertTrue(foundE);
- assertTrue(foundE1);
- assertTrue(foundE2);
- assertTrue(foundF);
- List markers = container.getComponentInstancesOfType(Marker.class);
- assertNotNull(markers);
- assertEquals(4, markers.size());
- assertTrue(markers.contains(e));
- assertTrue(markers.contains(f.e));
- assertTrue(markers.contains(f.e2));
- assertTrue(markers.contains(f));
- }
-
- public static class A
- {
- }
-
- public static class A2
- {
- @Inject
- public A2() {}
- }
-
- @Singleton
- public static class B
- {
- }
-
- public static class C
- {
- @Inject
- A a;
-
- @Inject
- A2 a2;
-
- @Inject
- A2 a2_2;
-
- @Inject
- B b;
-
- @Inject
- D d;
-
- @Inject
- D d2;
- }
-
- @Singleton
- public static class D
- {
- A a;
-
- B b;
-
- @Inject
- @Named("MyClassG")
- G g;
-
- @Inject
- @QG2
- G g2;
-
- @Inject
- Provider g3;
-
- @Inject
- public D(A a, B b)
- {
- this.a = a;
- this.b = b;
- }
- }
-
- public static class E implements Marker
- {
- }
-
- public static class E1 extends E
- {
- }
-
- public static class E2 extends E
- {
- }
-
- @Singleton
- public static class F implements Marker
- {
- @Inject
- @Named("MyClassE")
- E e;
-
- @Inject
- @Named("MyClassE")
- Marker m;
-
- @Inject
- @QE2
- E e2;
-
- @Inject
- Provider e3;
- }
-
- public abstract static class G
- {
- }
-
- @Singleton
- public static class G1 extends G
- {
- }
-
- @Singleton
- public static class G2 extends G
- {
- }
-
- @Singleton
- public static class G3 extends G
- {
- }
-
- @Singleton
- public static class H
- {
- }
-
- public static class MyModuleProvider implements ModuleProvider
- {
- public Module getModule()
- {
- return new AbstractModule()
- {
- @Override
- protected void configure()
- {
- bind(B.class);
- bind(C.class);
- bind(F.class);
- bind(G.class).annotatedWith(Names.named("MyClassG")).to(G1.class);
- bind(G.class).annotatedWith(QG2.class).to(G2.class);
- bind(G.class).to(G3.class);
- }
- };
- }
- }
-
-
- public static class MyModuleProvider2 implements ModuleProvider
- {
- public Module getModule()
- {
- return new AbstractModule()
- {
- @Override
- protected void configure()
- {
- bind(H.class);
- }
- };
- }
- }
- public static interface Marker {}
-
- @Retention(RetentionPolicy.RUNTIME)
- @Qualifier
- public static @interface QE2
- {
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- @Qualifier
- public static @interface QG2
- {
- }
-}
diff --git a/exo.kernel.container.ext.provider.impl.guice.v3/src/test/resources/META-INF/services/org.exoplatform.container.spi.Interceptor b/exo.kernel.container.ext.provider.impl.guice.v3/src/test/resources/META-INF/services/org.exoplatform.container.spi.Interceptor
deleted file mode 100644
index 8a77a68ac..000000000
--- a/exo.kernel.container.ext.provider.impl.guice.v3/src/test/resources/META-INF/services/org.exoplatform.container.spi.Interceptor
+++ /dev/null
@@ -1 +0,0 @@
-org.exoplatform.container.guice.GuiceContainer
\ No newline at end of file
diff --git a/exo.kernel.container.ext.provider.impl.guice.v3/src/test/resources/org/exoplatform/container/guice/test-exo-container.xml b/exo.kernel.container.ext.provider.impl.guice.v3/src/test/resources/org/exoplatform/container/guice/test-exo-container.xml
deleted file mode 100644
index 1c70be22f..000000000
--- a/exo.kernel.container.ext.provider.impl.guice.v3/src/test/resources/org/exoplatform/container/guice/test-exo-container.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
- org.exoplatform.container.guice.ModuleProvider
- org.exoplatform.container.guice.TestGuiceContainer$MyModuleProvider
-
-
- org.exoplatform.container.guice.TestGuiceContainer$A
-
-
- org.exoplatform.container.guice.TestGuiceContainer$A2
-
-
- org.exoplatform.container.guice.TestGuiceContainer$D
-
-
- MyClassE
- org.exoplatform.container.guice.TestGuiceContainer$E1
-
-
- org.exoplatform.container.guice.TestGuiceContainer$QE2
- org.exoplatform.container.guice.TestGuiceContainer$E2
-
-
- org.exoplatform.container.guice.TestGuiceContainer$E
-
-
\ No newline at end of file
diff --git a/exo.kernel.container.ext.provider.impl.guice.v3/src/test/resources/org/exoplatform/container/guice/test-exo-container2.xml b/exo.kernel.container.ext.provider.impl.guice.v3/src/test/resources/org/exoplatform/container/guice/test-exo-container2.xml
deleted file mode 100644
index c676a131b..000000000
--- a/exo.kernel.container.ext.provider.impl.guice.v3/src/test/resources/org/exoplatform/container/guice/test-exo-container2.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
- org.exoplatform.container.guice.ModuleProvider
- org.exoplatform.container.guice.TestGuiceContainer$MyModuleProvider2
-
-
\ No newline at end of file
diff --git a/exo.kernel.container.ext.provider.impl.guice.v3/src/test/resources/test.policy b/exo.kernel.container.ext.provider.impl.guice.v3/src/test/resources/test.policy
deleted file mode 100644
index 616a71b8b..000000000
--- a/exo.kernel.container.ext.provider.impl.guice.v3/src/test/resources/test.policy
+++ /dev/null
@@ -1,22 +0,0 @@
-grant codeBase "@MAVEN_REPO@-"{
- permission java.security.AllPermission;
-};
-
-grant codeBase "@MAIN_CLASSES@-"{
- permission java.security.AllPermission;
-};
-
-grant codeBase "@TEST_CLASSES@-"{
-};
-
-grant codeBase "@MAIN_CLASSES@../../../exo.kernel.commons.test/-"{
- permission java.security.AllPermission;
-};
-
-grant codeBase "@MAIN_CLASSES@../../../exo.kernel.commons/-"{
- permission java.security.AllPermission;
-};
-
-grant codeBase "@MAIN_CLASSES@../../../exo.kernel.container/-"{
- permission java.security.AllPermission;
-};
diff --git a/exo.kernel.container.ext.provider.impl.spring.v3/pom.xml b/exo.kernel.container.ext.provider.impl.spring.v3/pom.xml
deleted file mode 100755
index d30e7adb8..000000000
--- a/exo.kernel.container.ext.provider.impl.spring.v3/pom.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-
-
- 4.0.0
-
- org.exoplatform.kernel
- kernel-parent
- 6.5.x-SNAPSHOT
-
- exo.kernel.container.ext.provider.impl.spring.v3
- eXo PLF:: Kernel :: Container Extension :: Spring Implementation
- A component provider based on Spring.
-
- ${env.MAVEN_OPTS} -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy
- 0.7
-
-
-
- org.exoplatform.kernel
- exo.kernel.container
-
-
- org.exoplatform.kernel
- exo.kernel.container
- test-jar
- test
-
-
- org.springframework
- spring-context
-
-
- commons-logging
- commons-logging
-
-
-
-
- javax.inject
- javax.inject
- provided
-
-
- org.exoplatform.kernel
- exo.kernel.commons.test
- test
-
-
-
-
-
- maven-antrun-plugin
-
-
- prepare-test-policy
- process-test-resources
-
-
- Creating Access Policy for tests
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- run
-
-
-
-
-
- ant
- ant-optional
- 1.5.3-1
-
-
-
-
-
-
diff --git a/exo.kernel.container.ext.provider.impl.spring.v3/src/main/java/org/exoplatform/container/spring/AnnotationConfigApplicationContextProvider.java b/exo.kernel.container.ext.provider.impl.spring.v3/src/main/java/org/exoplatform/container/spring/AnnotationConfigApplicationContextProvider.java
deleted file mode 100644
index 9950d94da..000000000
--- a/exo.kernel.container.ext.provider.impl.spring.v3/src/main/java/org/exoplatform/container/spring/AnnotationConfigApplicationContextProvider.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2013 eXo Platform SAS.
- *
- * 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.exoplatform.container.spring;
-
-import org.exoplatform.commons.utils.ClassLoading;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.ValuesParam;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-
-/**
- * This is the implementation of the {@link ApplicationContextProvider} based on the
- * {@link AnnotationConfigApplicationContext} allowing to configure Spring programmatically.
- * It can be configured using a values-param, each value will be the FQN of the configuration class
- * to be registered.
- *
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public class AnnotationConfigApplicationContextProvider implements ApplicationContextProvider
-{
-
- /**
- * The name of the values parameter that will contain the fqn of the configuration
- * classes
- */
- private static final String CONFIG_CLASSES_PARAM_NAME = "config.classes";
-
- /**
- * The values param containing the configuration
- */
- private final ValuesParam params;
-
- /**
- * The default constructor
- * @param p the initial parameters
- */
- public AnnotationConfigApplicationContextProvider(InitParams p)
- {
- if (p == null || p.getValuesParam(CONFIG_CLASSES_PARAM_NAME) == null)
- {
- throw new IllegalArgumentException("The values parameter " + CONFIG_CLASSES_PARAM_NAME
- + " is mandatory, please set at least one value.");
- }
- this.params = p.getValuesParam(CONFIG_CLASSES_PARAM_NAME);
- }
-
- /**
- * {@inheritDoc}
- */
- public ApplicationContext getApplicationContext(ApplicationContext parent)
- {
- try
- {
- AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
- ctx.setParent(parent);
- for (String value : params.getValues())
- {
- Class> clazz = ClassLoading.forName(value, AnnotationConfigApplicationContextProvider.class);
- ctx.register(clazz);
- }
- ctx.refresh();
- return ctx;
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not create the ApplicationContext", e);
- }
- }
-}
diff --git a/exo.kernel.container.ext.provider.impl.spring.v3/src/main/java/org/exoplatform/container/spring/ApplicationContextProvider.java b/exo.kernel.container.ext.provider.impl.spring.v3/src/main/java/org/exoplatform/container/spring/ApplicationContextProvider.java
deleted file mode 100644
index b70c0f1cf..000000000
--- a/exo.kernel.container.ext.provider.impl.spring.v3/src/main/java/org/exoplatform/container/spring/ApplicationContextProvider.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2013 eXo Platform SAS.
- *
- * 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.exoplatform.container.spring;
-
-import org.springframework.context.ApplicationContext;
-
-/**
- * The main purpose of this class is to provide the {@link ApplicationContext} to the {@link SpringContainer}
- *
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public interface ApplicationContextProvider
-{
- /**
- * Gives the {@link ApplicationContext} that will be used by the {@link SpringContainer}
- * @param parent the parent context
- */
- ApplicationContext getApplicationContext(ApplicationContext parent);
-}
diff --git a/exo.kernel.container.ext.provider.impl.spring.v3/src/main/java/org/exoplatform/container/spring/FileSystemXmlApplicationContextProvider.java b/exo.kernel.container.ext.provider.impl.spring.v3/src/main/java/org/exoplatform/container/spring/FileSystemXmlApplicationContextProvider.java
deleted file mode 100644
index 6a6b27875..000000000
--- a/exo.kernel.container.ext.provider.impl.spring.v3/src/main/java/org/exoplatform/container/spring/FileSystemXmlApplicationContextProvider.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2013 eXo Platform SAS.
- *
- * 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.exoplatform.container.spring;
-
-import org.exoplatform.container.configuration.ConfigurationManager;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.ValuesParam;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.FileSystemXmlApplicationContext;
-
-import java.net.URL;
-
-/**
- * This is the implementation of the {@link ApplicationContextProvider} based on the
- * {@link FileSystemXmlApplicationContext} allowing to configure Spring thanks to XML files.
- * It can be configured using a values-param, each value will be the path of the XML files
- * to be registered. Please note that the expected paths will be retrieved thanks to the
- * {@link ConfigurationManager} which means that all the prefixes supported by the kernel
- * are supported by this component such as jar: and classpath:
- *
- *
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public class FileSystemXmlApplicationContextProvider implements ApplicationContextProvider
-{
-
- /**
- * The name of the values parameter that will contain the path to the configuration
- * files
- */
- private static final String CONFIG_PATHS_PARAM_NAME = "config.paths";
-
- /**
- * The values param containing the configuration
- */
- private final ValuesParam params;
-
- /**
- * The configuration manager
- */
- private final ConfigurationManager cm;
-
- /**
- * The default constructor
- * @param p the initial parameters
- * @param cm the configuration manager
- */
- public FileSystemXmlApplicationContextProvider(InitParams p, ConfigurationManager cm)
- {
- if (p == null || p.getValuesParam(CONFIG_PATHS_PARAM_NAME) == null)
- {
- throw new IllegalArgumentException("The values parameter " + CONFIG_PATHS_PARAM_NAME
- + " is mandatory, please set at least one value.");
- }
- this.params = p.getValuesParam(CONFIG_PATHS_PARAM_NAME);
- this.cm = cm;
- }
-
- /**
- * {@inheritDoc}
- */
- public ApplicationContext getApplicationContext(ApplicationContext parent)
- {
- try
- {
- String[] paths = new String[params.getValues().size()];
- int i = 0;
- for (String value : params.getValues())
- {
- URL url = cm.getResource(value);
- paths[i++] = url.toURI().toString();
- }
- return new FileSystemXmlApplicationContext(paths, true, parent);
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not create the ApplicationContext", e);
- }
- }
-}
diff --git a/exo.kernel.container.ext.provider.impl.spring.v3/src/main/java/org/exoplatform/container/spring/SpringContainer.java b/exo.kernel.container.ext.provider.impl.spring.v3/src/main/java/org/exoplatform/container/spring/SpringContainer.java
deleted file mode 100755
index 440e175ea..000000000
--- a/exo.kernel.container.ext.provider.impl.spring.v3/src/main/java/org/exoplatform/container/spring/SpringContainer.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * Copyright (C) 2013 eXo Platform SAS.
- *
- * 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.exoplatform.container.spring;
-
-import org.exoplatform.commons.utils.SecurityHelper;
-import org.exoplatform.container.AbstractComponentAdapter;
-import org.exoplatform.container.AbstractInterceptor;
-import org.exoplatform.container.configuration.ConfigurationManager;
-import org.exoplatform.container.spi.ComponentAdapter;
-import org.exoplatform.container.spi.ContainerException;
-import org.exoplatform.container.spi.Interceptor;
-import org.exoplatform.container.xml.Component;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.AutowireCandidateQualifier;
-import org.springframework.beans.factory.support.DefaultListableBeanFactory;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.GenericApplicationContext;
-
-import java.lang.annotation.Annotation;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.inject.Named;
-
-/**
- * The implementation of an {@link Interceptor} allowing eXo Kernel to interact with a spring container
- *
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public class SpringContainer extends AbstractInterceptor
-{
-
- /**
- * The serial version UID
- */
- private static final long serialVersionUID = -4841328894117928913L;
-
- /**
- * The logger
- */
- private static final Log LOG = ExoLogger
- .getLogger("exo.kernel.container.ext.provider.impl.spring.v3.SpringContainer");
-
- /**
- * The Spring {@link ApplicationContext}
- */
- private ApplicationContext ctx;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public T getComponentInstance(Object componentKey, Class bindType, boolean autoRegistration)
- {
- T result = super.getComponentInstance(componentKey, bindType, autoRegistration);
- if (ctx != null && result == null)
- {
- if (componentKey instanceof Class> && !((Class>)componentKey).isAnnotation())
- {
- return bindType.cast(getInstanceOfType((Class>)componentKey));
- }
- else if (!(componentKey instanceof String) && !(componentKey instanceof Class>))
- {
- return null;
- }
- String beanName = keyToBeanName(componentKey);
- if (ctx.containsBean(beanName) && bindType.isAssignableFrom(ctx.getType(beanName)))
- {
- return bindType.cast(ctx.getBean(beanName));
- }
- String[] names = ctx.getBeanNamesForType(bindType);
- if (names != null && names.length > 0)
- {
- for (int i = 0, length = names.length; i < length; i++)
- {
- String name = names[i];
- if (componentKey instanceof String)
- {
- Named n = ctx.findAnnotationOnBean(name, Named.class);
- if (n != null && componentKey.equals(n.value()))
- {
- return bindType.cast(ctx.getBean(name));
- }
- }
- else
- {
- @SuppressWarnings("unchecked")
- Annotation a = ctx.findAnnotationOnBean(name, (Class extends Annotation>)componentKey);
- if (a != null)
- {
- return bindType.cast(ctx.getBean(name));
- }
- }
- }
- }
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public T getComponentInstanceOfType(final Class componentType, boolean autoRegistration)
- {
- T result = super.getComponentInstanceOfType(componentType, autoRegistration);
- if (ctx != null && result == null)
- {
- result = getInstanceOfType(componentType);
- }
- return result;
- }
-
- private T getInstanceOfType(final Class componentType)
- {
- T result;
- PrivilegedAction action = new PrivilegedAction()
- {
- public T run()
- {
- String name = classToBeanName(componentType);
- if (ctx.containsBean(name) && componentType.isAssignableFrom(ctx.getType(name)))
- {
- return componentType.cast(ctx.getBean(name));
- }
- String[] names = ctx.getBeanNamesForType(componentType);
- if (names != null && names.length > 0)
- {
- return componentType.cast(ctx.getBean(names[0]));
- }
- return null;
- }
- };
- result = SecurityHelper.doPrivilegedAction(action);
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- @Override
- public ComponentAdapter getComponentAdapter(Object componentKey, Class bindType, boolean autoRegistration)
- {
- ComponentAdapter> result = super.getComponentAdapter(componentKey, bindType, autoRegistration);
- if (ctx != null && result == null)
- {
- if (componentKey instanceof Class> && !((Class>)componentKey).isAnnotation())
- {
- return getAdapterOfType(bindType);
- }
- else if (!(componentKey instanceof String) && !(componentKey instanceof Class>))
- {
- return null;
- }
- String beanName = keyToBeanName(componentKey);
- if (ctx.containsBean(beanName) && bindType.isAssignableFrom(ctx.getType(beanName)))
- {
- return createComponentAdapter(bindType, beanName);
- }
- String[] names = ctx.getBeanNamesForType(bindType);
- if (names != null && names.length > 0)
- {
- for (int i = 0, length = names.length; i < length; i++)
- {
- String name = names[i];
- if (componentKey instanceof String)
- {
- Named n = ctx.findAnnotationOnBean(name, Named.class);
- if (n != null && componentKey.equals(n.value()))
- {
- return createComponentAdapter(bindType, name);
- }
- }
- else
- {
- Annotation a = ctx.findAnnotationOnBean(name, (Class extends Annotation>)componentKey);
- if (a != null)
- {
- return createComponentAdapter(bindType, name);
- }
- }
- }
- }
- }
- return (ComponentAdapter)result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ComponentAdapter getComponentAdapterOfType(Class componentType, boolean autoRegistration)
- {
- ComponentAdapter result = super.getComponentAdapterOfType(componentType, autoRegistration);
- if (ctx != null && result == null)
- {
- result = getAdapterOfType(componentType);
- }
- return result;
- }
-
- private ComponentAdapter getAdapterOfType(Class componentType)
- {
- String name = classToBeanName(componentType);
- if (ctx.containsBean(name) && componentType.isAssignableFrom(ctx.getType(name)))
- {
- return createComponentAdapter(componentType, name);
- }
- String[] names = ctx.getBeanNamesForType(componentType);
- if (names != null && names.length > 0)
- {
- return createComponentAdapter(componentType, names[0]);
- }
- return null;
- }
-
- private ComponentAdapter createComponentAdapter(final Class type, final String name)
- {
- return new AbstractComponentAdapter(type, type)
- {
- /**
- * The serial UID
- */
- private static final long serialVersionUID = -4625398501079851570L;
-
- public T getComponentInstance() throws ContainerException
- {
- return type.cast(ctx.getBean(name));
- }
-
- public boolean isSingleton()
- {
- return ctx.isSingleton(name);
- }
- };
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- @Override
- public List> getComponentAdaptersOfType(Class componentType)
- {
- List> result = super.getComponentAdaptersOfType(componentType);
- if (ctx != null)
- {
- result = new ArrayList>(result);
- String[] names = ctx.getBeanNamesForType(componentType);
- if (names != null)
- {
- for (int i = 0, length = names.length; i < length; i++)
- {
- String name = names[i];
- result.add((ComponentAdapter)createComponentAdapter(ctx.getType(name), name));
- }
- }
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List getComponentInstancesOfType(Class componentType) throws ContainerException
- {
- List result = super.getComponentInstancesOfType(componentType);
- if (ctx != null)
- {
- result = new ArrayList(result);
- result.addAll(ctx.getBeansOfType(componentType).values());
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- @SuppressWarnings({"rawtypes", "unchecked"})
- public void start()
- {
- ConfigurationManager cm = super.getComponentInstanceOfType(ConfigurationManager.class, false);
- // We check if the component has been defined in the configuration of the current container
- // The goal is to enable the SpringContainer only if it is needed
- Component component = cm.getComponent(ApplicationContextProvider.class);
- if (component == null)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug("No ApplicationContextProvider has been defined, thus the SpringContainer will be disabled."
- + " To enable the Spring Integration please define an ApplicationContextProvider");
- }
- }
- else
- {
- DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
- bf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
- Collection> adapters = delegate.getComponentAdapters();
- for (ComponentAdapter> adapter : adapters)
- {
- Object key = adapter.getComponentKey();
- String name = keyToBeanName(key);
- String factoryName = name + "#factory";
- RootBeanDefinition def =
- new RootBeanDefinition(adapter.getComponentImplementation(), AbstractBeanDefinition.AUTOWIRE_NO, false);
- def.setScope(BeanDefinition.SCOPE_PROTOTYPE);
- def.setFactoryBeanName(factoryName);
- def.setFactoryMethodName("getInstance");
- def.setLazyInit(true);
- def.setTargetType(adapter.getComponentImplementation());
- if (key instanceof String)
- {
- def.addQualifier(new AutowireCandidateQualifier(Named.class, key));
- }
- else if (key instanceof Class> && ((Class>)key).isAnnotation())
- {
- def.addQualifier(new AutowireCandidateQualifier((Class>)key));
- }
- else
- {
- def.setPrimary(true);
- }
- bf.registerBeanDefinition(name, def);
- bf.registerSingleton(factoryName, new ComponentAdapterFactoryBean(adapter));
- }
- GenericApplicationContext parentContext = new GenericApplicationContext(bf);
- parentContext.refresh();
- ApplicationContextProvider provider =
- super.getComponentInstanceOfType(ApplicationContextProvider.class, false);
- ctx = provider.getApplicationContext(parentContext);
- LOG.info("A SpringContainer has been enabled using the ApplicationContextProvider " + provider.getClass());
- }
- super.start();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void stop()
- {
- super.stop();
- if (ctx instanceof DisposableBean)
- {
- try
- {
- ((DisposableBean)ctx).destroy();
- }
- catch (Exception e)
- {
- LOG.warn("Could not destroy the container: " + e.getMessage());
- }
- finally
- {
- ctx = null;
- }
- }
- }
-
- private static String classToBeanName(Class> type)
- {
- return type.getName();
- }
-
- private static String keyToBeanName(Object key)
- {
- if (key instanceof Class>)
- {
- return classToBeanName((Class>)key);
- }
- else
- {
- if (key instanceof String)
- {
- return (String)key;
- }
- else
- {
- return classToBeanName(key.getClass());
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public String getId()
- {
- return "SpringIntegration";
- }
-
- static class ComponentAdapterFactoryBean
- {
- private final ComponentAdapter adapter;
-
- private ComponentAdapterFactoryBean(ComponentAdapter adapter)
- {
- this.adapter = adapter;
- }
-
- public T getInstance() throws Exception
- {
- return adapter.getComponentInstance();
- }
- }
-}
diff --git a/exo.kernel.container.ext.provider.impl.spring.v3/src/main/resources/META-INF/services/org.exoplatform.container.spi.Interceptor b/exo.kernel.container.ext.provider.impl.spring.v3/src/main/resources/META-INF/services/org.exoplatform.container.spi.Interceptor
deleted file mode 100755
index 487d053f4..000000000
--- a/exo.kernel.container.ext.provider.impl.spring.v3/src/main/resources/META-INF/services/org.exoplatform.container.spi.Interceptor
+++ /dev/null
@@ -1 +0,0 @@
-org.exoplatform.container.spring.SpringContainer
\ No newline at end of file
diff --git a/exo.kernel.container.ext.provider.impl.spring.v3/src/test/java/org/exoplatform/container/spring/TestSpringContainer.java b/exo.kernel.container.ext.provider.impl.spring.v3/src/test/java/org/exoplatform/container/spring/TestSpringContainer.java
deleted file mode 100755
index 8a62ef85c..000000000
--- a/exo.kernel.container.ext.provider.impl.spring.v3/src/test/java/org/exoplatform/container/spring/TestSpringContainer.java
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * Copyright (C) 2013 eXo Platform SAS.
- *
- * 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.exoplatform.container.spring;
-
-import org.exoplatform.container.ContainerBuilder;
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.container.RootContainer;
-import org.exoplatform.container.jmx.AbstractTestContainer;
-import org.exoplatform.container.spi.ComponentAdapter;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Scope;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.net.URL;
-import java.util.List;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Provider;
-import javax.inject.Qualifier;
-import javax.inject.Singleton;
-
-/**
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public class TestSpringContainer extends AbstractTestContainer
-{
-
- public void testIntegrationClass()
- {
- URL rootURL = getClass().getResource("test-exo-container.xml");
- URL portalURL = getClass().getResource("test-exo-container2.xml");
- assertNotNull(rootURL);
- assertNotNull(portalURL);
- //
- new ContainerBuilder().withRoot(rootURL).withPortal(portalURL).profiledBy("class").build();
- RootContainer root = RootContainer.getInstance();
- testIntegration(root);
- }
-
- public void testIntegrationFile()
- {
- URL rootURL = getClass().getResource("test-exo-container.xml");
- URL portalURL = getClass().getResource("test-exo-container2.xml");
- assertNotNull(rootURL);
- assertNotNull(portalURL);
- //
- new ContainerBuilder().withRoot(rootURL).withPortal(portalURL).profiledBy("file").build();
- RootContainer root = RootContainer.getInstance();
- testIntegration(root);
- }
-
- @SuppressWarnings("unchecked")
- private void testIntegration(RootContainer container)
- {
- assertNotNull(container);
- ComponentAdapter adapterA = container.getComponentAdapterOfType(A.class);
- assertNotNull(adapterA);
- assertSame(adapterA, container.getComponentAdapterOfType(A.class));
- ComponentAdapter adapterB = container.getComponentAdapterOfType(B.class);
- assertNotNull(adapterB);
- ComponentAdapter adapterC = container.getComponentAdapterOfType(C.class);
- assertNotNull(adapterC);
- ComponentAdapter adapterD = container.getComponentAdapterOfType(D.class);
- assertNotNull(adapterD);
- assertSame(adapterD, container.getComponentAdapterOfType(D.class));
- ComponentAdapter adapterE = container.getComponentAdapterOfType(E.class);
- assertNotNull(adapterE);
- adapterE = (ComponentAdapter)container.getComponentAdapter("MyClassE");
- assertNotNull(adapterE);
- assertSame(adapterE, container.getComponentAdapter("MyClassE"));
- ComponentAdapter adapterF = container.getComponentAdapterOfType(F.class);
- assertNotNull(adapterF);
- ComponentAdapter adapterG = container.getComponentAdapterOfType(G.class);
- assertNotNull(adapterG);
- A a = container.getComponentInstanceOfType(A.class);
- assertNotNull(a);
- assertSame(a, container.getComponentInstanceOfType(A.class));
- assertSame(a, adapterA.getComponentInstance());
- B b = container.getComponentInstanceOfType(B.class);
- assertNotNull(b);
- assertSame(b, container.getComponentInstanceOfType(B.class));
- assertSame(b, adapterB.getComponentInstance());
- C c = container.getComponentInstanceOfType(C.class);
- assertNotNull(c);
- assertNotSame(c, container.getComponentInstanceOfType(C.class));
- assertNotSame(c, adapterC.getComponentInstance());
- assertSame(a, c.a);
- assertSame(b, c.b);
- assertSame(a, ((C)adapterC.getComponentInstance()).a);
- assertSame(b, ((C)adapterC.getComponentInstance()).b);
- assertSame(a, container.getComponentInstanceOfType(C.class).a);
- assertSame(b, container.getComponentInstanceOfType(C.class).b);
- assertNotNull(c.a2);
- assertNotNull(c.a2_2);
- assertNotSame(c.a2, c.a2_2);
- assertNotNull(c.d);
- assertSame(c.d, c.d2);
- D d = container.getComponentInstanceOfType(D.class);
- assertNotNull(d);
- assertSame(d, container.getComponentInstanceOfType(D.class));
- assertSame(d, adapterD.getComponentInstance());
- assertSame(a, d.a);
- assertSame(b, d.b);
- assertTrue(d.g instanceof G1);
- assertTrue(d.g_2 instanceof G2);
- assertTrue(d.g2 instanceof G2);
- assertTrue(d.g2_1 instanceof G1);
- assertTrue(d.g3.get() instanceof G3);
- E e = (E)container.getComponentInstance("MyClassE");
- assertNotNull(a);
- assertSame(e, container.getComponentInstance("MyClassE"));
- assertSame(e, adapterE.getComponentInstance());
- F f = container.getComponentInstanceOfType(F.class);
- assertNotNull(f);
- assertSame(f, container.getComponentInstanceOfType(F.class));
- assertSame(f, adapterF.getComponentInstance());
- assertSame(e, f.e);
- assertTrue(f.e instanceof E1);
- assertTrue(f.m instanceof E1);
- assertTrue(f.e2 instanceof E2);
- assertNotNull(f.e3.get());
- assertTrue(f.e3.get() instanceof E);
- assertFalse(f.e3.get() instanceof E1);
- assertFalse(f.e3.get() instanceof E2);
- G g = container.getComponentInstanceOfType(G.class);
- assertNotNull(g);
- assertSame(g, container.getComponentInstanceOfType(G.class));
- assertSame(g, adapterG.getComponentInstance());
- List> adapters = container.getComponentAdaptersOfType(Marker.class);
- assertNotNull(adapters);
- assertEquals(4, adapters.size());
- boolean foundE = false, foundF = false, foundE1 = false, foundE2 = false;
- for (ComponentAdapter adapter : adapters)
- {
- if (adapter.getComponentImplementation().equals(E1.class))
- {
- foundE1 = true;
- assertSame(e, adapter.getComponentInstance());
- }
- else if (adapter.getComponentImplementation().equals(E2.class))
- {
- foundE2 = true;
- assertSame(f.e2, adapter.getComponentInstance());
- }
- else if (adapter.getComponentImplementation().equals(E.class))
- {
- foundE = true;
- assertSame(f.e3.get(), adapter.getComponentInstance());
- }
- else if (adapter.getComponentImplementation().equals(F.class))
- {
- foundF = true;
- assertSame(f, adapter.getComponentInstance());
- }
- }
- assertTrue(foundE);
- assertTrue(foundE1);
- assertTrue(foundE2);
- assertTrue(foundF);
- List markers = container.getComponentInstancesOfType(Marker.class);
- assertNotNull(markers);
- assertEquals(4, markers.size());
- assertTrue(markers.contains(e));
- assertTrue(markers.contains(f.e));
- assertTrue(markers.contains(f.e2));
- assertTrue(markers.contains(f));
- ComponentAdapter adapterH = container.getComponentAdapterOfType(H.class);
- assertNull(adapterH);
- PortalContainer portal = PortalContainer.getInstance();
- adapterH = portal.getComponentAdapterOfType(H.class);
- assertNotNull(adapterH);
- H h = container.getComponentInstanceOfType(H.class);
- assertNull(h);
- h = portal.getComponentInstanceOfType(H.class);
- assertNotNull(h);
- assertSame(h, portal.getComponentInstanceOfType(H.class));
- assertSame(h, adapterH.getComponentInstance());
- List> adaptersH = container.getComponentAdaptersOfType(H.class);
- assertTrue(adaptersH == null || adaptersH.isEmpty());
- adaptersH = portal.getComponentAdaptersOfType(H.class);
- assertNotNull(adaptersH);
- assertEquals(1, adaptersH.size());
- assertSame(h, adaptersH.get(0).getComponentInstance());
- List allH = container.getComponentInstancesOfType(H.class);
- assertTrue(allH == null || allH.isEmpty());
- allH = portal.getComponentInstancesOfType(H.class);
- assertNotNull(allH);
- assertEquals(1, allH.size());
- assertSame(h, allH.get(0));
- }
-
- public static class A
- {
- }
-
- public static class A2
- {
- @Inject
- public A2() {}
- }
-
- @Singleton
- public static class B
- {
- }
-
- public static class C
- {
- @Inject
- A a;
-
- @Inject
- A2 a2;
-
- @Inject
- A2 a2_2;
-
- @Inject
- B b;
-
- @Inject
- D d;
-
- @Inject
- D d2;
- }
-
- @Singleton
- public static class D
- {
- A a;
-
- B b;
-
- @Inject
- @Named("MyClassG")
- G g;
-
- @Inject
- @Named("MyClassG2")
- G g_2;
-
- @Inject
- @QG2
- G g2;
-
- @Inject
- @QG2_1
- G g2_1;
-
- @Inject
- Provider g3;
-
- @Inject
- public D(A a, B b)
- {
- this.a = a;
- this.b = b;
- }
- }
-
- public static class E implements Marker
- {
- }
-
- public static class E1 extends E
- {
- }
-
- public static class E2 extends E
- {
- }
-
- @Singleton
- public static class F implements Marker
- {
- @Inject
- @Named("MyClassE")
- E e;
-
- @Inject
- @Named("MyClassE")
- Marker m;
-
- @Inject
- @QE2
- E e2;
-
- @Inject
- Provider e3;
- }
-
- public abstract static class G
- {
- }
-
- @Singleton
- @Named("MyClassG")
- public static class G1 extends G
- {
- }
-
- @Singleton
- @QG2
- public static class G2 extends G
- {
- }
-
- @Singleton
- public static class G3 extends G
- {
- }
-
- @Singleton
- public static class H
- {
- }
-
- public static interface Marker
- {
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- @Qualifier
- public static @interface QE2
- {
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- @Qualifier
- public static @interface QG2
- {
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- @Qualifier
- public static @interface QG2_1
- {
- }
-
- @Configuration
- public static class Config
- {
- @Autowired
- A a;
-
- @Autowired
- B b;
-
- @Bean
- public B b()
- {
- return new B();
- }
-
- @Bean
- @Scope("prototype")
- public C c()
- {
- C c = new C();
- c.a = a;
- c.b = b;
- return c;
- }
-
- @Bean
- public F f(@Named("MyClassE") E e, @Named("MyClassE") Marker m, @QE2 E e2, Provider e3)
- {
- F f = new F();
- f.e = e;
- f.m = m;
- f.e2 = e2;
- f.e3 = e3;
- return f;
- }
-
- @Bean
- public G g()
- {
- return new G1();
- }
-
- @Bean(name="MyClassG2")
- public G g_2()
- {
- return new G2();
- }
-
- @Bean
- public G g1()
- {
- return new G2();
- }
-
- @Bean(name="org.exoplatform.container.spring.TestSpringContainer$QG2_1")
- public G g1_2()
- {
- return new G1();
- }
-
- @Bean(name="org.exoplatform.container.spring.TestSpringContainer$G")
- public G g2()
- {
- return new G3();
- }
- }
-
- @Configuration
- public static class Config2
- {
- @Bean
- public H h()
- {
- return new H();
- }
- }
-}
\ No newline at end of file
diff --git a/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/META-INF/services/org.exoplatform.container.spi.Interceptor b/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/META-INF/services/org.exoplatform.container.spi.Interceptor
deleted file mode 100755
index 487d053f4..000000000
--- a/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/META-INF/services/org.exoplatform.container.spi.Interceptor
+++ /dev/null
@@ -1 +0,0 @@
-org.exoplatform.container.spring.SpringContainer
\ No newline at end of file
diff --git a/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/org/exoplatform/container/spring/beans-config.xml b/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/org/exoplatform/container/spring/beans-config.xml
deleted file mode 100755
index 826f8f443..000000000
--- a/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/org/exoplatform/container/spring/beans-config.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/org/exoplatform/container/spring/beans-config2.xml b/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/org/exoplatform/container/spring/beans-config2.xml
deleted file mode 100755
index 2b4eb6f5f..000000000
--- a/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/org/exoplatform/container/spring/beans-config2.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/org/exoplatform/container/spring/test-exo-container.xml b/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/org/exoplatform/container/spring/test-exo-container.xml
deleted file mode 100755
index d8174c342..000000000
--- a/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/org/exoplatform/container/spring/test-exo-container.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
- org.exoplatform.container.spring.TestSpringContainer$A
-
-
- org.exoplatform.container.spring.TestSpringContainer$A2
-
-
- org.exoplatform.container.spring.TestSpringContainer$D
-
-
- MyClassE
- org.exoplatform.container.spring.TestSpringContainer$E1
-
-
- org.exoplatform.container.spring.TestSpringContainer$QE2
- org.exoplatform.container.spring.TestSpringContainer$E2
-
-
- org.exoplatform.container.spring.TestSpringContainer$E
-
-
- org.exoplatform.container.spring.ApplicationContextProvider
- org.exoplatform.container.spring.AnnotationConfigApplicationContextProvider
-
-
- config.classes
- FQN of the configuration classes
- org.exoplatform.container.spring.TestSpringContainer$Config
-
-
-
-
- org.exoplatform.container.spring.ApplicationContextProvider
- org.exoplatform.container.spring.FileSystemXmlApplicationContextProvider
-
-
- config.paths
- Path of the configuration files
- beans-config.xml
-
-
-
-
\ No newline at end of file
diff --git a/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/org/exoplatform/container/spring/test-exo-container2.xml b/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/org/exoplatform/container/spring/test-exo-container2.xml
deleted file mode 100755
index 116908703..000000000
--- a/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/org/exoplatform/container/spring/test-exo-container2.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
- org.exoplatform.container.spring.ApplicationContextProvider
- org.exoplatform.container.spring.AnnotationConfigApplicationContextProvider
-
-
- config.classes
- FQN of the configuration classes
- org.exoplatform.container.spring.TestSpringContainer$Config2
-
-
-
-
- org.exoplatform.container.spring.ApplicationContextProvider
- org.exoplatform.container.spring.FileSystemXmlApplicationContextProvider
-
-
- config.paths
- Path of the configuration files
- classpath:/org/exoplatform/container/spring/beans-config2.xml
-
-
-
-
\ No newline at end of file
diff --git a/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/test.policy b/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/test.policy
deleted file mode 100755
index 616a71b8b..000000000
--- a/exo.kernel.container.ext.provider.impl.spring.v3/src/test/resources/test.policy
+++ /dev/null
@@ -1,22 +0,0 @@
-grant codeBase "@MAVEN_REPO@-"{
- permission java.security.AllPermission;
-};
-
-grant codeBase "@MAIN_CLASSES@-"{
- permission java.security.AllPermission;
-};
-
-grant codeBase "@TEST_CLASSES@-"{
-};
-
-grant codeBase "@MAIN_CLASSES@../../../exo.kernel.commons.test/-"{
- permission java.security.AllPermission;
-};
-
-grant codeBase "@MAIN_CLASSES@../../../exo.kernel.commons/-"{
- permission java.security.AllPermission;
-};
-
-grant codeBase "@MAIN_CLASSES@../../../exo.kernel.container/-"{
- permission java.security.AllPermission;
-};
diff --git a/exo.kernel.container.ext.provider.impl.weld.v1/pom.xml b/exo.kernel.container.ext.provider.impl.weld.v1/pom.xml
deleted file mode 100755
index ed03816bc..000000000
--- a/exo.kernel.container.ext.provider.impl.weld.v1/pom.xml
+++ /dev/null
@@ -1,112 +0,0 @@
-
-
-
-
- 4.0.0
-
- org.exoplatform.kernel
- kernel-parent
- 6.5.x-SNAPSHOT
-
- exo.kernel.container.ext.provider.impl.weld.v1
- eXo PLF:: Kernel :: Container Extension :: Weld 1 Implementation
- A component provider based on Weld 1.
-
- ${env.MAVEN_OPTS} -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy
- 0.8
-
-
-
- org.exoplatform.kernel
- exo.kernel.container
-
-
- javax.enterprise
- cdi-api
-
-
-
-
- org.exoplatform.kernel
- exo.kernel.container
- test-jar
- test
-
-
- javax.enterprise
- cdi-api
-
-
-
-
- org.jboss.weld.se
- weld-se
- 1.1.16.Final
-
-
- org.exoplatform.kernel
- exo.kernel.commons.test
- test
-
-
-
-
-
- maven-antrun-plugin
-
-
- prepare-test-policy
- process-test-resources
-
-
- Creating Access Policy for tests
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- run
-
-
-
-
-
- ant
- ant-optional
- 1.5.3-1
-
-
-
-
-
-
diff --git a/exo.kernel.container.ext.provider.impl.weld.v1/src/main/java/org/exoplatform/container/weld/BasicWeldContainerHelper.java b/exo.kernel.container.ext.provider.impl.weld.v1/src/main/java/org/exoplatform/container/weld/BasicWeldContainerHelper.java
deleted file mode 100644
index ec89dbdb9..000000000
--- a/exo.kernel.container.ext.provider.impl.weld.v1/src/main/java/org/exoplatform/container/weld/BasicWeldContainerHelper.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2013 eXo Platform SAS.
- *
- * 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.exoplatform.container.weld;
-
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.ValuesParam;
-import org.jboss.weld.environment.se.Weld;
-
-import java.util.List;
-
-import javax.enterprise.inject.spi.Extension;
-
-/**
- * This provider simply returns no {@link Extension} to be added to {@link Weld}. It also
- * relies on a configurable lists of prefixes of classes to be included or excluded from
- * the scope of {@link Weld}.
- *
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public class BasicWeldContainerHelper implements WeldContainerHelper
-{
-
- /**
- * The name of the values parameter that will contain the prefixes of the
- * classes to be included into the scope of Weld
- */
- private static final String INCLUDE_PARAM_NAME = "include";
-
- /**
- * The name of the values parameter that will contain the prefixes of the
- * classes to be excluded from the scope of Weld
- */
- private static final String EXCLUDE_PARAM_NAME = "exclude";
-
- /**
- * An array of String containing the prefixes of classes to be included into the scope of {@link Weld}
- */
- private final String[] includes;
-
- /**
- * An array of String containing the prefixes of classes to be excluded from the scope of {@link Weld}
- */
- private final String[] excludes;
-
- /**
- * The default constructor
- * @param p the initial parameters
- */
- public BasicWeldContainerHelper(InitParams p)
- {
- ValuesParam params = p == null ? null : p.getValuesParam(INCLUDE_PARAM_NAME);
- if (params != null && params.getValues().size() > 0)
- {
- includes = new String[params.getValues().size()];
- int i = 0;
- for (String value : params.getValues())
- {
- includes[i++] = value;
- }
- }
- else
- {
- includes = null;
- }
- params = p == null ? null : p.getValuesParam(EXCLUDE_PARAM_NAME);
- if (params != null && params.getValues().size() > 0)
- {
- excludes = new String[params.getValues().size()];
- int i = 0;
- for (String value : params.getValues())
- {
- excludes[i++] = value;
- }
- }
- else
- {
- excludes = null;
- }
- if (includes == null && excludes == null)
- {
- throw new IllegalArgumentException("The values parameter " + INCLUDE_PARAM_NAME + " and " + EXCLUDE_PARAM_NAME
- + " cannot be both empty, please set at least " + "one value to one of them.");
- }
- }
-
- /**
- * Simply returns null
- * {@inheritDoc}
- */
- public List getExtensions()
- {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isIncluded(Class> clazz)
- {
- String name = clazz.getName();
- boolean result;
- if (includes != null && includes.length > 0)
- {
- // We included at least one class prefix
- result = false;
- for (int i = 0, length = includes.length; i < length; i++)
- {
- if (name.startsWith(includes[i]))
- {
- result = true;
- break;
- }
- }
- }
- else
- {
- // we did not define any class prefix
- result = true;
- }
- if (excludes != null)
- {
- for (int i = 0, length = excludes.length; i < length; i++)
- {
- if (name.startsWith(excludes[i]))
- {
- result = false;
- break;
- }
- }
- }
- return result;
- }
-}
diff --git a/exo.kernel.container.ext.provider.impl.weld.v1/src/main/java/org/exoplatform/container/weld/WeldContainer.java b/exo.kernel.container.ext.provider.impl.weld.v1/src/main/java/org/exoplatform/container/weld/WeldContainer.java
deleted file mode 100755
index 6c6f92d5b..000000000
--- a/exo.kernel.container.ext.provider.impl.weld.v1/src/main/java/org/exoplatform/container/weld/WeldContainer.java
+++ /dev/null
@@ -1,681 +0,0 @@
-/*
- * Copyright (C) 2013 eXo Platform SAS.
- *
- * 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.exoplatform.container.weld;
-
-import org.exoplatform.commons.utils.SecurityHelper;
-import org.exoplatform.container.AbstractComponentAdapter;
-import org.exoplatform.container.AbstractInterceptor;
-import org.exoplatform.container.configuration.ConfigurationManager;
-import org.exoplatform.container.spi.ComponentAdapter;
-import org.exoplatform.container.spi.ContainerException;
-import org.exoplatform.container.spi.Interceptor;
-import org.exoplatform.container.xml.Component;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.jboss.weld.environment.se.Weld;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.Type;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.enterprise.context.Dependent;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Any;
-import javax.enterprise.inject.Default;
-import javax.enterprise.inject.Instance;
-import javax.enterprise.inject.spi.AfterBeanDiscovery;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
-import javax.enterprise.util.AnnotationLiteral;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-/**
- * The implementation of an {@link Interceptor} allowing eXo Kernel to interact with a weld container
- *
- * @author Nicolas Filotto
- * @version $Id$
- *
- */
-public class WeldContainer extends AbstractInterceptor
-{
-
- /**
- * The serial version UID
- */
- private static final long serialVersionUID = -5805946626633663689L;
-
- /**
- * The logger
- */
- private static final Log LOG = ExoLogger.getLogger("exo.kernel.container.ext.provider.impl.weld.v1.WeldContainer");
-
- /**
- * The name of the weld package
- */
- private static final String WELD_PACKAGE_NAME = org.jboss.weld.Container.class.getPackage().getName();
-
- /**
- * The weld object allowing to initialize and stop the weld container
- */
- private Weld weld;
-
- /**
- * The weld container
- */
- private org.jboss.weld.environment.se.WeldContainer container;
-
- /**
- * The helper used to access to the extensions and to know if a given class is part of the scope of
- * {@link Weld}
- */
- private WeldContainerHelper helper;
-
- /**
- * The weld container, we will use it mainly to shutdown it manually in case of a failure
- */
- private org.jboss.weld.Container weldContainer;
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- @Override
- public T getComponentInstance(final Object componentKey, Class bindType, boolean autoRegistration)
- {
- T result = super.getComponentInstance(componentKey, bindType, autoRegistration);
- if (weld != null && result == null)
- {
- if (componentKey instanceof Class> && !((Class>)componentKey).isAnnotation())
- {
- return getInstanceOfType((Class)componentKey);
- }
- else if (componentKey instanceof String)
- {
- Set> beans = container.getBeanManager().getBeans(bindType, createNamed((String)componentKey));
- if (beans != null && !beans.isEmpty())
- {
- return bindType.cast(container.instance().select(beans.iterator().next().getBeanClass()).get());
- }
- }
- else if (componentKey instanceof Class>)
- {
- final Class extends Annotation> annotationType = (Class extends Annotation>)componentKey;
- Annotation annotation = createAnnotation(annotationType);
-
- Set> beans = container.getBeanManager().getBeans(bindType, annotation);
- if (beans != null && !beans.isEmpty())
- {
- return bindType.cast(container.instance().select(beans.iterator().next().getBeanClass()).get());
- }
- }
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public T getComponentInstanceOfType(Class componentType, boolean autoRegistration)
- {
- T result = super.getComponentInstanceOfType(componentType, autoRegistration);
- if (weld != null && result == null)
- {
- result = getInstanceOfType(componentType);
- }
- return result;
- }
-
- @SuppressWarnings("unchecked")
- private T getInstanceOfType(final Class componentType)
- {
- return SecurityHelper.doPrivilegedAction(new PrivilegedAction()
- {
- public T run()
- {
- if (helper.isIncluded(componentType))
- {
- Instance instance = container.instance().select(componentType);
- if (instance != null)
- {
- if (instance.isAmbiguous())
- {
- Set> beans = container.getBeanManager().getBeans(componentType);
- for (Bean> b : beans)
- {
- if (b.getBeanClass().isAnnotationPresent(Default.class))
- {
- instance = (Instance)container.instance().select(b.getBeanClass());
- break;
- }
- }
- }
- return instance.get();
- }
- }
- return null;
- }
- });
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- @Override
- public ComponentAdapter getComponentAdapter(final Object componentKey, Class bindType,
- boolean autoRegistration)
- {
- ComponentAdapter result = super.getComponentAdapter(componentKey, bindType, autoRegistration);
- if (weld != null && result == null)
- {
- if (componentKey instanceof Class> && !((Class>)componentKey).isAnnotation())
- {
- return getAdapterOfType((Class)componentKey);
- }
- else if (componentKey instanceof String)
- {
- Set> beans = container.getBeanManager().getBeans(bindType, createNamed((String)componentKey));
- if (beans != null && !beans.isEmpty())
- {
- return createComponentAdapter(bindType,
- (Instance)container.instance().select(beans.iterator().next().getBeanClass()));
- }
- }
- else if (componentKey instanceof Class>)
- {
- final Class extends Annotation> annotationType = (Class extends Annotation>)componentKey;
- Annotation annotation = createAnnotation(annotationType);
- Set> beans = container.getBeanManager().getBeans(bindType, annotation);
- if (beans != null && !beans.isEmpty())
- {
- return createComponentAdapter(bindType,
- (Instance)container.instance().select(beans.iterator().next().getBeanClass()));
- }
- }
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ComponentAdapter getComponentAdapterOfType(Class componentType, boolean autoRegistration)
- {
- ComponentAdapter result = super.getComponentAdapterOfType(componentType, autoRegistration);
- if (weld != null && result == null)
- {
- result = getAdapterOfType(componentType);
- }
- return result;
- }
-
- @SuppressWarnings("unchecked")
- private ComponentAdapter getAdapterOfType(Class componentType)
- {
- if (helper.isIncluded(componentType))
- {
- Instance instance = container.instance().select(componentType);
- if (instance != null)
- {
- if (instance.isAmbiguous())
- {
- Set> beans = container.getBeanManager().getBeans(componentType);
- for (Bean> b : beans)
- {
- if (b.getBeanClass().isAnnotationPresent(Default.class))
- {
- instance = (Instance)container.instance().select(b.getBeanClass());
- break;
- }
- }
- }
- return createComponentAdapter(componentType, instance);
- }
- }
- return null;
- }
-
- private ComponentAdapter createComponentAdapter(final Class type, final Instance instance)
- {
- return new AbstractComponentAdapter(type, type)
- {
- /**
- * The serial UID
- */
- private static final long serialVersionUID = 8230487164261120364L;
-
- public T getComponentInstance() throws ContainerException
- {
- return SecurityHelper.doPrivilegedAction(new PrivilegedAction()
- {
- public T run()
- {
- return instance.get();
- }
- });
- }
-
- public boolean isSingleton()
- {
- return false;
- }
- };
- }
-
- @SuppressWarnings("unchecked")
- private ComponentAdapter createComponentAdapter(final Class type, final Bean> b)
- {
- return new AbstractComponentAdapter(type, (Class)b.getBeanClass())
- {
- /**
- * The serial UID
- */
- private static final long serialVersionUID = -2398896047339159840L;
-
- public T getComponentInstance() throws ContainerException
- {
- return type.cast(container.instance().select(b.getBeanClass()).get());
- }
-
- public boolean isSingleton()
- {
- return Singleton.class.equals(b.getScope());
- }
- };
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List> getComponentAdaptersOfType(Class componentType)
- {
- List> result = super.getComponentAdaptersOfType(componentType);
- if (weld != null)
- {
- result = new ArrayList>(result);
- Set> beans = container.getBeanManager().getBeans(componentType);
- if (beans != null)
- {
- for (Bean> b : beans)
- {
- result.add(createComponentAdapter(componentType, b));
- }
- }
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List getComponentInstancesOfType(Class componentType) throws ContainerException
- {
- List result = super.getComponentInstancesOfType(componentType);
- if (weld != null)
- {
- Instance instance = container.instance().select(componentType);
- if (instance != null)
- {
- for (T t : instance)
- {
- result.add(t);
- }
- }
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void start()
- {
- ConfigurationManager cm = super.getComponentInstanceOfType(ConfigurationManager.class, false);
- // We check if the component has been defined in the configuration of the current container
- // The goal is to enable the WeldContainer only if it is needed
- Component component = cm.getComponent(WeldContainerHelper.class);
- if (component == null)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug("No WeldContainerHelper has been defined, thus the WeldContainer will be disabled."
- + " To enable the Weld Integration please define an WeldContainerHelper");
- }
- }
- else
- {
- Weld weld = new Weld();
- weld.addExtension(new WeldExtension(this));
- WeldContainerHelper helper = super.getComponentInstanceOfType(WeldContainerHelper.class, false);
- List extensions = helper.getExtensions();
- if (extensions != null)
- {
- for (Extension e : extensions)
- {
- weld.addExtension(e);
- }
- }
- this.helper = helper;
- this.container = weld.initialize();
- // This is an ugly hack to make sure that the BeanManagerProxy is initialized with the right Container
- // This is needed especially when we intend to initialize several weld containers within the same instance
- container.getBeanManager().getBeans(org.jboss.weld.environment.se.WeldContainer.class);
- this.weldContainer = org.jboss.weld.Container.instance();
- this.weld = weld;
- LOG.info("A WeldContainer has been enabled using the WeldContainerHelper " + helper.getClass());
- }
- super.start();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void stop()
- {
- super.stop();
- if (weld != null)
- {
- org.jboss.weld.Container currentContainer =
- org.jboss.weld.Container.available() ? org.jboss.weld.Container.instance() : null;
- try
- {
- weld.shutdown();
- }
- catch (RuntimeException e)
- {
- // In case we have several weld container initialized, we will get an IllegalStateException because weld doesn't allow to have several weld containers
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Could not shutdown the weld container properly", e);
- }
- }
- if (currentContainer != weldContainer) //NOSONAR
- {
- // Clean up manually the container in case the current container is not the container corresponding to the container of this weld container
- weldContainer.cleanup();
- }
- weld = null;
- container = null;
- helper = null;
- weldContainer = null;
- }
- }
-
- private static Annotation createAnnotation(final Class extends Annotation> annotationType)
- {
- return (Annotation)Proxy.newProxyInstance(annotationType.getClassLoader(), annotationType.getInterfaces(),
- new InvocationHandler()
- {
- public Object invoke(Object proxy, Method method, Object[] args)
- {
- if ("hashCode".equals(method.getName()))
- {
- return annotationType.getName().hashCode();
- }
- else if ("equals".equals(method.getName()))
- {
- return args[0].hashCode() == annotationType.getName().hashCode()
- && args[0].toString().equals(annotationType.getName());
- }
- else if ("toString".equals(method.getName()))
- {
- return annotationType.getName();
- }
-
- return annotationType;
- }
- });
- }
-
- private static Named createNamed(final String name)
- {
- return new Named()
- {
- public Class extends Annotation> annotationType()
- {
- return Named.class;
- }
-
- public String value()
- {
- return name;
- }
- };
- }
-
- /**
- * {@inheritDoc}
- */
- public String getId()
- {
- return "WeldIntegration";
- }
-
- /**
- * We switch to a public static class to allow weld to create a proxy the class
- */
- public static class WeldExtension implements Extension
- {
- private final WeldContainer container;
-
- public WeldExtension()
- {
- this(null);
- }
-
- public WeldExtension(WeldContainer container)
- {
- this.container = container;
- }
-
- @SuppressWarnings({"unchecked", "rawtypes"})
- void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm)
- {
- Collection> adapters = container.delegate.getComponentAdapters();
- for (ComponentAdapter> adapter : adapters)
- {
- abd.addBean(new ComponentAdapterBean(adapter));
- }
- }
-
- void processAnnotatedType(@Observes ProcessAnnotatedType pat)
- {
- Class clazz = pat.getAnnotatedType().getJavaClass();
- if (clazz.getName().startsWith(WELD_PACKAGE_NAME))
- return;
- if (!container.helper.isIncluded(clazz))
- {
- pat.veto();
- }
- }
- }
-
- private static void bindAll(Class> clazz, Set types)
- {
- if (clazz == null || clazz.equals(Object.class))
- return;
- types.add(clazz);
- for (Class> c : clazz.getInterfaces())
- {
- bindAll(c, types);
- }
- bindAll(clazz.getSuperclass(), types);
- }
-
- private static class ComponentAdapterBean implements Bean
- {
- private final ComponentAdapter adapter;
-
- private Set types;
-
- private Set qualifiers;
-
- public ComponentAdapterBean(ComponentAdapter adapter)
- {
- this.adapter = adapter;
- }
-
- /**
- * {@inheritDoc}
- */
- public T create(CreationalContext ctx)
- {
- return adapter.getComponentInstance();
- }
-
- /**
- * {@inheritDoc}
- */
- public void destroy(T instance, CreationalContext ctx)
- {
- ctx.release();
- }
-
- /**
- * {@inheritDoc}
- */
- public Set getTypes()
- {
- if (types != null)
- {
- return types;
- }
- Set types = new HashSet();
- if (adapter.getComponentKey() instanceof Class> && !((Class>)adapter.getComponentKey()).isAnnotation())
- {
- types.add((Class>)adapter.getComponentKey());
- types.add(adapter.getComponentImplementation());
- }
- else
- {
- bindAll(adapter.getComponentImplementation(), types);
- }
- types.add(Object.class);
- return this.types = types;
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings({"serial", "unchecked"})
- public Set getQualifiers()
- {
- if (qualifiers != null)
- {
- return qualifiers;
- }
- Set qualifiers = new HashSet();
- if (adapter.getComponentKey() instanceof String)
- {
- qualifiers.add(createNamed((String)adapter.getComponentKey()));
- }
- else if (adapter.getComponentKey() instanceof Class> && ((Class>)adapter.getComponentKey()).isAnnotation())
- {
- qualifiers.add(createAnnotation((Class extends Annotation>)adapter.getComponentKey()));
- }
- else
- {
- qualifiers.add(new AnnotationLiteral()
- {
- });
- qualifiers.add(new AnnotationLiteral