forked from b3log/symphony
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
717 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,3 +163,5 @@ pip-log.txt | |
|
||
# Mac crap | ||
.DS_Store | ||
!/src/main/resources/local.properties | ||
/target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
src/main/java/org/b3log/symphony/SymphonyServletListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright (c) 2012, B3log Team | ||
* | ||
* 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. | ||
*/ | ||
package org.b3log.symphony; | ||
|
||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import javax.servlet.ServletContextEvent; | ||
import javax.servlet.ServletRequestEvent; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpSessionEvent; | ||
import org.b3log.latke.Keys; | ||
import org.b3log.latke.servlet.AbstractServletListener; | ||
import org.b3log.latke.util.Stopwatchs; | ||
import org.b3log.latke.util.Strings; | ||
import org.b3log.latke.util.Requests; | ||
|
||
/** | ||
* B3log Symphony servlet listener. | ||
* | ||
* @author <a href="mailto:[email protected]">Liang Ding</a> | ||
* @version 1.0.0.0, Jul 30, 2011 | ||
* @since 0.2.0 | ||
*/ | ||
public final class SymphonyServletListener extends AbstractServletListener { | ||
|
||
/** | ||
* B3log Symphony version. | ||
*/ | ||
public static final String VERSION = "0.2.0"; | ||
/** | ||
* Logger. | ||
*/ | ||
private static final Logger LOGGER = Logger.getLogger(SymphonyServletListener.class.getName()); | ||
/** | ||
* JSONO print indent factor. | ||
*/ | ||
public static final int JSON_PRINT_INDENT_FACTOR = 4; | ||
/** | ||
* B3log Rhythm address. | ||
*/ | ||
public static final String B3LOG_RHYTHM_ADDRESS = "http://rhythm.b3log.org:80"; | ||
|
||
@Override | ||
public void contextInitialized(final ServletContextEvent servletContextEvent) { | ||
Stopwatchs.start("Context Initialized"); | ||
|
||
super.contextInitialized(servletContextEvent); | ||
|
||
LOGGER.info("Initialized the context"); | ||
|
||
Stopwatchs.end(); | ||
LOGGER.log(Level.FINE, "Stopwatch: {0}{1}", new Object[]{Strings.LINE_SEPARATOR, Stopwatchs.getTimingStat()}); | ||
} | ||
|
||
@Override | ||
public void contextDestroyed(final ServletContextEvent servletContextEvent) { | ||
super.contextDestroyed(servletContextEvent); | ||
|
||
LOGGER.info("Destroyed the context"); | ||
} | ||
|
||
@Override | ||
public void sessionCreated(final HttpSessionEvent httpSessionEvent) { | ||
} | ||
|
||
// Note: This method will never invoked on GAE production environment | ||
@Override | ||
public void sessionDestroyed(final HttpSessionEvent httpSessionEvent) { | ||
} | ||
|
||
@Override | ||
public void requestInitialized(final ServletRequestEvent servletRequestEvent) { | ||
final HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequestEvent.getServletRequest(); | ||
final String requestURI = httpServletRequest.getRequestURI(); | ||
Stopwatchs.start("Request Initialized[requestURI=" + requestURI + "]"); | ||
|
||
if (Requests.searchEngineBotRequest(httpServletRequest)) { | ||
LOGGER.log(Level.FINER, "Request made from a search engine[User-Agent={0}]", httpServletRequest.getHeader("User-Agent")); | ||
httpServletRequest.setAttribute(Keys.HttpRequest.IS_SEARCH_ENGINE_BOT, true); | ||
} | ||
} | ||
|
||
@Override | ||
public void requestDestroyed(final ServletRequestEvent servletRequestEvent) { | ||
Stopwatchs.end(); | ||
|
||
LOGGER.log(Level.FINE, "Stopwatch: {0}{1}", new Object[]{Strings.LINE_SEPARATOR, Stopwatchs.getTimingStat()}); | ||
Stopwatchs.release(); | ||
|
||
super.requestDestroyed(servletRequestEvent); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (c) 2012, B3log Team | ||
* | ||
* 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. | ||
*/ | ||
package org.b3log.symphony.dev; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import org.b3log.latke.Latkes; | ||
import org.b3log.latke.annotation.RequestProcessing; | ||
import org.b3log.latke.annotation.RequestProcessor; | ||
import org.b3log.latke.repository.jdbc.util.JdbcRepositories; | ||
import org.b3log.latke.servlet.HTTPRequestContext; | ||
import org.b3log.latke.servlet.HTTPRequestMethod; | ||
import org.b3log.latke.util.Stopwatchs; | ||
|
||
/** | ||
* Initializes database. | ||
* | ||
* @author <a href="mailto:[email protected]">Liang Ding</a> | ||
* @version 1.0.0.0, Jul 30, 2012 | ||
* @since 0.2.0 | ||
*/ | ||
@RequestProcessor | ||
public class InitProcessor { | ||
|
||
/** | ||
* Logger. | ||
*/ | ||
private static final Logger LOGGER = Logger.getLogger(InitProcessor.class.getName()); | ||
|
||
/** | ||
* Generates tables. | ||
* | ||
* @param context the specified context | ||
* @param request the specified request | ||
* @param response the specified response | ||
* @throws IOException io exception | ||
*/ | ||
@RequestProcessing(value = "/dev/db/table/gen", method = HTTPRequestMethod.GET) | ||
public void genTables(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) | ||
throws IOException { | ||
Stopwatchs.start("Gen Tables"); | ||
|
||
try { | ||
LOGGER.log(Level.INFO, "Database [{0}], creates all tables", Latkes.getRuntimeDatabase()); | ||
final List<JdbcRepositories.CreateTableResult> createTableResults = JdbcRepositories.initAllTables(); | ||
for (final JdbcRepositories.CreateTableResult createTableResult : createTableResults) { | ||
LOGGER.log(Level.INFO, "Creates table result[tableName={0}, isSuccess={1}]", | ||
new Object[]{createTableResult.getName(), createTableResult.isSuccess()}); | ||
} | ||
} catch (final Exception e) { | ||
LOGGER.log(Level.SEVERE, "Creates database tables failed", e); | ||
} | ||
|
||
Stopwatchs.end(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# | ||
# Copyright (c) 2012, B3log Team | ||
# | ||
# 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. | ||
# | ||
|
||
# | ||
# Description: B3log Latke configurations. Configures the section "Server" carefully. | ||
# Version: 1.0.0.0, Jul 30, 2012 | ||
# Author: Liang Ding | ||
# | ||
|
||
#### Server #### | ||
# Configures the followings before deploy | ||
serverScheme=http | ||
serverHost=localhost | ||
serverPort=8080 | ||
staticServerScheme=http | ||
staticServerHost=localhost | ||
staticServerPort=8080 | ||
# Note: The context path and static path should be "" if deploy app on ROOT. For other cases, starts with '/' | ||
# and not ends with '/', for example, /blog | ||
contextPath= | ||
staticPath= | ||
|
||
#### Runtime Environment #### | ||
runtimeEnv=LOCAL | ||
#runtimeEnv=GAE | ||
|
||
#### Cache Implementation #### | ||
# Note: If the runtime environment is LOCAL, the cache will be LOCAL always | ||
cache=LOCAL | ||
#cache=GAE | ||
|
||
#### User Service Implementation #### | ||
# userService=GAE | ||
userService=LOCAL | ||
|
||
#### Static resource version #### | ||
staticResourceVersion=201207301345 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# | ||
# Copyright (c) 2012, B3log Team | ||
# | ||
# 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. | ||
# | ||
|
||
# | ||
# Description: B3log Symphony local environment configurations. | ||
# Version: 1.0.0.0, Jul 30, 2012 | ||
# Author: Liang Ding | ||
# | ||
|
||
#### Runtime Database (RuntimeDatabase) #### | ||
runtimeDatabase=MYSQL | ||
|
||
#### JDBC database Configurations #### | ||
jdbc.driver=com.mysql.jdbc.Driver | ||
jdbc.URL=jdbc:mysql://localhost:3306/b3log-symphony?useUnicode=yes&characterEncoding=UTF-8 | ||
jdbc.username=root | ||
jdbc.password= | ||
# The minConnCnt MUST larger or equal to 3 | ||
jdbc.minConnCnt=3 | ||
jdbc.maxConnCnt=10 | ||
# Be care to change the transaction isolation | ||
jdbc.transactionIsolation=READ_COMMITTED |
Oops, something went wrong.