Examples of AbstractResourceDescriptor


Examples of org.exoplatform.services.rest.resource.AbstractResourceDescriptor

    */
   public boolean bind(final Class<?> resourceClass)
   {
      final Path path = resourceClass.getAnnotation(Path.class);

      AbstractResourceDescriptor descriptor = null;
      if (path != null)
      {
         try
         {
            descriptor = new AbstractResourceDescriptorImpl(resourceClass, invokerFactory);
         }
         catch (Exception e)
         {
            String msg = "Unexpected error occurs when process resource class " + resourceClass.getName();
            LOG.error(msg, e);
            return false;
         }
      }
      else
      {
         String msg =
            "Resource class " + resourceClass.getName() + " it is not root resource. "
               + "Path annotation javax.ws.rs.Path is not specified for this class.";
         LOG.warn(msg);
         return false;
      }

      // validate AbstractResourceDescriptor
      try
      {
         descriptor.accept(rdv);
      }
      catch (Exception e)
      {
         LOG.error("Validation of root resource failed. ", e);
         return false;
      }

      synchronized (rootResources)
      {
         // check does exist other resource with the same URI pattern
         for (ObjectFactory<AbstractResourceDescriptor> exist : rootResources)
         {
            AbstractResourceDescriptor existDescriptor = exist.getObjectModel();
            if (exist.getObjectModel().getUriPattern().equals(descriptor.getUriPattern()))
            {

               String msg =
                  "Resource class " + descriptor.getObjectClass().getName() + " can't be registered. Resource class "
                     + existDescriptor.getObjectClass().getName() + " with the same pattern "
                     + exist.getObjectModel().getUriPattern().getTemplate() + " already registered.";
               LOG.warn(msg);
               return false;
            }
         }
View Full Code Here

Examples of org.exoplatform.services.rest.resource.AbstractResourceDescriptor

   private void processSubResourceLocators(org.exoplatform.services.rest.wadl.research.Resource wadlResource,
      AbstractResourceDescriptor resourceDescriptor)
   {
      for (SubResourceLocatorDescriptor srld : resourceDescriptor.getSubResourceLocators().values())
      {
         AbstractResourceDescriptor subResourceDescriptor =
            new AbstractResourceDescriptorImpl(srld.getMethod().getReturnType());
         org.exoplatform.services.rest.wadl.research.Resource wadlSubResource = processResource(subResourceDescriptor);
         wadlSubResource.setPath(srld.getPathValue().getPath());
         wadlResource.getMethodOrResource().add(wadlSubResource);
      }
View Full Code Here

Examples of org.exoplatform.services.rest.resource.AbstractResourceDescriptor

   protected RootResourcesList rootResources()
   {
      List<RootResource> resources = new ArrayList<RootResource>();
      for (ObjectFactory<AbstractResourceDescriptor> om : binder.getResources())
      {
         AbstractResourceDescriptor descriptor = om.getObjectModel();
         resources.add(new RootResource(descriptor.getObjectClass().getName(), //
            descriptor.getPathValue().getPath(), //
            descriptor.getUriPattern().getRegex()));
      }
      return new RootResourcesList(resources);
   }
View Full Code Here

Examples of org.exoplatform.services.rest.resource.AbstractResourceDescriptor

   protected RootResourcesList rootResources()
   {
      List<RootResource> resources = new ArrayList<RootResource>();
      for (ObjectFactory<AbstractResourceDescriptor> om : binder.getResources())
      {
         AbstractResourceDescriptor descriptor = om.getObjectModel();
         resources.add(new RootResource(descriptor.getObjectClass().getName(), //
            descriptor.getPathValue().getPath(), //
            descriptor.getUriPattern().getRegex()));
      }
      return new RootResourcesList(resources);
   }
View Full Code Here

Examples of org.exoplatform.services.rest.resource.AbstractResourceDescriptor

      String requestPath = context.getPath(false);
      List<String> parameterValues = context.getParameterValues();

      // Get root resource
      ObjectFactory<AbstractResourceDescriptor> resourceFactory = getRootResourse(parameterValues, requestPath);
      AbstractResourceDescriptor resourceDescriptor = resourceFactory.getObjectModel();

      if (providersRegistry != null)
      {
         // Be sure instance of ProvidersRegistry injected if this class is extended.
         String applicationId = null;
View Full Code Here

Examples of org.exoplatform.services.rest.resource.AbstractResourceDescriptor

      // NOTE Locators can't accept entity
      MethodInvoker invoker = srld.getMethodInvoker();
      resource = invoker.invokeMethod(resource, srld, context);

      AbstractResourceDescriptor descriptor = new AbstractResourceDescriptorImpl(resource, invokerFactory);
      SingletonObjectFactory<AbstractResourceDescriptor> locResource =
         new SingletonObjectFactory<AbstractResourceDescriptor>(descriptor, resource);

      // dispatch again newly created resource
      dispatch(request, response, context, locResource, resource, newRequestPath);
View Full Code Here

Examples of org.exoplatform.services.rest.resource.AbstractResourceDescriptor

         throw new ResourcePublicationException("Resource class " + resourceClass.getName()
            + " it is not root resource. " + "Path annotation javax.ws.rs.Path is not specified for this class.");
      }
      try
      {
         AbstractResourceDescriptor descriptor = new AbstractResourceDescriptorImpl(resourceClass, invokerFactory);
         // validate AbstractResourceDescriptor
         descriptor.accept(rdv);
         if (properties != null)
         {
            descriptor.getProperties().putAll(properties);
         }
         addResource(new PerRequestObjectFactory<AbstractResourceDescriptor>(descriptor));
      }
      catch (Exception e)
      {
View Full Code Here

Examples of org.exoplatform.services.rest.resource.AbstractResourceDescriptor

         throw new ResourcePublicationException("Resource class " + resource.getClass().getName()
            + " it is not root resource. " + "Path annotation javax.ws.rs.Path is not specified for this class.");
      }
      try
      {
         AbstractResourceDescriptor descriptor = new AbstractResourceDescriptorImpl(resource, invokerFactory);
         // validate AbstractResourceDescriptor
         descriptor.accept(rdv);
         if (properties != null)
         {
            descriptor.getProperties().putAll(properties);
         }
         addResource(new SingletonObjectFactory<AbstractResourceDescriptor>(descriptor, resource));
      }
      catch (Exception e)
      {
View Full Code Here

Examples of org.exoplatform.services.rest.resource.AbstractResourceDescriptor

               if (obj instanceof ResponseFilter)
                  appProviders.addResponseFilter((ResponseFilter)obj);
            }
            else if (clazz.getAnnotation(Path.class) != null)
            {
               AbstractResourceDescriptor descriptor = new ApplicationResource(applicationId, obj);
               descriptor.accept(rdv);
               resources.addResource(new SingletonObjectFactory<AbstractResourceDescriptor>(descriptor, obj));
            }
            else
            {
               LOG.warn("Unknown class type: " + clazz.getName() + " found in " + applicationId);
            }
         }
      }
      Set<Class<?>> classes = app.getClasses();
      if (classes != null && classes.size() > 0)
      {
         for (Class clazz : classes)
         {
            if (clazz.getAnnotation(Provider.class) != null)
            {
               if (ContextResolver.class.isAssignableFrom(clazz))
                  appProviders.addContextResolver(clazz);
               if (ExceptionMapper.class.isAssignableFrom(clazz))
                  appProviders.addExceptionMapper(clazz);
               if (MessageBodyReader.class.isAssignableFrom(clazz))
                  appProviders.addMessageBodyReader(clazz);
               if (MessageBodyWriter.class.isAssignableFrom(clazz))
                  appProviders.addMessageBodyWriter(clazz);
            }
            else if (clazz.getAnnotation(Filter.class) != null)
            {
               if (MethodInvokerFilter.class.isAssignableFrom(clazz))
                  appProviders.addMethodInvokerFilter(clazz);
               if (RequestFilter.class.isAssignableFrom(clazz))
                  appProviders.addRequestFilter(clazz);
               if (ResponseFilter.class.isAssignableFrom(clazz))
                  appProviders.addResponseFilter(clazz);
            }
            else if (clazz.getAnnotation(Path.class) != null)
            {
               AbstractResourceDescriptor descriptor = new ApplicationResource(applicationId, clazz);
               descriptor.accept(rdv);
               resources.addResource(new PerRequestObjectFactory<AbstractResourceDescriptor>(descriptor));
            }
            else
            {
               LOG.warn("Unknown class type: " + clazz.getName() + " found in: " + applicationId);
View Full Code Here

Examples of org.exoplatform.services.rest.resource.AbstractResourceDescriptor

   }

   public void testBaseWadlGenerator() throws Exception
   {

      AbstractResourceDescriptor ard = new AbstractResourceDescriptorImpl(Resource1.class);
      WadlProcessor wadlProcessor = new WadlProcessor();
      Application app = wadlProcessor.process(ard, new URI("http://localhost:8080/ws/rs"));

      JAXBContext jctx = JAXBContext.newInstance(Application.class);
      ByteArrayOutputStream bout = new ByteArrayOutputStream();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.