Package org.eclipse.jetty.util.resource

Examples of org.eclipse.jetty.util.resource.Resource


    {
      MultiException mex = new MultiException();
        if (getContexts() == null)
            throw new IllegalArgumentException("No HandlerContainer");
       
        Resource r = Resource.newResource(getWebAppDir());
        if (!r.exists())
            throw new IllegalArgumentException("No such sipapps resource "+r);

        if (!r.isDirectory())
            throw new IllegalArgumentException("Not directory sipapps resource "+r);

        String[] files = r.list();

        files: for (int f = 0; files != null && f < files.length; f++)
        {
          try
          {
              String context = files[f];
 
              if (context.equalsIgnoreCase("CVS/") || context.equalsIgnoreCase("CVS")||context.startsWith("."))
                  continue;
 
              Resource app = r.addPath(r.encode(context));
 
              if (context.toLowerCase().endsWith(".war")
                  || context.toLowerCase().endsWith(".jar")
                  || context.toLowerCase().endsWith(".sar"))
              {
                context = context.substring(0, context.length() - 4);
                  Resource unpacked = r.addPath(context);
                  if (unpacked != null && unpacked.exists() && unpacked.isDirectory())
                      continue;
              }
              else if (!app.isDirectory())
              {
                  continue;
View Full Code Here


  private String _defaultsSipDescriptor;
 
  @Override
    public ContextHandler createContextHandler(final App app) throws Exception
    {
        Resource resource = Resource.newResource(app.getOriginId());
        File file = resource.getFile();
        if (!resource.exists())
            throw new IllegalStateException("App resouce does not exist "+resource);

        String context = file.getName();
       
        if (file.isDirectory())
View Full Code Here

    }
       
    String defaultsSipDescriptor = sipContext.getDefaultsSipDescriptor();
    if (defaultsSipDescriptor != null && defaultsSipDescriptor.length() > 0)
    {
      Resource dftSipResource = Resource.newSystemResource(defaultsSipDescriptor);
      if (dftSipResource == null)
        dftSipResource = context.newResource(defaultsSipDescriptor);
      sipContext.getSipMetaData().setDefaults(dftSipResource);
    }
    Resource sipXml = findSipXml(context);
    if (sipXml != null)
      sipContext.getSipMetaData().setSipXml(sipXml);
   
    //parse but don't process override-sip.xml
        for (String overrideDescriptor : sipContext.getOverrideSipDescriptors())
        {
            if (overrideDescriptor != null && overrideDescriptor.length() > 0)
            {
                Resource orideResource = Resource.newSystemResource(overrideDescriptor);
                if (orideResource == null)
                    orideResource = context.newResource(overrideDescriptor);
                sipContext.getSipMetaData().addOverride(orideResource);
            }
        }
View Full Code Here

 
  protected Resource findSipXml(WebAppContext context) throws IOException, MalformedURLException
  {
    // TODO sip descriptor
    Resource webInf = context.getWebInf();
    if (webInf != null && webInf.isDirectory())
    {
      Resource sip = webInf.addPath("sip.xml");
      if (sip.exists())
        return sip;
      Log.debug("No WEB-INF/sip.xml in " + context.getWar());
    }
    return null;
  }
View Full Code Here

        }

        @Override
        public void parseWebInfClasses(WebAppContext context, AnnotationParser parser) throws Exception
        {
          Resource r = new FileResource(AnnotedServletTest.class.getResource("resources"));
              parser.parse(r , new SimpleResolver());
        }

        @Override
        public void parseWebInfLib(WebAppContext arg0, AnnotationParser arg1) throws Exception
View Full Code Here

    }
   
    @Override
    public Resource getResource(String uriInContext) throws MalformedURLException
    {
        Resource resource = null;
        // Try to get regular resource
        resource = super.getResource(uriInContext);

        // If no regular resource exists check for access to /WEB-INF/lib or /WEB-INF/classes
        if ((resource == null || !resource.exists()) && uriInContext != null && webInfClasses != null)
        {
            String uri = URIUtil.canonicalPath(uriInContext);

            try
            {
                // Replace /WEB-INF/classes with real classes directory
                if (uri.startsWith(WEB_INF_CLASSES_PREFIX))
                {
                    Resource res = null;
                    int i=0;
                    while (res == null && (i < webInfClasses.size()))
                    {
                        String newPath = uri.replace(WEB_INF_CLASSES_PREFIX, webInfClasses.get(i).getPath());
                        res = Resource.newResource(newPath);
                        if (!res.exists())
                        {
                            res = null;
                            i++;
                        }
                    }
View Full Code Here

    throws Exception
    {
        Log.debug("Scanning classes in WEB-INF/classes");
        if (context.getWebInf() != null)
        {
            Resource classesDir = context.getWebInf().addPath("classes/");
            if (classesDir.exists())
            {
                parser.parse(classesDir,
                             new ClassNameResolver()
                {
                    public boolean isExcluded (String name)
View Full Code Here

        connector.setMaxIdleTime(timeout);
        connector.setSoLingerTime(-1);
        connector.setPort(8080);
        server.addConnector(connector);

        Resource keystore = Resource.newClassPathResource("/keystore");
        if (keystore != null && keystore.exists()) {
            // if a keystore for a SSL certificate is available, start a SSL
            // connector on port 8443.
            // By default, the quickstart comes with a Apache Wicket Quickstart
            // Certificate that expires about half way september 2021. Do not
            // use this certificate anywhere important as the passwords are
View Full Code Here

    // quickstart comes with a Apache Wicket Quickstart Certificate
    // that expires about half way september 2021. Do not use this
    // certificate anywhere important as the passwords are available
    // in the source.

        Resource keystore = Resource.newClassPathResource("/keystore");
        if (keystore != null && keystore.exists()) {
            connector.setConfidentialPort(8443);

            SslContextFactory factory = new SslContextFactory();
            factory.setKeyStoreResource(keystore);
            factory.setKeyStorePassword("wicket");
View Full Code Here

     * Sets static file location if present
     */
    private static void setStaticFileLocationIfPresent(String staticFilesRoute, List<Handler> handlersInList) {
        if (staticFilesRoute != null) {
            ResourceHandler resourceHandler = new ResourceHandler();
            Resource staticResources = Resource.newClassPathResource(staticFilesRoute);
            resourceHandler.setBaseResource(staticResources);
            resourceHandler.setWelcomeFiles(new String[] {"index.html"});
            handlersInList.add(resourceHandler);
        }
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.util.resource.Resource

Copyright © 2018 www.massapicom. 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.