@Override
  public Resource create(Request request) throws IllegalActionOnResourceException {
    String pid = request.get(PID, String.class);
    String factoryPid = request.get(FACTORY_PID, String.class);
    Configuration configuration = null;
    String location = request.get(BUNDLE_LOCATION, String.class);
    if (location != null) {
      if (pid != null) {
        try {
          configuration = m_configAdmin.getConfiguration(pid, location);
        } catch (IOException e) {
          throw new IllegalActionOnResourceException(request, e.getMessage());
        }
      } else if (factoryPid != null) {
        try {
          configuration = m_configAdmin.createFactoryConfiguration(factoryPid, location);
        } catch (IOException e) {
          throw new IllegalActionOnResourceException(request, e.getMessage());
        }
      } else {
        throw new IllegalActionOnResourceException(
            request, "factory pid or pid parameter is mandatory");
      }

    } else {
      throw new IllegalActionOnResourceException(request, "location parameter is mandatory");
    }
    ConfigurationResource configurationResource = new ConfigurationResource(configuration);
    synchronized (m_configurationResourceMap) {
      m_configurationResourceMap.put(pid, configurationResource);
    }
    return configurationResource;
  }
Example #2
0
 private RequestAttributes getRequestAttributes() {
   RequestAttributes attributes = request.get(RequestAttributes.class);
   if (attributes == null) {
     attributes = new RequestAttributes();
     request.add(attributes);
   }
   return attributes;
 }
Example #3
0
 public static Sender create(String url) {
   return create(Request.get(url));
 }
Example #4
0
 public static Response get(String url, int timeout) {
   return Sender.create(Request.get(url)).setTimeout(timeout).send();
 }
Example #5
0
 public static Response get(String url) {
   return Sender.create(Request.get(url)).send();
 }