Share

Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





#Java - Code Snippets for '#Properties' - 4 code snippet(s) found

 Sample 1. Load Properties using Property Class

private static Properties props = null;
   
private static void loadProperties(){
   try {
      if(props == null || props1 == null || props2 == null){
         props = new Properties();
         props.load(new FileInputStream(Constants.PROP_BASE_DIR + Constants.EMPLOYEE_REPORTING_PROP));
      } catch (FileNotFoundException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      } catch (IOException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }

   }
}

   Like      Feedback     property class  properties  FileInputStream  file handling


 Sample 2. Get the properties of class (i.e package name , interfaces , subclasses etc ) using ClassUtils( Apache Commons )

Class class1 = ClassUtils.getClass("BuggyBreadTest"); 
System.out.println(ClassUtils.getPackageName(class1));
System.out.println(ClassUtils.getAllInterfaces(class1));

   Like      Feedback     ClassUtils  Apache Commons  Get Class Properties  java.lang.Class


 Sample 3. Code Sample / Example / Snippet of java.util.Properties

    public Connection createConnection() throws SQLException {

final Properties info = new Properties();

for (Map.Entry<String, String> entry : map.entrySet()) {

info.setProperty(entry.getKey(), entry.getValue());

}

Connection connection =

DriverManager.getConnection("jdbc:calcite:", info);

for (ConnectionPostProcessor postProcessor : postProcessors) {

connection = postProcessor.apply(connection);

}

return connection;

}


   Like      Feedback      java.util.Properties


 Sample 4. Code Sample / Example / Snippet of java.util.Properties

    public void init(BundleContext context, DependencyManager manager) throws Exception {

manager.add(createComponent()

.setInterface(Servlet.class.getName(), null)

.setImplementation(DeploymentServlet.class)

.add(createConfigurationDependency().setPropagate(true).setPid(DEPLOYMENT_PID))

.add(createServiceDependency().setService(StreamGenerator.class).setRequired(true))

.add(createServiceDependency().setService(DeploymentProvider.class).setRequired(true))

.add(createServiceDependency().setService(DeploymentProcessor.class).setRequired(false).setCallbacks("addProcessor", "removeProcessor"))

.add(createServiceDependency().setService(LogService.class).setRequired(false))

);

manager.add(createComponent()

.setInterface(Servlet.class.getName(), null)

.setImplementation(AgentDeploymentServlet.class)

.add(createConfigurationDependency().setPropagate(true).setPid(AGENT_PID))

.add(createServiceDependency().setService(ConnectionFactory.class).setRequired(true))

.add(createServiceDependency().setService(LogService.class).setRequired(false))

);



Properties props = new Properties();

props.put("pattern", "/*");

manager.add(createComponent()

.setInterface(Filter.class.getName(), null)

.setImplementation(OverloadedFilter.class)

);

}


   Like      Feedback      java.util.Properties



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus