Win a copy of Rust Web Development this week in the Other Languages forum!

Ricky Murphy

Ranch Hand
+ Follow
since Oct 16, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ricky Murphy

Thank you guys for all your valuable suggestions. I learned a lot indeed.

-RickM
9 years ago

But to answer why it always matches.... the first ".*" will basically greedily take the whole string, leaving the negative look ahead to always not match (meaning succeed), and the last ".*" to always have a zero length match.



Thank you Henry. I will certainly give some thought on breaking it into two regexs. It sure will be more clearer for a later on revisit.

First of all, it is a negative look ahead. It is not a negative match..... ie. "(?!2008)" is not the opposite case of "(2008)".



You are right that the (2008) is not the opposite of (?!2008). Then, is the (?=2008) the opposite of (?!2008)? While ^A\d{6}((?!2008).)*$ gives me good negative filtering,
^A\d{6}((?=2008).)*$ does NOT give me any positive findings (I tried other combinations too, such as ((?=(2008)), etc.). Could you please help me on on this? I am not very clear on the look ahead mixed with the regular expression.

-RickM
9 years ago
Thank you Daniel and Henry.

I think that I know what I did wrong (but not why). I started with the "positive" comparison:
a). begins with A and followed by 6 digits
b). AND has the word 2008 in it.

So i ended up with regex: ^A\d{6}\s.*(2008).*$ and ( ^A\d{6}\s.*((2008).)*$ works too )

While above worked for me, I thought the (?!2008) would give what I originally wanted ( i.e. the regex: ^A\d{6}\s.*(?!2008).*$ ). Wrong, not the case, with added ?! I still got a match.

By comparing to your solution, you didn't have the "\s.*" in your regex. So i removed that from my version of the positive match. And the positive match stopped working. So, the conclusion, for a positive match, I need to have \s.* after{6}; while to do a negative match with ?!, I need to remove \s.* . Could you help me out why?

Not sure if I explained it clearly.

Thank you,

-RickM
9 years ago
I have been struggling to achive following by using regex in Java:

For example. if I have following 5 sentences:

1. A123456 some 2008 junk in my PC
2. A234567 another pile of 2008 junk
3. A345678 collected 2009 rocks
4. A456 got that in 2009.
5. A567890 sent me 3 letters.


What I want to achieve is: pick out the sentences that each should:
a). begins with A and followed by 6 digits
b). does NOT have the word 2008 in it.

This should give me sentence 3) and 5).

How do I construct a regex patten?

Greatly appreciate it

Thank you

-RickM

9 years ago
Thanks guys. It makes a lot of sense. I will take it forward and hope that I can break the mold...
9 years ago
Thank you Martin for the valuable analysis and suggestions. Let me provide more detailed background:

The java app are indeed utility kind, no user interface. Basically, each of those unix scripts calls the java app with a source and a target directory name. The java program searches the source directory and calls another web service to upload the files found in the source folder into the target directory in a document repository. The unix scripts, my java app, and the web service are located on the same unix box. The web service and the document repository are provided by a vendor. I only need to provide the java program to connect the unix shell scripts and the web service.

As you can see, depends on how many files found in the source directory, each call could last to 1 or 2 min, if not longer. Hence, if I start the jobs using: java MyApp arg1, arg2... chances are 300 jvm instances could run at the same time. I am not sure how big the overhead of having 300 JVM instances running at the same time, could you please comment on it? Or, what if I turn my java app into a web service (basically it means to wrap the vender service calls inside my service), 300 requests will therefore be handled by the app server, that means the app server will manage the 300 threads. I was originally trying to avoid another web app (i.e. web service), but let me bring it up for the discussion, it maybe the feasible approach.

As to your suggestion of have one job taking params from a text file, it wont fit the bill for my situation, because our jobs were created and configured with with different dependencies, In/Out conditions. etc (~300 is just the last step, as there are many more steps ahead it).

Thank you again,


RickM
9 years ago
Hello:

Trying to get some suggestions to resolve this issue: I have a set of 300 unix shell scripts (jobs) , each will pass in a set of parameters to a java program (the same java program) for further processing.

The first solution came to me was that I wrote a MyApp class with a main() method, then each of these unix shell script will call: "java MyApp param1, param2..." the problem of this is that it will launch too many JVM instances.

I am wondering is there a way that I only launch and use one JVM instance and all 300 calls become 300 threads? I thought about making a web app and deploy it to Tomcat. However, is there a way to avoid making it a web app?

Please shed some light.

Thank you.

RickM
9 years ago
Hello All:

I am using Axis2-1.4 to host my services. This service is protected using NTLM authentication scheme. In one use case, I need to call this service from another service. In 'Axis 1' days, I can create a NTLM credential and passed it to my stub (generated by wsdl2java) and in the mean time provide a client.wsdd file for client to specify the transport layer so that HttpClient can be used and problem is solved. However, how would I do this in Axis2-1.4 (my first version in Axis2 series)?

