there is a case that I need search the bigger application log and only list the logs from 2 or 3 specific classes.
i use grep to get the result.
here is the syntax
grep -r "SapPaymentDataAccessor1\|SapFiPaymentSOAPImpl1\|PaymentClrProcess" *.*
Tuesday, December 17, 2013
Monday, December 2, 2013
Node code for Ternary and minus combined
saw a very simple solution for learnyounode as following
//console.log(process.argv);
var total = 0;
process.argv.forEach(function(item){
total += +item ? + item: 0;
});
console.log(total);
this is used to print out summary of command parameters
fouth line need to be explained
+item is the a minus operation on variable "item" value(not item itself),try to convert item value(String) to a number,if the result is a number,then the ternary operator will be true,since item might be a string,we also use +item to convert item value into a number if it is a string when ternary operator returns true.
//console.log(process.argv);
var total = 0;
process.argv.forEach(function(item){
total += +item ? + item: 0;
});
console.log(total);
this is used to print out summary of command parameters
fouth line need to be explained
+item is the a minus operation on variable "item" value(not item itself),try to convert item value(String) to a number,if the result is a number,then the ternary operator will be true,since item might be a string,we also use +item to convert item value into a number if it is a string when ternary operator returns true.
Wednesday, August 28, 2013
find out the stack trace at any point
sometimes,code call embeded too complex,we want know what is the call stack from a point of code.
we can do it like this
logger.debug(stackTraceToString(Thread.currentThread().getStackTrace()));
public String stackTraceToString(StackTraceElement[] ste){
StringBuilder sb = new StringBuilder();
for (StackTraceElement element : ste) {
sb.append(element.toString());
sb.append("\n");
}
return sb.toString();
}
we can do it like this
logger.debug(stackTraceToString(Thread.currentThread().getStackTrace()));
public String stackTraceToString(StackTraceElement[] ste){
StringBuilder sb = new StringBuilder();
for (StackTraceElement element : ste) {
sb.append(element.toString());
sb.append("\n");
}
return sb.toString();
}
Tuesday, August 27, 2013
find who is log in in linux server
1) pinky command will show ips that user lo in from(actually name already there)
Login Name TTY Idle When Where
sprathaban fisrname lastname pts/1 17:34 2013-08-26 13:27 10.136.xx.xxx
2)windows
nbtstat -A 10.136.xxx.xxx
Local Area Connection:
Node IpAddress: [10.136.xxx.xxx] Scope Id: []
NetBIOS Remote Machine Name Table
Name Type Status
---------------------------------------------
GCHELLIAH-DT 00 UNIQUE Registered
MAC Address = 00-1E-0B-xx-xx-xx
Login Name TTY Idle When Where
sprathaban fisrname lastname pts/1 17:34 2013-08-26 13:27 10.136.xx.xxx
2)windows
nbtstat -A 10.136.xxx.xxx
Local Area Connection:
Node IpAddress: [10.136.xxx.xxx] Scope Id: []
NetBIOS Remote Machine Name Table
Name Type Status
---------------------------------------------
GCHELLIAH-DT 00 UNIQUE Registered
MAC Address = 00-1E-0B-xx-xx-xx
Wednesday, August 21, 2013
Tuesday, August 20, 2013
Tuesday, June 11, 2013
Liskov substitution principle
Substitutability is a principle in object-oriented programming. It states that, in a computer program, if S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substituted for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.). More formally, the Liskov substitution principle (LSP) is a particular definition of a subtyping relation, called (strong) behavioral subtyping, that was initially introduced by Barbara Liskov in a 1987 conference keynote address entitled Data abstraction and hierarchy. It is a semantic rather than merely syntactic relation because it intends to guarantee semantic interoperability of types in a hierarchy, object types in particular. Liskov and Jeannette Wingformulated the principle succinctly in a 1994 paper as follows:
- Let
be a property provable about objects
of type
. Then
should be provable for objects
of type
where
is a subtype of
.
In the same paper, Liskov and Wing detailed their notion of behavioral subtyping in an extension of Hoare logic, which bears a certain resemblance with Bertrand Meyer's Design by Contract in that it considers the interaction of subtyping with pre- and postconditions.
Principle
Liskov's notion of a behavioral subtype defines a notion of substitutability for mutable objects; that is, if S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program (e.g., correctness).
Behavioral subtyping is a stronger notion than typical subtyping of functions defined in type theory, which relies only on the contravariance of argument types and covariance of the return type. Behavioral subtyping is trivially undecidable in general: if q is the property "method for x always terminates", then it is impossible for a program (e.g. a compiler) to verify that it holds true for some subtype S of T even if q does hold for T. Nonetheless, the principle is useful in reasoning about the design of class hierarchies.
Liskov's principle imposes some standard requirements on signatures that have been adopted in newer object-oriented programming languages (usually at the level of classes rather than types; see nominal vs. structural subtyping for the distinction):
- Contravariance of method arguments in the subtype.
- Covariance of return types in the subtype.
- No new exceptions should be thrown by methods of the subtype, except where those exceptions are themselves subtypes of exceptions thrown by the methods of the supertype.
In addition to these, there are a number of behavioral conditions that the subtype must meet. These are detailed in a terminology resembling that of design by contractmethodology, leading to some restrictions on how contracts can interact with inheritance:
- Preconditions cannot be strengthened in a subtype.
- Postconditions cannot be weakened in a subtype.
- Invariants of the supertype must be preserved in a subtype.
- History constraint (the "history rule"). Objects are regarded as being modifiable only through their methods (encapsulation). Since subtypes may introduce methods that are not present in the supertype, the introduction of these methods may allow state changes in the subtype that are not permissible in the supertype. The history constraint prohibits this. It was the novel element introduced by Liskov and Wing. A violation of this constraint can be exemplified by defining a MutablePoint as a subtype of an ImmutablePoint. This is a violation of the history constraint, because in the history of the Immutable point, the state is always the same after creation, so it cannot include the history of a MutablePoint in general. Fields added to the subtype may however be safely modified because they are not observable through the supertype methods. Thus, one may derive a CircleWithFixedCenterButMutableRadius from ImmutablePoint without violating LSP.
Origins
The rules on pre- and postconditions are identical to those introduced by Bertrand Meyer in his 1988 book. Both Meyer, and later Pierre America, who was the first to use the termbehavioral subtyping, gave proof-theoretic definitions of some behavioral subtyping notions, but their definitions did not take into account aliasing that may occur in programming language that supports references or pointers. Taking aliasing into account was the major improvement made by Liskov and Wing (1994), and a key ingredient is the history constraint. Under the definitions of Meyer and America, a MutablePoint would be a behavioral subtype of ImmutablePoint, whereas LSP forbids this.
A typical violation
A typical example that violates LSP is a Square class that derives from a Rectangle class, assuming getter and setter methods exist for both width and height. The Square class always assumes that the width is equal with the height. If a Square object is used in a context where a Rectangle is expected, unexpected behavior may occur because the dimensions of a Square cannot (or rather should not) be modified independently. This problem cannot be easily fixed: if we can modify the setter methods in the Square class so that they preserve the Square invariant (i.e., keep the dimensions equal), then these methods will weaken (violate) the postconditions for the Rectangle setters, which state that dimensions can be modified independently. Violations of LSP, like this one, may or may not be a problem in practice, depending on the postconditions or invariants that are actually expected by the code that uses classes violating LSP. Mutability is a key issue here. If Square and Rectangle had only getter methods (i.e., they were immutable objects), then no violation of LSP could occur.
Open/Closed Principle
In object-oriented programming, the open/closed principle states "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification";[1] that is, such an entity can allow its behaviour to be modified without altering itssource code. This is especially valuable in a production environment, where changes to source code may necessitate code reviews,unit tests, and other such procedures to qualify it for use in a product: code obeying the principle doesn't change when it is extended, and therefore needs no such effort.
The name Open/Closed Principle has been used in two ways. Both ways use inheritance to resolve the apparent dilemma, but the goals, techniques, and results are different.
Bertrand Meyer is generally credited as having originated the term Open/Closed Principle, which appeared in his 1988 book Object Oriented Software Construction. The idea was that once completed, the implementation of a class could only be modified to correct errors; new or changed features would require that a different class be created. That class could reuse coding from the original class through inheritance. The derived subclass might or might not have the same interface as the original class.
Meyer's Open/Closed Principle
Meyer's definition advocates implementation inheritance. Implementation can be reused through inheritance but interface specifications need not be. The existing implementation is closed to modifications, and new implementations need not implement the existing interface.
Polymorphic Open/Closed Principle
During the 1990s, the Open/Closed Principle became popularly redefined to refer to the use of abstracted interfaces, where the implementations can be changed and multiple implementations could be created and polymorphically substituted for each other.
In contrast to Meyer's usage, this definition advocates inheritance from abstract base classes. Interface specifications can be reused through inheritance but implementation need not be. The existing interface is closed to modifications and new implementations must, at a minimum, implement that interface.
Robert C. Martin's 1996 article "The Open-Closed Principle" was one of the seminal writings to take this approach. In 2001 Craig Larman related the Open/Closed Principle to the pattern by Alistair Cockburn called Protected Variations, and to the David Parnas discussion of information hiding.
Dependency inversion principle
In conventional application architecture, lower-level components are designed to be consumed by higher-level components which enable increasingly complex systems to be built. In this composition, higher-level components depend directly upon lower-level components to achieve some task. This dependency upon lower-level components limits the reuse opportunities of the higher-level components.
The goal of the dependency inversion principle is to decouple high-level components from low-level components such that reuse with different low-level component implementations becomes possible. This is facilitated by the separation of high-level components and low-level components into separate packages/libraries, where interfaces defining the behavior/services required by the high-level component are owned by, and exist within the high-level component's package. The implementation of the high-level component's interface by the low level component requires that the low-level component package depend upon the high-level component for compilation, thus inverting the conventional dependency relationship. Various patterns such as Plugin, Service Locator, or Dependency Injection are then employed to facilitate the run-time provisioning of the chosen low-level component implementation to the high-level component.
Applying the dependency inversion principle can also be seen as applying the Adapter pattern, i.e. the high-level class defines its own adapter interface which is the abstraction that the high-level class depends on. The adaptee implementation also depends on the adapter interface abstraction (of course, since it implements its interface) while it can be implemented by using code from within its own low-level module. The high-level has no dependency to the low-level module since it only uses the low-level indirectly through the adapter interface by invoking polymorphic methods to the interface which are implemented by the adaptee and its low-level module.
Single responsibility principle
In object-oriented programming, the single responsibility principle states that every class should have a single responsibility, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility.
Martin defines a responsibility as a reason to change, and concludes that a class or module should have one, and only one, reason to change. As an example, consider a module that compiles and prints a report. Such a module can be changed for two reasons. First, the content of the report can change. Second, the format of the report can change. These two things change for very different causes; one substantive, and one cosmetic. The single responsibility principle says that these two aspects of the problem are really two separate responsibilities, and should therefore be in separate classes or modules. It would be a bad design to couple two things that change for different reasons at different times.
The reason it is important to keep a class focused on a single concern is that it makes the class more robust. Continuing with the foregoing example, if there is a change to the report compilation process, there is greater danger that the printing code will break if it is part of the same class.
(FROM WIKIPEDIA)
Thursday, April 18, 2013
Monday, April 8, 2013
remote desktop The connection has been lost. Attempting to reconnect
using following command to fix it.
netsh interface tcp set global autotuninglevel=disabled
This disabled windows(7)’s TCP/IP autotuning feature. I didn’t even have to reboot, Remote Desktop has worked great ever since I made this change. No more problems, not even once.
If for some reason you want to re-enable TCP/IP auto tuning, the command is:
netsh interface tcp set global autotuninglevel=normal
Thursday, March 28, 2013
Thursday, March 21, 2013
find out when a index applied
select created from dba_objects where object_type='INDEX' and object_name='IX1_STAGE_NCF_OPTION';
find dates difference in oracle
select numtodsinterval(max(create_date)-min(create_date),'day') from table where master_process_id=17292640;
Wednesday, March 20, 2013
Orcale client tools tnsping
Oracle client has a tool called tnsping,it help us to check a tns name working or not.
tnsping somename
tnsping somename
Thursday, March 7, 2013
VBA operate on excel sheet
I have situation that create seeding query from data in excel sheet,so I write some VBA code that scan the data in excel cell,then generate query in one column
here is the code:
Sub ExpandRows()
Dim dat As Variant
Dim i As Long
Dim rw As Range
Dim rng As Range
Dim access_group_id As Long
Set rng = ActiveSheet.UsedRange
dat = rng
' Loop thru your data, starting at the first row
For i = 2 To UBound(dat, 1) Step 1
' clean the cell
Set rw = rng.Rows(i).EntireRow
rw.Cells(1, 12).Value = ""
If dat(i, 4) = "Y" Then
Set rw = rng.Rows(i).EntireRow
rw.Cells(1, 12).Value = rw.Cells(1, 12).Value & vbLf
rw.Cells(1, 12).Value = rw.Cells(1, 12).Value & "insert into logins_roles (login_id,role_id,access_group_id,organization_id) select (select login_id from logins where name='" & rw.Cells(1, 7).Value & _
"' and rownum <= 1)," & _
"27," & _
rw.Cells(1, 3) & _
"," & rw.Cells(1, 2).Value & " from dual " & _
" where not exists (select 1 from logins_roles where login_id = (select login_id from logins where name='" & rw.Cells(1, 7).Value & _
"'" & _
" and rownum <= 1) and " & _
" role_id=27" & " and access_group_id=" & _
rw.Cells(1, 3) & _
" and organization_id = " & rw.Cells(1, 2) & ")" & _
" and exists (select 1 from logins where name='" & _
rw.Cells(1, 7).Value & _
"' and active = 1);"
End If
If dat(i, 5) = "Y" Then
Set rw = rng.Rows(i).EntireRow
rw.Cells(1, 12).Value = rw.Cells(1, 12).Value & vbLf
rw.Cells(1, 12).Value = rw.Cells(1, 12).Value & "insert into logins_roles (login_id,role_id,access_group_id,organization_id) select (select login_id from logins where name='" & rw.Cells(1, 7).Value & _
"' and rownum <= 1)," & _
"2," & _
rw.Cells(1, 3) & _
"," & rw.Cells(1, 2) & " from dual " & _
" where not exists (select 1 from logins_roles where login_id = (select login_id from logins where name='" & rw.Cells(1, 7).Value & _
"'" & _
" and rownum <= 1) and " & _
" role_id=2" & " and access_group_id=" & _
rw.Cells(1, 3) & _
" and organization_id = " & rw.Cells(1, 2).Value & ")" & _
" and exists (select 1 from logins where name='" & _
rw.Cells(1, 7).Value & _
"' and active = 1);"
End If
If dat(i, 6) = "Y" Then
Set rw = rng.Rows(i).EntireRow
rw.Cells(1, 12).Value = rw.Cells(1, 12).Value & vbLf
rw.Cells(1, 12).Value = rw.Cells(1, 12).Value & "insert into logins_roles (login_id,role_id,access_group_id,organization_id) select (select login_id from logins where name='" & rw.Cells(1, 7).Value & _
"' and rownum <= 1)," & _
"26," & _
rw.Cells(1, 3) & _
"," & rw.Cells(1, 2).Value & " from dual " & _
" where not exists (select 1 from logins_roles where login_id = (select login_id from logins where name='" & rw.Cells(1, 7).Value & _
"'" & _
" and rownum <= 1) and " & _
" role_id=26" & " and access_group_id=" & _
rw.Cells(1, 3) & _
" and organization_id = " & rw.Cells(1, 2).Value & ")" & _
" and exists (select 1 from logins where name='" & _
rw.Cells(1, 7).Value & _
"' and active = 1);"
End If
Set rw = rng.Rows(i).EntireRow
rw.Cells(1, 12).Value = rw.Cells(1, 12).Value & vbNewLine
Next
End Sub
here is the code:
Sub ExpandRows()
Dim dat As Variant
Dim i As Long
Dim rw As Range
Dim rng As Range
Dim access_group_id As Long
Set rng = ActiveSheet.UsedRange
dat = rng
' Loop thru your data, starting at the first row
For i = 2 To UBound(dat, 1) Step 1
' clean the cell
Set rw = rng.Rows(i).EntireRow
rw.Cells(1, 12).Value = ""
If dat(i, 4) = "Y" Then
Set rw = rng.Rows(i).EntireRow
rw.Cells(1, 12).Value = rw.Cells(1, 12).Value & vbLf
rw.Cells(1, 12).Value = rw.Cells(1, 12).Value & "insert into logins_roles (login_id,role_id,access_group_id,organization_id) select (select login_id from logins where name='" & rw.Cells(1, 7).Value & _
"' and rownum <= 1)," & _
"27," & _
rw.Cells(1, 3) & _
"," & rw.Cells(1, 2).Value & " from dual " & _
" where not exists (select 1 from logins_roles where login_id = (select login_id from logins where name='" & rw.Cells(1, 7).Value & _
"'" & _
" and rownum <= 1) and " & _
" role_id=27" & " and access_group_id=" & _
rw.Cells(1, 3) & _
" and organization_id = " & rw.Cells(1, 2) & ")" & _
" and exists (select 1 from logins where name='" & _
rw.Cells(1, 7).Value & _
"' and active = 1);"
End If
If dat(i, 5) = "Y" Then
Set rw = rng.Rows(i).EntireRow
rw.Cells(1, 12).Value = rw.Cells(1, 12).Value & vbLf
rw.Cells(1, 12).Value = rw.Cells(1, 12).Value & "insert into logins_roles (login_id,role_id,access_group_id,organization_id) select (select login_id from logins where name='" & rw.Cells(1, 7).Value & _
"' and rownum <= 1)," & _
"2," & _
rw.Cells(1, 3) & _
"," & rw.Cells(1, 2) & " from dual " & _
" where not exists (select 1 from logins_roles where login_id = (select login_id from logins where name='" & rw.Cells(1, 7).Value & _
"'" & _
" and rownum <= 1) and " & _
" role_id=2" & " and access_group_id=" & _
rw.Cells(1, 3) & _
" and organization_id = " & rw.Cells(1, 2).Value & ")" & _
" and exists (select 1 from logins where name='" & _
rw.Cells(1, 7).Value & _
"' and active = 1);"
End If
If dat(i, 6) = "Y" Then
Set rw = rng.Rows(i).EntireRow
rw.Cells(1, 12).Value = rw.Cells(1, 12).Value & vbLf
rw.Cells(1, 12).Value = rw.Cells(1, 12).Value & "insert into logins_roles (login_id,role_id,access_group_id,organization_id) select (select login_id from logins where name='" & rw.Cells(1, 7).Value & _
"' and rownum <= 1)," & _
"26," & _
rw.Cells(1, 3) & _
"," & rw.Cells(1, 2).Value & " from dual " & _
" where not exists (select 1 from logins_roles where login_id = (select login_id from logins where name='" & rw.Cells(1, 7).Value & _
"'" & _
" and rownum <= 1) and " & _
" role_id=26" & " and access_group_id=" & _
rw.Cells(1, 3) & _
" and organization_id = " & rw.Cells(1, 2).Value & ")" & _
" and exists (select 1 from logins where name='" & _
rw.Cells(1, 7).Value & _
"' and active = 1);"
End If
Set rw = rng.Rows(i).EntireRow
rw.Cells(1, 12).Value = rw.Cells(1, 12).Value & vbNewLine
Next
End Sub
Monday, February 25, 2013
copy file between machines
following command is copy file from linux server into local folder of windows by cygwin
scp uploads@xxx.autc.com:testftp/ncf/inbound/280DAY.DAT 280DAT.DAY
"testftp/ncf/inbound/280DAY.DAT" is the file in remote server's uploads' home folder,last parameter is the file name in local folder
scp uploads@xxx.autc.com:testftp/ncf/inbound/280DAY.DAT 280DAT.DAY
"testftp/ncf/inbound/280DAY.DAT" is the file in remote server's uploads' home folder,last parameter is the file name in local folder
Thursday, February 14, 2013
can not download pom dependency from remote repository while VPN connected and under JDK7
add following to system properties will solve problem
MAVEN_OPTS=-Djava.net.preferIPv4Stack=true
MAVEN_OPTS=-Djava.net.preferIPv4Stack=true
Friday, February 8, 2013
exclude files while using xcopy
created a file exclude.txt in current folder,put the wild cards that we need to exclude while copy,the nusing following xcopy command
xcopy c:\test d:\test1 /exclude:exclude.txt /s /i
xcopy c:\test d:\test1 /exclude:exclude.txt /s /i
connected a net resource into local mapped driver
net use \\remote ip\share_folders password /USER:username@domain.com
Tuesday, February 5, 2013
double quote added while copy from excel into notepad
the best way to get rid of those double quotes is copy from excel into word,then copy from word into notepad.
Thursday, January 31, 2013
Posting keys in the standard system
Posting Key | Description |
40 | G/L account debit posting |
50 | G/L account credit posting |
01 | Customer invoice |
11 | Customer credit memo |
21 | Vendor credit memo |
25 | Vendor payment |
31 | Vendor invoice |
Purpose of Defining Internal Orders
following information comes from http://sapdocs.info.
An example would help us understand this much better.
Lets say in an organization there are various events such as trade fairs, training seminars, which occur during the year. Now lets assume for a second that these Trade fairs are organized by the Marketing cost center of the organization. Therefore in this case marketing cost center is responsible for all the trade fairs costs. All these trade fairs costs are posted to the marketing cost centers. Now if the management wants an analysis of the cost incurred for each of the trade fair organized by the marketing cost center how would the marketing manager get this piece of information across to them? The cost center report would not give this piece of info
Lets say in an organization there are various events such as trade fairs, training seminars, which occur during the year. Now lets assume for a second that these Trade fairs are organized by the Marketing cost center of the organization. Therefore in this case marketing cost center is responsible for all the trade fairs costs. All these trade fairs costs are posted to the marketing cost centers. Now if the management wants an analysis of the cost incurred for each of the trade fair organized by the marketing cost center how would the marketing manager get this piece of information across to them? The cost center report would not give this piece of info
Now this is where Internal Order steps in .If you go through all cost center reports this information is not readily available since all the costs are posted to the cost center.
SAP, therefore provides the facility of using internal orders which comes in real handy in such situations. In the above scenario the controlling department would then need to create an internal order for each of the trade fair organized. The cost incurred for each of the trade fair will be posted to the internal orders during the month. At the month end, these costs which are collected in the internal order will be settled from these orders to the marketing cost center. Thus the controlling person is now in a position to analyze the cost for each of the trade fair separately. Thus internal order is used to monitor costs for short term events, activities. It helps in providing more information than that is provided on the cost centers. It can be widely used for various purposes .
Sales Order in SAP SD
following information comes from http://sapdocs.info.
A ‘Sales Order’ is a contract between your Sales Organization and a Customer for supply of specified goods and/services over a specified timeframe and in an agreed upon quantity or unit. All the relevant information from the customer master record and the material master record, for a specific sales area, are copied to the sales order. The sales order may be created with reference to a ‘preceding document’ such as a quotation, then all the initial data from the preceding document is copied to the sales order.
The ‘sales order’ contains:
The ‘sales order’ contains:
- Organizational data (sales organization, distribution channel, division, sales document type, pricing procedure, etc.).
- Header data (sold-to-party, sales office, sales group, pricing date, document date, order reason, document currency, price group, sales district, customer group, shipping condition, incoterms, payment terms, billing schedule, PO number, etc.).
- Item data (item category, order quantity, material, batch number, product hierarchy, plant, material group, shipping point, route, delivery priority, customer material, item number, etc.).
- Schedule line data (schedule line, schedule line number, delivery date, order quantity, confirmed quantity, material availability date, loading date, proposed goods issue date, transportation date, movement type, shipping point, etc.).
Insert Horizontal Lines In Word Documents Quickly
in word document,just put three of any characters in following list,then hit enter,it will automatically created the horizontal lines in word
1)_
2)-
2)*
3)=
4)#
5)~
1)_
2)-
2)*
3)=
4)#
5)~
Thursday, January 17, 2013
bypass SSO
recently we has a situation that need fix and test few web applications that has been join the company SSO feature,but it looks like the SSO is not working for that environmental,we need bypass SSO,fix and test application.
go through the application,find out that,there is a Jspfilter that add SSO securityToken to session,for all url if they are not exist,so we commented out the filter from web.xml, and change the auth-method to basic in web.xml,rebuild application and deploy to server,vola, SSO was bypassed.
go through the application,find out that,there is a Jspfilter that add SSO securityToken to session,for all url if they are not exist,so we commented out the filter from web.xml, and change the auth-method to basic in web.xml,rebuild application and deploy to server,vola, SSO was bypassed.
Ho to log the web service soap communication
while working with a third part,doing web service communication with their API,some time,we need fidure out what soap message we send out by our java code,here is the how
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");
Previous system property will help you print out all debug information include soap message(header,body) in IDE console.
SoapUI has a build in feature that can capture all HTTP communication,include soap communications,it it only apply to call fired from soapUI.
since Axis is using httpclient framework,this method tested successfully with axis.
we can also use log4j to log all debug information and get all soap communication details.
here is the article that has all details in the internet from Apache.
http://hc.apache.org/httpclient-3.x/logging.html
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");
Previous system property will help you print out all debug information include soap message(header,body) in IDE console.
SoapUI has a build in feature that can capture all HTTP communication,include soap communications,it it only apply to call fired from soapUI.
since Axis is using httpclient framework,this method tested successfully with axis.
we can also use log4j to log all debug information and get all soap communication details.
here is the article that has all details in the internet from Apache.
http://hc.apache.org/httpclient-3.x/logging.html
Logging Practices
Being a library HttpClient is not to dictate which logging framework the user has to use. Therefore HttpClient utilizes the logging interface provided by theCommons Logging package. Commons Logging provides a simple and generalized log interface to various logging packages. By using Commons Logging,HttpClient can be configured for a variety of different logging behaviours. That means the user will have to make a choice which logging framework to use. By default Commons Logging supports the following logging frameworks:
- Log4J
- java.util.logging
- SimpleLog (internal to Commons Logging)
HttpClient performs two different kinds of logging: the standard context logging used within each class, and wire logging.
Context Logging
Context logging contains information about the internal operation of HttpClient as it performs HTTP requests. Each class has its own log named according to the class's fully qualified name. For example the class
HttpClient
has a log named org.apache.commons.httpclient.HttpClient
. Since all classes follow this convention it is possible to configure context logging for all classes using the single log named org.apache.commons.httpclient
.Wire Logging
The wire log is used to log all data transmitted to and from servers when executing HTTP requests. This log should only be enabled to debug problems, as it will produce an extremely large amount of log data, some of it in binary format.
Because the content of HTTP requests is usually less important for debugging than the HTTP headers, these two types of data have been separated into different wire logs. The content log is
httpclient.wire.content
and the header log is httpclient.wire.header
.Configuration Examples
Commons Logging can delegate to a variety of loggers for processing the actual output. Below are configuration examples for Commons Logging, Log4j andjava.util.logging.
Commons Logging Examples
Commons Logging comes with a basic logger called
SimpleLog
. This logger writes all logged messages to System.err
. The following examples show how to configure Commons Logging via system properties to use SimpleLog
.
Note: The system properties must be set before a reference to any Commons Logging class is made.
Enable header wire + context logging - Best for Debugging
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header", "debug");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");
Enable full wire(header and content) + context logging
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");
Enable just context logging
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");
Log4j Examples
The simplest way to configure Log4j is via a log4j.properties file. Log4j will automatically read and configure itself using a file named log4j.properties when it's present at the root of the application classpath. Below are some Log4j configuration examples.
Note: Log4j is not included in the HttpClient distribution.
Enable header wire + context logging - Best for Debugging
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%c] %m%n
log4j.logger.httpclient.wire.header=DEBUG
log4j.logger.org.apache.commons.httpclient=DEBUG
Enable full wire(header and content) + context logging
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%c] %m%n
log4j.logger.httpclient.wire=DEBUG
log4j.logger.org.apache.commons.httpclient=DEBUG
Log wire to file + context logging
log4j.rootLogger=INFO
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%c] %m%n
log4j.appender.F=org.apache.log4j.FileAppender
log4j.appender.F.File=wire.log
log4j.appender.F.layout=org.apache.log4j.PatternLayout
log4j.appender.F.layout.ConversionPattern =%5p [%c] %m%n
log4j.logger.httpclient.wire=DEBUG, F
log4j.logger.org.apache.commons.httpclient=DEBUG, stdout
Enable just context logging
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%c] %m%n
log4j.logger.org.apache.commons.httpclient=DEBUG
Note that the default configuration for Log4J is very inefficient as it causes all the logging information to be generated but not actually sent anywhere. The Log4J manual is the best reference for how to configure Log4J. It is available at http://logging.apache.org/log4j/docs/manual.html
java.util.logging Examples
Since JDK 1.4 there has been a package java.util.logging that provides a logging framework similar to Log4J. By default it reads a config file from
$JAVA_HOME/jre/lib/logging.properties
which looks like this (comments stripped):handlers=java.util.logging.ConsoleHandlerTo customize logging a custom
.level=INFO
java.util.logging.FileHandler.pattern = %h/java%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
com.xyz.foo.level = SEVERE
logging.properties
file should be created in the project directory. The location of this file must be passed to the JVM as a system property. This can be done on the command line like so:$JAVA_HOME/java -Djava.util.logging.config.file=$HOME/myapp/logging.properties -classpath $HOME/myapp/target/classes com.myapp.MainAlternatively LogManager#readConfiguration(InputStream) can be used to pass it the desired configuration.
Enable header wire + context logging - Best for Debugging
.level=INFO
handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
httpclient.wire.header.level=FINEST
org.apache.commons.httpclient.level=FINEST
Enable full wire(header and content) + context logging
.level=INFO
handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
httpclient.wire.level=FINEST
org.apache.commons.httpclient.level=FINEST
Enable just context logging
.level=INFO
handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
org.apache.commons.httpclient.level=FINEST
More detailed information is available from the Java Logging documentation.
delete outlook emails from a folder without move them to deleted items folder
select the emails that you want delete permanently, click shift+ delete,confirmed with yes,the the email will delete permanently from you folder.
Subscribe to:
Posts (Atom)