shwetank singh

Greenhorn
+ Follow
since Apr 02, 2007
Merit badge: grant badges
For More
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 shwetank singh

Thanks everyone!
perhaps i've another question for something similar..
does reflection also work with annotations and entities maintained by container. sorry i am unable to quote an example here for container managed entities with injected resources..i am still working on what i am trying to say here
12 years ago
Thanks Rob!
Yes i agree we can use a filter and then use the cascaded request object. The problem is, the architecture i am dealing with for this problem won't hand over the object passed this way (or any other manner).
i am specifically looking to implement injection based mechanisms for this. i think this request object can be derived from container and added to a state which can then be injected anywhere i wish to.
the problem is i am unable to figure that out : )
Much thanks for help!
12 years ago
Hello Ranchers!

Please help understand how can i use a custom annotation to inject ServletRequest into an object.
is this understanding i have correct? :
a) only resources managed by container can be derived or injected
b) if i define an annotation, i should have the annotation processor for it
c) i need something like:


where myAnnotation should be able to inject ServletRequest into myRequest

now,
1) is my understanding correct?
2) if it is, how to achieve this, how do i wire it together?
3) how is annotation state maintained?
4) can i guarantee each object will receive its own copy from container, with its association to servlet request?

please move the post to correct module, i can't see something dedicated to annotations.

help! : )
12 years ago
Thanks for suggestions!
i was able to solve this by using ANT tasks. used SCP task to move the jar file to server and then SSHEXEC task to execute the remote build.
thanks yet again!

shwetank
13 years ago
Sure..in case ANT can do it that will save me a lot of effort in writing the logic.
i didn't explore this part and will try as suggested..will post back success/failure in doing so!

Thanks!
13 years ago
Thanks Dittmer!
Yes i am writing an auto-build process for multiple projects to use same structure.
There is one ANT based script which executes after a jar has been created. This script, as i wish, should port the jar file to the server where i've written remaining part of build - for generating EAR (this part of build depends on various factors all of which are not known to me as they keep changing), and deploying on server.

The server is accessible through SCP and yes i can place files through WinSCP and similar tools.
However, i wish to understand how, if possible or if not then other ways; can i write this piece of logic, in any manner(be it code or not), with minimal dependencies on users generating the builds.
i dot want the users to worry about availability of an FTP server on target machine..all they should bother is to trigger build and it should generate jar > send it to server > where it's bundled in an ear > and is deployed.
i understand build tools and other approaches can do it but i don't have them at my disposal. How should i approach this then?
as i said, it may not be a very sane thought
13 years ago
Hi

I am not sure if this question has been asked on ranch..it would certainly have been but i can't find a suggestion around.

I have a jar file created from a project build. i wish to move it to a Unix server (where i'll generate an ear - merging this jar into a template ear; and then deploy it to a server).
There are perhaps many ways to achieve it including use of FTP etc. but we don't have one.

please suggest if this has a programmatic solution..can i think on lines of opening a server socket and using a socket to move this file to server (i am not sure if this is sane!..or would doing this not corrupt the jar?)..
please help!

thanks
shwetank
13 years ago
Hi Wouter
Thanks for reply!
Yes i completely misused the term override..i meant override the behavior.
as i explained, i've an annotation; that, suppose, declares version of the class it is applied to. what i wish to understand is, all possible ways to give a program, capabilities to change this version (or may be name X) to a desired value.
Yes i've not done much research on internals of annotations (but that is what i am trying to ask here ).
is this even possible?

thanks!
13 years ago
Hi

Please suggest how can a custom annotation be overridden
the annotation is restricted to be applicable to methods and is enabled to retain state over runtime.

annotation:
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ServiceResource {
public String version() default "1.0";
public String appId() default "AppSeq1";
}


Use:
public class ServicePreDefFactory {

@ServiceResource(version="2",appId="AppSeq2")
public Object lookupByName(String serviceName){
try {
<do something here>
} catch(Exception ex) {

}
return new String("status");
}
}

i've created a custom annotation @ServiceResource.
To keep the matter simple, there are only two attributes to this annotation i.e. version (default 1.0) and appId (default AppSeq1).
In the usage however, i've assigned version=2 and appId=AppSeq2. what i wish to understand is, what is the most simple way to override the annotation attributes and change them to, say, version=3; for some particular cases.
i am not sure if the example may sufficiently explain the need of doing so, yet i need a way to be able to modify the annotation attribute values on the fly.
one of the ways i know about is (and have used) somewhat like a class level authorizations can be changed in EJB3 by using deployment-descriptor for the beans (as the xml takes precedence over annotation directives issued in code).
is there a similar / more easier solution of doing this if i don't have potential to use frameworks and cant rely on xml configurations being available all the time

much thanks!
13 years ago
Hi Bear
Thanks for reply!
here is a background on where this question comes from:
i have an ear (having dynamic and static content) which has some jsp's that refer to images in below stated fashion (absolute path).
i have, to leverage upon powers of app server, moved the static content to a web-server and serve it from there.
this is done using plugins and directives used on webserver..an alias in httpd.conf tells the webserver...if a resource request comes with /context-root/... , it will be served by app server, or else the webserver can handle that (we can conveniently overlook this lest this becomes a question for server forums )

now to the problem..we already have so many jsp's having absolute path (url's to images/css etc.) that making a change everywhere is..what to say : )
and hence the question: can i refer to a static resource without using context-root?
>the image is remote.
>yes all resources will come from webserver and we can put them up into any structure in document-root.
>no this essentially is not a shorthand. i am trying to figure out a way to lookup a resource without actually referring to the context-root