I searched the internet and there were some suggestions given but none seemed to be working well, plus, all seemed to be for older versions of Axis2. The places that I went were (http://wso2.org/library/161 and http://ws.apache.org/axis2/0_94/http-transport.html and, etc.). None of them really works for me. Could any one please make some suggestions, any samples that I can leverage? Thank you.

-Ricky
13 years ago
Thank you Balaji and Ulf.

I think that you kind of answered my question. let me rephrase it.

in Axis-1, there are basically two options to deploy a web service:
1. deploy axis.war into /webapps, so that axis is a regular web application. After I develop my own web service app, I can then loaded inside the "axis" app. that I just deployed. This way, I let "axis" app to manage my service. if I develop more services, I install them the same way into existing "axis" application. As you can see, "axis" application becomes an entry point to all my services.

This method is explained everywhere in Axis-2 service development and deployment.

2. The other way in Axis-1 is that I development my service app, say myApp, in myApp's lib directory, I put an axis.jar and other jars that axis-1 needs. After all the development is done, I deploy this myApp.war under /webapps, so Tomcat in this case will manage this myApp (i.e. my service app). If i need to develop more services then I do the same. therefore, under /webapps I may end up with many axis services, each one is a separate application managed by Tomcat, and inside each app's lib, you will find axis.jar and other axis needed jar file.

This method, in Axis-2, is not explained anywhere, at least I didn't see it, that was the reason I asked if I can do it this way, any document or examples that I can find out. The jar files in axis-2 seems to be a lot.

Yes, I have looked at the doc to integrate Spring with Axis-2 mentioned at the Axis web site. and that is also related to the method 1 above.

Thank you all and I hope this makes it more clearer.

Rick
13 years ago
Hello,

have been working with Axis-1 and trying to learn Axis-2. I am reading the Axis2 doc, etc. It looks like that I need to (at least it is advocated) deploy axis2.war into Tomcat first and all my future services will be deployed into axis2. That means axis2 app itself serves as an entry point for all services. However, in Axis-1, even this approach is valid, I may also develop my service app with axis.jar included as a ref library. I could then deploy myApp.war under Tomcat. is this kind of development/deployment approach still OK with Axis-2, any examples, especially work with Spring framework will be much helpful. Anyone please shed some light.

Thank you so much!!!

Rick
13 years ago
I am developing a set of web services methods for some admin users. now I need to add in some authentication and authorization to secure those methods. Now I have some performance concerns. Say when an admin is using the UI, every time this admin does a submit to a service method, the admin needs to pass through the authentication and authorization process. This seems to be chatty. I understand that web service should be designed to be stateless, but in order to reduce the times of the auth calls, shall I use session for this purpose? that means: when the same user tries to use those secured methods in the same session. He or she only needs to go thru auth once. What is the usual practice on this issue? I am using Axis 1.4 by the way with jdk 1.5.

Thank you.

Rick
[ June 21, 2008: Message edited by: Ricky Murphy ]
13 years ago
Trying to compare the advantage of a web service method returning complex type or xml string in different situations.

It looks more generic to return a xml string to represent the complex type object, but if so, what is the need to make a web service return a complex data type (i.e. a pojo, a bean). I know there must be some sort of judgment (depends on the use case) to pick either one, what is your standards to determine which approach to choose?

Thank you

-Rick
13 years ago

Originally posted by Henry Wong:


First of all, why "/"? Your example uses "#".

Second, take a look at the code again -- mine doesn't need to replace anything. It uses groups to extract the content in-between. (notice the group(1) call)

Thanks Henry. First of all, it should be # as I stated in my first post. what happened was after weekend, we started to deal with with "/" in a similar case. when I posted my code Tuesday, I changed the regex portion to comply with my original post but I forgot to change the "/" sign in the while loop.

Second, yes, you are right. the group(1) did it. This is my first time using the regex/pattern/match. my original understand on group() method was off. I did a further reading today and understand how to use number for group. Learned a lot. Thank you.


Henry

[ March 26, 2008: Message edited by: Henry Wong ]

13 years ago

Originally posted by Campbell Ritchie:
[Pedantic mode]There is no such thing as a multi-dimensional array in Java. What I suggested was an array of arrays.[/Pedantic mode]



Yes. Campbell. you are right. There is no "multi-dimensional" array in Java. array of arrays is the right term.
13 years ago
I am trying to see the difference between "applying a ReentrantReadWriteLock to a static method" and "applying a ReentrantReadWriteLock to a non-static method". I thought it should be the same, but somehow I thought it should have some difference. I got myself in a unclear state. Can anyone help me out? By the way, I defined these set of static methods in a cache utility class to add/remove/invalidate cache.

or this is a lower level question? what the pro and cons on static method comparing to regular method in a multi-threaded environment?

Thank you

-Rick
13 years ago