Skip to content

Commit

Permalink
minor tweaks to nav
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Jun 16, 2010
1 parent 39fe9ff commit d3b9abb
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
Expand Up @@ -22,6 +22,8 @@
package org.jboss.weld.examples.pastecode.servlets;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.inject.Inject;
import javax.servlet.ServletException;
Expand All @@ -38,6 +40,9 @@
public class DownloadServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;

@Inject
private Logger log;

@Inject
private CodeFragmentManager codeFragmentManager;
Expand All @@ -61,7 +66,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
}
catch (Exception e)
{
e.printStackTrace();
log.log(Level.WARNING, "Error processing file for download", e);
}
finally
{
Expand Down
Expand Up @@ -26,6 +26,7 @@
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.logging.Logger;

import javax.ejb.Stateless;
import javax.enterprise.inject.Produces;
Expand All @@ -40,6 +41,8 @@
@Stateless
public class CodeFragmentManagerImpl implements CodeFragmentManager
{

@Inject Logger log;

// The number of code fragments to return in our recentCodeFragments query
private static int MAX_RECENT_FRAGMENTS = 7;
Expand Down Expand Up @@ -74,6 +77,7 @@ public String addCodeFragment(CodeFragment code, boolean privateFragment)
String hashValue = hashComputer.getHashValue(code);
code.setHash(hashValue);
entityManager.persist(code);
log.info("Added private pastecode: " + hashValue);
return hashValue;
}
catch (NoSuchAlgorithmException e)
Expand All @@ -86,6 +90,9 @@ public String addCodeFragment(CodeFragment code, boolean privateFragment)
else
{
entityManager.persist(code);
// Make sure we have the latest version (with the generated id!)
entityManager.refresh(code);
log.info("Added pastecode: " + code.getId());
return new Integer(code.getId()).toString();
}
}
Expand Down
@@ -0,0 +1,18 @@
package org.jboss.weld.examples.pastecode.session;

import java.util.logging.Logger;

import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;

public class LogManager
{

@Produces
public Logger getLogger(InjectionPoint ip)
{
String category = ip.getMember().getDeclaringClass().getName();
return Logger.getLogger(category);
}

}
Expand Up @@ -54,7 +54,7 @@ public PasteWindow()
// The send method is called when we hit the Send button
public String send()
{
codeFragmentManager.addCodeFragment(codeFragment, privateFragment);
codeFragmentId = codeFragmentManager.addCodeFragment(codeFragment, privateFragment);
return "success";
}

Expand Down
Expand Up @@ -27,6 +27,8 @@
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
Expand All @@ -49,6 +51,8 @@
public class PopulateDatabaseBean
{

@Inject Logger log;

private static final String DATA_FILE_NAME = "data.sql";

@Inject
Expand Down Expand Up @@ -89,9 +93,10 @@ public void populate()
}
catch (Exception e)
{
System.err.println("Unable to read all records from " + DATA_FILE_NAME + " file");
log.log(Level.WARNING, "Unable to read all records from " + DATA_FILE_NAME + " file");
}

log.info("Successfully imported data!");
populated = true;
}

Expand Down
2 changes: 1 addition & 1 deletion jsf/pastecode/src/main/webapp/WEB-INF/faces-config.xml
Expand Up @@ -8,7 +8,7 @@
<navigation-rule>
<from-view-id>/home.xhtml</from-view-id>
<navigation-case>
<from-action>#{pasteWindow.send}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/#{pasteWindow.codeFragmentId}</to-view-id>
<redirect />
</navigation-case>
Expand Down

0 comments on commit d3b9abb

Please sign in to comment.