gatein SVN: r599 - in portal/trunk/web/eXoResources/src/main/webapp: skin/DefaultSkin/portal/webui/component/view/UIDashboard and 1 other directory.
by do-not-reply@jboss.org
Author: tan_pham_dinh
Date: 2009-11-15 22:14:23 -0500 (Sun, 15 Nov 2009)
New Revision: 599
Modified:
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIDashboard.js
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/view/UIDashboard/Stylesheet.css
Log:
GTNPORTAL-80: CSS break when set columns of dashboard to 4
Modified: portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIDashboard.js
===================================================================
--- portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIDashboard.js 2009-11-15 22:45:00 UTC (rev 598)
+++ portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIDashboard.js 2009-11-16 03:14:23 UTC (rev 599)
@@ -302,7 +302,7 @@
var uiGadget = DOMUtil.findAncestorByClass(gadgetControls[j],"UIGadget");
var iframe = DOMUtil.findFirstDescendantByClass(uiGadget, "iframe", "gadgets-gadget") ;
if (iframe) {
- iframe.style.width = "auto" ;
+ iframe.style.width = "99.9%" ;
}
var minimizeButton = DOMUtil.findFirstDescendantByClass(gadgetControls[j], "div", "MinimizeAction") ;
if(canEdit) {
Modified: portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/view/UIDashboard/Stylesheet.css
===================================================================
--- portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/view/UIDashboard/Stylesheet.css 2009-11-15 22:45:00 UTC (rev 598)
+++ portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/view/UIDashboard/Stylesheet.css 2009-11-16 03:14:23 UTC (rev 599)
@@ -361,10 +361,6 @@
background: #fff;
}
-.UIDashboard .UIDashboardContainer .GadgetTitle {
- width: 197px;
-}
-
.UIDashboardContainer .GadgetContainer {
overflow: auto;
height: 100%;
15 years, 1 month
gatein SVN: r598 - in components/common/trunk: common and 16 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2009-11-15 17:45:00 -0500 (Sun, 15 Nov 2009)
New Revision: 598
Added:
components/common/trunk/logging/
components/common/trunk/logging/pom.xml
components/common/trunk/logging/src/
components/common/trunk/logging/src/main/
components/common/trunk/logging/src/main/java/
components/common/trunk/logging/src/main/java/org/
components/common/trunk/logging/src/main/java/org/gatein/
components/common/trunk/logging/src/main/java/org/gatein/common/
components/common/trunk/logging/src/main/java/org/gatein/common/logging/
components/common/trunk/logging/src/main/java/org/gatein/common/logging/LogLevel.java
components/common/trunk/logging/src/main/java/org/gatein/common/logging/Logger.java
components/common/trunk/logging/src/main/java/org/gatein/common/logging/LoggerFactory.java
components/common/trunk/logging/src/main/java/org/gatein/common/logging/SLF4JLocationAwareLogger.java
components/common/trunk/logging/src/main/java/org/gatein/common/logging/SimpleLogger.java
components/common/trunk/logging/src/main/java/org/gatein/common/logging/package-info.java
components/common/trunk/logging/src/main/resources/
components/common/trunk/logging/src/test/
components/common/trunk/logging/src/test/java/
components/common/trunk/logging/src/test/java/org/
components/common/trunk/logging/src/test/java/org/gatein/
components/common/trunk/logging/src/test/java/org/gatein/common/
components/common/trunk/logging/src/test/java/org/gatein/common/logging/
components/common/trunk/logging/src/test/java/org/gatein/common/logging/LogTestCase.java
components/common/trunk/logging/src/test/java/org/slf4j/
components/common/trunk/logging/src/test/java/org/slf4j/impl/
components/common/trunk/logging/src/test/java/org/slf4j/impl/Log.java
components/common/trunk/logging/src/test/java/org/slf4j/impl/LoggerFactoryImpl.java
components/common/trunk/logging/src/test/java/org/slf4j/impl/LoggerImpl.java
components/common/trunk/logging/src/test/java/org/slf4j/impl/StaticLoggerBinder.java
components/common/trunk/logging/src/test/java/org/slf4j/impl/StaticMDCBinder.java
components/common/trunk/logging/src/test/java/org/slf4j/impl/StaticMarkerBinder.java
components/common/trunk/logging/src/test/resources/
Modified:
components/common/trunk/common/pom.xml
components/common/trunk/pom.xml
Log:
GTNCOMMON-4: Logging facade
Modified: components/common/trunk/common/pom.xml
===================================================================
--- components/common/trunk/common/pom.xml 2009-11-13 22:36:33 UTC (rev 597)
+++ components/common/trunk/common/pom.xml 2009-11-15 22:45:00 UTC (rev 598)
@@ -76,6 +76,12 @@
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.6</version>
+ </dependency>
+
</dependencies>
<build>
Added: components/common/trunk/logging/pom.xml
===================================================================
--- components/common/trunk/logging/pom.xml (rev 0)
+++ components/common/trunk/logging/pom.xml 2009-11-15 22:45:00 UTC (rev 598)
@@ -0,0 +1,46 @@
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.gatein.common</groupId>
+ <artifactId>common-parent</artifactId>
+ <version>2.0.0-CR1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>common-logging</artifactId>
+ <packaging>jar</packaging>
+ <name>GateIn - Common component (logging)</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added: components/common/trunk/logging/src/main/java/org/gatein/common/logging/LogLevel.java
===================================================================
--- components/common/trunk/logging/src/main/java/org/gatein/common/logging/LogLevel.java (rev 0)
+++ components/common/trunk/logging/src/main/java/org/gatein/common/logging/LogLevel.java 2009-11-15 22:45:00 UTC (rev 598)
@@ -0,0 +1,139 @@
+/**
+ * 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.gatein.common.logging;
+
+import org.slf4j.spi.LocationAwareLogger;
+
+/**
+ * The level of a log message.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public enum LogLevel
+{
+ /**
+ * Trace log level.
+ */
+ TRACE(LocationAwareLogger.TRACE_INT)
+ {
+ @Override
+ void log(org.slf4j.Logger delegate, Object msg, Throwable throwable)
+ {
+ delegate.trace(String.valueOf(msg), throwable);
+ }
+
+ @Override
+ boolean isEnabled(org.slf4j.Logger delegate)
+ {
+ return delegate.isTraceEnabled();
+ }
+ },
+
+ /**
+ * Debug log level.
+ */
+ DEBUG(LocationAwareLogger.DEBUG_INT)
+ {
+ @Override
+ void log(org.slf4j.Logger delegate, Object msg, Throwable throwable)
+ {
+ delegate.debug(String.valueOf(msg), throwable);
+ }
+
+ @Override
+ boolean isEnabled(org.slf4j.Logger delegate)
+ {
+ return delegate.isDebugEnabled();
+ }
+ },
+
+ /**
+ * Info log level.
+ */
+ INFO(LocationAwareLogger.INFO_INT)
+ {
+ @Override
+ void log(org.slf4j.Logger delegate, Object msg, Throwable throwable)
+ {
+ delegate.info(String.valueOf(msg), throwable);
+ }
+
+ @Override
+ boolean isEnabled(org.slf4j.Logger delegate)
+ {
+ return delegate.isInfoEnabled();
+ }
+ },
+
+ /**
+ * Warn log level.
+ */
+ WARN(LocationAwareLogger.WARN_INT)
+ {
+ @Override
+ void log(org.slf4j.Logger delegate, Object msg, Throwable throwable)
+ {
+ delegate.warn(String.valueOf(msg), throwable);
+ }
+
+ @Override
+ boolean isEnabled(org.slf4j.Logger delegate)
+ {
+ return delegate.isWarnEnabled();
+ }
+ },
+
+ /**
+ * Warn log level.
+ */
+ ERROR(LocationAwareLogger.ERROR_INT)
+ {
+ @Override
+ void log(org.slf4j.Logger delegate, Object msg, Throwable throwable)
+ {
+ delegate.error(String.valueOf(msg), throwable);
+ }
+
+ @Override
+ boolean isEnabled(org.slf4j.Logger delegate)
+ {
+ return delegate.isErrorEnabled();
+ }
+ }
+
+ ;
+
+ private final int slf4Jlevel;
+
+ LogLevel(int slf4Jlevel)
+ {
+ this.slf4Jlevel = slf4Jlevel;
+ }
+
+ int getSLF4Jlevel()
+ {
+ return slf4Jlevel;
+ }
+
+ abstract void log(org.slf4j.Logger delegate, Object msg, Throwable throwable);
+
+ abstract boolean isEnabled(org.slf4j.Logger delegate);
+
+}
Added: components/common/trunk/logging/src/main/java/org/gatein/common/logging/Logger.java
===================================================================
--- components/common/trunk/logging/src/main/java/org/gatein/common/logging/Logger.java (rev 0)
+++ components/common/trunk/logging/src/main/java/org/gatein/common/logging/Logger.java 2009-11-15 22:45:00 UTC (rev 598)
@@ -0,0 +1,158 @@
+/**
+ * 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.gatein.common.logging;
+
+/**
+ * The logger for GateIn.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class Logger
+{
+
+ /** Helps the compiler to be happy. */
+ private static final Object[] NO_PARAMETERS = null;
+
+ protected abstract void doLog(LogLevel level, Object msg, Throwable throwable);
+
+ protected abstract org.slf4j.Logger getDelegate();
+
+ private void log(LogLevel level, Object msg, Throwable throwable, Object... parameters)
+ {
+ if (level == null)
+ {
+ level = LogLevel.INFO;
+ }
+
+ // Take care of interpolation
+ if (parameters != null && parameters.length > 0)
+ {
+ throw new UnsupportedOperationException("log interpolation to do, for now it cannot be called");
+ }
+
+ //
+ doLog(level, msg, throwable);
+ }
+
+ public final String getName()
+ {
+ return getDelegate().getName();
+ }
+
+ public final boolean isEnabled(LogLevel level)
+ {
+ if (level == null)
+ {
+ level = LogLevel.INFO;
+ }
+ return level.isEnabled(getDelegate());
+ }
+
+ public final void log(LogLevel level, Object msg)
+ {
+ log(level, msg, null, NO_PARAMETERS);
+ }
+
+ public final void log(LogLevel level, Object msg, Throwable throwable)
+ {
+ log(level, msg, throwable, NO_PARAMETERS);
+ }
+
+ public final boolean isTraceEnabled()
+ {
+ return isEnabled(LogLevel.TRACE);
+ }
+
+ public final void trace(Object msg)
+ {
+ log(LogLevel.TRACE, msg, null, NO_PARAMETERS);
+ }
+
+ public final void trace(Object msg, Throwable throwable)
+ {
+ log(LogLevel.TRACE, msg, throwable, NO_PARAMETERS);
+ }
+
+ public final boolean isDebugEnabled()
+ {
+ return isEnabled(LogLevel.DEBUG);
+ }
+
+ public final void debug(Object msg)
+ {
+ log(LogLevel.DEBUG, msg, null, NO_PARAMETERS);
+ }
+
+ public final void debug(Object msg, Throwable throwable)
+ {
+ log(LogLevel.DEBUG, msg, throwable, NO_PARAMETERS);
+ }
+
+ public final boolean isInfoEnabled()
+ {
+ return isEnabled(LogLevel.INFO);
+ }
+
+ public final void info(Object msg)
+ {
+ log(LogLevel.INFO, msg, null, NO_PARAMETERS);
+ }
+
+ public final void info(Object msg, Throwable throwable)
+ {
+ log(LogLevel.INFO, msg, throwable, NO_PARAMETERS);
+ }
+
+ public final boolean isWarnEnabled()
+ {
+ return isEnabled(LogLevel.WARN);
+ }
+
+ public final void warn(Object msg)
+ {
+ log(LogLevel.WARN, msg, null, NO_PARAMETERS);
+ }
+
+ public final void warn(Object msg, Throwable throwable)
+ {
+ log(LogLevel.WARN, msg, throwable, NO_PARAMETERS);
+ }
+
+ public final boolean isErrorEnabled()
+ {
+ return isEnabled(LogLevel.ERROR);
+ }
+
+ public final void error(Object msg)
+ {
+ log(LogLevel.ERROR, msg, null, NO_PARAMETERS);
+ }
+
+ public final void error(Object msg, Throwable throwable)
+ {
+ log(LogLevel.ERROR, msg, throwable, NO_PARAMETERS);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Logger[name=" + getDelegate().getName() + "]";
+ }
+}
Added: components/common/trunk/logging/src/main/java/org/gatein/common/logging/LoggerFactory.java
===================================================================
--- components/common/trunk/logging/src/main/java/org/gatein/common/logging/LoggerFactory.java (rev 0)
+++ components/common/trunk/logging/src/main/java/org/gatein/common/logging/LoggerFactory.java 2009-11-15 22:45:00 UTC (rev 598)
@@ -0,0 +1,92 @@
+/**
+ * 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.gatein.common.logging;
+
+import org.slf4j.spi.LocationAwareLogger;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * The common way to obtain a logger.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class LoggerFactory
+{
+
+ /** . */
+ private static final ConcurrentMap<String, Logger> loggers = new ConcurrentHashMap<String, Logger>();
+
+ /**
+ * Returns a logger by its name.
+ *
+ * @param name the logger name
+ * @return the logger
+ * @throws NullPointerException if the logger name is null
+ */
+ public static Logger getLogger(String name) throws NullPointerException
+ {
+ if (name == null)
+ {
+ throw new NullPointerException("No null logger name accepted");
+ }
+ Logger logger = loggers.get(name);
+ if (logger == null)
+ {
+ logger = createLogger(name);
+ Logger phantom = loggers.putIfAbsent(name, logger);
+ if (phantom != null)
+ {
+ logger = phantom;
+ }
+ }
+ return logger;
+ }
+
+ /**
+ * Returns a logger by its name based on the value returned by {@link Class#getName()}
+ *
+ * @param type the class type
+ * @return the logger
+ * @throws NullPointerException if the class type is null
+ */
+ public static Logger getLogger(Class type)
+ {
+ if (type == null)
+ {
+ throw new NullPointerException("No null class type accepted");
+ }
+ return getLogger(type.getName());
+ }
+
+ private static Logger createLogger(String name)
+ {
+ org.slf4j.Logger slf4jlogger = org.slf4j.LoggerFactory.getLogger(name);
+ if (slf4jlogger instanceof LocationAwareLogger)
+ {
+ return new SLF4JLocationAwareLogger((LocationAwareLogger)slf4jlogger);
+ }
+ else
+ {
+ return new SimpleLogger(slf4jlogger);
+ }
+ }
+}
Added: components/common/trunk/logging/src/main/java/org/gatein/common/logging/SLF4JLocationAwareLogger.java
===================================================================
--- components/common/trunk/logging/src/main/java/org/gatein/common/logging/SLF4JLocationAwareLogger.java (rev 0)
+++ components/common/trunk/logging/src/main/java/org/gatein/common/logging/SLF4JLocationAwareLogger.java 2009-11-15 22:45:00 UTC (rev 598)
@@ -0,0 +1,52 @@
+/**
+ * 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.gatein.common.logging;
+
+import org.slf4j.spi.LocationAwareLogger;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+class SLF4JLocationAwareLogger extends Logger
+{
+
+ /** . */
+ private static final String FQCN = SLF4JLocationAwareLogger.class.getName();
+
+ /** . */
+ private final LocationAwareLogger delegate;
+
+ public SLF4JLocationAwareLogger(LocationAwareLogger delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ @Override
+ protected void doLog(LogLevel level, Object msg, Throwable throwable)
+ {
+ delegate.log(null, FQCN, level.getSLF4Jlevel(), String.valueOf(msg), throwable);
+ }
+
+ @Override
+ protected org.slf4j.Logger getDelegate()
+ {
+ return delegate;
+ }
+}
Added: components/common/trunk/logging/src/main/java/org/gatein/common/logging/SimpleLogger.java
===================================================================
--- components/common/trunk/logging/src/main/java/org/gatein/common/logging/SimpleLogger.java (rev 0)
+++ components/common/trunk/logging/src/main/java/org/gatein/common/logging/SimpleLogger.java 2009-11-15 22:45:00 UTC (rev 598)
@@ -0,0 +1,47 @@
+/**
+ * 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.gatein.common.logging;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+class SimpleLogger extends Logger
+{
+
+ /** . */
+ private final org.slf4j.Logger delegate;
+
+ public SimpleLogger(org.slf4j.Logger delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ @Override
+ protected void doLog(LogLevel level, Object msg, Throwable throwable)
+ {
+ level.log(delegate, msg, throwable);
+ }
+
+ @Override
+ protected org.slf4j.Logger getDelegate()
+ {
+ return delegate;
+ }
+}
Added: components/common/trunk/logging/src/main/java/org/gatein/common/logging/package-info.java
===================================================================
--- components/common/trunk/logging/src/main/java/org/gatein/common/logging/package-info.java (rev 0)
+++ components/common/trunk/logging/src/main/java/org/gatein/common/logging/package-info.java 2009-11-15 22:45:00 UTC (rev 598)
@@ -0,0 +1,9 @@
+/**
+ * <p>The logging system for GateIn components and project.</p>
+ *
+ * <p>The logging system focuses on providing an API and not an implementation. The implementation of the logging
+ * system uses the <a href="http://www.slf4j.org/">SLF4J</a> logging framework. Although the SLF4J frameworks
+ * is already a facade for various logging framework, the goal of this facade is to decouple the GateIn project
+ * from a system considered as proprietary although under an open source license.</p>
+ */
+package org.gatein.common.logger;
Added: components/common/trunk/logging/src/test/java/org/gatein/common/logging/LogTestCase.java
===================================================================
--- components/common/trunk/logging/src/test/java/org/gatein/common/logging/LogTestCase.java (rev 0)
+++ components/common/trunk/logging/src/test/java/org/gatein/common/logging/LogTestCase.java 2009-11-15 22:45:00 UTC (rev 598)
@@ -0,0 +1,253 @@
+/*
+ * 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.gatein.common.logging;
+
+import junit.framework.TestCase;
+import org.slf4j.impl.Log;
+import org.slf4j.impl.LoggerFactoryImpl;
+import org.slf4j.impl.LoggerImpl;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class LogTestCase extends TestCase
+{
+
+ public void testGetLogger()
+ {
+ Logger logger = LoggerFactory.getLogger(LogTestCase.class);
+ assertNotNull(logger);
+ assertEquals(LogTestCase.class.getName(), logger.getName());
+ assertSame(logger, LoggerFactory.getLogger(LogTestCase.class.getName()));
+ }
+
+ public void testConcurrentGetRace() throws Exception
+ {
+ final ReentrantLock lock = LoggerFactoryImpl.getLock();
+ lock.lock();
+ final AtomicReference<Logger> loggerRef = new AtomicReference<Logger>();
+ final AtomicBoolean done = new AtomicBoolean();
+ Thread t = new Thread()
+ {
+ public void run()
+ {
+ Logger logger = LoggerFactory.getLogger("testConcurrentGetRace");
+ loggerRef.set(logger);
+ done.set(true);
+ }
+ };
+ t.start();
+ while (!lock.hasQueuedThread(t))
+ {
+ Thread.sleep(1);
+ }
+ assertEquals(null, LoggerFactoryImpl.peekLogger("testConcurrentGetRace"));
+ Logger logger = LoggerFactory.getLogger("testConcurrentGetRace");
+ assertNotNull(logger);
+ lock.unlock();
+ while (!done.get())
+ {
+ Thread.sleep(1);
+ }
+ assertSame(logger, loggerRef.get());
+ }
+
+ public void testTraceEnabled()
+ {
+ Logger logger = LoggerFactory.getLogger("testTraceEnabled");
+ LoggerImpl loggerImpl = LoggerFactoryImpl.peekLogger("testTraceEnabled");
+ assertTrue(logger.isTraceEnabled());
+ loggerImpl.traceEnabled = false;
+ assertFalse(logger.isTraceEnabled());
+ }
+
+ public void testTrace()
+ {
+ LoggerFactoryImpl.assertEmpty();
+ Logger logger = LoggerFactory.getLogger("testTrace");
+ logger.trace("testTrace1");
+ LoggerFactoryImpl.assertLog("testTrace", Log.TRACE, "testTrace1", null);
+ LoggerFactoryImpl.assertEmpty();
+ Throwable t = new Throwable();
+ logger.trace("testTrace2", t);
+ LoggerFactoryImpl.assertLog("testTrace", Log.TRACE, "testTrace2", t);
+ LoggerFactoryImpl.assertEmpty();
+ }
+
+ public void testDebugEnabled()
+ {
+ Logger logger = LoggerFactory.getLogger("testDebugEnabled");
+ LoggerImpl loggerImpl = LoggerFactoryImpl.peekLogger("testDebugEnabled");
+ assertTrue(logger.isDebugEnabled());
+ loggerImpl.debugEnabled = false;
+ assertFalse(logger.isDebugEnabled());
+ }
+
+ public void testDebug()
+ {
+ LoggerFactoryImpl.assertEmpty();
+ Logger logger = LoggerFactory.getLogger("testDebug");
+ logger.debug("testDebug1");
+ LoggerFactoryImpl.assertLog("testDebug", Log.DEBUG, "testDebug1", null);
+ LoggerFactoryImpl.assertEmpty();
+ Throwable t = new Throwable();
+ logger.debug("testDebug2", t);
+ LoggerFactoryImpl.assertLog("testDebug", Log.DEBUG, "testDebug2", t);
+ LoggerFactoryImpl.assertEmpty();
+ }
+
+ public void testInfoEnabled()
+ {
+ Logger logger = LoggerFactory.getLogger("testInfoEnabled");
+ LoggerImpl loggerImpl = LoggerFactoryImpl.peekLogger("testInfoEnabled");
+ assertTrue(logger.isInfoEnabled());
+ loggerImpl.infoEnabled = false;
+ assertFalse(logger.isInfoEnabled());
+ }
+
+ public void testInfo()
+ {
+ LoggerFactoryImpl.assertEmpty();
+ Logger logger = LoggerFactory.getLogger("testInfo");
+ logger.info("testInfo1");
+ LoggerFactoryImpl.assertLog("testInfo", Log.INFO, "testInfo1", null);
+ LoggerFactoryImpl.assertEmpty();
+ Throwable t = new Throwable();
+ logger.info("testInfo2", t);
+ LoggerFactoryImpl.assertLog("testInfo", Log.INFO, "testInfo2", t);
+ LoggerFactoryImpl.assertEmpty();
+ }
+
+ public void testWarnEnabled()
+ {
+ Logger logger = LoggerFactory.getLogger("testWarnEnabled");
+ LoggerImpl loggerImpl = LoggerFactoryImpl.peekLogger("testWarnEnabled");
+ assertTrue(logger.isWarnEnabled());
+ loggerImpl.warnEnabled = false;
+ assertFalse(logger.isWarnEnabled());
+ }
+
+ public void testWarn()
+ {
+ LoggerFactoryImpl.assertEmpty();
+ Logger logger = LoggerFactory.getLogger("testWarn");
+ logger.warn("testWarn1");
+ LoggerFactoryImpl.assertLog("testWarn", Log.WARN, "testWarn1", null);
+ LoggerFactoryImpl.assertEmpty();
+ Throwable t = new Throwable();
+ logger.warn("testWarn2", t);
+ LoggerFactoryImpl.assertLog("testWarn", Log.WARN, "testWarn2", t);
+ LoggerFactoryImpl.assertEmpty();
+ }
+
+ public void testErrorEnabled()
+ {
+ Logger logger = LoggerFactory.getLogger("testErrorEnabled");
+ LoggerImpl loggerImpl = LoggerFactoryImpl.peekLogger("testErrorEnabled");
+ assertTrue(logger.isErrorEnabled());
+ loggerImpl.errorEnabled = false;
+ assertFalse(logger.isErrorEnabled());
+ }
+
+ public void testError()
+ {
+ LoggerFactoryImpl.assertEmpty();
+ Logger logger = LoggerFactory.getLogger("testError");
+ logger.error("testError1");
+ LoggerFactoryImpl.assertLog("testError", Log.ERROR, "testError1", null);
+ LoggerFactoryImpl.assertEmpty();
+ Throwable t = new Throwable();
+ logger.error("testError2", t);
+ LoggerFactoryImpl.assertLog("testError", Log.ERROR, "testError2", t);
+ LoggerFactoryImpl.assertEmpty();
+ }
+
+ public void testDetypedEnabled()
+ {
+ Logger logger = LoggerFactory.getLogger("testDetypedEnabled");
+ LoggerImpl loggerImpl = LoggerFactoryImpl.peekLogger("testDetypedEnabled");
+ LogLevel[] levels = LogLevel.values();
+ for (LogLevel level : levels)
+ {
+ assertTrue(logger.isEnabled(level));
+ switch (level)
+ {
+ case TRACE:
+ loggerImpl.traceEnabled = false;
+ break;
+ case DEBUG:
+ loggerImpl.debugEnabled = false;
+ break;
+ case INFO:
+ loggerImpl.infoEnabled = false;
+ break;
+ case WARN:
+ loggerImpl.warnEnabled = false;
+ break;
+ case ERROR:
+ loggerImpl.errorEnabled = false;
+ break;
+ }
+ assertFalse(logger.isEnabled(level));
+ }
+ }
+
+ public void testDetypedLog()
+ {
+ LoggerFactoryImpl.assertEmpty();
+ Logger logger = LoggerFactory.getLogger("testDetypedLog");
+ LogLevel[] levels = LogLevel.values();
+ for (int i = 0;i < levels.length;i++)
+ {
+ LogLevel level = levels[i];
+ logger.log(level, "testDetypedLog1_" + i);
+ LoggerFactoryImpl.assertLog("testDetypedLog", level.ordinal(), "testDetypedLog1_" + i, null);
+ LoggerFactoryImpl.assertEmpty();
+ Throwable t = new Throwable();
+ logger.log(level, "testDetypedLog2_" + i, t);
+ LoggerFactoryImpl.assertLog("testDetypedLog", level.ordinal(), "testDetypedLog2_" + i, t);
+ LoggerFactoryImpl.assertEmpty();
+ }
+ }
+
+ public void testGetLoggerNPE()
+ {
+ try
+ {
+ LoggerFactory.getLogger((String)null);
+ fail();
+ }
+ catch (NullPointerException e)
+ {
+ }
+ try
+ {
+ LoggerFactory.getLogger((Class)null);
+ fail();
+ }
+ catch (NullPointerException e)
+ {
+ }
+ }
+}
Added: components/common/trunk/logging/src/test/java/org/slf4j/impl/Log.java
===================================================================
--- components/common/trunk/logging/src/test/java/org/slf4j/impl/Log.java (rev 0)
+++ components/common/trunk/logging/src/test/java/org/slf4j/impl/Log.java 2009-11-15 22:45:00 UTC (rev 598)
@@ -0,0 +1,84 @@
+/*
+ * 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.slf4j.impl;
+
+import org.gatein.common.logging.LogLevel;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class Log
+{
+
+ /** . */
+ public static final int TRACE = LogLevel.TRACE.ordinal();
+
+ /** . */
+ public static final int DEBUG = LogLevel.DEBUG.ordinal();
+
+ /** . */
+ public static final int INFO = LogLevel.INFO.ordinal();
+
+ /** . */
+ public static final int WARN = LogLevel.WARN.ordinal();
+
+ /** . */
+ public static final int ERROR = LogLevel.ERROR.ordinal();
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final int level;
+
+ /** . */
+ private final String msg;
+
+ /** . */
+ private final Throwable throwable;
+
+ public Log(String name, int level, String msg, Throwable throwable)
+ {
+ this.name = name;
+ this.level = level;
+ this.msg = msg;
+ this.throwable = throwable;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public int getLevel()
+ {
+ return level;
+ }
+
+ public String getMessage()
+ {
+ return msg;
+ }
+
+ public Throwable getThrowable()
+ {
+ return throwable;
+ }
+}
Added: components/common/trunk/logging/src/test/java/org/slf4j/impl/LoggerFactoryImpl.java
===================================================================
--- components/common/trunk/logging/src/test/java/org/slf4j/impl/LoggerFactoryImpl.java (rev 0)
+++ components/common/trunk/logging/src/test/java/org/slf4j/impl/LoggerFactoryImpl.java 2009-11-15 22:45:00 UTC (rev 598)
@@ -0,0 +1,99 @@
+/*
+ * 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.slf4j.impl;
+
+import junit.framework.Assert;
+import org.slf4j.ILoggerFactory;
+import org.slf4j.Logger;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class LoggerFactoryImpl implements ILoggerFactory
+{
+
+ /** . */
+ private static final LinkedList<Log> logs = new LinkedList<Log>();
+
+ /** . */
+ private static final Map<String, LoggerImpl> loggers = Collections.synchronizedMap(new HashMap<String, LoggerImpl>());
+
+ /** For testing concurrency purpose. */
+ private static final ReentrantLock lock = new ReentrantLock();
+
+ public LoggerFactoryImpl()
+ {
+ }
+
+ synchronized static void log(String name, int level, String msg, Throwable t)
+ {
+ logs.add(new Log(name, level, msg, t));
+ }
+
+ public synchronized static void assertEmpty()
+ {
+ Assert.assertTrue(logs.isEmpty());
+ }
+
+ public synchronized static void assertLog(String name, int level, String msg, Throwable t)
+ {
+ Assert.assertFalse(logs.isEmpty());
+ Log log = logs.removeFirst();
+ Assert.assertEquals(name, log.getName());
+ Assert.assertEquals(level, log.getLevel());
+ Assert.assertEquals(msg, log.getMessage());
+ Assert.assertEquals(t, log.getThrowable());
+ }
+
+ public static LoggerImpl peekLogger(String name)
+ {
+ return loggers.get(name);
+ }
+
+ public static ReentrantLock getLock()
+ {
+ return lock;
+ }
+
+ public LoggerImpl getLogger(String name)
+ {
+ lock.lock();
+ try
+ {
+ LoggerImpl logger = loggers.get(name);
+ if (logger == null)
+ {
+ logger = new LoggerImpl(name);
+ loggers.put(name, logger);
+ }
+ return logger;
+ }
+ finally
+ {
+ lock.unlock();
+ }
+ }
+}
Added: components/common/trunk/logging/src/test/java/org/slf4j/impl/LoggerImpl.java
===================================================================
--- components/common/trunk/logging/src/test/java/org/slf4j/impl/LoggerImpl.java (rev 0)
+++ components/common/trunk/logging/src/test/java/org/slf4j/impl/LoggerImpl.java 2009-11-15 22:45:00 UTC (rev 598)
@@ -0,0 +1,204 @@
+/*
+ * 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.slf4j.impl;
+
+import org.slf4j.helpers.MarkerIgnoringBase;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class LoggerImpl extends MarkerIgnoringBase
+{
+
+ /** . */
+ public boolean traceEnabled = true;
+
+ /** . */
+ public boolean debugEnabled = true;
+
+ /** . */
+ public boolean infoEnabled = true;
+
+ /** . */
+ public boolean warnEnabled = true;
+
+ /** . */
+ public boolean errorEnabled = true;
+
+ public LoggerImpl(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public boolean isTraceEnabled()
+ {
+ return traceEnabled;
+ }
+
+ public boolean isDebugEnabled()
+ {
+ return debugEnabled;
+ }
+
+ public boolean isInfoEnabled()
+ {
+ return infoEnabled;
+ }
+
+ public boolean isWarnEnabled()
+ {
+ return warnEnabled;
+ }
+
+ public boolean isErrorEnabled()
+ {
+ return errorEnabled;
+ }
+
+ public void trace(String msg)
+ {
+ trace(msg, (Throwable)null);
+ }
+
+ public void trace(String msg, Throwable t)
+ {
+ LoggerFactoryImpl.log(name, Log.TRACE, msg, t);
+ }
+
+ public void debug(String msg)
+ {
+ debug(msg, (Throwable)null);
+ }
+
+ public void debug(String msg, Throwable t)
+ {
+ LoggerFactoryImpl.log(name, Log.DEBUG, msg, t);
+ }
+
+ public void info(String msg)
+ {
+ info(msg, (Throwable)null);
+ }
+
+ public void info(String msg, Throwable t)
+ {
+ LoggerFactoryImpl.log(name, Log.INFO, msg, t);
+ }
+
+ public void warn(String msg)
+ {
+ warn(msg, (Throwable)null);
+ }
+
+ public void warn(String msg, Throwable t)
+ {
+ LoggerFactoryImpl.log(name, Log.WARN, msg, t);
+ }
+
+ public void error(String msg)
+ {
+ error(msg, (Throwable)null);
+ }
+
+ public void error(String msg, Throwable t)
+ {
+ LoggerFactoryImpl.log(name, Log.ERROR, msg, t);
+ }
+
+ public void trace(String format, Object arg)
+ {
+ throw new Error();
+ }
+
+ public void trace(String format, Object arg1, Object arg2)
+ {
+ throw new Error();
+ }
+
+ public void trace(String format, Object[] argArray)
+ {
+ throw new Error();
+ }
+
+ public void debug(String format, Object arg)
+ {
+ throw new Error();
+ }
+
+ public void debug(String format, Object arg1, Object arg2)
+ {
+ throw new Error();
+ }
+
+ public void debug(String format, Object[] argArray)
+ {
+ throw new Error();
+ }
+
+ public void info(String format, Object arg)
+ {
+ throw new Error();
+ }
+
+ public void info(String format, Object arg1, Object arg2)
+ {
+ throw new Error();
+ }
+
+ public void info(String format, Object[] argArray)
+ {
+ throw new Error();
+ }
+
+ public void warn(String format, Object arg)
+ {
+ throw new Error();
+ }
+
+ public void warn(String format, Object[] argArray)
+ {
+ throw new Error();
+ }
+
+ public void warn(String format, Object arg1, Object arg2)
+ {
+ throw new Error();
+ }
+
+ public void error(String format, Object arg)
+ {
+ throw new Error();
+ }
+
+ public void error(String format, Object arg1, Object arg2)
+ {
+ throw new Error();
+ }
+
+ public void error(String format, Object[] argArray)
+ {
+ throw new Error();
+ }
+}
Added: components/common/trunk/logging/src/test/java/org/slf4j/impl/StaticLoggerBinder.java
===================================================================
--- components/common/trunk/logging/src/test/java/org/slf4j/impl/StaticLoggerBinder.java (rev 0)
+++ components/common/trunk/logging/src/test/java/org/slf4j/impl/StaticLoggerBinder.java 2009-11-15 22:45:00 UTC (rev 598)
@@ -0,0 +1,54 @@
+/*
+ * 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.slf4j.impl;
+
+import org.slf4j.ILoggerFactory;
+import org.slf4j.spi.LoggerFactoryBinder;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class StaticLoggerBinder implements LoggerFactoryBinder
+{
+
+ private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
+
+ public static StaticLoggerBinder getSingleton() {
+ return SINGLETON;
+ }
+
+ public static String REQUESTED_API_VERSION = "1.5.6";
+
+ private static final String loggerFactoryClassStr = LoggerFactoryImpl.class.getName();
+
+ private final ILoggerFactory loggerFactory;
+
+ private StaticLoggerBinder() {
+ loggerFactory = new LoggerFactoryImpl();
+ }
+
+ public ILoggerFactory getLoggerFactory() {
+ return loggerFactory;
+ }
+
+ public String getLoggerFactoryClassStr() {
+ return loggerFactoryClassStr;
+ }
+}
Added: components/common/trunk/logging/src/test/java/org/slf4j/impl/StaticMDCBinder.java
===================================================================
--- components/common/trunk/logging/src/test/java/org/slf4j/impl/StaticMDCBinder.java (rev 0)
+++ components/common/trunk/logging/src/test/java/org/slf4j/impl/StaticMDCBinder.java 2009-11-15 22:45:00 UTC (rev 598)
@@ -0,0 +1,42 @@
+/*
+ * 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.slf4j.impl;
+
+import org.slf4j.helpers.NOPMakerAdapter;
+import org.slf4j.spi.MDCAdapter;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class StaticMDCBinder
+{
+
+ public static final StaticMDCBinder SINGLETON = new StaticMDCBinder();
+
+ public MDCAdapter getMDCA()
+ {
+ return new NOPMakerAdapter();
+ }
+
+ public String getMDCAdapterClassStr()
+ {
+ return NOPMakerAdapter.class.getName();
+ }
+}
Added: components/common/trunk/logging/src/test/java/org/slf4j/impl/StaticMarkerBinder.java
===================================================================
--- components/common/trunk/logging/src/test/java/org/slf4j/impl/StaticMarkerBinder.java (rev 0)
+++ components/common/trunk/logging/src/test/java/org/slf4j/impl/StaticMarkerBinder.java 2009-11-15 22:45:00 UTC (rev 598)
@@ -0,0 +1,46 @@
+/*
+ * 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.slf4j.impl;
+
+import org.slf4j.IMarkerFactory;
+import org.slf4j.helpers.BasicMarkerFactory;
+import org.slf4j.spi.MarkerFactoryBinder;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class StaticMarkerBinder implements MarkerFactoryBinder
+{
+
+ public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
+
+ final IMarkerFactory markerFactory = new BasicMarkerFactory();
+
+ private StaticMarkerBinder() {
+ }
+
+ public IMarkerFactory getMarkerFactory() {
+ return markerFactory;
+ }
+
+ public String getMarkerFactoryClassStr() {
+ return BasicMarkerFactory.class.getName();
+ }
+}
Modified: components/common/trunk/pom.xml
===================================================================
--- components/common/trunk/pom.xml 2009-11-13 22:36:33 UTC (rev 597)
+++ components/common/trunk/pom.xml 2009-11-15 22:45:00 UTC (rev 598)
@@ -59,6 +59,7 @@
</repositories>
<modules>
+ <module>logging</module>
<module>common</module>
<module>mc</module>
</modules>
15 years, 1 month
gatein SVN: r597 - in portal/trunk/component/wsrp: src/main/java/org/gatein/portal/wsrp and 3 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-11-13 17:36:33 -0500 (Fri, 13 Nov 2009)
New Revision: 597
Added:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/ConsumerRegistry.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/EndpointInfoMapping.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfosMapping.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationInfoMapping.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationPropertyDescriptionMapping.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationPropertyMapping.java
Modified:
portal/trunk/component/wsrp/pom.xml
Log:
- Started adding support for consumers configuration. This code is currently inert (i.e. it is not called from main integration point).
Committing for review purpose. Will probably move back to a branch soon.
Modified: portal/trunk/component/wsrp/pom.xml
===================================================================
--- portal/trunk/component/wsrp/pom.xml 2009-11-13 21:33:30 UTC (rev 596)
+++ portal/trunk/component/wsrp/pom.xml 2009-11-13 22:36:33 UTC (rev 597)
@@ -1,24 +1,26 @@
<!--
+ ~ JBoss, a division of Red Hat
+ ~ Copyright 2009, Red Hat Middleware, LLC, and individual
+ ~ contributors as indicated by the @authors tag. See the
+ ~ copyright.txt in the distribution for a full listing of
+ ~ individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
- 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.
-
--->
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
@@ -89,6 +91,11 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.chromattic</groupId>
+ <artifactId>chromattic.api</artifactId>
+ <version>${version.chromattic}</version>
+ </dependency>
</dependencies>
<build>
Added: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/ConsumerRegistry.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/ConsumerRegistry.java (rev 0)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/ConsumerRegistry.java 2009-11-13 22:36:33 UTC (rev 597)
@@ -0,0 +1,221 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.gatein.portal.wsrp.state.consumer;
+
+import org.chromattic.api.Chromattic;
+import org.chromattic.api.ChromatticBuilder;
+import org.chromattic.api.ChromatticSession;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.services.jcr.ext.registry.RegistryService;
+import org.gatein.portal.wsrp.state.consumer.mapping.EndpointInfoMapping;
+import org.gatein.portal.wsrp.state.consumer.mapping.ProducerInfoMapping;
+import org.gatein.portal.wsrp.state.consumer.mapping.ProducerInfosMapping;
+import org.gatein.portal.wsrp.state.consumer.mapping.RegistrationInfoMapping;
+import org.gatein.portal.wsrp.state.consumer.mapping.RegistrationPropertyDescriptionMapping;
+import org.gatein.portal.wsrp.state.consumer.mapping.RegistrationPropertyMapping;
+import org.gatein.wsrp.WSRPConsumer;
+import org.gatein.wsrp.consumer.ProducerInfo;
+import org.gatein.wsrp.consumer.registry.AbstractConsumerRegistry;
+import org.gatein.wsrp.consumer.registry.xml.XMLConsumerRegistry;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class ConsumerRegistry extends AbstractConsumerRegistry
+{
+ private Chromattic chrome;
+ private static final String WSRP_SERVICES_PATH = RegistryService.EXO_SERVICES + "/wsrp/";
+ private static final String PRODUCER_INFOS_PATH = WSRP_SERVICES_PATH + "producerinfos";
+
+ public ConsumerRegistry(InitParams params, RegistryService jcrRegistry) throws Exception
+ {
+
+ ChromatticBuilder builder = ChromatticBuilder.create();
+ builder.setOption(ChromatticBuilder.INSTRUMENTOR_CLASSNAME, "org.chromattic.apt.InstrumentorImpl");
+
+ builder.add(ProducerInfosMapping.class);
+ builder.add(ProducerInfoMapping.class);
+ builder.add(EndpointInfoMapping.class);
+ builder.add(RegistrationInfoMapping.class);
+ builder.add(RegistrationPropertyMapping.class);
+ builder.add(RegistrationPropertyDescriptionMapping.class);
+
+ chrome = builder.build();
+ }
+
+ @Override
+ protected void save(ProducerInfo info, String messageOnError)
+ {
+ String path = getPathFor(info);
+ ChromatticSession session = chrome.openSession();
+
+ session.persist(toProducerInfoMapping(info), path);
+
+ // todo: find a way to inject JCR Id into ProducerInfo
+
+ session.close();
+ }
+
+ @Override
+ protected void delete(ProducerInfo info)
+ {
+ ChromatticSession session = chrome.openSession();
+ delete(session, getPathFor(info));
+
+ session.close();
+ }
+
+ @Override
+ protected String update(ProducerInfo producerInfo)
+ {
+ // todo: need JCR id to be able to find the previous ProducerInfo in case the id has been modified
+ return null;
+ }
+
+ @Override
+ protected Iterator getAllProducerInfos()
+ {
+ ChromatticSession session = chrome.openSession();
+ ProducerInfosMapping producerInfosMapping = session.findByPath(ProducerInfosMapping.class, PRODUCER_INFOS_PATH);
+
+ Iterator<ProducerInfo> producerInfos;
+
+ // if we don't have info from JCR, load from XML and populate JCR
+ if (producerInfosMapping == null)
+ {
+ producerInfosMapping = session.insert(ProducerInfosMapping.class, PRODUCER_INFOS_PATH);
+
+ List<ProducerInfoMapping> infos = producerInfosMapping.getProducerInfos();
+
+ // Load from XML
+ XMLConsumerRegistry fromXML = new XMLConsumerRegistry();
+ fromXML.reloadConsumers();
+
+ // Save to JCR
+ List<WSRPConsumer> consumers = fromXML.getConfiguredConsumers();
+ for (WSRPConsumer consumer : consumers)
+ {
+ infos.add(toProducerInfoMapping(consumer.getProducerInfo()));
+ }
+ session.persist(infos); // todo: is that sufficient?
+
+ producerInfos = new ConsumerToProducerInfoIterator(consumers.iterator());
+ }
+ else
+ {
+ List<ProducerInfoMapping> mappings = producerInfosMapping.getProducerInfos();
+ producerInfos = new MappingToProducerInfoIterator(mappings.iterator());
+ }
+
+ session.save();
+ session.close();
+ return producerInfos;
+ }
+
+ private void delete(ChromatticSession session, String path)
+ {
+ ProducerInfoMapping old = session.findByPath(ProducerInfoMapping.class, path);
+
+ if (old != null)
+ {
+ session.remove(old);
+ }
+ }
+
+ private String getPathFor(ProducerInfo info)
+ {
+ return PRODUCER_INFOS_PATH + "/" + info.getId();
+ }
+
+ private static ProducerInfoMapping toProducerInfoMapping(ProducerInfo producerInfo)
+ {
+ return null; // todo: implement
+ }
+
+ private static ProducerInfo toProducerInfo(ProducerInfoMapping mapping)
+ {
+ return null; // todo: implement
+ }
+
+ private static class ConsumerToProducerInfoIterator implements Iterator<ProducerInfo>
+ {
+
+ private final Iterator<WSRPConsumer> consumers;
+
+ public ConsumerToProducerInfoIterator(Iterator<WSRPConsumer> consumers)
+ {
+ this.consumers = consumers;
+ }
+
+ @Override
+ public boolean hasNext()
+ {
+ return consumers.hasNext();
+ }
+
+ @Override
+ public ProducerInfo next()
+ {
+ return consumers.next().getProducerInfo();
+ }
+
+ @Override
+ public void remove()
+ {
+ throw new UnsupportedOperationException("Remove not supported!");
+ }
+ }
+
+ private static class MappingToProducerInfoIterator implements Iterator<ProducerInfo>
+ {
+ private Iterator<ProducerInfoMapping> mappings;
+
+ public MappingToProducerInfoIterator(Iterator<ProducerInfoMapping> infoMappingIterator)
+ {
+ this.mappings = infoMappingIterator;
+ }
+
+ @Override
+ public boolean hasNext()
+ {
+ return mappings.hasNext();
+ }
+
+ @Override
+ public ProducerInfo next()
+ {
+ return toProducerInfo(mappings.next());
+ }
+
+ @Override
+ public void remove()
+ {
+ throw new UnsupportedOperationException("Remove not supported!");
+ }
+ }
+}
Added: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/EndpointInfoMapping.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/EndpointInfoMapping.java (rev 0)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/EndpointInfoMapping.java 2009-11-13 22:36:33 UTC (rev 597)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.gatein.portal.wsrp.state.consumer.mapping;
+
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.Property;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+@NodeMapping(name = EndpointInfoMapping.NODE_NAME)
+public abstract class EndpointInfoMapping
+{
+ public static final String NODE_NAME = "wsrp:endpointinfo";
+
+ @Property(name = "wsdlurl")
+ public abstract String getWSDLURL();
+
+ public abstract void setWSDLURL(String wsdlURL);
+}
Added: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java (rev 0)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfoMapping.java 2009-11-13 22:36:33 UTC (rev 597)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.gatein.portal.wsrp.state.consumer.mapping;
+
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.OneToOne;
+import org.chromattic.api.annotations.Property;
+import org.chromattic.api.annotations.RelatedMappedBy;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+@NodeMapping(name = ProducerInfoMapping.NODE_NAME)
+public abstract class ProducerInfoMapping
+{
+ public static final String NODE_NAME = "wsrp:producerinfo";
+
+ @OneToOne
+ @RelatedMappedBy("endpoint")
+ public abstract EndpointInfoMapping getEndpointInfo();
+
+ @OneToOne
+ @RelatedMappedBy("registration")
+ public abstract RegistrationInfoMapping getRegistrationInfo();
+
+ @Property(name = "producerid")
+ public abstract String getProducerId();
+
+ public abstract void setProducerId(String id);
+
+ @Property(name = "cache")
+ public abstract Integer getExpirationCacheSeconds();
+
+ public abstract void setExpirationCacheSeconds(Integer expiration);
+
+ @Property(name = "active")
+ public abstract boolean getActive();
+
+ public abstract void setActive(boolean active);
+
+ @Property(name = "available")
+ public abstract boolean getAvailable();
+
+ public abstract void setAvailable(boolean available);
+}
Added: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfosMapping.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfosMapping.java (rev 0)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/ProducerInfosMapping.java 2009-11-13 22:36:33 UTC (rev 597)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.gatein.portal.wsrp.state.consumer.mapping;
+
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.OneToMany;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+@NodeMapping(name = ProducerInfosMapping.NODE_NAME)
+public abstract class ProducerInfosMapping
+{
+ public static final String NODE_NAME = "wsrp:producerinfos";
+
+ @OneToMany
+ public abstract List<ProducerInfoMapping> getProducerInfos();
+}
Added: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationInfoMapping.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationInfoMapping.java (rev 0)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationInfoMapping.java 2009-11-13 22:36:33 UTC (rev 597)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.gatein.portal.wsrp.state.consumer.mapping;
+
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.OneToMany;
+import org.chromattic.api.annotations.Property;
+
+import java.io.InputStream;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+@NodeMapping(name = RegistrationInfoMapping.NODE_NAME)
+public abstract class RegistrationInfoMapping
+{
+ public static final String NODE_NAME = "wsrp:registrationinfo";
+
+ @Property(name = "consumername")
+ public abstract String getConsumerName();
+
+ public abstract void setConsumerName(String name);
+
+ @Property(name = "handle")
+ public abstract String getRegistrationHandle();
+
+ public abstract void setRegistrationHandle(String handle);
+
+ @Property(name = "state")
+ public abstract InputStream getRegistrationState();
+
+ public abstract void setRegistrationState(InputStream state);
+
+ @OneToMany
+ public abstract List<RegistrationPropertyMapping> getRegistrationProperties();
+}
Added: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationPropertyDescriptionMapping.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationPropertyDescriptionMapping.java (rev 0)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationPropertyDescriptionMapping.java 2009-11-13 22:36:33 UTC (rev 597)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.gatein.portal.wsrp.state.consumer.mapping;
+
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.Property;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+@NodeMapping(name = RegistrationPropertyDescriptionMapping.NODE_NAME)
+public abstract class RegistrationPropertyDescriptionMapping
+{
+ public static final String NODE_NAME = "wsrp:registrationpropertydescription";
+
+ // todo: this should really be a QName
+ @Property(name = "name")
+ public abstract String getName();
+
+ public abstract void setName(String name);
+
+ // todo: this should really be a QName
+ @Property(name = "type")
+ public abstract String getType();
+
+ public abstract void setType(String type);
+
+
+ // todo: this should really be a LocalizedString
+ @Property(name = "description")
+ public abstract String getDescription();
+
+ public abstract void setDescription(String description);
+
+ // todo: this should really be a LocalizedString
+ @Property(name = "hint")
+ public abstract String getHint();
+
+ public abstract void setHint(String hint);
+
+ // todo: this should really be a LocalizedString
+ @Property(name = "label")
+ public abstract String getLabel();
+
+ public abstract void setLabel(String label);
+}
Added: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationPropertyMapping.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationPropertyMapping.java (rev 0)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/mapping/RegistrationPropertyMapping.java 2009-11-13 22:36:33 UTC (rev 597)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.gatein.portal.wsrp.state.consumer.mapping;
+
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.OneToOne;
+import org.chromattic.api.annotations.Property;
+import org.chromattic.api.annotations.RelatedMappedBy;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+@NodeMapping(name = RegistrationPropertyMapping.NODE_NAME)
+public abstract class RegistrationPropertyMapping
+{
+ public static final String NODE_NAME = "wsrp:registrationproperty";
+
+ @Property(name = "value")
+ public abstract String getValue();
+
+ public abstract void setValue(String value);
+
+ @OneToOne
+ @RelatedMappedBy("description")
+ public abstract RegistrationPropertyDescriptionMapping getDescription();
+
+ // todo: this should really be an enum�
+ @Property(name = "status")
+ public abstract String getStatus();
+
+ public abstract void setStatus(String status);
+}
15 years, 1 month
gatein SVN: r596 - in components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry: hibernate and 1 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-11-13 16:33:30 -0500 (Fri, 13 Nov 2009)
New Revision: 596
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/AbstractConsumerRegistry.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/hibernate/HibernateConsumerRegistry.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/xml/XMLConsumerRegistry.java
Log:
- Renamed AbstractConsumerRegistry.getAllProducerInfos to getProducerInfosFromStorage and make the return type explicit.
- Reworked de-/activate methods so they take a WSRPConsumer as an argument to avoid roundtrips between id and consumer.
- Fixed XMLConsumerRegistry as it wasn't fitting properly in the registry hierarchy by fixing getProducerInfosFromStorage
implementation and refitting start method into reloadConsumers method.
Modified: components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/AbstractConsumerRegistry.java
===================================================================
--- components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/AbstractConsumerRegistry.java 2009-11-13 16:03:06 UTC (rev 595)
+++ components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/AbstractConsumerRegistry.java 2009-11-13 21:33:30 UTC (rev 596)
@@ -116,7 +116,7 @@
registerOrDeregisterConsumerWith(id, false);
}
- deactivateConsumerWith(id);
+ deactivateConsumer(consumer);
consumers.remove(id);
delete(info);
@@ -156,20 +156,25 @@
public void activateConsumerWith(String id) throws ConsumerException
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer identifier", "Activating a Consumer");
+ activateConsumer(getConsumer(id));
+ }
- // if the consumer associated with the given id is already registered, don't do anything
+ protected void activateConsumer(WSRPConsumer consumer)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumer, "WSRPConsumer");
+ String id = consumer.getProducerId();
+
if (federatingPortletInvoker.getFederatedInvoker(id) == null)
{
- startOrStopConsumer(id, true);
+ startOrStopConsumer(consumer, true);
}
else
{
// todo: fix-me federated portlet invoker gets desynchronized...
- WSRPConsumer consumer = getConsumer(id);
- if (consumer != null && !consumer.isActive())
+ if (!consumer.isActive())
{
federatingPortletInvoker.unregisterInvoker(id);
- startOrStopConsumer(id, true);
+ startOrStopConsumer(consumer, true);
}
}
}
@@ -177,20 +182,26 @@
public void deactivateConsumerWith(String id) throws ConsumerException
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer identifier", "Deactivating a Consumer");
+ deactivateConsumer(getConsumer(id));
+ }
+ protected void deactivateConsumer(WSRPConsumer consumer)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumer, "Consumer");
+ String id = consumer.getProducerId();
+
// only process if there is a registered Consumer with the specified id
if (federatingPortletInvoker.getFederatedInvoker(id) != null)
{
- startOrStopConsumer(id, false);
+ startOrStopConsumer(consumer, false);
}
else
{
// todo: fix-me federated portlet invoker gets desynchronized...
- WSRPConsumer consumer = getConsumer(id);
- if (consumer != null && consumer.isActive())
+ if (consumer.isActive())
{
federatingPortletInvoker.registerInvoker(id, consumer);
- startOrStopConsumer(id, false);
+ startOrStopConsumer(consumer, false);
}
}
}
@@ -219,13 +230,13 @@
// load the configured consumers
consumers = new TreeMap<String, WSRPConsumer>();
- Iterator producerInfos = getAllProducerInfos();
+ Iterator<ProducerInfo> producerInfos = getProducerInfosFromStorage();
// load the configured producers
ProducerInfo producerInfo;
while (producerInfos.hasNext())
{
- producerInfo = (ProducerInfo)producerInfos.next();
+ producerInfo = producerInfos.next();
// need to set the registry after loading from DB since registry is not persisted.
producerInfo.setRegistry(this);
@@ -310,28 +321,20 @@
catch (Exception e)
{
// unexpected exception: deactivate the consumer
- deactivateConsumerWith(id);
+ deactivateConsumer(consumer);
Throwable cause = e.getCause();
throw new ConsumerException("Couldn't " + (register ? "register" : "deregister") + CONSUMER_WITH_ID + id + "'",
cause != null ? cause : e);
}
}
- private void startOrStopConsumer(String id, boolean start)
+ private void startOrStopConsumer(WSRPConsumer consumer, boolean start)
{
- WSRPConsumer consumer;
-
try
{
+ String id = consumer.getProducerId();
if (start)
{
- consumer = getConsumer(id);
-
- if (consumer == null)
- {
- throw new IllegalArgumentException(CONSUMER_WITH_ID + id + "' doesn't exist!");
- }
-
consumer.activate();
federatingPortletInvoker.registerInvoker(id, consumer);
sessionEventBroadcaster.registerListener(getListenerIdFrom(id), consumer);
@@ -362,7 +365,7 @@
}
catch (Exception e)
{
- throw new ConsumerException("Couldn't " + (start ? "start" : "stop") + " Consumer service '" + id + "'", e);
+ throw new ConsumerException("Couldn't " + (start ? "start" : "stop") + " Consumer service '" + consumer.getProducerId() + "'", e);
}
// update ProducerInfo
@@ -380,5 +383,5 @@
protected abstract String update(ProducerInfo producerInfo);
- protected abstract Iterator getAllProducerInfos();
+ protected abstract Iterator<ProducerInfo> getProducerInfosFromStorage();
}
Modified: components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/hibernate/HibernateConsumerRegistry.java
===================================================================
--- components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/hibernate/HibernateConsumerRegistry.java 2009-11-13 16:03:06 UTC (rev 595)
+++ components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/hibernate/HibernateConsumerRegistry.java 2009-11-13 21:33:30 UTC (rev 596)
@@ -104,12 +104,11 @@
return oldId;
}
- protected Iterator getAllProducerInfos()
+ protected Iterator<ProducerInfo> getProducerInfosFromStorage()
{
Session session = sessionFactory.getCurrentSession();
- Iterator producerInfos = session.createQuery("from ProducerInfo pi order by pi.persistentId").iterate();
- return producerInfos;
+ return session.createQuery("from ProducerInfo pi order by pi.persistentId").iterate();
}
@Override
Modified: components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/xml/XMLConsumerRegistry.java
===================================================================
--- components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/xml/XMLConsumerRegistry.java 2009-11-13 16:03:06 UTC (rev 595)
+++ components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/xml/XMLConsumerRegistry.java 2009-11-13 21:33:30 UTC (rev 596)
@@ -34,6 +34,7 @@
import org.slf4j.LoggerFactory;
import org.xml.sax.EntityResolver;
+import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Iterator;
@@ -68,12 +69,20 @@
this.entityResolver = entityResolver;
}
- public void start() throws Exception
+ public void reloadConsumers()
{
URL defaultWSRPURL = Thread.currentThread().getContextClassLoader().getResource(defaultWSRPLocation);
if (defaultWSRPURL != null)
{
- InputStream inputStream = defaultWSRPURL.openStream();
+ InputStream inputStream;
+ try
+ {
+ inputStream = defaultWSRPURL.openStream();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Couldn't open default XML WSRP Consumer configuration file", e);
+ }
Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
ObjectModelFactory factory = new XMLWSRPConsumerFactory(this);
@@ -82,19 +91,33 @@
log.debug("Could not obtain entity resolver for XMLConsumerRegistry");
entityResolver = new NullEntityResolver();
}
- unmarshaller.setEntityResolver(entityResolver);
try
{
+ unmarshaller.setEntityResolver(entityResolver);
consumers = (SortedMap<String, WSRPConsumer>)unmarshaller.unmarshal(inputStream, factory, null);
}
catch (JBossXBException e)
{
- e.printStackTrace();
+ throw new RuntimeException("Couldn't set unmarshall WSRP Consumers configuration", e);
}
for (WSRPConsumer consumer : consumers.values())
{
- activateConsumerWith(consumer.getProducerId());
+
+ ProducerInfo producerInfo = consumer.getProducerInfo();
+ try
+ {
+ // if the producer is marked as active, activate it fo' real! :)
+ if (producerInfo.isActive())
+ {
+ activateConsumer(consumer);
+ }
+ }
+ catch (Exception e)
+ {
+ producerInfo.setActive(false);
+ updateProducerInfo(producerInfo);
+ }
}
}
}
@@ -127,13 +150,38 @@
}
@Override
- protected Iterator getAllProducerInfos()
+ protected Iterator<ProducerInfo> getProducerInfosFromStorage()
{
- return consumers.values().iterator();
+ return new ProducerInfoIterator(consumers.values().iterator());
}
SortedMap<String, WSRPConsumer> getConsumers()
{
return consumers;
}
+
+ class ProducerInfoIterator implements Iterator<ProducerInfo>
+ {
+ private Iterator<WSRPConsumer> consumers;
+
+ ProducerInfoIterator(Iterator<WSRPConsumer> consumers)
+ {
+ this.consumers = consumers;
+ }
+
+ public boolean hasNext()
+ {
+ return consumers.hasNext();
+ }
+
+ public ProducerInfo next()
+ {
+ return consumers.next().getProducerInfo();
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException("remove not supported on this iterator implementation");
+ }
+ }
}
15 years, 1 month
gatein SVN: r595 - in portal/trunk/component/portal/src: test/java/org/exoplatform/portal/config and 1 other directory.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2009-11-13 11:03:06 -0500 (Fri, 13 Nov 2009)
New Revision: 595
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
Log:
GTNPORTAL-166 : Portal Page inside Container generates an 'Unknown error'
Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java 2009-11-13 13:36:53 UTC (rev 594)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java 2009-11-13 16:03:06 UTC (rev 595)
@@ -558,10 +558,13 @@
String childId = child.getStorageId();
if (childId != null)
{
- if (hierarchyRelationships.put(childId, parentId) != null)
+ if (hierarchyRelationships.containsKey(childId))
{
throw new AssertionError("The same object is present two times in the object hierarchy");
- }
+ }
+
+ // Note that we are aware that parent id may be null
+ hierarchyRelationships.put(childId, parentId);
}
if (child instanceof ContainerData)
{
@@ -637,9 +640,10 @@
//
if (!found)
{
- String srcId = hierarchyRelationships.get(srcChildId);
- if (srcId != null)
+ if (hierarchyRelationships.containsKey(srcChildId))
{
+ String srcId = hierarchyRelationships.get(srcChildId);
+
// It's a move operation, so we move the node first
dst.add(dstChild);
@@ -648,8 +652,8 @@
}
else
{
- throw new IllegalArgumentException("Attempt for updating a ui component " + session.pathOf(dstChild)
- + "that is not present in the target ui container " + session.pathOf(dst));
+ throw new IllegalArgumentException("Attempt for updating a ui component " + session.pathOf(dstChild)
+ + " that is not present in the target ui container " + session.pathOf(dst));
}
}
Modified: portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
===================================================================
--- portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2009-11-13 13:36:53 UTC (rev 594)
+++ portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2009-11-13 16:03:06 UTC (rev 595)
@@ -228,8 +228,30 @@
assertEquals(a3.getStorageId(), ch6.getObject().getStorageId());
}
- // Need to make window move 2 unit test
+ public void testWindowMove2() throws Exception
+ {
+ Page page = storage_.getPage("portal::test::test3");
+ Container container = new Container();
+ Application application = (Application)page.getChildren().remove(0);
+ container.getChildren().add(application);
+ page.getChildren().add(container);
+
+ //
+ storage_.save(page);
+ //
+ Page page2 = storage_.getPage("portal::test::test3");
+
+ //
+ assertEquals(1, page2.getChildren().size());
+ Container container2 = (Container)page2.getChildren().get(0);
+ assertEquals(1, page2.getChildren().size());
+ Application application2 = (Application)container2.getChildren().get(0);
+ assertEquals(application2.getStorageId(), application.getStorageId());
+ }
+
+ // Need to make window move 3 unit test
+
public void testCreateNavigation() throws Exception
{
PortalConfig portal = new PortalConfig();
15 years, 1 month
gatein SVN: r594 - portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2009-11-13 08:36:53 -0500 (Fri, 13 Nov 2009)
New Revision: 594
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
Log:
remove hard coded cache max ttl that was there only for testing purpose
Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java 2009-11-13 13:35:01 UTC (rev 593)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java 2009-11-13 13:36:53 UTC (rev 594)
@@ -108,9 +108,6 @@
this.cache = cacheService.getCacheInstance(POMSessionManager.class.getSimpleName());
this.repositoryService = repositoryService;
this.pomService = null;
-
- //
- this.cache.setLiveTime(100000000);
}
public void clearCache()
15 years, 1 month
gatein SVN: r593 - in portal/trunk/component/portal/src: main/java/org/exoplatform/portal/pom/config and 3 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2009-11-13 08:35:01 -0500 (Fri, 13 Nov 2009)
New Revision: 593
Added:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortalConfigTask.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
Log:
better cache eviction based on mop session life cycle
Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java 2009-11-13 10:49:53 UTC (rev 592)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/DataStorageImpl.java 2009-11-13 13:35:01 UTC (rev 593)
@@ -148,7 +148,7 @@
public void create(PageNavigation navigation) throws Exception
{
- delegate.save(navigation.build());
+ delegate.create(navigation.build());
}
private abstract class Bilto<O extends ModelObject, D extends ModelData>
Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2009-11-13 10:49:53 UTC (rev 592)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2009-11-13 13:35:01 UTC (rev 593)
@@ -320,6 +320,11 @@
}
PortalConfig pconfig = fromXML(config.getOwnerType(), owner, xml, PortalConfig.class);
+
+ // We use that owner value because it may have been fixed for group names
+ owner = pconfig.getName();
+
+ //
PortalConfig currentPortalConfig = pdcService_.getPortalConfig(type, owner);
if (currentPortalConfig == null)
{
Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java 2009-11-13 10:49:53 UTC (rev 592)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMDataStorage.java 2009-11-13 13:35:01 UTC (rev 593)
@@ -48,7 +48,6 @@
import org.exoplatform.portal.pom.data.PageKey;
import org.exoplatform.portal.pom.data.PortalData;
import org.exoplatform.portal.pom.data.PortalKey;
-import org.exoplatform.services.cache.CacheService;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.jibx.runtime.BindingDirectory;
@@ -79,11 +78,11 @@
/** . */
private final TaskExecutionDecorator executor;
- public POMDataStorage(CacheService cacheService, POMSessionManager pomMgr, ConfigurationManager confManager)
+ public POMDataStorage(POMSessionManager pomMgr, ConfigurationManager confManager)
{
this.pomMgr = pomMgr;
this.confManager_ = confManager;
- this.executor = new DataCache(cacheService, new ExecutorDispatcher());
+ this.executor = new DataCache(new ExecutorDispatcher());
}
public POMSessionManager getPOMSessionManager()
@@ -134,7 +133,7 @@
public void create(PortalData config) throws Exception
{
- execute(new PortalConfigTask.Save(config, true));
+ execute(new PortalConfigTask.Save(config, false));
}
public void save(PortalData config) throws Exception
Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java 2009-11-13 10:49:53 UTC (rev 592)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java 2009-11-13 13:35:01 UTC (rev 593)
@@ -36,10 +36,13 @@
import org.gatein.mop.core.api.workspace.PageImpl;
import javax.jcr.RepositoryException;
+import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -65,13 +68,51 @@
/** . */
private boolean markedForRollback;
+ /** . */
+ private List<Serializable> staleKeys;
+
+ /** . */
+ private boolean modified;
+
public POMSession(POMSessionManager mgr)
{
this.mgr = mgr;
this.isInTask = false;
this.markedForRollback = false;
+ this.staleKeys = null;
}
+ public Object getFromCache(Serializable key)
+ {
+ if (isModified())
+ {
+ throw new IllegalStateException("Cannot read object in shared cache from a modified session");
+ }
+ return mgr.cache.get(key);
+ }
+
+ public void putInCache(Serializable key, Object value)
+ {
+ if (isModified())
+ {
+ throw new IllegalStateException("Cannot put object in shared cache from a modified session");
+ }
+ mgr.cache.put(key, value);
+ }
+
+ public void scheduleForEviction(Serializable key)
+ {
+ if (key == null)
+ {
+ throw new NullPointerException();
+ }
+ if (staleKeys == null)
+ {
+ staleKeys = new LinkedList<Serializable>();
+ }
+ staleKeys.add(key);
+ }
+
private Model getModel()
{
if (model == null)
@@ -81,17 +122,21 @@
return model;
}
- // julien todo : investigate how expensive is the call to hasPendingChanges method
public boolean isModified()
{
+ if (modified)
+ {
+ return true;
+ }
try
{
- return getSession().getJCRSession().hasPendingChanges();
+ modified = getSession().getJCRSession().hasPendingChanges();
}
catch (RepositoryException e)
{
throw new UndeclaredRepositoryException(e);
}
+ return modified;
}
protected ChromatticSession getSession()
@@ -356,5 +401,14 @@
{
model.close();
}
+
+ //
+ if (staleKeys != null)
+ {
+ for (Serializable key : staleKeys)
+ {
+ mgr.cache.remove(key);
+ }
+ }
}
}
Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java 2009-11-13 10:49:53 UTC (rev 592)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java 2009-11-13 13:35:01 UTC (rev 593)
@@ -35,6 +35,8 @@
import org.exoplatform.portal.pom.spi.wsrp.WSRP;
import org.exoplatform.portal.pom.spi.wsrp.WSRPContentProvider;
import org.exoplatform.portal.pom.spi.wsrp.WSRPState;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.ExoCache;
import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.ext.registry.RegistryService;
@@ -68,6 +70,7 @@
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.UndeclaredThrowableException;
import java.util.Set;
@@ -94,14 +97,26 @@
/** . */
final String workspaceName = "portal-system";
- public POMSessionManager(RegistryService service) throws Exception
+ /** . */
+ final ExoCache<Serializable, Object> cache;
+
+ public POMSessionManager(CacheService cacheService, RegistryService service) throws Exception
{
RepositoryService repositoryService = service.getRepositoryService();
//
+ this.cache = cacheService.getCacheInstance(POMSessionManager.class.getSimpleName());
this.repositoryService = repositoryService;
this.pomService = null;
+
+ //
+ this.cache.setLiveTime(100000000);
}
+
+ public void clearCache()
+ {
+ cache.clearCache();
+ }
public Session login() throws RepositoryException
{
Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java 2009-11-13 10:49:53 UTC (rev 592)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java 2009-11-13 13:35:01 UTC (rev 593)
@@ -22,8 +22,6 @@
import org.exoplatform.portal.pom.config.POMTask;
import org.exoplatform.portal.pom.config.TaskExecutor;
import org.exoplatform.portal.pom.config.TaskExecutionDecorator;
-import org.exoplatform.services.cache.CacheService;
-import org.exoplatform.services.cache.ExoCache;
import java.io.Serializable;
import java.util.concurrent.atomic.AtomicLong;
@@ -36,48 +34,35 @@
{
/** . */
- private final ExoCache<Serializable, Object> cache;
-
- /** . */
private final AtomicLong readCount = new AtomicLong();
- public DataCache(CacheService cacheService, TaskExecutor next)
+ public DataCache(TaskExecutor next)
{
super(next);
-
- //
- this.cache = cacheService.getCacheInstance(DataCache.class.getSimpleName());
}
public void execute(POMSession session, POMTask task) throws Exception
{
if (task instanceof CacheableDataTask)
{
- if (!session.isModified())
+ CacheableDataTask<?, ?> loadTask = (CacheableDataTask<?,?>)task;
+ switch (loadTask.getAccessMode())
{
- CacheableDataTask<?, ?> loadTask = (CacheableDataTask<?,?>)task;
- switch (loadTask.getAccessMode())
- {
- case READ:
- read(session, loadTask);
- break;
- case CREATE:
- create(session, loadTask);
- break;
- case WRITE:
- write(session, loadTask);
- break;
- case DESTROY:
- remove(session, loadTask);
- break;
- default:
- throw new UnsupportedOperationException();
- }
+ case READ:
+ read(session, loadTask);
+ break;
+ case CREATE:
+ create(session, loadTask);
+ break;
+ case WRITE:
+ write(session, loadTask);
+ break;
+ case DESTROY:
+ remove(session, loadTask);
+ break;
+ default:
+ throw new UnsupportedOperationException();
}
- else
- {
- super.execute(session, task);
- }
}
else
{
@@ -85,22 +70,17 @@
}
}
- public void clear()
- {
- cache.clearCache();
- }
-
private <K extends Serializable, V> void remove(POMSession session, CacheableDataTask<K, V> task) throws Exception
{
K key = task.getKey();
- cache.remove(key);
+ session.scheduleForEviction(key);
super.execute(session, task);
}
private <K extends Serializable, V> void write(POMSession session, CacheableDataTask<K, V> task) throws Exception
{
K key = task.getKey();
- cache.remove(key);
+ session.scheduleForEviction(key);
super.execute(session, task);
}
@@ -112,37 +92,44 @@
private <K extends Serializable, V> void read(POMSession session, CacheableDataTask<K, V> task) throws Exception
{
- K key = task.getKey();
- Object o = cache.get(key);
- V v = null;
- if (o != null)
+ if (!session.isModified())
{
- Class<V> type = task.getValueType();
- if (type.isInstance(o))
+ K key = task.getKey();
+ Object o = session.getFromCache(key);
+ V v = null;
+ if (o != null)
{
- v = type.cast(o);
+ Class<V> type = task.getValueType();
+ if (type.isInstance(o))
+ {
+ v = type.cast(o);
+ }
}
- }
- //
- if (v != null)
- {
- task.setValue(v);
- }
- else
- {
- readCount.incrementAndGet();
-
//
- super.execute(session, task);
-
- //
- v = task.getValue();
if (v != null)
{
- cache.put(key, v);
+ task.setValue(v);
}
+ else
+ {
+ readCount.incrementAndGet();
+
+ //
+ super.execute(session, task);
+
+ //
+ v = task.getValue();
+ if (v != null)
+ {
+ session.putInCache(key, v);
+ }
+ }
}
+ else
+ {
+ super.execute(session, task);
+ }
}
public long getReadCount()
Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortalConfigTask.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortalConfigTask.java 2009-11-13 10:49:53 UTC (rev 592)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PortalConfigTask.java 2009-11-13 13:35:01 UTC (rev 593)
@@ -125,7 +125,7 @@
public DataAccessMode getAccessMode()
{
- return config.getStorageId() != null ? DataAccessMode.WRITE : DataAccessMode.CREATE;
+ return overwrite ? DataAccessMode.WRITE : DataAccessMode.CREATE;
}
public void setValue(PortalData value)
@@ -161,6 +161,12 @@
}
else
{
+ if (overwrite)
+ {
+ throw new IllegalArgumentException("Cannot update portal " + config.getName() + " that does not exist");
+ }
+
+ //
site = workspace.addSite(type, config.getName());
Page root = site.getRootPage();
root.addChild("pages");
Added: portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java
===================================================================
--- portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java (rev 0)
+++ portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java 2009-11-13 13:35:01 UTC (rev 593)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2003-2007 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.portal.config;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.exoplatform.test.BasicTestCase;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestCache extends BasicTestCase
+{
+
+ /** . */
+ DataStorage storage_;
+
+ /** . */
+ private POMSessionManager mgr;
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ if (storage_ != null)
+ return;
+ PortalContainer container = PortalContainer.getInstance();
+ storage_ = (DataStorage)container.getComponentInstanceOfType(DataStorage.class);
+ mgr = (POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
+ mgr.openSession();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ mgr.closeSession(false);
+ }
+
+ public void testDirtyWrite() throws Exception
+ {
+ // Read
+ Page page = storage_.getPage("portal::test::test4");
+ assertEquals(null, page.getTitle());
+
+ // Update
+ page.setTitle("foo");
+ storage_.save(page);
+
+ //
+ final AtomicBoolean go = new AtomicBoolean(false);
+
+ // Force a cache update
+ new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ mgr.openSession();
+ storage_.getPage("portal::test::test4");
+ mgr.closeSession(false);
+ }
+ catch (Exception e)
+ {
+ throw new Error(e);
+ }
+ finally
+ {
+ go.set(true);
+ }
+ }
+ }.start();
+
+ //
+ while (!go.get())
+ {
+ Thread.sleep(1);
+ }
+
+ // Reopen session with no modifications that use the cache
+ mgr.closeSession(true);
+ mgr.openSession();
+
+ //
+ page = storage_.getPage("portal::test::test4");
+ assertEquals("foo", page.getTitle());
+ }
+}
Modified: portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
===================================================================
--- portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2009-11-13 10:49:53 UTC (rev 592)
+++ portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2009-11-13 13:35:01 UTC (rev 593)
@@ -236,7 +236,7 @@
portal.setName("foo");
portal.setLocale("en");
portal.setAccessPermissions(new String[]{UserACL.EVERYONE});
- storage_.save(portal);
+ storage_.create(portal);
//
PageNavigation navigation = new PageNavigation();
Modified: portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
===================================================================
--- portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java 2009-11-13 10:49:53 UTC (rev 592)
+++ portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java 2009-11-13 13:35:01 UTC (rev 593)
@@ -722,16 +722,22 @@
{
public void execute() throws Exception
{
+// mgr.clearCache();
+
PortalConfig cfg = storage_.getPortalConfig(PortalConfig.USER_TYPE, "overwritelayout");
assertNotNull(cfg);
+
+
Container container = cfg.getPortalLayout();
assertNotNull(container);
assertEquals(2, container.getChildren().size());
assertTrue(container.getChildren().get(0) instanceof PageBody);
assertTrue(((Application)container.getChildren().get(1)).getType() == ApplicationType.PORTLET);
Application<Portlet> pa = (Application<Portlet>)container.getChildren().get(1);
- ApplicationState state = pa.getState();
- assertEquals("overwrite_application_ref/overwrite_portlet_ref", storage_.getId(pa.getState()));
+ ApplicationState<Portlet> state = pa.getState();
+
+
+ assertEquals("overwrite_application_ref/overwrite_portlet_ref", storage_.getId(state));
}
}.execute(null);
}
@@ -775,6 +781,7 @@
{
public void execute() throws Exception
{
+ mgr.clearCache();
DataCache cache = mopStorage.getDecorator(DataCache.class);
long readCount0 = cache.getReadCount();
userPortalConfigSer_.getUserPortalConfig("classic", null);
@@ -793,6 +800,7 @@
{
public void execute() throws Exception
{
+ mgr.clearCache();
DataCache cache = mopStorage.getDecorator(DataCache.class);
long readCount0 = cache.getReadCount();
userPortalConfigSer_.getPage("portal::test::test1");
@@ -811,6 +819,7 @@
{
public void execute() throws Exception
{
+ mgr.clearCache();
DataCache cache = mopStorage.getDecorator(DataCache.class);
long readCount0 = cache.getReadCount();
userPortalConfigSer_.getPageNavigation("portal", "test");
@@ -862,8 +871,7 @@
}
// Clear cache
- DataCache cache = mopStorage.getDecorator(DataCache.class);
- cache.clear();
+// mgr.clearCache();
//
mopSession = mgr.openSession();
15 years, 1 month
gatein SVN: r592 - portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2009-11-13 05:49:53 -0500 (Fri, 13 Nov 2009)
New Revision: 592
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
Log:
GTNPORTAL-196: Add unit test
Modified: portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
===================================================================
--- portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java 2009-11-13 08:36:41 UTC (rev 591)
+++ portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java 2009-11-13 10:49:53 UTC (rev 592)
@@ -119,7 +119,8 @@
};
PortalContainer container = PortalContainer.getInstance();
- userPortalConfigSer_ = (UserPortalConfigService)container.getComponentInstanceOfType(UserPortalConfigService.class);
+ userPortalConfigSer_ =
+ (UserPortalConfigService)container.getComponentInstanceOfType(UserPortalConfigService.class);
orgService_ = (OrganizationService)container.getComponentInstanceOfType(OrganizationService.class);
idmService = (JBossIDMService)container.getComponentInstanceOfType(JBossIDMService.class);
mgr = (POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
@@ -132,7 +133,8 @@
// Register only once for all unit tests
if (!registered)
{
- // I'm using this due to crappy design of org.exoplatform.services.listener.ListenerService
+ // I'm using this due to crappy design of
+ // org.exoplatform.services.listener.ListenerService
listenerService.addListener(UserPortalConfigService.CREATE_PAGE_EVENT, listener);
listenerService.addListener(UserPortalConfigService.REMOVE_PAGE_EVENT, listener);
listenerService.addListener(UserPortalConfigService.UPDATE_PAGE_EVENT, listener);
@@ -469,7 +471,6 @@
}.execute(null);
}
-
// Julien : see who added that and find out is test is relevant or not
public void testClonePage()
@@ -484,17 +485,16 @@
page.setName("whatever");
page.setTitle("testTitle");
userPortalConfigSer_.create(page);
-
+
String newName = "newPage";
- Page newPage = userPortalConfigSer_.renewPage(page.getPageId(), newName, page.getOwnerType(), page.getOwnerId());
- assertEquals(newName, newPage.getName());
- assertEquals(page.getTitle(), newPage.getTitle());
+ Page newPage =
+ userPortalConfigSer_.renewPage(page.getPageId(), newName, page.getOwnerType(), page.getOwnerId());
+ assertEquals(newName, newPage.getName());
+ assertEquals(page.getTitle(), newPage.getTitle());
}
}.execute(null);
}
-
-
public void testUpdatePage()
{
new UnitTest()
@@ -573,6 +573,64 @@
}.execute(null);
}
+ public void testCreateMultipleNavigations(){
+ for(int i =0; i < 10; i++){
+ createNavigation(null, "group", "/platform/administrators" + i);
+ }
+ }
+
+ private void createNavigation(final String user, final String ownerType, final String ownerId)
+ {
+ new UnitTest()
+ {
+
+ public void execute() throws Exception
+ {
+ createNavigationInSeperatedThread();
+ }
+
+ private void createNavigationInSeperatedThread()
+ {
+ Thread task = new Thread()
+ {
+ public void run()
+ {
+ PageNavigation navigation = new PageNavigation();
+ navigation.setOwnerType(ownerType);
+ navigation.setOwnerId(ownerId);
+ try
+ {
+ userPortalConfigSer_.create(navigation);
+ Event event = events.removeFirst();
+ assertEquals(UserPortalConfigService.CREATE_NAVIGATION_EVENT, event.getEventName());
+ PageNavigation n1 = (PageNavigation)event.getSource();
+ assertEquals(ownerType, n1.getOwnerType());
+ assertEquals(ownerId, n1.getOwnerId());
+ PageNavigation n2 = userPortalConfigSer_.getPageNavigation(ownerType, ownerId);
+ assertEquals(ownerType, n2.getOwnerType());
+ assertEquals(ownerId, n2.getOwnerId());
+ }
+ catch (Exception ex)
+ {
+ assertTrue("Failed while create '" + ownerType + " ' navigation for owner: " + ownerId, false);
+ ex.printStackTrace();
+ }
+ }
+ };
+
+ task.start();
+ try
+ {
+ task.sleep(200);
+ }
+ catch (InterruptedException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }.execute(user);
+ }
+
public void testUpdateNavigation()
{
new UnitTest()
@@ -650,8 +708,8 @@
assertEquals("Dashboard", app.getTitle());
assertNotNull(app.getState());
assertEquals("dashboard/DashboardPortlet", storage_.getId(app.getState()));
- // assertEquals("portal", app.getInstanceState().getOwnerType());
- // assertEquals("test", app.getInstanceState().getOwnerId());
+ // assertEquals("portal", app.getInstanceState().getOwnerType());
+ // assertEquals("test", app.getInstanceState().getOwnerId());
Portlet prefs2 = storage_.load(app.getState());
assertNull(prefs2);
}
15 years, 1 month
gatein SVN: r591 - portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization.
by do-not-reply@jboss.org
Author: liem_nguyen
Date: 2009-11-13 03:36:41 -0500 (Fri, 13 Nov 2009)
New Revision: 591
Modified:
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/UIUserProfileInputSet.java
Log:
GTNPORTAL-182 Always keep old language when change langauge in New Account portlet
Modified: portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/UIUserProfileInputSet.java
===================================================================
--- portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/UIUserProfileInputSet.java 2009-11-13 08:34:02 UTC (rev 590)
+++ portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/UIUserProfileInputSet.java 2009-11-13 08:36:41 UTC (rev 591)
@@ -104,34 +104,64 @@
}
else if (key.equalsIgnoreCase("user.language"))
{
- List<SelectItemOption<String>> lang = new ArrayList<SelectItemOption<String>>();
- LocaleConfigService localeService = getApplicationComponent(LocaleConfigService.class);
- Locale currentLocale = ((PortletRequestContext)WebuiRequestContext.getCurrentInstance()).getLocale();
- Iterator i = localeService.getLocalConfigs().iterator();
- String displayLanguage = null;
- String displayName = null;
- String language = null;
- while (i.hasNext())
- {
- LocaleConfig config = (LocaleConfig)i.next();
- displayLanguage = config.getLocale().getDisplayLanguage(currentLocale);
- displayName = config.getLocale().getDisplayName(currentLocale);
- language = config.getLanguage();
- if (config.getLanguage().equals("en"))
- {
- lang.add(0, new SelectItemOption<String>(displayLanguage, language, displayName));
- continue;
- }
- lang.add(new SelectItemOption<String>(displayLanguage, language, displayName));
- }
- UIFormSelectBox langSelectBox = new UIFormSelectBox(key, key, lang);
+ UIFormSelectBox langSelectBox = new UIFormSelectBox(key, key, null);
set.addUIFormInput(langSelectBox);
+ initLanguageCombo();
continue;
}
set.addUIFormInput(new UIFormStringInput(key, null, null));
}
}
+ /**
+ * Update language select box
+ */
+ @Override
+ public void processRender(WebuiRequestContext context) throws Exception
+ {
+ initLanguageCombo();
+ super.processRender(context);
+ }
+
+ private void initLanguageCombo()
+ {
+ UIFormSelectBox langSelectBox = this.findComponentById("user.language");
+ if (langSelectBox == null)
+ return;
+ String selectedLang = langSelectBox.getSelectedValues()[0];
+
+ List<SelectItemOption<String>> lang = new ArrayList<SelectItemOption<String>>();
+ langSelectBox.setOptions(lang); // Clear
+
+ LocaleConfigService localeService = getApplicationComponent(LocaleConfigService.class);
+ Locale currentLocale = ((PortletRequestContext)WebuiRequestContext.getCurrentInstance()).getLocale();
+ Iterator<LocaleConfig> i = localeService.getLocalConfigs().iterator();
+ String displayLanguage = null;
+ String displayName = null;
+ String language = null;
+ SelectItemOption<String> option;
+ while (i.hasNext())
+ {
+ LocaleConfig config = i.next();
+ displayLanguage = config.getLocale().getDisplayLanguage(currentLocale);
+ displayName = config.getLocale().getDisplayName(currentLocale);
+ language = config.getLanguage();
+ option = new SelectItemOption<String>(displayLanguage, language, displayName);
+ if (lang.equals(selectedLang))
+ {
+ option.setSelected(true);
+ }
+ if (config.getLanguage().equals("en"))
+ {
+ lang.add(0, option);
+ continue;
+ }
+ lang.add(option);
+ }
+
+ langSelectBox.setOptions(lang);
+ }
+
@SuppressWarnings("deprecation")
public void setUserProfile(String user) throws Exception
{
15 years, 1 month
gatein SVN: r590 - in portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin: webui/component/UIPopup/UIPopupWindow and 1 other directories.
by do-not-reply@jboss.org
Author: thanh.do
Date: 2009-11-13 03:34:02 -0500 (Fri, 13 Nov 2009)
New Revision: 590
Added:
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/background/BackIcon.gif
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/background/EdittedSaveIcon.gif
Removed:
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/background/TopExitBtn.gif
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/background/UnSaveIcon.gif
Modified:
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/view/UIDashboard/Stylesheet.css
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/Stylesheet.css
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/background/CloseIcon.gif
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/background/SaveIcon.gif
Log:
GTNPORTAL-238:no back button icon when creating a new page
Modified: portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/view/UIDashboard/Stylesheet.css
===================================================================
--- portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/view/UIDashboard/Stylesheet.css 2009-11-13 08:31:56 UTC (rev 589)
+++ portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/view/UIDashboard/Stylesheet.css 2009-11-13 08:34:02 UTC (rev 590)
@@ -17,6 +17,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
+
.UIWindow .UIDashboardPortlet {
margin: 0px;
}
Modified: portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/Stylesheet.css
===================================================================
--- portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/Stylesheet.css 2009-11-13 08:31:56 UTC (rev 589)
+++ portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/Stylesheet.css 2009-11-13 08:34:02 UTC (rev 590)
@@ -52,8 +52,8 @@
margin: 5px 3px 0px 0px; /* orientation=lt */
margin: 5px 0px 0px 3px; /* orientation=rt */
cursor: pointer;
- width: 18px; height: 18px;
- background: url('background/TopExitBtn.gif') no-repeat right bottom;
+ width: 23px; height: 17px;
+ background: url('background/CloseIcon.gif') no-repeat right top;
}
.UIPopupWindow .BackButton {
@@ -63,7 +63,7 @@
margin: 5px 0px 0px 3px; /* orientation=rt */
cursor: pointer;
width: 18px; height: 18px;
- background: url('background/BackBtn.gif') no-repeat right bottom;
+ background: url('background/Back.gif') no-repeat right bottom;
}
.UIPopupWindow .TopLeftCornerDecorator {
@@ -182,41 +182,48 @@
}
.UIPortalComposer .CloseButton {
- background: transparent url(background/CloseIcon.gif) no-repeat scroll right bottom; /* orientation=lt */
- background: transparent url(background/CloseIcon-rt.gif) no-repeat scroll left bottom; /* orientation=rt */
- width: 25px;
- height: 17px;
- margin: 6px 0px 0px 0px;
+ background: url(background/CloseIcon.gif) no-repeat right bottom; /* orientation=lt */
+ background: url(background/CloseIcon-rt.gif) no-repeat left bottom; /* orientation=rt */
+ width: 23px;
+ height: 17px;
+ float: right; /* orientation=lt */
+ float: left; /* orientation=rt */
+ margin: 6px 0px 0px 2px; /* orientation=lt */
+ margin: 6px 2px 0px 0px; /* orientation=rt */
}
.UIPortalComposer .SaveButton {
- background: transparent url(background/UnSaveIcon.gif) no-repeat scroll right bottom; /* orientation=lt */
- background: transparent url(background/UnSaveIcon-rt.gif) no-repeat scroll left bottom; /* orientation=rt */
+ background: url(background/SaveIcon.gif) no-repeat right bottom; /* orientation=lt */
+ background: url(background/SaveIcon-rt.gif) no-repeat left bottom; /* orientation=rt */
cursor: pointer;
float: right; /* orientation=lt */
float: left; /* orientation=rt */
height: 17px;
- margin-top: 6px;
- width: 25px;
+ margin: 6px 0px 0px 2px; /* orientation=lt */
+ margin: 6px 2px 0px 0px; /* orientation=rt */
+ width: 23px;
}
.UIPortalComposer .BackButton {
- background: #666666 no-repeat scroll right bottom; /* orientation=lt */
- background: #666666 no-repeat scroll left bottom; /* orientation=rt */
- width: 25px;
- height: 17px;
+ background: url(background/BackIcon.gif) no-repeat right bottom; /* orientation=lt */
+ background: url(background/BackIcon-rt.gif) no-repeat left bottom; /* orientation=rt */
+ width: 23px;
+ height: 17px;
+ float: right; /* orientation=lt */
+ float: left; /* orientation=rt */
margin: 6px 0px 0px 0px;
}
.UIPortalComposer .EdittedSaveButton {
- background: transparent url(background/SaveIcon.gif) no-repeat scroll right bottom; /* orientation=lt */
- background: transparent url(background/SaveIcon-rt.gif) no-repeat scroll left bottom; /* orientation=rt */
+ background: url(background/EdittedSaveIcon.gif) no-repeat right bottom; /* orientation=lt */
+ background: url(background/EdittedSaveIcon-rt.gif) no-repeat left bottom; /* orientation=rt */
cursor: pointer;
float: right; /* orientation=lt */
float: left; /* orientation=rt */
- height: 17px;
- margin-top: 6px;
- width: 25px;
+ height: 17px;
+ margin: 6px 0px 0px 2px; /* orientation=lt */
+ margin: 6px 2px 0px 0px; /* orientation=rt */
+ width: 23px;
}
.UIPortalComposer .PopupTitle {
Added: portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/background/BackIcon.gif
===================================================================
(Binary files differ)
Property changes on: portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/background/BackIcon.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/background/CloseIcon.gif
===================================================================
(Binary files differ)
Added: portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/background/EdittedSaveIcon.gif
===================================================================
(Binary files differ)
Property changes on: portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/background/EdittedSaveIcon.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/background/SaveIcon.gif
===================================================================
(Binary files differ)
Deleted: portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/background/TopExitBtn.gif
===================================================================
(Binary files differ)
Deleted: portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UIPopup/UIPopupWindow/background/UnSaveIcon.gif
===================================================================
(Binary files differ)
15 years, 1 month