From do-not-reply at jboss.org Fri Sep 4 02:25:33 2009
Content-Type: multipart/mixed; boundary="===============8025996187338392860=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r136 - in
ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest: impl and 1
other directories.
Date: Fri, 04 Sep 2009 02:25:33 -0400
Message-ID: <200909040625.n846PXpq011868@svn01.web.mwc.hst.phx2.redhat.com>
--===============8025996187338392860==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
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/meth=
od/PropertyResolver.java
Modified:
ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/Requ=
estHandlerImpl.java
Log:
EXOJCR-143 : Add property resolver
Added: ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/Prope=
rty.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 Andrey Parfonov
+ * @version $Id$
+ *
+ */
+(a)Target({ElementType.PARAMETER, ElementType.FIELD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface Property {
+
+ String value();
+
+}
Property changes on: ws/trunk/rest/core/src/main/java/org/exoplatform/servi=
ces/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/im=
pl/RequestHandlerImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/Req=
uestHandlerImpl.java 2009-09-03 08:24:44 UTC (rev 135)
+++ ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/Req=
uestHandlerImpl.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 =3D ExoLogger.getLogger(RequestHandlerImpl=
.class.getName());
-
+ =
/**
+ * Application properties.
+ */
+ private static final MultivaluedMap properties =3D 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/met=
hod/PropertyResolver.java (rev 0)
+++ ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/met=
hod/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 Andrey Parfonov
+ * @version $Id$
+ *
+ */
+public class PropertyResolver extends ParameterResolver
+{
+
+ /**
+ * See {@link Property}
+ */
+ private final Property property;
+
+ /**
+ * @param property Property
+ */
+ PropertyResolver(Property property)
+ {
+ this.property =3D property;
+ }
+
+ /**
+ * @see org.exoplatform.services.rest.impl.method.ParameterResolver#res=
olve(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 =3D this.property.value();
+ TypeProducer typeProducer =3D
+ ParameterHelper.createTypeProducer(parameter.getParameterClass(),=
parameter.getGenericType());
+ return typeProducer.createValue(param, null, parameter.getDefaultVal=
ue());
+ }
+
+}
Property changes on: ws/trunk/rest/core/src/main/java/org/exoplatform/servi=
ces/rest/impl/method/PropertyResolver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
--===============8025996187338392860==--