@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;
  }
예제 #2
0
 private RequestAttributes getRequestAttributes() {
   RequestAttributes attributes = request.get(RequestAttributes.class);
   if (attributes == null) {
     attributes = new RequestAttributes();
     request.add(attributes);
   }
   return attributes;
 }
예제 #3
0
파일: Sender.java 프로젝트: nutzam/nutzlib
 public static Sender create(String url) {
   return create(Request.get(url));
 }
예제 #4
0
파일: Http.java 프로젝트: wanghongrui/nutz
 public static Response get(String url, int timeout) {
   return Sender.create(Request.get(url)).setTimeout(timeout).send();
 }
예제 #5
0
파일: Http.java 프로젝트: wanghongrui/nutz
 public static Response get(String url) {
   return Sender.create(Request.get(url)).send();
 }