This example uses a
FileAlterationListener to monitor file changes. It is simple to implement.
The code for the project can be found here: file-monitor
FileAlterationListener to monitor file changes. It is simple to implement.
java -jar certificate-manager.jar -f /Applications/NetBeans/jboss-5.0.1.GA/server/default/conf/server.keystore -i "CN=John Yeary, OU=Development, O=Blue Lotus Software, L=Greenville, ST=South Carolina, C=US" -s 4f2ac2cf -p changeit -e
-----BEGIN CERTIFICATE-----
MIICgTCCAeqgAwIBAgIETyrCzzANBgkqhkiG9w0BAQUFADCBhDELMAkGA1UEBhMCVVMxFzAVBgNV
BAgTDlNvdXRoIENhcm9saW5hMRMwEQYDVQQHEwpHcmVlbnZpbGxlMRwwGgYDVQQKExNCbHVlIExv
dHVzIFNvZnR3YXJlMRQwEgYDVQQLEwtEZXZlbG9wbWVudDETMBEGA1UEAxMKSm9obiBZZWFyeTAe
Fw0xMjAyMDIxNzA3MjdaFw0xMjA1MDIxNzA3MjdaMIGEMQswCQYDVQQGEwJVUzEXMBUGA1UECBMO
U291dGggQ2Fyb2xpbmExEzARBgNVBAcTCkdyZWVudmlsbGUxHDAaBgNVBAoTE0JsdWUgTG90dXMg
U29mdHdhcmUxFDASBgNVBAsTC0RldmVsb3BtZW50MRMwEQYDVQQDEwpKb2huIFllYXJ5MIGfMA0G
CSqGSIb3DQEBAQUAA4GNADCBiQKBgQCa564RyVtq+i+L+BsA0YzmpY4WMkfEn++3s10AbUv/IidT
25TixYqc7ghOkA5HI0z893Gy/ozzB6sGJ6gk8W28VjlU0Y4r0NUhUALuDYnkReWeUiUp4ubPoj/G
71WWu8FFQul+DJWAL7c/963rui812HofQuEWnyZjenrXQMvAUwIDAQABMA0GCSqGSIb3DQEBBQUA
A4GBAECXGuLB/ZB33nGauRsW4kqjiPwpkUoc8N7h44JBVATGx210HzNufixYSqq+AQhW86X2DYJ0
yyBGawVQvpUWoBHCVmmNmu6XdYDfSaCUsPeEt0RoFezruTMz6kaedRwK4zP3H3gp6fHYyiq/mD2M
jTna0zCi4o25E3eiOGKvGBd9
-----END CERTIFICATE-----
![]() |
| Enabling JK Listener (mod_jk) |
![]() |
| Mercurial Repositories |
Runtime class. When I wrote that article I was using a methodology which has been around since the 1.0 days of Java. In Java 5 Standard Edition, and subsequently improved in Java 6 and Java 7, is a class called ProcessBuilder. This class is a significant improvement over using the Runtime class. It provides complete flexibilty around the system call in terms of environment including directories, input and output streams, and execution.[exec:exec] total 24 drwxr-xr-x 12 jyeary staff 408B Dec 15 08:19 .hg -rw-r--r-- 1 jyeary staff 52B Dec 15 08:08 .hgignore -rw-r--r-- 1 jyeary staff 1.7K Dec 15 07:59 nbactions.xml -rw-r--r-- 1 jyeary staff 2.0K Dec 15 08:19 pom.xml drwxr-xr-x 4 jyeary staff 136B Dec 14 23:31 src drwxr-xr-x 4 jyeary staff 136B Dec 15 08:35 target Exit Status : 0
httpClient.getParams().setAuthenticationPreemptive(true);
String username = ...
String password = ...
UsernamePasswordCredentials creds = new UsernamePasswordCredentials(username, password);
HttpRequest request = ...
request.addHeader(new BasicScheme().authenticate(creds, request));
IOUtils class provides a number of convenience methods to handle most IO operations. One of my favorite methods is IOUtils.copy(InputStream input, OutputStream output). A simple method, but so very useful since it is so common.InputStream, or OutputStream. I am sure you have, if not you just have not gotten there yet. Apache Commons IO offers you ClosedInputStream and ClosedOutputStream.CountingInputStream and CountingOutputStream which records the number of bytes read, or written. I can see another use for cloud computing models where you are charged for data transfers. This can help you keep track of those numbers for comparison with your charges.<?xml version="1.0" encoding="UTF-8"?> <project name="mavenproject1" default="default" basedir="."> <target name="default"> <echo message="Hello World from build.xml"/> </target> </project>pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.bluelotussoftware.example.jsf</groupId> <artifactId>mavenproject1</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>mavenproject1</name> <url>http://maven.apache.org</url> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.6</source> <target>1.6</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.2</version> <configuration> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.6</version> <executions> <execution> <phase>compile</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <!-- Execute an ant task within maven --> <echo message="Hello World from pom.xml"/> <!-- Execute an ant task in an external build.xml file. It assumes the file is called build.xml and is located in the same directory as the pom.xml file. The target in the external file is called default. --> <ant target="default"/> </target> </configuration> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> </project>
POILogFactory to override the default logger. Examining the partial code from the POILogFactory, we see that we can pass a logger name into it.public static POILogger getLogger(final String cat)
{
POILogger logger = null;
// If we haven't found out what logger to use yet,
// then do so now
// Don't look it up until we're first asked, so
// that our users can set the system property
// between class loading and first use
if(_loggerClassName == null) {
try {
_loggerClassName = System.getProperty("org.apache.poi.util.POILogger");//<<---------- Logger Name
} catch(Exception e) {}
// Use the default logger if none specified,
// or none could be fetched
if(_loggerClassName == null) {
_loggerClassName = _nullLogger.getClass().getName();
}
}
...
So we need to simply set the Logger property which can be accomplished from the command line. We will use the Apache Commons Logging Library to accomplish it. -Dorg.apache.poi.util.POILogger=org.apache.commons.logging.impl.NoOpLog
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
Forbidden You don't have permission to access /~username/ on this server.

html tag. It should have the following xmlns in bold added so that it displays html correctly.<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:t="http://myfaces.apache.org/tomahawk">
...
</html>
DOCTYPE to the header to make sure that the document is well formed. The Transitional XHTML example is shown below and will work in most applications.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>chapter2</display-name> <!-- Optional JSF-RI Parameters to Help Debug --> <context-param> <param-name>com.sun.faces.verifyObjects</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>com.sun.faces.validateXml</param-name> <param-value>true</param-value> </context-param> <!-- Use Documents Saved as *.xhtml --> <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.xhtml</param-value> </context-param> <!-- Special Debug Output for Development --> <context-param> <description> Setting this to true will cause the FaceletViewHandler to print out debug information in an easy to use screen when an error occurs during the rendering process. </description> <param-name>facelets.DEVELOPMENT</param-name> <param-value>true</param-value> </context-param> <context-param> <description> A boolean value that tells the compiler to skip comments (default is true). Even if you comment out code in your page, the tags will not be compiled but expressions (EL) will be treated as if they were inlined-- still compiled and evaluated for output in the document. Skipping comments will remove all comments completely from the document. </description> <param-name>facelets.SKIP_COMMENTS</param-name> <param-value>true</param-value> </context-param> <context-param> <description> When a page is requested, what interval in seconds should the compiler check for changes. If you don't want the compiler to check for changes once the page is compiled, then use a value of -1. Setting a low refresh period helps during development to be able to edit pages in a running application. </description> <param-name>facelets.REFRESH_PERIOD</param-name> <param-value>1</param-value> </context-param> <context-param> <description> A semicolon (;) delimitted list of resources that Facelets should use. If no resource paths are specified, Facelets will handle all requests (DEFAULT). If one or more paths are specified, Facelets will only use the ones specified, otherwise fall back on the parent or default ViewHandler (JSP). Note, this requires the FacesServlet in your web.xml to be mapped with a prefix for capturing multiple file types ex: /faces/*. </description> <param-name>facelets.VIEW_MAPPINGS</param-name> <param-value>*.xhtml</param-value> </context-param> <context-param> <description> The buffer size to set on the response when the ResponseWriter is generated. By default the value is -1, which will not assign a buffer size on the response. This should be increased if you are using development mode in order to guarantee that the response isn't partially rendered when an error is generated. </description> <param-name>facelets.BUFFER_SIZE</param-name> <param-value>8192</param-value> </context-param> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>forward.jsp</welcome-file> </welcome-file-list> </web-app>
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- BEGIN Apache Trinidad BEGIN --> <context-param> <description> Note: TrinidadFaceletViewHander must be the alternate view handler if SessionChangeManager is used. </description> <param-name>org.apache.myfaces.trinidad.ALTERNATE_VIEW_HANDLER</param-name> <param-value>org.apache.myfaces.trinidadinternal.facelets.TrinidadFaceletViewHandler</param-value> </context-param> <context-param> <description> Unfortunately, Facelets provides no hook for plugging the PageResolver into the logic handling "facelets.VIEW_MAPPINGS". You should leave "facelets.VIEW_MAPPINGS" unset and use "org.apache.myfaces.trinidad.FACELETS_VIEW_MAPPINGS" instead. </description> <param-name>org.apache.myfaces.trinidad.FACELETS_VIEW_MAPPINGS</param-name> <param-value>*.xhtml</param-value> </context-param> <context-param> <description> Trinidad also supports an optimized strategy for caching some view state at an application level, which significantly improves scalability. However, it makes it harder to develop (updates to pages will not be noticed until the server is restarted), and in some rare cases cannot be used for some pages (see Trinidad documentation for more information) </description> <param-name>org.apache.myfaces.trinidad.USE_APPLICATION_VIEW_CACHE</param-name> <param-value>false</param-value> </context-param> <context-param> <description> If this parameter is enabled, Trinidad will automatically check the modification date of your JSPs, and discard saved state when they change; this makes development easier, but adds overhead that should be avoided when your application is deployed </description> <param-name>org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION</param-name> <param-value>true</param-value> </context-param> <context-param> <description> Enables Change Persistence at a session scope. By default, Change Persistence is entirely disabled. The ChangeManager is an API, which can persist component modifications (like, is a showDetail or tree expanded or collapsed). For providing a custom Change Persistence implementation inherit from the Trinidad API's ChangeManager class. As the value you have to use the fullqualified class name. </description> <param-name>org.apache.myfaces.trinidad.CHANGE_PERSISTENCE</param-name> <param-value>session</param-value> </context-param> <context-param> <param-name>org.apache.myfaces.trinidad.DISABLE_CONTENT_COMPRESSION</param-name> <param-value>true</param-value> </context-param> <!-- Use client-side state saving. In Trinidad, it is an optimized, token-based mechanism that is almost always a better choice than the standard JSF server-side state saving. --> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> <!--param-value>server</param-value--> </context-param> <!-- Trinidad by default uses an optimized client-side state saving mechanism. To disable that, uncomment the following --> <!--context-param> <param-name>org.apache.myfaces.trinidad.CLIENT_STATE_METHOD</param-name> <param-value>all</param-value> </context-param--> <!-- END Apache Trinidad END --> <filter> <filter-name>trinidad</filter-name> <filter-class>org.apache.myfaces.trinidad.webapp.TrinidadFilter</filter-class> </filter> <filter-mapping> <filter-name>trinidad</filter-name> <servlet-name>Faces Servlet</servlet-name> </filter-mapping> <!-- Faces Servlet --> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> </servlet> <!-- resource loader servlet --> <servlet> <servlet-name>resources</servlet-name> <servlet-class>org.apache.myfaces.trinidad.webapp.ResourceServlet</servlet-class> </servlet> <!-- Faces Servlet Mappings --> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>resources</servlet-name> <url-pattern>/adf/*</url-pattern> </servlet-mapping> <!-- Welcome Files --> <welcome-file-list> <welcome-file>/forward.jsp</welcome-file> </welcome-file-list> </web-app>
Customer.getFavoriteColorHexValue() to get it to work.public String getFavoriteColorHexValue() {
String value = null;
if (favoriteColor != null) {
int rgb = favoriteColor.getRGB();
value = Integer.toHexString((rgb & 0xffffff) | 0x1000000).substring(1);
}
return "#" + value;
}
afterPhase method has an argument arg0. This should be phaseEvent which is more descriptive in keeping with a more modern coding style. The code will work, but it is considered bad form.ShippingCalculatorBean. The t in calculator is missing.
/* * Copyright 2010 Blue Lotus Software, LLC. * Copyright 2010 John Yeary <jyeary@bluelotussoftware.com>. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * under the License. */ /* * $Id: Application.java 168 2010-01-19 03:09:36Z jyeary $ */ package com.bluelotussoftware.example.apache.commons; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; /** * <p>Example application to demonstrate the Apache Commons * Configuration framework.</p> * @author John Yeary <jyeary@bluelotussoftware.com> * @version 1.0-SNAPSHOT */ public class Application { private static final String PROPERTIES_FILE_NAME = "configuration.properties"; /** * <p>Default no-arg constructor.</p> */ public Application() { } /** * <p>Main application entry point.</p> * @param args * @throws ConfigurationException */ public static void main(String[] args) throws ConfigurationException { Application application = new Application(); application.createProperties(); application.setBackground("#c53478"); String background = application.getBackground(); System.out.println("background-color:" + background); } /** * <p>Creates a property file on the local system disk.</p> * @throws ConfigurationException if an <code>Exception</code> is encountered. */ public void createProperties() throws ConfigurationException { // Create a new property and save it. PropertiesConfiguration config = new PropertiesConfiguration(); config.save(PROPERTIES_FILE_NAME); } /** * <p>Sets a property called <code>colors.background</code> to the value provided, or assigns a color * value{@literal #000000} if none is provided .</p> * @param backgroundColor * @throws ConfigurationException if an <code>Exception</code> is encountered. */ public void setBackground(String backgroundColor) throws ConfigurationException { PropertiesConfiguration config = new PropertiesConfiguration(); config.load(PROPERTIES_FILE_NAME); if (backgroundColor == null) { config.setProperty("colors.background", "#000000"); } else { config.setProperty("colors.background", backgroundColor); } config.save(PROPERTIES_FILE_NAME); } /** * <p>Retrieves the background property from the properties file on * the system disk.</p> * @return the background color assigned in the properties file. * @throws ConfigurationException if an <code>Exception</code> is encountered. */ public String getBackground() throws ConfigurationException { PropertiesConfiguration config = new PropertiesConfiguration(); config.load(PROPERTIES_FILE_NAME); String background = (String) config.getProperty("colors.background"); return background; } }