annotations

Annotation as shortcut for another annotation?

拈花ヽ惹草 提交于 2020-01-04 05:30:46
问题 How can I create an annotation, such as @DateOutput that is equivalent with another Jackson annotation, such as: @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone="UTC") Or ideally, to a set of annotations, such as @JsonSerialize(using = XSerializer.class) @JsonDeserialize(using = XDeserializer.class) 回答1: You can use @JacksonAnnotationsInside as a annotation container like follows: @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD,

Struts2 token interceptor in annotation

耗尽温柔 提交于 2020-01-04 04:40:12
问题 I'm using struts 2.3.1 with token interceptor.How can i use token interceptor in annotation(convension) based Action Class. here is My struts.xml <action name="tokenAction" class="roseindia.action.TokenAction"> <interceptor-ref name="token" /> <interceptor-ref name="basicStack"/> <result name="success" >/success.jsp</result> <result name="invalid.token">/index.jsp</result> can any one please tell annotation based for the same. 回答1: It looks to me like this is fairly clear in the documentation

Abstract classes, interfaces and Autowired

自古美人都是妖i 提交于 2020-01-04 03:57:30
问题 I have the following main class: public class Startup implements UncaughtExceptionHandler { @Autowired private MessageListener messageListener; private static Startup startup; public static void main(String[] args) { Startup start = new Startup(); start.init(args); } public void init(String[] args) { context = new ClassPathXmlApplicationContext("applicationContext.xml"); startup = (Startup) context.getBean( "startup" ); startup.start(); //here the messageListener is used } // here goes the

Embedded Jetty does not find Annotated Servlet

假如想象 提交于 2020-01-04 03:50:14
问题 Short: I have a project that provides a war artifact which includes a servlet with annotations but no web.xml. If i try to use the war in jetty i always get only the directory listing of the war content but not the servlet execution. Any idea? Long story: My servlets look like this package swa; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet

Is there a way to hide annotations in Netbeans or Eclipse?

陌路散爱 提交于 2020-01-04 03:16:30
问题 Maybe a dumb question, but it would be nice if there was a way to hide or collapse Java annotations when viewing source in Netbeans (or Eclipse). I'm not finding an option and a quick search didn't turn anything up. Is this one of those "you should never want to do that, code folding is a sin!" things? Personally I'd find it useful for annotated entity classes. All the hibernate / etc annotations are just fluff that I never look at once my mapping is working fine. It's similar to imports,

@Schedule annotation in Java EE

丶灬走出姿态 提交于 2020-01-04 02:57:29
问题 I use the following annotation to call a stateless session bean once a 5 minutes: @Schedule(second = "0", minute = "0/5", hour = "*") I works as expected, except it stops itself after a few days. I guess there may be a default lifetime and I do not know how to override it. Please help me to configure the scheduler to run indefinitely. 回答1: to know if there is expiration date for your object you can use getTimers() to return an object of that timer then use this method getTimeRemaining() to

What is annotation to override transaction timeout?

不羁的心 提交于 2020-01-04 02:34:06
问题 New to EE - trying to reconfigure Weblogic's default timeout of 30 seconds without having to write up a weblogic-ejb-jar.xml file. I've used only annotations now but the only thing that I have seen is in the DD here: <transaction-descriptor> <trans-timeout-seconds>1200</trans-timeout-seconds> </transaction-descriptor> Anyway to avoid have a descriptor file just for this? 回答1: I feel weird answering my own question but someone at work found this annotation. @ weblogic.javaee

jaxb @XmlIDREF @XmlID work amazingly

倖福魔咒の 提交于 2020-01-04 02:32:24
问题 jaxb @XmlIDREF @XmlID work amazingly my xml input is <dept> <courses> <course id="1" units="4" level="UNDERGRAD" name="Fundamentals of Programming"/> <course id="2" units="3" level="UNDERGRAD" name="Advanced Programming"> <pre>1</pre> </course> <course id="3" units="3" level="UNDERGRAD" name="Discrete Mathematics"> <pre>1</pre> </course> <course id="4" units="3" level="UNDERGRAD" name="Data Structures"/> <course id="5" units="3" level="UNDERGRAD" name="Database Systems"> <pre>4</pre> <pre>2<

Setting scan.all.resources for Swagger in JAXRS

空扰寡人 提交于 2020-01-04 02:22:27
问题 I am using plain vanilla JAXRS in a provided Application Server with Swagger 1.5.18. I can get the Swagger annotated classes to appear in the swagger.json , but I am having trouble setting the Swagger to scan for non annotated classes, those with just the @Path JAXRS annotations. I currently have the BeanConfig in the Class that is extending Application . I tried using a Servlet that extended DefaultJaxrsConfig with @WebInitParam(name="scan.all.resources", value="true") but that did not work

Can't get annotations from classes loaded by custom classloader in tomcat

 ̄綄美尐妖づ 提交于 2020-01-03 17:25:08
问题 Given the class org.popper.example.pages.Login @Page(name="Login") public interface Login { } exported to c:\pos\example.jar and the following servlet public class PopperServlet extends HttpServlet { private static final long serialVersionUID = 1L; public static void main(String[] args) throws MalformedURLException, ClassNotFoundException { URLClassLoader ucl = new URLClassLoader(new URL[] {new File("c:/pos/example.jar").toURI().toURL()}); System.out.println(Arrays.asList(ucl.loadClass("org