annotations

Injecting a static EJB, nonsense?

走远了吗. 提交于 2020-01-19 05:51:47
问题 I want to write this piece of code : @Stateless public class MyEjb { @EJB private static MyOtherEjbWhichIWantStatic myOtherEjb; } It makes sense to me, that I want to inject an EJB in my class, as a static element, for various reason. Java is not very happy with that unfortunately com.sun.enterprise.container.common.spi.util.InjectionException: Illegal use of static field private static MyOtherEjbWhichIWantStatic myOtherEjb on class that only supports instance-based injection I don't get it,

@Transactional propogate transactions only for a few exceptions

笑着哭i 提交于 2020-01-17 12:13:40
问题 I am trying to make a transaction fail for all the unchecked exceptions except for a particular unchecked exception(in my case - DuplicateKeyException). How can I achieve this customization using @Transactional annotation of Spring framework ? Thank you! 回答1: Try the noRollbackFor option @Transactional(noRollbackFor=DuplicateKeyException.class) 回答2: Do it like this : public void driverMethod(){ try{ BeforeException() } catch(DuplicateKeyException e) AfterException() } @Transactional

how to dynamically download a file using struts 2 annotations (passing variable into annotation)

扶醉桌前 提交于 2020-01-16 19:07:02
问题 im new to struts 2 and im asking if there's a way to pass a variable argument into struts 2 annotation. here is what i already did but with no luck public class DownloadFileAction extends ModuleGenericClass{ private InputStream inputStream; private String fileName; @Action(value="/downloadFile",results={ @Result(name="success",type="stream",params = { "contentType", "application/octet-stream", "inputName","inputStream", "bufferSize","1024","contentDisposition", "filename=\"${fileName}\""}) })

how to dynamically download a file using struts 2 annotations (passing variable into annotation)

落花浮王杯 提交于 2020-01-16 19:05:51
问题 im new to struts 2 and im asking if there's a way to pass a variable argument into struts 2 annotation. here is what i already did but with no luck public class DownloadFileAction extends ModuleGenericClass{ private InputStream inputStream; private String fileName; @Action(value="/downloadFile",results={ @Result(name="success",type="stream",params = { "contentType", "application/octet-stream", "inputName","inputStream", "bufferSize","1024","contentDisposition", "filename=\"${fileName}\""}) })

Retrieving annotations from the same module

陌路散爱 提交于 2020-01-15 23:01:29
问题 Suppose I define my own annotation type: {-# LANGUAGE DeriveDataTypeable #-} module Def where import Data.Data data MyAnn = MyAnn Int deriving (Show, Typeable, Data) and some Template Haskell function to access it: module TH where import Def import Language.Haskell.TH.Syntax myAnn :: Name -> Q Exp myAnn name = do [MyAnn x] <- reifyAnnotations (AnnLookupName name) lift x I would now like to use it like this: {-# LANGUAGE TemplateHaskell #-} module Client where import Def import TH x :: () x =

Eclipse - Imported a project and Eclipse is giving me wrong @override method annotation errors

北战南征 提交于 2020-01-15 10:59:33
问题 I imported an Android project and it has a lot of @override method annotations, which Eclipse is complaining about (although the project has worked before and it should not be complaining). I'm using java sdk 1.7. Does anyone know anything about this? Thanks. 回答1: Are the overrides on interface methods or superclass methods? Interface methods can only be marked with this annotation as of Java 6. What is the compiler compliance level set to for your project? What about for Eclipse in general?

Java + Play Framework 2 with nested action compositions in the same class

你离开我真会死。 提交于 2020-01-15 09:09:10
问题 I was looking how to implement a filter in Play Framework 2 and, for the best of my knowledge, the best approach is to implement that using action composition. That said, I started doing some testing and I was able to make that to work. The only limitation is when I have nested annotations in the same class. My current use case Perform domain validation when domain parameter is present in the request. If the domain is not present in the local database, perform syntax validation only.

When overriding JacksonJsonProvider.writeTo, can I specify the view used to serialize?

你离开我真会死。 提交于 2020-01-15 09:01:22
问题 I have a setup with Resteasy-3.0.6, Jackson-2.2.3 and CDI (running on Wildfly-8.0.0.CR1). In my case, every entity has a mix-in class that extends it and specifies the attributes that are to be serialized. There are two "views", let's call them Basic and Extended . Since what kind of view of an object I need depends on the "root" object of the serialization, these views need to be per object. So I re-use the mix-in classes for that. Example: public class Job { @Id private Long id; @OneToMany

iOS Mapkit - Annotations disappear on map scroll/zoom

扶醉桌前 提交于 2020-01-15 06:36:27
问题 On initial load, the annotations show just fine. But if I scroll the map, they all disappear and the code is only called for the user location, not the other annotations in the viewForAnnotation delegate method. Plot Pins -(void)viewDidLoad{ ...Download Coordinates and Data from Web here... [self.mapView addAnnotation:pin]; } Delegate Method - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { //Player's Pin if([annotation class] ==

Multiline annotation: problem with num2str

两盒软妹~` 提交于 2020-01-15 06:27:09
问题 I expect the text in the textbox to show up as: Simulation parameters: Number of loops = 500 Number of subcarriers = 12 Number of frames = 5, MT = 2, MR = 2 % or MR x MT = 2 x 2 I have code written as: txt = {'Simulation parameters: ','Number of loops = ', num2str(loops_num),'Number of subcarriers = ',num2str(Nfft),,'Number of frames = ',num2str(K),'MT = ',num2str(MT),'MR = ',num2str(MR)}; text(4,0.5,txt,'FontSize',12) And I got: 1) How to fix it? ( Number of subcarriers = 100 , etc need to