[exo-jcr-commits] exo-jcr SVN: r136 - in ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest: impl and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Sep 4 02:25:33 EDT 2009


Author: aparfonov
Date: 2009-09-04 02:25:33 -0400 (Fri, 04 Sep 2009)
New Revision: 136

Added:
   ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/Property.java
   ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/method/PropertyResolver.java
Modified:
   ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java
Log:
EXOJCR-143 : Add property resolver

Added: ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/Property.java
===================================================================
--- ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/Property.java	                        (rev 0)
+++ ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/Property.java	2009-09-04 06:25:33 UTC (rev 136)
@@ -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.exoplatform.services.rest;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.exoplatform.services.rest.impl.RequestHandlerImpl;
+
+/**
+ * Useful for injection in service, provider or filter properties which
+ * is preset in {@link RequestHandlerImpl}.
+ *  
+ * @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
+ * @version $Id$
+ *
+ */
+ at Target({ElementType.PARAMETER, ElementType.FIELD})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Property {
+
+   String value();
+
+}


Property changes on: ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/Property.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id

Modified: ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java
===================================================================
--- ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java	2009-09-03 08:24:44 UTC (rev 135)
+++ ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java	2009-09-04 06:25:33 UTC (rev 136)
@@ -46,6 +46,7 @@
 
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.StreamingOutput;
 import javax.ws.rs.ext.ExceptionMapper;
@@ -61,8 +62,13 @@
     * Logger.
     */
    private static final Log LOG = ExoLogger.getLogger(RequestHandlerImpl.class.getName());
-
+   
    /**
+    * Application properties.
+    */
+   private static final MultivaluedMap<String, String> properties = new MultivaluedMapImpl();
+   
+   /**
     * See {@link RequestDispatcher}.
     */
    private final RequestDispatcher dispatcher;

Added: ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/method/PropertyResolver.java
===================================================================
--- ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/method/PropertyResolver.java	                        (rev 0)
+++ ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/method/PropertyResolver.java	2009-09-04 06:25:33 UTC (rev 136)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.rest.impl.method;
+
+import org.exoplatform.services.rest.ApplicationContext;
+import org.exoplatform.services.rest.Property;
+import org.exoplatform.services.rest.method.TypeProducer;
+
+/**
+ * @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
+ * @version $Id$
+ *
+ */
+public class PropertyResolver extends ParameterResolver<Property>
+{
+
+   /**
+    * See {@link Property}
+    */
+   private final Property property;
+
+   /**
+    * @param property Property
+    */
+   PropertyResolver(Property property)
+   {
+      this.property = property;
+   }
+
+   /**
+    * @see org.exoplatform.services.rest.impl.method.ParameterResolver#resolve(org.exoplatform.services.rest.Parameter, org.exoplatform.services.rest.ApplicationContext)
+    */
+   @Override
+   public Object resolve(org.exoplatform.services.rest.Parameter parameter, ApplicationContext context)
+      throws Exception
+   {
+      String param = this.property.value();
+      TypeProducer typeProducer =
+         ParameterHelper.createTypeProducer(parameter.getParameterClass(), parameter.getGenericType());
+      return typeProducer.createValue(param, null, parameter.getDefaultValue());
+   }
+
+}


Property changes on: ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/method/PropertyResolver.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id



More information about the exo-jcr-commits mailing list