please suggest further.
Thanks!!
13 years ago
JSP
Hi

This may sound absurd, yet i can use some thoughts here!
i've a jsp which has link to an image http://<server_ip>/context-root/largeImages/Collection/a.jpg
this will search and load an image a.jpg which should be under the context-root

what i wish to understand is,
a) is it possible, without changing this line of code, to somehow refer the image without context-root, if the image is not on same machine which has the servlet container?
b) if doing this is not possible without changing code, what changes should be brought about so that the image could be loaded provided hosting configuration stated above.

~ access the image as /largeImages/Collection/a.jsp and not /context-root/large...

please help!
thanks!
13 years ago
JSP
Hi Ranchers

this has gone above me and am unable to move past this rock..so any help is much appreciated..
i've an ear file and have split the ear into two..one part is a war file having only static resources (like images, html, etc.), the other part contains dynamic content.
i've deployed dynamic content (ear) onto a websphere instance and have moved the static-content war to a Sun One webserver installed on same machine.

i've, after this, created an Alias in httpd.conf file and have restarted the httpd service and the webserver too.

now to the problem:
a jsp refers to following URL:
https://<ip>:<port>/a/xhtml/large/basicxhtml.css

and my Alias is :
Alias /a/xhtml/large "/opt/webserver/docs/a/xhtml/large/"

the application has been deployed with context "/a" i.e. "<server ip>:<port>/a"

the page is unable to access the stated css file and error is:
com.ibm.ws.webcontainer.servlet.exception.NoTargetForURIException\: No target servlet configured for uri\: /xhtml/large/basicxhtml.css

which detail am i missing?..i've tried with all different Alias say, /a/xhtml/large and /xhtml/large/ etc.
i am able to directly hit the webserver and can view the css file by doing so, it is only so that the application server is unable to either redirect or find the resource!

please suggest!
thanks!
13 years ago
Thanks Rob!
got it:

String pattern = "<a[^>]*?href\\s*=\\s*((\'|\")(.*?)(\'|\"))[^>]*?(?!/)>";
System.out.println(m.group(1) + "<-- -->"+ m.start() + "<-- -->" + ss);

output :

'google.com'<-- -->6<-- -->hello link

will take those quotes out too..and the case when there are no quotes..will post back when done.

thanks..i did take the thought step by step..but did not write them down!..nice learning from you!
13 years ago
Thanks Rob for the useful insight..i tried doing all as suggested but can't crack it..tried:
removing the optional "(" or using an escape
using ?: --has already tried with this but can't get it to work
- require your opening quote using a back reference \\1 -- didn't actually get this

could you please suggest if the approach is correct or if it could have a simpler approach!

@Raymond: yes, i am trying to do the same. suggestions?

thanks!
13 years ago
Hi Ranchers!

Please help understand what may possibly be wrong with following:
error:thanks in advance!
13 years ago