List of usage examples for java.lang ClassLoader getSystemResource
public static URL getSystemResource(String name)
From source file:org.apache.axis2.util.Loader.java
/** * Searches for <code>resource</code> in different * places. The search order is as follows: * <ol>// w w w .j a v a2s . co m * <p><li>Search for <code>resource</code> using the thread context * class loader under Java2. If that fails, search for * <code>resource</code> using the class loader that loaded this * class (<code>Loader</code>). * <p><li>Try one last time with * <code>ClassLoader.getSystemResource(resource)</code>, that is is * using the system class loader in JDK 1.2 and virtual machine's * built-in class loader in JDK 1.1. * </ol> * <p/> * * @param resource * @return Returns URL */ static public URL getResource(String resource) { ClassLoader classLoader = null; URL url = null; try { // We could not find resource. Ler us now try with the // classloader that loaded this class. classLoader = getTCL(); if (classLoader != null) { log.debug("Trying to find [" + resource + "] using " + classLoader + " class loader."); url = classLoader.getResource(resource); if (url != null) { return url; } } } catch (Throwable t) { log.warn("Caught Exception while in Loader.getResource. This may be innocuous.", t); } // Last ditch attempt: get the resource from the class path. It // may be the case that clazz was loaded by the Extentsion class // loader which the parent of the system class loader. Hence the // code below. log.debug("Trying to find [" + resource + "] using ClassLoader.getSystemResource()."); return ClassLoader.getSystemResource(resource); }
From source file:fr.gael.dhus.server.http.webapp.owc.controller.OwcMenuController.java
@RequestMapping(value = "/settings/menu", method = RequestMethod.GET) public ResponseEntity<?> getMenu() throws JSONException { URL configFile = ClassLoader.getSystemResource("../etc/conf/menu.json"); if (configFile != null) { logger.debug("Loading configuration file " + configFile.getPath()); try {// w ww. ja v a 2 s .com File file = new File(configFile.getPath()); FileReader fileReader = new FileReader(file); BufferedReader bufferedReader = new BufferedReader(fileReader); String line = ""; StringBuffer sb = new StringBuffer(); while ((line = bufferedReader.readLine()) != null) { sb.append(line); } bufferedReader.close(); JSONObject menu = new JSONObject(sb.toString()); return new ResponseEntity<>(menu.toString(), HttpStatus.OK); } catch (IOException e) { logger.error(" Cannot load menu configration file content"); e.printStackTrace(); return new ResponseEntity<>("{\"code\":\"unauthorized\"}", HttpStatus.UNAUTHORIZED); } } else { logger.error(" Cannot get menu configration file "); return new ResponseEntity<>("{\"code\":\"unauthorized\"}", HttpStatus.UNAUTHORIZED); } }
From source file:org.nebulaframework.ui.swing.AboutDialog.java
/** * No-args Constructor constructs and displays * the about dialog as a modal dialog of the * specified owner frame.//from w ww. j av a2s . c o m * * @param owner Owner frame */ public AboutDialog(Frame owner) { super(owner, true); setTitle("About Nebula Framework " + Grid.VERSION); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setSize(320, 500); this.setLayout(new BorderLayout()); this.setLocationRelativeTo(this); // Center on Main UI /* -- Logo Image Section -- */ JLabel lbl = new JLabel( new ImageIcon(ClassLoader.getSystemResource("META-INF/resources/nebula-about.png"))); this.add(lbl, BorderLayout.CENTER); JPanel southPanel = new JPanel(); southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.Y_AXIS)); this.add(southPanel, BorderLayout.SOUTH); /* -- Information Section -- */ JPanel information = new JPanel(); information.setBorder(BorderFactory.createTitledBorder("Information")); information.setLayout(new BorderLayout()); JPanel westPanel = new JPanel(); westPanel.setLayout(new BoxLayout(westPanel, BoxLayout.Y_AXIS)); information.add(westPanel, BorderLayout.WEST); JPanel centerPanel = new JPanel(); centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS)); information.add(centerPanel, BorderLayout.CENTER); westPanel.add(new JLabel("Version : ")); centerPanel.add(new JLabel(Grid.VERSION)); westPanel.add(new JLabel("Project Site : ")); final String site_link = "http://code.google.com/p/nebulaframework"; JLabel siteLabel = new JLabel( "<html><body><a href=\"" + site_link + "\">" + site_link + "</a></body></html>"); centerPanel.add(siteLabel); siteLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { try { Browser.displayURL(site_link); } catch (IOException e) { log.warn("[UI] Unable to invoke Browser", e); } } }); westPanel.add(new JLabel("Project Blog : ")); final String blog_link = "http://nebulaframework.blogspot.com"; JLabel blogLabel = new JLabel( "<html><body><a href=\"" + blog_link + "\">" + blog_link + "</a></body></html>"); centerPanel.add(blogLabel); blogLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { try { Browser.displayURL(blog_link); } catch (IOException e) { log.warn("[UI] Unable to invoke Browser", e); } } }); westPanel.add(new JLabel("License : ")); centerPanel.add(new JLabel("Apache 2.0 License")); southPanel.add(information); /* -- Copyright Section -- */ JPanel developedBy = new JPanel(); developedBy.setBorder(BorderFactory.createTitledBorder("Developer / Copyright")); developedBy.setLayout(new BorderLayout()); developedBy.add(new JLabel("Copyright (C) 2008 Yohan Liyanage", JLabel.CENTER), BorderLayout.CENTER); southPanel.add(developedBy); // Resize to fit to size this.pack(); this.setResizable(false); // Initialize Browser Browser.init(); // Show this.setVisible(true); }
From source file:Phong.java
/** * Erstellt den Szenegraphen//from w w w. j av a 2 s . c om * * @return BranchGroup */ public BranchGroup macheSzene() { BranchGroup objWurzel = new BranchGroup(); // Transformation, 2 Rotationen: Transform3D drehung = new Transform3D(); Transform3D drehung2 = new Transform3D(); drehung.rotX(Math.PI / 4.0d); drehung2.rotY(Math.PI / 5.0d); drehung.mul(drehung2); TransformGroup objDreh = new TransformGroup(drehung); //Loader ObjectFile file = new ObjectFile(ObjectFile.RESIZE); Scene scene = null; try { scene = file.load(ClassLoader.getSystemResource("teapot.obj")); } catch (Exception e) { System.err.println(e); System.exit(1); } objDreh.addChild(scene.getSceneGroup()); DirectionalLight d_Licht = new DirectionalLight(new Color3f(1.0f, 1.0f, 1.0f), new Vector3f(-1.0f, -1.0f, -1.0f)); d_Licht.setInfluencingBounds(new BoundingSphere(new Point3d(0.0d, 0.0d, 0.0d), 100.0d)); objDreh.addChild(d_Licht); objWurzel.addChild(objDreh); return objWurzel; }
From source file:ObjectLoader.java
/** * Erstellt den Szenegraphen//from w w w . j a v a2 s .c om * * @return BranchGroup */ public BranchGroup macheSzene() { BranchGroup objWurzel = new BranchGroup(); // Transformation, 2 Rotationen: Transform3D drehung = new Transform3D(); Transform3D drehung2 = new Transform3D(); drehung.rotX(Math.PI / 4.0d); drehung2.rotY(Math.PI / 5.0d); drehung.mul(drehung2); TransformGroup objDreh = new TransformGroup(drehung); //Loader ObjectFile file = new ObjectFile(ObjectFile.RESIZE); Scene scene = null; try { scene = file.load(ClassLoader.getSystemResource("teapot.obj")); } catch (Exception e) { } objDreh.addChild(scene.getSceneGroup()); DirectionalLight d_Licht = new DirectionalLight(new Color3f(1.0f, 0.5f, 0.3f), new Vector3f(-1.0f, -1.0f, -1.0f)); d_Licht.setInfluencingBounds(new BoundingSphere(new Point3d(0.0d, 0.0d, 0.0d), 100.0d)); // d_Licht.setColor(new Color3f(1.0f,0.5f,0.3f)); objDreh.addChild(d_Licht); objWurzel.addChild(objDreh); return objWurzel; }
From source file:org.n52.sir.IT.solr.OpenSearchSpatialExtensionIT.java
@Before public void insertSensor() throws OwsExceptionReport, XmlException, IOException { File sensor_status = new File(ClassLoader.getSystemResource("Requests/testsensor.xml").getFile()); SensorMLDocument doc = SensorMLDocument.Factory.parse(sensor_status); SOLRInsertSensorInfoDAO dao = new SOLRInsertSensorInfoDAO(); dao.insertSensor(SensorMLDecoder.decode(doc)); }
From source file:org.n52.oss.IT.OpenSearchSpatialExtensionIT.java
@Before public void insertSensor() throws OwsExceptionReport, XmlException, IOException { File sensor_status = new File(ClassLoader.getSystemResource("Requests/testsensor.xml").getFile()); SensorMLDocument doc = SensorMLDocument.Factory.parse(sensor_status); SolrConnection c = new SolrConnection("http://localhost:8983/solr", 2000); SOLRInsertSensorInfoDAO dao = new SOLRInsertSensorInfoDAO(c); SensorMLDecoder d = new SensorMLDecoder(); dao.insertSensor(d.decode(doc));//w w w . j av a 2 s .c o m }
From source file:org.n52.sir.IT.GetCapabilitiesIT.java
@Test public void postRequest() throws IOException, OwsExceptionReport, HttpException, XmlException, SAXException { File f = new File(ClassLoader.getSystemResource("Requests/GetCapabilities.xml").getFile()); GetCapabilitiesDocument doc = GetCapabilitiesDocument.Factory.parse(f); XmlObject response = client.xSendPostRequest(doc); CapabilitiesDocument actual = CapabilitiesDocument.Factory.parse(response.getDomNode()); checkCapabilities(actual);/*from w w w . j av a 2 s . c o m*/ }
From source file:org.apache.camel.component.schematron.SchematronEndpointTest.java
@Test public void testSchematronFileReadFromFileSystem() throws Exception { String payload = IOUtils.toString(ClassLoader.getSystemResourceAsStream("xml/article-2.xml")); String path = ClassLoader.getSystemResource("sch/schematron-1.sch").getPath(); Endpoint endpoint = context().getEndpoint("schematron://" + path); Producer producer = endpoint.createProducer(); Exchange exchange = new DefaultExchange(context, ExchangePattern.InOut); exchange.getIn().setBody(payload);//from w ww .j a v a 2s .co m // invoke the component. producer.process(exchange); String report = exchange.getOut().getHeader(Constants.VALIDATION_REPORT, String.class); assertNotNull(report); }
From source file:Proiect.uploadFTP.java
public static ImageIcon getImageIcon(String name) { return new ImageIcon(ClassLoader.getSystemResource(name)); }