|
|
Trackback Address >> http://www.sjava.net/trackback/227
Trackback Address >> http://www.sjava.net/trackback/217
카산드라에 대한 내용 정리 자료입니다...
Introduction 수준이며, 테스트 자료는 명확하지 않을 수 있습니다.
대략적인 내용은 아래와 같습니다.
1.Definition
2.History & Reference
3.Features
4.Data Model
5.Project Package
6.Performance
7.적용가능 부분
8.Q&A
Trackback Address >> http://www.sjava.net/trackback/203
Cassandra의 경우, Cassandra의 서버 설정에서 <ReplicationFactor>1</ReplicationFactor>를 통해서 데이타 복제에 대한 설정을 할 수 잇습니다. 클라이언트에서는 데이타를 쓰고, 읽는데 ConsistencyLevel을 통해서 Async 또는 Sync(1개만 되면 리턴, 설정된 개수만큼 저장이 되야 리턴)등의 설정 파라미터를 통해서 정책적으로 성격에 맞게 사용할 수 있습니다. 그래서, ConsistencyLevel은 잘 알고 있어야 할거 같습니다.
0.6.2버전에서의 ConsitencyLevel에 대한 주석내용은 아래와 같습니다.
/**
* The ConsistencyLevel is an enum that controls both read and write behavior based on <ReplicationFactor> in your
* storage-conf.xml. The different consistency levels have different meanings, depending on if you're doing a write or read
* operation. Note that if W + R > ReplicationFactor, where W is the number of nodes to block for on write, and R
* the number to block for on reads, you will have strongly consistent behavior; that is, readers will always see the most
* recent write. Of these, the most interesting is to do QUORUM reads and writes, which gives you consistency while still
* allowing availability in the face of node failures up to half of <ReplicationFactor>. Of course if latency is more
* important than consistency then you can use lower values for either or both.
*
* Write:
* ZERO Ensure nothing. A write happens asynchronously in background
* ANY Ensure that the write has been written once somewhere, including possibly being hinted in a non-target node.
* ONE Ensure that the write has been written to at least 1 node's commit log and memory table before responding to the client.
* QUORUM Ensure that the write has been written to <ReplicationFactor> / 2 + 1 nodes before responding to the client.
* ALL Ensure that the write is written to <code><ReplicationFactor></code> nodes before responding to the client.
*
* Read:
* ZERO Not supported, because it doesn't make sense.
* ANY Not supported. You probably want ONE instead.
* ONE Will return the record returned by the first node to respond. A consistency check is always done in a
* background thread to fix any consistency issues when ConsistencyLevel.ONE is used. This means subsequent
* calls will have correct data even if the initial read gets an older value. (This is called 'read repair'.)
* QUORUM Will query all storage nodes and return the record with the most recent timestamp once it has at least a
* majority of replicas reported. Again, the remaining replicas will be checked in the background.
* ALL Not yet supported, but we plan to eventually.
*/ 클라이언트에서 데이타를 쓰고, 읽기를 진행할때, 위의 주석에 대한 숙지가 꼭 필요할 것 같습니다. ^^
Trackback Address >> http://www.sjava.net/trackback/198
Trackback Address >> http://www.sjava.net/trackback/191
Cassandra.Client는 http://incubator.apache.org/thrift/ 를 이용해서 Cassandra에 데이타를 insert하고 select하는 inner 클래스 입니다. Cassandra.Client를 생성하고 사용하기 위해서 제가 사용하는 CassandraClientFactory 클래스는 아래와 같습니다.
import org.apache.cassandra.thrift.Cassandra;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
public class CassandraClientFactory {
private final String SERVER = "localhost";
private final int PORT = 9160;
// inner class
private Cassandra.Client client;
// singleton instance
private static CassandraClientFactory instance = new CassandraClientFactory();
private CassandraClientFactory() {
try {
TTransport socket = new TSocket(SERVER, PORT);
//out.println(String.format("connected to %s : %d .", SERVER, PORT));
TBinaryProtocol binaryProtocol = new TBinaryProtocol(socket, false, false);
this.client = new Cassandra.Client(binaryProtocol);
socket.open();
} catch(org.apache.thrift.transport.TTransportException e) {
e.printStackTrace();
}
}
public static CassandraClientFactory getInstance() {
return instance;
}
public Cassandra.Client getClient() {
return this.client;
}
}
Trackback Address >> http://www.sjava.net/trackback/189
mssql 2008을 ibatis에서 사용하기 위한 세팅입니다.
흠.. mssql을 잘 몰라서 포트 세팅하는데 힘들었네요.. ^^;;
전에는 default port가 1433이었는데..
Sql Server Configuration Manager --> SQL Server 네트워크 구성 --> TCP/IP 사용의 속성창을 보시면 아래의 화면이 나옵니다.. 그리고 TCP 동적포트로 접근을 하시면 됩니다.. ^^;;
<sqlMapConfig>
<transactionManager type="JDBC" commitRequired="false">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
<property name="JDBC.ConnectionURL" value="jdbc:sqlserver://computer-name\SQLEXPRESS: 4147;databaseName=testdb;integratedSecurity=true;"/>
<property name="JDBC.Username" value="id"/>
<property name="JDBC.Password" value="password"/>
<property name="Pool.MaximumIdleConnections" value="5"/>
<property name="Pool.MaximumCheckoutTime" value="120000"/>
<property name="Pool.TimeToWait" value="500"/>
</dataSource>
</transactionManager>
<sqlMap resource="article.xml"/>
</sqlMapConfig>
그리고, 혹시 경고: Failed to load the sqljdbc_auth.dll 메세지를 뿌르게 되면..
플랫폼에 맞는 sqljdbc_auth.dl를 windows\system32폴더에 카피를 하시면 됩니다.
Trackback Address >> http://www.sjava.net/trackback/186
HTTP 프로토콜을 이용한 요청/응답을 쉽게 가능하게 도와주는 라이브러리로 Apache HttpClient를 사용해 봤습니다. 흠.. UTF-8등은 문제가 되지 않지만, EUC-KR로 인코딩된 페이지는 한글이 깨져서 나옵니다.
위 문제를 해결하기 위해서는 받은 데이타를 맞는 포맷으로 인코딩해 주시면 됩니다.
아래 코드처럼, 받은 데이타를 String 변수인 x에 저장하고, 다시 x를 아래의 포맷(iso-8859-1)으로 바꿔서 String y에 저장을 하고 뿌려주면 아래그림처럼 잘 나오게 됩니다.
String y = new String(x.getBytes("iso-8859-1"));
Trackback Address >> http://www.sjava.net/trackback/156
아래 내용은 http://www.javabeat.net/tips/139-struts-10-vs-struts-20.html의 내용입니다.
Difference between Struts 1.0 and Struts 2.0
In the following section, we are going to compare the various features between the two frameworks. Struts 2.0 is very simple as compared to struts 1.0,1.1, few of its excelent features are:
1.Servlet Dependency
Actions in Struts1 have dependencies on the servlet API since the
HttpServletRequest and HttpServletResponse objects are passed to the
execute method when an Action is invoked but in case of Struts 2.0, Actions are not container dependent because they are made simple POJOs. In Struts 2.0, the servlet contexts are represented as simple Maps which allows actions to be tested in isolation. Struts 2.0
Actions can access the original request and response, if required.
However, other architectural elements reduce or eliminate the need to
access the HttpServetRequest or HttpServletResponse directly.
2.Action classes
Programming the abstract classes instead of interfaces is one of
design issues of struts 1.0 framework that has been resolved in the Struts 2.0
framework. Struts 1.0 Action classes needs to extend framework
dependent abstract base class. But in case of Struts 2.0 Action class
may or may not implement interfaces to enable optional and custom
services. In case of Struts 2.0 , Actions are not container dependent because they are made simple POJOs. Struts 2.0
provides a base ActionSupport class to implement commonly used
interfaces. Albeit, the Action interface is not required. Any POJO
object with an execute signature can be used as an Struts 2.0 Action object.
3.Validation
Struts 1.0 and Struts 2.0 both supports the manual
validation via a validate method.
Struts 1.0 uses validate method on the ActionForm, or validates through
an extension to the Commons Validator. However, Struts 2.0 supports
manual validation via the validate method and the XWork Validation
framework. The Xwork Validation Framework supports chaining validation
into sub-properties using the validations defined for the properties
class type and the validation context.
4.Threading Model
In Struts1, Action resources must be thread-safe or synchronized. So
Actions are singletons and thread-safe, there should only be one
instance of a class to handle all requests for that Action. The
singleton strategy places restrictions on what can be done with Struts
1.0 Actions and requires extra care to develop. However in case of Struts 2.0,
Action objects are instantiated for each request, so there are no
thread-safety issues. (In practice, servlet containers generate many
throw-away objects per request, and one more object does not impose a
performance penalty or impact garbage collection.)
5.Testability
Testing Struts 1.0 applications are a bit complex. A major hurdle to
test Struts 1.0 Actions is that the execute method because it exposes
the Servlet API. A third-party extension, Struts TestCase, offers a set
of mock object for Struts1. But the Struts 2.0
Actions can be tested by instantiating the Action, setting properties
and invoking methods. Dependency Injection support also makes testing
simpler. Actions in struts2 are simple POJOs and are framework
independent, hence testability is quite easy in struts2.
6.Harvesting Input
Struts 1.0 uses an ActionForm object to capture input. And all
ActionForms needs to extend a framework dependent base class. JavaBeans
cannot be used as ActionForms, so the developers have to create
redundant classes to capture input. However Struts 2.0 uses Action properties (as input
properties independent of underlying framework) that eliminates the
need for a second input object, hence reduces redundancy. Additionally
in Struts 2.0, Action properties can be accessed from the web page via the taglibs. Struts 2.0
also supports the ActionForm pattern, as well as POJO form objects and
POJO Actions. Even rich object types, including business or domain
objects, can be used as input/output objects.
7.Expression Language
Struts 1.0 integrates with JSTL, so it uses the JSTL-EL. The struts1 EL has basic object graph traversal, but relatively weak collection and indexed property support. Struts 2.0
can also use JSTL, however it supports a more powerful and flexible
expression language called "Object Graph Notation Language" (OGNL).
8.Binding values into views
In the view section, Struts1 uses the standard JSP mechanism to bind
objects (processed from the model section) into the page context to
access. However Struts 2.0
uses a "ValueStack" technology so that the taglibs can access values
without coupling your view to the object type it is rendering. The
ValueStack strategy allows the reuse of views across a range of types
which may have the same property name but different property types.
9.Type Conversion
Usually, Struts 1.0 ActionForm properties are all Strings. Struts
1.0 uses Commons-Beanutils for type conversion. These type converters
are per-class and not configurable per instance. However Struts 2.0 uses OGNL for type conversion. The framework includes converters for basic and common object types and primitives.
10.Control Of Action Execution
Struts 1.0 supports separate Request Processor (lifecycles) for each
module, but all the Actions in a module must share the same lifecycle.
However Struts 2.0
supports creating different lifecycles on a per Action basis via
Interceptor Stacks. Custom stacks can be created and used with
different Actions as needed.
Trackback Address >> http://www.sjava.net/trackback/104
1. 어플리케이션 서버에서 필요한 메모리 계산 방법
- 계산식 : (MaxProcessMemory - JVMMemory - ReservedOsMemory) / (ThreadStackSize) = Number of threads - 메모리 계산 예가정 : Java 1.5를 사용중이며 OS가 120MB를, 디폴트 스택사이즈는 0.5M
- JVM에 1.5GB할당되었을 경우 : (2GB-1.5Gb-120MB)/(1MB) = ~380 threads
- JVM에 1.0GB할당되었을 경우 : (2GB-1.0Gb-120MB)/(1MB) = ~880 threads
통계적으로 대략 200명의 동시 사용자 수용할 경우 300MB정도 필요하합니다. 이것을 고려해서 메모리를 계산하면 됩니다. 2. Application Server 에러 대처 방안(java.lang.OutOfMemoryError: PermGen space 현상)
- Tomcat의 경우 v6.0.14이상의 안정적 릴리즈 된것을 선택
- JDK1.4보다는 1.5, 1.6의 사용을 권고함
- -XXMaxPermSize 설정을 통해 perm 사이즈를 증가시킴
- JHat으로 메모리릭 원인을 찾고 JConsole, Lambda probe 등을 통해 메모리 모니터링을 함
- Application Server운영자는 Garbage Collection에 대한 이해가 있어야 함
3. Tomcat에서 설정 예시
- 힙메모리 정보를 출력 : -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC
위 설정을 통해 출력되는 로그를 보고 New Generation의 eden 영역, Old Generation 영역, Permanent 영역을 확인하여 각 영역이 작으면 아래와 같은 설정으로 적당 사이즈를 확보해 줍니다.
- 도출된 설정 : -Xms256m -Xmx512m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:MaxPermSize=128m -XX:SurvivorRatio=5
-Xms : 최소 힙 싸이즈 -Xmx : 최대 힙 싸이즈 -XX:NewSize : New Generation의 최소 싸이즈 -XX:MaxNewSize : New Generation의 최대 싸이즈 -XX:MaxPermSize : Permanent Generation의 최대 싸이즈 가 되겠다. -XX:SurvivorRatio : 영역비율(New Generation)
결론적으로 적용할 설정은 아래와 같습니다.
- CATALINA_OPTS="-server -Xss256k -Xms256m -Xmx512m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:MaxPermSize=128m -XX:SurvivorRatio=5 -XX:ReservedCodeCacheSize=128m -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true "
Open Soure는 100% 안정적이지 않기 때문에 가장 최신의 안정적인 버젼이 릴리즈되는지 항상 예의 주시하여 버전업에 게을러서는 안됩니다
위 내용은 http://www.mimul.com/pebble/default/2008/01/26/1201346400000.html 에서 발췌를 하였습니다.
Trackback Address >> http://www.sjava.net/trackback/83
Apache iBatis에서 다중의 데이타 베이스에 접속하는 방법에 대한 내용입니다.
1. database.properties
driver=oracle.jdbc.driver.OracleDriver jdbc.url1=jdbc:oracle:thin:@mimuluserdb:1521:mimuluser username1=mimuluser password1=mimuluser
jdbc.url2=jdbc:oracle:thin:@pepsiuserdb:1521:pepsiuser username2=pepsiuser password2=pepsiuser
2. sqlmap1.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd"> <sqlMapConfig> <properties resource="com/mimul/dwr/app/ resource/database.properties"/> <settings cacheModelsEnabled="true" enhancementEnabled="true" lazyLoadingEnabled="true" maxRequests="40" maxSessions="20" maxTransactions="5" useStatementNamespaces="false" /> <transactionManager type="JDBC"> <dataSource type="DBCP"> <property name="driverClassName" value="${driver}"/> <property name="url" value="${jdbc.url1}"/> <property name="username" value="${username1}"/> <property name="password" value="${password1}"/>
<!-- OPTIONAL PROPERTIES BELOW --> <property name="initialSize" value="5"/> <property name="maxActive" value="30"/> <property name="maxIdle" value="20"/> <property name="maxWait" value="60000"/> <property name="poolPreparedStatements" value="true"/> <property name="validationQuery" value="select 0 from dual"/> <property name="testOnBorrow" value="true"/> <property name="maximumActiveConnections" value="10"/> <property name="maximumIdleConnections" value="5"/> <property name="maximumWait" value="60000"/> <property name="logAbandoned" value="false"/> <property name="removeAbandoned" value="false"/> <property name="removeAbandonedTimeout" value="50000"/> </dataSource> </transactionManager> <sqlMap resource="com/mimul/dwr/app/sql/Mimul.xml"/> </sqlMapConfig>
3. sqlmap2.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd"> <sqlMapConfig> <properties resource="com/mimul/dwr/app/resource/database.properties"/> <settings cacheModelsEnabled="true" enhancementEnabled="true" lazyLoadingEnabled="true" maxRequests="40" maxSessions="20" maxTransactions="5" useStatementNamespaces="false" /> <transactionManager type="JDBC"> <dataSource type="DBCP"> <property name="driverClassName" value="${driver}"/> <property name="url" value="${jdbc.url2}"/> <property name="username" value="${username2}"/> <property name="password" value="${password2}"/>
<!-- OPTIONAL PROPERTIES BELOW --> <property name="initialSize" value="5"/> <property name="maxActive" value="30"/> <property name="maxIdle" value="20"/> <property name="maxWait" value="60000"/> <property name="poolPreparedStatements" value="true"/> <property name="validationQuery" value="select 0 from dual"/> <property name="testOnBorrow" value="true"/> <property name="maximumActiveConnections" value="10"/> <property name="maximumIdleConnections" value="5"/> <property name="maximumWait" value="60000"/> <property name="logAbandoned" value="false"/> <property name="removeAbandoned" value="false"/> <property name="removeAbandonedTimeout" value="50000"/> </dataSource> </transactionManager> <sqlMap resource="com/mimul/dwr/app/sql/Pepsi.xml"/> </sqlMapConfig>
4. SqlCondig.java
import java.io.File; import java.io.Reader;
import com.ibatis.common.resources.Resources; import com.ibatis.sqlmap.client.SqlMapClient; import com.ibatis.sqlmap.client.SqlMapClientBuilder; import com.jaeminara.common.log.LogPool;
public class SqlConfig { private static SqlMapClient sqlMap1 = null; private static SqlMapClient sqlMap2 = null; private static SqlConfig instance_ = null; private SqlConfig() throws Exception { Reader reader = null; String resource = null; try { if (sqlMap == null) { resource = "sqlmap1.xml"; reader = Resources.getResourceAsReader(resource); sqlMap1 = SqlMapClientBuilder.buildSqlMapClient(reader); resource = "sqlmap2.xml"; reader = Resources.getResourceAsReader(resource); sqlMap2 = SqlMapClientBuilder.buildSqlMapClient(reader); reader.close(); } } catch (Exception e) { System.out.println(e); throw e; } finally { if (reader != null) reader.close(); reader = null; rsc = null; } } public static SqlConfig instance() { try { if (instance_ == null) { synchronized (SqlConfig.class) { if (instance_ == null) instance_ = new SqlConfig(); } } } catch (Exception e) { System.out.println(e); } return instance_; }
/** * Return SqlMapClient for SDP schema * * @return */ public static SqlMapClient getSqlMap1Instance() { return sqlMap1; }
/** * Return SqlMapClient for SDP schema * * @return */ public static SqlMapClient getSqlMap2Instance() { return sqlMap2; } }
이 내용은 http://mimul.com/pebble/default/2008/02/24/1203779580000.html 에서 발췌를 하였습니다.
Trackback Address >> http://www.sjava.net/trackback/82
Tomcat5.5 클래스 로딩 순서Bootstrap classes of your JVM System class loader classses (described above) /WEB-INF/classes of your web application /WEB-INF/lib/*.jar of your web application $CATALINA_HOME/common/classes $CATALINA_HOME/common/endorsed/*.jar $CATALINA_HOME/common/i18n/*.jar $CATALINA_HOME/common/lib/*.jar $CATALINA_BASE/shared/classes $CATALINA_BASE/shared/lib/*.jar Tomcat5.0 클래스로딩 순서Bootstrap classes of your JVM System class loader classses (described above) /WEB-INF/classes of your web application /WEB-INF/lib/*.jar of your web application $CATALINA_HOME/common/classes $CATALINA_HOME/common/endorsed/*.jar $CATALINA_HOME/common/lib/*.jar $CATALINA_BASE/shared/classes $CATALINA_BASE/shared/lib/*.jar Tomcat4.1 클래스로딩 순서/WEB-INF/classes of your web application /WEB-INF/lib/*.jar of your web application Bootstrap classes of your JVM System class loader classses (described above) $CATALINA_HOME/common/classes $CATALINA_HOME/common/endorsed/*.jar $CATALINA_HOME/common/lib/*.jar $CATALINA_BASE/shared/classes $CATALINA_BASE/shared/lib/*.jar 출처 : http://www.jakartaproject.com/article/jsptip/111456818395700
Trackback Address >> http://www.sjava.net/trackback/47
에고... IBatis에서 MSSQL2000 인스턴스의 카탈로그에 접속하기 위해서 한참을 헤메서 겨우 찾았네요.. ^^;; 아래는 해결책입니다.. ^^;; 해결책은 인스턴스의 실제 TCP 포트로 접속하면 됩니다.. ^^;; 넘 간단한가?? ㅋㅋ
Trackback Address >> http://www.sjava.net/trackback/46
Apache iBatis에서 MSSQL DB에 Insert시에 리턴값을 받아오는 형태입니다.
1. 코드 int key = (int)sqlMap.Insert("InsertOrganization", organization);
2. xml 내용
<insert id="InsertOrganization" parameterClass="Organization" resultClass="int"> <selectKey property="Id" type="post" resultClass="int"> SELECT @@IDENTITY AS value </selectKey> INSERT INTO Organizations (Org_Code, Org_Name) VALUES (#Code#, #Name#) </insert>
Trackback Address >> http://www.sjava.net/trackback/39
struts2 dtd file <?xml version="1.0" encoding="UTF-8"?> <!-- /* * * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ -->
<!-- START SNIPPET: strutsDtd -->
<!-- Struts configuration DTD. Use the following DOCTYPE <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> -->
<!ELEMENT struts (package|include|bean|constant)*>
<!ELEMENT package (result-types?, interceptors?, default-interceptor-ref?, default-action-ref?, default-class-ref?, global-results?, global-exception-mappings?, action*)> <!ATTLIST package name CDATA #REQUIRED extends CDATA #IMPLIED namespace CDATA #IMPLIED abstract CDATA #IMPLIED externalReferenceResolver NMTOKEN #IMPLIED >
<!ELEMENT result-types (result-type+)>
<!ELEMENT result-type (param*)> <!ATTLIST result-type name CDATA #REQUIRED class CDATA #REQUIRED default (true|false) "false" >
<!ELEMENT interceptors (interceptor|interceptor-stack)+>
<!ELEMENT interceptor (param*)> <!ATTLIST interceptor name CDATA #REQUIRED class CDATA #REQUIRED >
<!ELEMENT interceptor-stack (interceptor-ref*)> <!ATTLIST interceptor-stack name CDATA #REQUIRED >
<!ELEMENT interceptor-ref (param*)> <!ATTLIST interceptor-ref name CDATA #REQUIRED >
<!ELEMENT default-interceptor-ref (#PCDATA)> <!ATTLIST default-interceptor-ref name CDATA #REQUIRED >
<!ELEMENT default-action-ref (#PCDATA)> <!ATTLIST default-action-ref name CDATA #REQUIRED >
<!ELEMENT default-class-ref (#PCDATA)> <!ATTLIST default-class-ref class CDATA #REQUIRED >
<!ELEMENT global-results (result+)>
<!ELEMENT global-exception-mappings (exception-mapping+)>
<!ELEMENT action (param|result|interceptor-ref|exception-mapping)*> <!ATTLIST action name CDATA #REQUIRED class CDATA #IMPLIED method CDATA #IMPLIED converter CDATA #IMPLIED >
<!ELEMENT param (#PCDATA)> <!ATTLIST param name CDATA #REQUIRED >
<!ELEMENT result (#PCDATA|param)*> <!ATTLIST result name CDATA #IMPLIED type CDATA #IMPLIED >
<!ELEMENT exception-mapping (#PCDATA|param)*> <!ATTLIST exception-mapping name CDATA #IMPLIED exception CDATA #REQUIRED result CDATA #REQUIRED >
<!ELEMENT include (#PCDATA)> <!ATTLIST include file CDATA #REQUIRED >
<!ELEMENT bean (#PCDATA)> <!ATTLIST bean type CDATA #IMPLIED name CDATA #IMPLIED class CDATA #REQUIRED scope CDATA #IMPLIED static CDATA #IMPLIED optional CDATA #IMPLIED >
<!ELEMENT constant (#PCDATA)> <!ATTLIST constant name CDATA #REQUIRED value CDATA #REQUIRED >
<!-- END SNIPPET: strutsDtd -->
Trackback Address >> http://www.sjava.net/trackback/34
아래구조상으로 사용자가 요청을 하면,
1.
액션(Action)이 처리가 된다2.
액션(Action)이 처리가 되면서 Interceptor 전,후 처리를 한다.3.
응답을 처리한다. struts In the diagram, an
initial request goes to the Servlet container (such as Jetty or Resin) which is
passed through a standard filter chain. The chain includes the (optional)
ActionContextCleanUp filter, which is useful when integrating
technologies such as SiteMesh
Plugin. Next, the required FilterDispatcher is called, which
in turn consults the ActionMapper
to determine if the request should invoke an action.
If the ActionMapper
determines that an Action should be invoked, the FilterDispatcher delegates
control to the ActionProxy. The ActionProxy consults the framework Configuration
Files manager (initialized from the struts.xml
file). Next, the ActionProxy creates an ActionInvocation, which is
responsible for the command pattern implementation. This includes invoking any
Interceptors (the before clause)
in advance of invoking the Action itself.
Once the Action
returns, the ActionInvocation is responsible for looking up the proper
result associated with the Action result code mapped in
struts.xml. The
result is then executed, which often (but not always, as is the case for Action
Chaining) involves a template written in JSP or FreeMarker to
be rendered. While rendering, the templates can use the Struts Tags
provided by the framework. Some of those components will work with the
ActionMapper to render proper URLs for additional
requests.
|
<!--[if !vml]--> <!--[endif]--> |
All
objects in this architecture (Actions, Results, Interceptors,
and so forth) are created by an ObjectFactory.
This ObjectFactory is pluggable. We can provide our own ObjectFactory for any
reason that requires knowing when objects in the framework are created. A
popular ObjectFactory implementation uses Spring as provided by the Spring
Plugin. |
Interceptors are
executed again (in reverse order, calling the after
clause). Finally, the response returns through the filters configured in the
web.xml. If the
ActionContextCleanUp filter is present, the FilterDispatcher will
not clean
up the ThreadLocal ActionContext. If the ActionContextCleanUp filter is
not present, the FilterDispatcher will cleanup all
ThreadLocals.
Trackback Address >> http://www.sjava.net/trackback/21
기본적으로 아래와 같은 환경파일을
struts 2에서 사용하고 있습니다.그 중에서 struts.properties가
struts 2에 대한 기본설정을 담고 있습니다.
| File
|
Optional
|
Location
|
Purpose
|
| web.xml |
no |
/WEB-INF/ |
Web deployment descriptor to include all
necessary framework components |
| struts.xml |
yes |
/WEB-INF/classes/ |
Main configuration, contains result/view
types, action mappings, interceptors, and so forth
|
| struts.properties |
yes |
/WEB-INF/classes/ |
Framework properties |
| struts-default.xml |
yes |
/WEB-INF/lib/struts2-core.jar |
Default configuration provided by Struts
|
| struts-default.vm |
yes |
/WEB-INF/classes/ |
Default macros referenced by
velocity.properties |
| struts-plugin.xml |
yes |
At the root of a plugin JAR |
Optional configuration files for Pluginsstruts.xml. in
the same format as |
| velocity.properties |
yes |
/WEB-INF/classes/ |
Override the default Velocity configuration
| 위의 설정파일들 중에서 struts.properties 에서 ### Used by the DefaultActionMapper
### You may provide a comma separated list, e.g.
struts.action.extension=action,jnlp,do struts.action.extension=action 위의 빨간색 설정 부분을
xxx,do,action 등과 같이 우선순위가 높은 순서데로 설정을 한다.
Trackback Address >> http://www.sjava.net/trackback/20
내용의 출처는 http://www.mimul.com/pebble/default/2007/12/09/1197199680000.html 입니다. 프로젝트 개발을 하다보면 light한 환경을 요하는 경우가 있습니다. 이럴 경우 spring framework를 대신하여 dbcp +
ibatis를 가지고 개발을 진행하는 경우도 발생할 것입니다. 이럴 경우 유용하리라 생각되어 설치과정을 공유합니다. 일단 Tomcat
환경에서 설치 과정을 설명하겠습니다. 1. DBCP 설치 - 실치 과정은 여기에
가시면 설치과정을 설명해 놓았습니다. 2. iBatis 설치 - 여기에 가서 다운로드 -
${ProjectWebRoot}/WEB-INF/lib에 ibatis-2.3.0.677.jar 카피 3.
sqlmap.xml 정의<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd"> <sqlMapConfig> <properties resource="com/mimul/dwr/app/resource/database.properties"/> <settings cacheModelsEnabled="true" enhancementEnabled="true" lazyLoadingEnabled="true" maxRequests="40" maxSessions="20" maxTransactions="5" useStatementNamespaces="false" /> <transactionManager type="JDBC"> <dataSource type="DBCP"> <property name="driverClassName" value="${driver}"/> <property name="url" value="${jdbc.url}"/> <property name="username" value="${username}"/> <property name="password" value="${password}"/>
<!-- OPTIONAL PROPERTIES BELOW --> <property name="initialSize" value="5"/> <property name="maxActive" value="30"/> <property name="maxIdle" value="20"/> <property name="maxWait" value="60000"/> <property name="poolPreparedStatements" value="true"/> <property name="validationQuery" value="select 0 from dual"/> <property name="testOnBorrow" value="true"/> <property name="maximumActiveConnections" value="10"/> <property name="maximumIdleConnections" value="5"/> <property name="maximumWait" value="60000"/> <property name="logAbandoned" value="false"/> <property name="removeAbandoned" value="false"/> <property name="removeAbandonedTimeout" value="50000"/> </dataSource> </transactionManager> <sqlMap resource="com/mimul/dwr/app/sql/Mimul.xml"/> </sqlMapConfig> 4.
com/mimul/dwr/app/resource/database.properties 정의driver=oracle.jdbc.driver.OracleDriver jdbc.url=jdbc:oracle:thin:@mimuluserdb:1521:mimuluser username=mimuluser password=mimuluser 5.
com/mimul/dwr/app/sql/Mimul.xml 정의 - DDL2iBatis.exe를 활용하여 자동
생성하게 하는 것이 개발 속도가 올라갑니다. <?xml version='1.0'?> <!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd"> <sqlMap namespace="Mimul"> <cacheModel id="mimul-cache" type="MEMORY"> <flushInterval hours="24"/> <flushOnExecute statement="insertMimul"/> <flushOnExecute statement="updateMimul"/> <flushOnExecute statement="deleteMimul"/> <property name="reference-type" value="WEAK" /> </cacheModel> <resultMap class="com.mimul.dwr.model.Mimul" id="mimul-result" > <result property="lseq" column="lseq" /> <result property="sseq" column="sseq" /> <result property="assetid" column="assetid" /> <result property="title" column="title" /> <result property="imgurl" column="imgurl" /> <result property="vodurl" column="vodurl" /> <result property="use" column="use" /> <result property="chgdate" column="chgdate" /> </resultMap> <select id="getMimul" resultClass="com.mimul.dwr.model.Mimul" parameterClass="Integer" > <![CDATA[ SELECT lseq, sseq, assetid, title, imgurl, vodurl, use, chgdate FROM mimul WHERE lseq = #lseq# ]]> </select> <update id="updateMimul" parameterClass="com.mimul.dwr.model.Mimul" > <![CDATA[ UPDATE mimul SET sseq = #sseq#, assetid = #assetid#, title = #title#, imgurl = #imgurl#, vodurl = #vodurl#, use = #use#, chgdate = #chgdate# WHERE lseq = #lseq# ]]> </update> <insert id="insertMimul" parameterClass="com.mimul.dwr.model.Mimul" > <selectKey resultClass="int" keyProperty="lseq" > SELECT mimul_lseq_seq.nextval as lseq FROM dual </selectKey> INSERT INTO mimul (lseq, sseq, assetid, title, imgurl, vodurl, use, chgdate) VALUES (#lseq#, #sseq#, #assetid#, #title#, #imgurl#, #vodurl#, #use#, #chgdate#) </insert> <delete id="deleteMimul" parameterClass="com.mimul.dwr.model.Mimul" > <![CDATA[ DELETE FROM mimul WHERE lseq = #lseq# ]]> </delete> </sqlMap> 6.
DAO에서 사용하기 위한 SqlConfig 객체 정의(dbcp+ibatis연결 정보 정의)import java.io.File; import java.io.Reader;
import com.ibatis.common.resources.Resources; import com.ibatis.sqlmap.client.SqlMapClient; import com.ibatis.sqlmap.client.SqlMapClientBuilder; import com.jaeminara.common.log.LogPool;
public class SqlConfig { private static SqlMapClient sqlMap = null; private static SqlConfig instance_ = null; private SqlConfig() throws Exception { Reader reader = null; StringBuffer rsc = null; try { if (sqlMap == null) { rsc = new StringBuffer(200); rsc.append("com").append(File.separator); rsc.append("jaeminara").append(File.separator); rsc.append("dwr").append(File.separator); rsc.append("app").append(File.separator); rsc.append("sql").append(File.separator).append("sqlmap.xml"); reader = Resources.getResourceAsReader(rsc.toString()); sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader); reader.close(); } } catch (Exception e) { System.out.println(e); throw e; } finally { if (reader != null) reader.close(); reader = null; rsc = null; } } public static SqlConfig instance() { try { if (instance_ == null) { synchronized (SqlConfig.class) { if (instance_ == null) instance_ = new SqlConfig(); } } } catch (Exception e) { System.out.println(e); } return instance_; }
/** * Return SqlMapClient for SDP schema * * @return */ public static SqlMapClient getSqlMapInstance() { return sqlMap; } } 7. DAO 클래스 정의import java.util.HashMap; import java.util.List; import java.util.Map;
import com.ibatis.sqlmap.client.SqlMapClient; import com.mimul.common.log.LogPool; import com.mimul.dwr.model.getMimulByLSEQ;
public class MimulDao { private SqlMapClient smc = SqlConfig.instance().getSqlMapInstance(); public void MimulDao() {} public Mimul getMimulByLSEQ(int lseq) throws Exception { Mimul mimul = null;
try { if (lseq == 0) { LogPool.instance("DAO").debug("getMimulByLSEQ() : Parameter is null!"); return null; } mimul = (Mimul) smc.queryForObject("getMimul", lseq); } catch (Exception e) { LogPool.instance("DAO").error(e); throw e; } return mimul; } // 기타 필요한 함수 정의 } 크게
어려운 점은 없습니다. 그리고 transaction 무결성을 보장하기 위해서는 executor.startBatch();와
executor.executeBatch(); transaction 처리 로직을 넣으시면 됩니다. 나머진 자동으로 iBatis에서 트랜젝션
자원의 할당 및 해지의 라이프사이클을 관리해 줍니다.
Trackback Address >> http://www.sjava.net/trackback/10
|
|
|