473,563 Members | 2,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

It is necessary that the code displays all objects

10 New Member
I wrote the code, but it displays only one object when loading, with the rest there is difficulty. Who faced similar situations, how did you solve similar situations?
And I also want to conduct a full code analysis in order to see all the errors at once, and not when loading the application into work. Are there any services?
Expand|Select|Wrap|Line Numbers
  1. public Bean inject(Bean obj) {
  2.         File file = new File("src/main/resources/data.properties");
  3.         Properties properties = new Properties();
  4.         try {
  5.             properties.load(new FileReader(file));
  6.         } catch (IOException e) {
  7.             throw new RuntimeException(e);
  8.         }
  9.         Field[] fields = obj.getClass().getDeclaredFields();
  10.         for (Field field : fields) {
  11.             field.setAccessible(true);
  12.             if (field.isAnnotationPresent(AutoInjectable.class) && field.getType() == FirstInterface.class) {
  13.                 try {
  14.                     Object someObject = null;
  15.                     try {
  16.                         Class<?> clazz = Class.forName(properties.getProperty("FirstInterface"));
  17.                         try {
  18.                             someObject = clazz.newInstance();
  19.                         } catch (InstantiationException e) {
  20.                             throw new RuntimeException(e);
  21.                         }
  22.                     } catch (ClassNotFoundException e) {
  23.                         throw new RuntimeException(e);
  24.                     }
  25.                     field.set(obj, someObject);
  26.                 } catch (IllegalAccessException e) {
  27.                     throw new RuntimeException(e);
  28.                 }
  29.             }
  30.             if (field.isAnnotationPresent(AutoInjectable.class) && field.getType() == SecondInterface.class) {
  31.                 try {
  32.                     Object someObject = null;
  33.                     try {
  34.                         Class<?> clazz = Class.forName(properties.getProperty("SecondInterface"));
  35.                         try {
  36.                             someObject = clazz.newInstance();
  37.                         } catch (InstantiationException e) {
  38.                             throw new RuntimeException(e);
  39.                         }
  40.                     } catch (ClassNotFoundException e) {
  41.                         throw new RuntimeException(e);
  42.                     }
  43.                     field.set(obj, someObject);
  44.                 } catch (IllegalAccessException e) {
  45.                     throw new RuntimeException(e);
  46.                 }
  47.             }
  48.         }
  49.         return obj;
  50.     }
Nov 25 '22 #1
0 6779

Sign in to post your reply or Sign up for a free account.

Similar topics

8
3937
by: Irmen de Jong | last post by:
What would be the best way, if any, to obtain the bytecode for a given loaded module? I can get the source: import inspect import os src = inspect.getsource(os) but there is no ispect.getbytecode() ;-)
2
2208
by: Jonathan LaRosa | last post by:
Hi all - I'm wondering if anyone has (or knows of) a tool that will allow me to search through VB code, tables, queries, reports, forms, and other objects, for references to all other types of objects. That's not really that clear, so here's an example: If I have a table named...
2
1103
by: **Developer** | last post by:
I've been asking about a Menu problem I have without results. So here is a test case I've developed that shows the problem. Simply create a soultion with one project containg one form and replace the form code with this. Run it, right click and select Edit/Paste Special/Test1 Then try to do that again
8
4458
by: Wilbur Slice | last post by:
I need to write some VB.NET objects that can be called from another environment (a Progress app, specifically). I'm having some difficulty getting this to work. My first assumption was that I should write a COM object. Is this a good approach? Or is there a better one? I wrote the new VB.NET object and included a COM Class object. All...
5
1076
by: Doug Wright | last post by:
Hi The code in question is available from http://mozilla.pastebin.com/596645 Any help would be extremly appreciated, because I've spent many hours on trying to figure this out!!
0
2189
by: ftech | last post by:
I am saving PDF files in SQL Server 2005 as an image and retrieve them back by their document ids. I use the following code: byte buffer = (byte)dtDoc.Rows; if(buffer != null) { Response.ContentType =
1
1969
by: teddysnips | last post by:
I'm collaborating on a project with a colleague, sharing files through SourceSafe. So, I run GetLatestVersion and suddenly I have 264 build errors - all "Unexpected character" The file in question is Myfile.Designer.cs and contains a number of rows looking like this: /// <summary਍ഀ
1
1176
by: Vbbeginner07 | last post by:
The follwing code is of a listview where i have to a to display the id and the name from a particular table ,empdetail. This is in the second form,dispalying id and name Private Sub Form_Load() ListView1.View = lvwReport ListView1.ColumnHeaders.Add , , "NAME" ListView1.ColumnHeaders.Add , , "ID" ListView1.Refresh rs.Open "select * from...
2
2176
by: Bongani Mgibi | last post by:
Hi guys please see attachment code, the code displays well with all browsers except with IE 8, if you guys can copy and paste then open it with IE then try opening it again using another browser you will see how it displays what please check and advice. <Mod edit: Code from attachment posted below. --Atli> <!DOCTYPE html PUBLIC...
2
3012
by: tmarynell | last post by:
I have created an SPC chart in Access. I need specific details of each data point wihtin the line graph to display when you hover over or double-click on the specific data point. It should include the data point value and which test was failed if out of spec. The data resides in a table. I am looking for the VBA code that will perform this...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.