Allow to create, only two objects for a class
Hi,
This question is asked in my interview. In singleton concept only one object is created, likewise only two objects are created for a class.
For that i have write a code like this,
public class OnlyTwoObjects {
private static OnlyTwoObjects a1;
private static OnlyTwoObjects a2;
public static int n = 0;
public static OnlyTwoObjects getInstance() {
if (a1 == null) {
a1 = new OnlyTwoObjects();
return a1;
} else if (a2 == null) {
a2 = new OnlyTwoObjects();
return a2;
} else if (n == 1) {
return a1;
} else if (n == 2) {
return a2;
return null;
} But they told this is not good way to do this.
I don't know how to do this, if any body knows kindly let me know.
vijay wrote:
But i will explain my code, in that code we are allowed to create only two objects, Maximum. Understood.
suppose both objects are created, then i will ask which object you need first or second, this is decided using the variable n if it is 1 then it will return the first object and it is 2 it will return the second object. sorry i didn't explain this in my previous post.This is your approach. Is this the requirement as well? Is it necessary that the user decide on which instance (first or second) is returned?Even if it was the requirement that the user decides which instance (first or second) is returned, with the original proposed implementation, the user only gets to decide which instance after calling getInstance() twice. If he calls getInstance() with n=2 when a1 is still null, he still gets a1. If he calls getInstance with n=1 when a2 is still null but a1 is non-null, then he gets a2. As is, he always gets a1 on the first call, a2 on the second call, and after that gets null unless he has set n to 1 or 2. (This explanation ignores any multi-threading issues that may come into play. This explanation is for a single thread.)
Similar Messages
-
Create object for a class in jar file
Hi
I am using Oracle JDeveloper 10g. I have created a main application using Swing/JClient technologies. I am facing a problem for the past one week. I let u all people know my problem and I kindly request you to send a solution if known possibly confirmed.
Problem: I have created a main application using swing that class extends JFrame. This main application consists of two parts. One left side panel and one right side panel. Left side panel contains JTree component. Each item in that tree refers to a class file located in a separate jar file.i.e that acts as a separate application. If we are executing separately that jar file class, I am able to see that small application running. If I am selecting an item in JTree during runtime, I should place that small application from the respective jar file in the right side panel of the main application. I can locate the jar file and even I can create object to that particular class file. But I cannot execute the application even separately and also not able to place in the right side panel of the main application.
Note: The small application from the jar file contains one class file containing main method. That class file extends JPanel and implements JUPanel. i.e., with data binding. I am trying to create an object for this class file with data binding from my main application. Navigation bar is used in the main class file.
If possible can any provide me solution at the earliest. Waiting eagerly for the positive reply.
Regards,
s.senthilkumarCan you sure that there is only a A class in the classpath of Tomcat, I advise you to add
some statements into the A class so that you can be sure which classloader is used
to load the A class. -
Create a business object for a Maintenance object
Hello,
I want to create a business object for a maintenance object to change all XML attributes to XML elements.
Should I have to change the whole XML Schema from attributes to elements one by one?
For example, I create the business object CM_Person_BO for the maintenance object Person, and use the business object to add user in a more standard way.
But it is a quite large job to rewrite the whole schema for the maintenance object Person, which has following elements, which are PersonIdentifiers, PersonNames, PersonPhones, PersonCharacteristics, Person and SeasAddress.
Is there any easy way to do it?
Thanks,
KerrShould I have to change the whole XML Schema from attributes to elements one by one?
Is there any easy way to do it?Unfortunately not, you will have to define the schema containing each field/element, once. The primary objective is that you should create a scaled down version of the BO having only the required fields or subset of available fields, you may not need all the fields of a MO. This increases performance as the IO is performed only for specified fields in the BO.
You can define separate Data Areas for each Person object's context, i.e. Identifiers, Names, Phones, etc. and include them (includeDA) within the Person BO (CM_Person_BO) for clarity. -
TimesTen Release 11.2.1.9.6 (64 bit Linux/x86_64)
Command> dssize;
PERM_ALLOCATED_SIZE: 51200000
PERM_IN_USE_SIZE: 45996153
PERM_IN_USE_HIGH_WATER: 50033464
TEMP_ALLOCATED_SIZE: 2457600
TEMP_IN_USE_SIZE: 19680
TEMP_IN_USE_HIGH_WATER: 26760
Is there any command/query/etc, which would allow to understand what database objects (for example tables) are consuming memory and how much of it?
tried to use ttsize function, but it gives some senseless results – for example, for the biggest table, tokens, it produces following output (that this table is 90GB in size – what physically cannot be true):
Command> call ttsize('tokens',null,null);
< 90885669274.0000 >
1 row found.Are you able to use the command line version of ttSize instead? This splits out how much space is being used by indexes (in the Temp section of the TT memory segment), which I think is being combined into one, whole figure in the procedure version of ttSize you're using. For example:
ttSize -tbl ia my_ttdb
Rows = 4
Total in-line row bytes = 17524
Total = 17524
Command> create index i1 on ia(a);
ttSize -tbl ia my_ttdb;
Rows = 4
Total in-line row bytes = 17524
Indexes:
Range index JSPALMER.I1 adds 5618 bytes
Total index bytes = 5618
Total = 23142
Command> call ttsize ('ia',,);
< 23142.0000000000 >
1 row found.
In 11.2.2 we added the procedure ttComputeTabSizes which populates system tables with detailed table size data, and was designed to be an alternative to ttSize. Unfortunately it still doesn't calculate index usage though, and it isn't in 11.2.1. -
How to create a new object for a particular class?
Hi,
Can anybody please tell the steps for creating a new object for a particular class.
Thanks,
SreejaDeclare the object as TYPE REF TO the class and use the CREATE OBJECT statement to create an object.
DATA <obj_name> TYPE REF TO <class_name>.
CREATE OBJECT <obj_name>.
Please mark points if the solution was useful.
Regards,
Manoj -
TestStand create different object for singleton class
Hi all,
we have a singleton class which has some functions used to do testing a harware.
Our main Exe will create an object for that singleton class(which opens Com1 port and communicate with hardware). so the Exe will do basic communication test with hardware it is working well. We are using Teststand operator interface to do various testing by using sequence files. Main exe will use teststand usercontrols to execute tests when the user clicks Testbutton. after that, teststand try to create an object for that singleton but it returns new object not the existing one which is created by EXE. So it throwing me exeception "Com1 port access denied." (since we created object for signleton class @ very first in EXE)
My question is Since that teststand runs in a separate Appdoamin will the singltonclass create separate object for different appdomain? if so is there any solution to reslove this?
Hope i clearly explained my probs.
Thanks in advance
SriniHi Srini,
How are you calling the executable? From a Call Executable step? Or are you using another means of calling it? Also, why is TestStand trying to recreate the object? As long as you have the correct handle to the object I don't think it matters what app domain you are in.
Regards,
jigg
CTA, CLA
teststandhelp.com
~Will work for kudos and/or BBQ~ -
System should create only one delivery for 100 different PO's in STO
Hi All
i need help
Plant B raising 100 different po's daily for different materials to Plant A.(STO)
Now Plant A will do Dilivery via VL10B.
Here my requirement is system should create only one delivery for 100 different PO's and delivery should contain all the
materials as line items bcause system should not create 100 deliveries( time consuming process).
Here there is no manual transaction for VL10B.
That is system is goining to excecute the VL10B automatically, there is no manual transation for VL10B
How can we do this?
Thanks
MSKHi
We can able to do your requirement
1. All the STO materials should have same sales view in materials for the *Unique)following field: Loading group, shipping Point, so on..
2. In the config, hope we have do the combine delivery setting for VL10B
Regards
Prasanna
Edited by: Prasanna Raju on Feb 17, 2010 1:52 PM -
Creating Multiple Resource Objects for OOTB Connectors
All,
I am trying to create a second AD User resource object for the OOTB connector. I would like to think that the AD Connector (and all connectors, for that matter) was designed to handle the creation of multiple Resource Objects for the same Resource Types, but am I wrong? It doesn't seem like the OIM Connector can handle this easily.
Has anyone created multiple resource objects for a connector? Is this a fairly simple task, or will it require a large effort? Is it even possible? Any pointers?
Thanks!I will provide a little help with the duplication. I found the best way to do it is to import the original connector. Go through the different pieces making each one have a unique name, that is not part of any of the other piece names. You need to have unique names for the following:
1. Resource Object
2. Process Definition - Provisioning
3. IT Resource
4. Form - Process
5. Scheduled Task
After you import the connector, rename each of the following to something unique. I would also update your process form to have a default value of your IT Resource, as well as your scheduled task values to point to the new unique names. Export the 5 items, no dependecies. The adapters will all be the same. Use find and replace for the values and then import the new XML. If it works, duplicate the XML for each of the new workflows you want to create.
-Kevin -
Maximum no'of Objects for one class
Hello friends
Please, tell me....Maximum no'of Obects for One Java class.
Thanks & Regards
S.RajakrishnaIs there any limit of creating the objects for One class?Instantiated objects go into the heap. There is only one heap for the whole JVM. There is no correlation between objects in the heap and the individual class files.
100,000 objects may or may not fit into the heap. In general they probably will. If you don't, then yes, you'll get an Out Of Memory exception.
Regardless there is no excuse for loading 100,000 objects just to render a JSP! You don't imagine your user is going read all of them do you? Restrict them to the number of objects that the user is actually going to be able to handle at any given time.
You can do this by putting WHERE clauses on the hibernate query, and/or by setting limits (setFirstResult and setMaxResult) on the Query object before listing it. -
HI, I'm having problems initializi​ng object for CNiFgen class.
Hello, I'm having problems initializing object for CNiFgen class, I declare a pointer *m_pFgen to the CNiFgen class, then m_pFgen = new CNiFgen(m_driver, true, true) and then it gives me an error message Primary Error: (Hex 0xBFFA000C) Invalid attribute.
Here is how to make a call to initialize a session to niFgen:
//Create a new session on the device
_session = new CNiFgen(m_resourcename);
Also. I'm attaching an example on how to generate standard waveforms with the class interface for Fgen.
Let me know if you have any other questions,
Jack Arnold
Applcation Engineer
National Instruments
Attachments:
niFgen_Function_Generator_Ex.zip 5569 KB -
How to create a file object for a file on Remote Server? UNIX
Hi all,
I am working on two servers A and B. BOTH ARE UNIX MACHINES. My java class exist on server A and executes on same server. The file that I need to process resides on server B. (Lets call it test.txt in MYTEST directory. So path will be /MYTEST/test.txt on server B) I need to do few things before I can process it:
1) Check if file exist
2) If it does FTP it to Server A. (I already know how to.)
For both of these tasks, I need a File object for that file.
My problem is that I am unable to set it up.
\\B\MYTEST\test.txt will not work on UNIX. I already tried that. (It only works on Windows)
I tried:
/B/MYTEST/test.txt ---- Does not work
B:/MYTEST/test.txt ---- Does not work
:B/MYTEST/test.txt ---- Does not work
B:MYTEST/test.txt ---- Does not work
All of these instances say the same thing: "File does not exist."
Any ideas? Please help!!!
-ChiragI by no means want to sound belittling... so don't take me that way..
You need to understand the basics of files, and networks. You can't check if a file exists on another machine if you don't have a network protocol to communicate with. The reason \\ works under windows is because you are using an invisible (to you) network protocol. You probably know it as windows sharing. If your file were not shared under it's own name, that method wouldn't work (I'm assuming your entire drive is shared without a password... a horrible security flaw...but one thing at a time)
You can use FTP protocol to check if a file exists. You can either send the raw text FTP commands through a socket connection in java, or you can use a freely available FTP java API to make it a bit more simple. You could also write a small java server on the other machine, and have it tell you what you need to know with a socket connection. In this way, you have created your very own network protocol. -
Error while creating a system object for R3 in portal
Hi,
I am getting error while trying to create a system object in portal.
Following are the details I used :
Under WAS...
Web AS Host Name :<XXXX>:8001
Web AS path: /sap/bc/bsp/sap/
Web AS protocol : http
Under User management:
Authentication Ticket Type : SAP Logon Ticket
Logon Method :SAPLOGONTICKET
User Mapping Type : admin,user
Under Connector:
SAP Client : <Client NO>
SAP System ID : <System ID>
SAP System No : <System No>
System Type : SAP_R3
While trying with connection test... I am getting like this:
SAP Web AS Connection
Test Details:
The test consists of the following steps:
1. Checks the validity of system ID in the system object.
2. Checks if the system can be retrieved from the PCD.
3. Check whether a SAP system is defined in the system object
4. Validate the following parameters: WAS protocol; WAS host name
5. Checks if the host name of the server can be resolved.
6. Pings the server to see if it is alive.
7. Pings the WAS ping service; works only if the service is activated on the ABAP WAS.
8. Checks HTTP/S connectivity to the defined back-end application
Results
1. The system ID is valid
2. The system was retrieved.
3. The system object represents an SAP system
4. The following parameters are valid: Web AS Protocol (http) Web AS Host Name (<FQDN server name>:8001)
5. The host name <FQDN Server Name> was resolved successfully.
6. The server sapdwh01 could not be pinged successfully.
Test Connection with Connector
Test Details:
The test consists of the following steps:
1. Retrieve the default alias of the system
2. Check the connection to the backend application using the connector defined in this system object
Results
Retrieval of default alias successful
Connection failed. Make sure that Single Sign-On is configured correctly
It seems that the portal is not able to ping to R3 system. I tried to ping to R3 server from portal server by command prompt. I am able to ping. Also under SICF, I can see ping service as in activated state.
Kindly help.
Regards,
Niraj
Edited by: Niraj Kumar on Dec 11, 2008 10:41 AMI created a SAP Transactional iView for transaction SE80.
Also, I tried from under System Administration -> Support -> SAP Transaction. It is not working.
Got portal Runtime error :
Portal Runtime Error
An exception occurred while processing your request
Exception id: 12:57_11/12/08_0003_2795650
See the details for the exception ID in the log file.
Regards,
Niraj -
How to create new authorisation object for Transactions?
Hi,
How to create new authorisaton object and how to assign that object on a transaction code?
Case ->
The transaction code VL01N have the object called V_LIKP_VST under Class "LE_V" that have two auth. fields. one is 'Activity' and other one is "Shipping Point/Receiving Point".
Here I want to add "Storage location" also. I have created one object called "Z_LIKP_VST" under same calass "LE_V". and added "Activity", "Shipping Poing/Receiving Poing" and "Storage Location". After that I added that object ("Z_LIKP_VST") for particular transaction through "SU24". I maintained the "Display check indicator" for VL01N.
I created one new role and assigend the particular transacation for a user. but still SAP taking V_LIKP_VST insted of Z_LIKP_VST.
How can I change my Z_LIKP_VST on profile.
Please help
Thanks in Advance
LalHi Kariyath,
I suppose its not about interest but a MUST.. sorry but.. unless u include the Logic in the program how can SAP pick these custom Z objects ?
after u create them and assign to a Tcode in SU24 there is no logic to check these objects. Frankly i see no other chance.... unless SAP comes to us with a great easy way to input these Custom objects
Keep looking and please Update me if u have any Inputs....on this front..
All the Best
Br,
Sri
Award points for helpful answers -
Problem in creating time series objects for a planning area
Hi Friends,
I am working on SCM 4.0 APO. I am trying to create the time series objects for a 'Z'planning area which i have created. This Planning area is linked to a planning object structure which contains only three characteristics 9amatnr,9alocno & zplnpart. But the creation of time series objects is taking a long time. the screen just remains the same.
Can anybody encountered such a problem any time?
request you all to put some light as what could be wrong or causing the delay in creating them???
All helpfull answers will be suitably rewarded.
Thanks
mvdHi mv d,
I have a couple of questions:
1) how many Key Figures does your planning area have?
2) what is the length of your time series horizon?
3) how many characteristic combinations are currently in the Planning Object Structure? and how many newly character
I am asking because these aspects might affect the running time of the time series creation. Have you also tried creating the time series in the background? How long did it take there? -
How to create custom BOL object for dynamic query in CRM 7.0
Hi,
Could anyone please explain me with steps that how to create the custom BOL object for dynamic query in CRM 7.0, I did it in previous version but its throwing exception when i try to create the object of my dynamic query class. I just defined the entry of my in crmv_obj_btil to create the dynamic query BOL object. do i need to do any other thing also to make it work?
Regards,
Kamesh Bathla
Edited by: Kamesh Bathla on Jul 6, 2009 5:12 PMHi Justin,
First of thanks for your reply, and coming to my requirement, I need to report the list of items which are there in the dynamic select statement what am getting from the DB. The select statement number of columns may vary in my example for different countries the select item columns count is different. For US its '15', for UK it may be 10 ...like so, and some of the column value might be a combination or calculation part of other table columns (The select query contains more than one table in the from clause).
In order to execute the dynamic select statement and return the result i choose to write a function which will parse the cursor for dynamic query and then iterate the values and construct a Type Object and append it to the pipe row.
Am relatively very new for these sort of things, welcome in case of any suggestions to make it simple (Instead of the function what i thought to work with) also a sample narrating the new procedure will be appreciated.
Thanks in Advance,
mallikj2.
Maybe you are looking for
-
PowerMac G4 FireWire 800 freezes/crashes-post modification 300GB drive
wondering if anyone one had any insight into this problem: I recently installed a 300GB internal drive into my G4, running on the same carrier as the one that came with the computer, both on the ATA/100 bus, the rear carrier. The system software and
-
The solutinons to value mapping during exchanging
Howdy! Here's the general senario: We got a 3rd party system named KS and a local R3 system called RS. We have a interface that send invoice data from KS to RS. But the customer number from KS is different from RS customer number, so we need not noly
-
What to enter in Group Authentication ?
Hi People, I am connecting to the server however, i am entering the host as what i know. What do i need to enter in group authentication??
-
Conditions is not displaying the required result
Hi Experts i have a query with Key figure (calculated on query level) No of days and i have created a condition with characterstic assignment all chars and created a condition on this key figure no of days, eventhough i have enough values which satis
-
Vertex, Sabrix and Taxware?
Hi What is the difference between the 3 external tax engines - Vertex, Sabrix and Taxware? Is there any difference as to which countries are these tools valid? Thanks SV