Is it possible to restrict the object creation for stateless session beans

Hi,
Is it possible to restrict/fix the ejb object creation for stateless session beans in application server?
For example, i want to configure the application server ( am using JBOSS ) to create maximum of 10 session bean objects. and if any requests for the stateless session bean come, as application server has created 10 objects, the requests should be blocked.
Thanks in advance,
nvseenu

You can keep a counter in the application code. A static var won't work, but an entity and a consistent id should. This version would affect performance, but it would be portable to other app servers.
// ConstrainedBean.java
package unq.ejb;
import javax.ejb.Stateless;
import javax.ejb.CreateException;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.persistence.PersistenceContext;
import javax.persistence.EntityManager;
@Stateless
public class ConstrainedBean implements Constrained {
    final static int DEFAULT_COUNTERID = 1;
    @PersistenceContext EntityManager em;
    @PostConstruct
    protected void init() throws CreateException {
     ConstrainedBeanCounter counter =
         em.find(ConstrainedBeanCounter.class, DEFAULT_COUNTERID);
     if( counter == null ) {
         counter = new ConstrainedBeanCounter();
         counter.counterId = 1;
         counter.counterValue = 0;
         em.persist(counter);
     if( counter.atMaximum() ) {
         throw new CreateException("error attempting to create > 10 beans");
     else {
         counter.increment();
    @PreDestroy
    protected void destroy() {
     ConstrainedBeanCounter counter = em.find(ConstrainedBeanCounter.class,
                               DEFAULT_COUNTERID);
     counter.decrement();
    public void doSomething() { System.out.println("doSomething()"); }
// ConstrainedBeanCounter.java
package unq.ejb;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class ConstrainedBeanCounter implements java.io.Serializable
    @Id public int counterId;
    public int counterValue = 0;
    public void increment() {
     counterValue++;
    public void decrement() {
     counterValue--;
    public boolean atMaximum() {
     return counterValue > 9;
}

Similar Messages

  • How to restrict the news creations for members of the collaboration room

    Hi all,
    I have created a Project Room in collaboration and assigned members to that
    room.I need to restrict the room members from creating the news and folders.
    And also only Owner/Admin of the room should be able created the news and
    folders and members should be able view the news and folder
    One more query,i need to remove the room parts which are by default selected
    for that room when select the default templates.
    Can anyone please give me the solution on the above queries.
    It will be very much helpful for me to create collaboration rooms with the
    restricted permissions.
    Thanks in advance.
    PonnusamyP

    Hi Sascha,
        Here I am explaining what is my requirement.
        I have created collaboration room and added room admin and members to the
        room.
        Then in the room maintaince -> I have added the room parts as
         News(private) and the role I have assigned to member.
         When login into portal with the member login and go to the news in the
          collaboration room, member is getting the permissions to add/create news.
          At this point  I want to restrict the members of the collaboration room to view
          the news and only admin of the room should be able to post the news.
          how to go ahead for the above senario.
    Thanks
    Ponnusamy

  • Transaction F110 - Possible to restrict the input of Identification-field?

    Hello all,
    is it possible to restrict the input of the "Identification"-field in transaction F110 (Automatic Payment Transactions: Status)?
    e.g.: User X with company code XX is only allowed to enter XX01 in the identification field.
            User Y with company code YY is only allowed to enter YY01...
    Is that possible?
    Thanks in advance for any reply!
    Steffen
    Message was edited by:
            Steffen Poetsch

    Hi
    You can control the "identification" with the help of the BASIS guy.
    They will define the authorization object to field level.
    Create seperate roles for that and assign accordingly
    VVR

  • Is it possible to restrict the user from creating a sibling and allow him to ONLY create child nodes in DRM?

    When in a hierarchy, a user right clicks on a node to crate a new node, he has two options
    -Child
    -Sibling
    Is it possible to restrict the user from creating a sibling and allow him to ONLY create child nodes?
    Business cases:
    1. different level nodes need to have different prefixes.
    - Thus, the default prefix property definition uses the level number to assign a prefix
    - Also, a validation, to ensure the correct prefix, uses the level number
    But if the user can create a child and a sibling then the default prefix will only be right for a single case and not both.
    Thanks

    If the images are exactly the same size then make sure the layer with the mask
    is the active layer and in the other documents go to Select>Load Selection and choose
    your document with the layer mask under Source document and under channel choose the layer mask.
    After the selection loads press the layer mask icon at the bottom of the layers panel.
    MTSTUNER

  • How can we restrict the objects..?

    Hi it was a question asked in an interview.
    How can we restrict the object..?
    is it with RSSM and PFCG settings..?
    Correct me if I am wrong..!
    Cheers,
    Vasu

    hi Vasu,
    if the question is restriction in reporting by authorization, then you are right. take a look some bw authorization docs
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/adeac294-0501-0010-5a97-9ac5d562b1be
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1b439590-0201-0010-ea8e-cba686f21f06
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/39f29890-0201-0010-1197-f0ed3a0d279f
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/a6329790-0201-0010-b4a1-fdd384045fdb
    hope this helps.

  • How to restrict the attribute values for the user in query designer

    Hi All,
    I have a requirment where certain user would see certain vailes in the query desiner of the attribute.
    The requirment is we have planing material which is attribute of material
    When X user want to restrict the  values for planning material ,where he is able to see all the planning material.But who is not authorized for all the value.
    Ex: X user has authorization for see planning material 100,101,102. of material But when he try to restrict the planning material in query designer where is getting all values of planing material.
    Or
    is there way to blank the restriction help.so that he can't able to see values while restricting
    Please some one can advise me on it..

    Hi,
    Let me sum up:
    you have an object ZPLNMAT for the planning material
    you have the object 0MATERIAL for material and this object has ZPLNMAT as attribute.
    If you can restrict in the query designer, I suppose this attribute is then as navigationnal and also added in the multi-provider.
    The object ZPLNMAT is checked as relevant for authorization, and you set up a role with the attached values of ZPLNMAT this user should have access to.
    Are you sure the users are restricting on the ZPLNMAT object and not 0MATERIAL, because you should have everything now
    PY

  • Disabling the object cache for value OciObjects

    Hi.
    I have a program using OCIObjects as value objects to pass data from OCI to PL/SQL procedures. However in a multithreaded test there is a lot of mutex blocking occuring within the oracle client library (on OCIObjectNew, OCIObjectFree and others), which i am guessing is associated with the OciObjects being managed within the object cache.
    Is it possible to disable the object cache? Or maybe construct the value objects in such a way that they are ignored by the cache.
    Thanks for any help.

    Hi,
    thanks for your response.
    I did consider using OCI_ENV_NO_MUTEX but i would like the oracle OCI library to implement mutexing because i am assuming it does it efficiently and only where required. However it is not clear to me why mutexing would be required when creating/deleting value OCIObjects. I'm guessing it's because of the object cache. (The documentation doesn't explain.)

  • How is ist possible to maintain the time dependencies for Abap Privileges?

    How is ist possible to maintain the time dependencies for Abap Privileges?
    In our Installation of SAP IDM 7.0 SP2 Patch 4 the time dependencies of Abap Roles are imported in the IC by Initial loads Jobs. How can the see / change the dependencies in our IDM Workflow UI? Presently nothing jet is shown, no Attribute is predefined..
    Can anybody give us a hint?
    Thank you in advance !!

    If you click VIEW/SHOW PLAYHEAD INFO, you will see the timecodes as you scrub. (Consumer timecodes, not pro timecodes).
    This works if you imported your footage from a camcorder, either miniDV or AVCHD.
    However, if you have imported an analog file, or saved a DV file to a QuickTime File, you may just see the file creation date in VIEW PLAYHEAD.
    However, there is a trick to getting even these clips to display timecodes if you know the start time.
    First pick a clip. Make a copy and drag it to your desktop, just so you don't lose anything.
    Rename this copy in the following format clip-yyyy-mm-dd hh;mm;ss.current file extension.
    For example, clip-2001-07-14 09;30;45.mov (note the space between the day and the hour)
    This would be a .mov clip that starts with the first frame at July 14, 2001 at 9:30:45 AM
    Then import the clip into iMovie. You now have timecodes at the playhead.

  • HOW to Restrict the input Help for 0MATERIAL in the BPS Layout

    Hi,
    I have requirement to Restrict the input Help for 0MATERIAL  in the BPS Layout.
    For Example if the Planning Package is Restricted to SALES ORGANISATION ( 3000 )  then the system shuold  check the 0MAT_SALES  where SALES ORGANISATION IS "3000" )AND PASS THE Material Numbers to the 0material list.
    I have Copied the standard Funtcion group  "UPF_VARIABLE_USER_EXIT"  to Z fucttion and have attached to Z Variabe as User Exit .
    this Variable is  Attached to 0material in the Planning Pakage. So tha now the 0MATERIAL is restricted to the variable which is having the User Exit.
    But how to acces the Values of Planning Package for which the Layout is bein Executed from this Z User Exit ???
    I Know how to restrict the input help, but my only problem is that how to get the values of Planning package through this User Exit.
    Please suggest if it is possible.
    Regards,
    Nilesh Labde

    Hi Nilesh,
    As I understand from your question,you know how to restrict but the issue is to know the value in the package with which you need to restrict.
    There are two tables which can help you finding the value used in package for sales organisation:
    1. UPC_PACKAGE
    2. UPC_OPTIOS
    How to use ?
    From UPC Package you will get one GUID, Hit the second table UPC_OPTIOS with this GUID.
    In field "FIELDNAME" enter the name of the characteristic whose value is req (sales organisation in your case)
    Hope this helps you
    Mann

  • Error ACLContainer: 65315 does NOT EXIST in  the Object Cache for parentID:

    Expert,
    I did the following steps to upgrade the OWB repository from 10g to 11g
    • Created a dummy workspace in the 11.2 repository
    • Created users in the destination environment
    • Run Repository Assistant against the 11.1 source database
    • Then selected *“Export entire repository to a file”* and selected the MDL(10g) to import
    After 99% of completing I have got the below error
    Error ACLContainer: 65315 does NOT EXIST in  the Object Cache for parentID: 65314
    Please let me know the solution.
    Thanks,
    Balaa...

    Hi I had the same error and worked on it for almost a week with no success but there is few work around for this try it it might work for you.
    Step 1>Run a health check on OWB 10.2 enviroment(make sure you clone your OWB 10.2 enviroment and then do this healthcheck ,these checks are tricky )
    refer
    Note 559542.1 Health Check of the Oracle Warehouse Builder 10.2 Metadata Repository
    This will give you info about your missing ACL
    Step 2> download these two scripts fixLostACLContainer.sql ,fixAllACLContainers.sql
    please refer :
    Note 559542.1 Health Check of the Oracle Warehouse Builder 10.2 Metadata Repository
    OWB 10.2 - Internal ERROR: Can not find the ACL container for object (Doc ID 460411.1)
    Note 754763.1 Repository Cleanup Script for OWB 10.2 and OWB 11.1
    Note 460411.1 Opening Map Returns Cannot find ACL Containter for Object
    Note 1165068.1 Internal Error: Can Not Find The ACL Containter For for object:CMPPhysical Object
    It might resolve this ACL issue but it did not work for me.
    If none of these work then
    Perform export from design center of OWB 10.2 and import through design center of OWB 11.2.(ONLY OPTION)
    It worked for me.
    Varun

  • In my family we have 3IPhones 4S, one IPhone5, one IPad3, one IPadMini and two IPad 4. Is it possible to use the same energieadapter for all of those ?

    In my family we have 3IPhones 4S, one IPhone5, one IPad3, one IPadMini and two IPad 4. Is it possible to use the same energieadapter for all of those ?

    Yes but the iPhone chargers will struggle to charge the iPads ,they need more power than the iPhone chargers produce and with an iPad will charge VERY slowly
    The iPad chargers whether 10w or 12 will happily charge all your devices and Apple confirms the compatibility on the relevant web page.

  • Is it possible to use the same Switch for two different clusters.

    I have 10g Rac setup on windows.
    Now I am planning to install 11gR2 on different servers.
    Is it possible to use the same Switch for two different clusters.

    user9198027 wrote:
    I have 10g Rac setup on windows.
    Now I am planning to install 11gR2 on different servers.
    Is it possible to use the same Switch for two different clusters.
    Yes.  Technically there will not be any conflict as long as the private addresses used by the 2 clusters do not collide, and provided that the switch's port capacity and bandwidth will not be exceeded.
    Your NA (netadmin) can also configure the switch to separate the 2 Interconnects from one another (called partitioning when using Infiniband) - if the switch supports such features.
    A major consideration is not to make the switch, public. That typically cause a range of problems and can have a serious impact on an Interconnect. But using 2 private networks on the same infrastructure should not have the same problems - if configured and implemented correctly.

  • Is it possible to change the Apple ID for my macbook pro?

    Is it possible to change the Apple ID for my macbook pro? My laptop is currently registered under my husband`s ID, and I would like to change it to my apple ID so I can install changes / updates (as we are now separated). Would appreciate any help.

    In your post you have indicated that the MBP has Snow Leopard (10.6.8) installed.  You will have to use the original OSX disk and slide it into the DVD drive on startup holding the C key.  Then you follow the instructions on the display.
    Worst case is to take it to an Apple store and have them assist you in the installation process.
    Ciao.

  • How can we restrict the users/planners for a planning book?

    Hi experts,
    How can we restrict the users/planners for a planning book?
    Thanks,
    Naga.

    Hi Naga,
    we describe this in our SAP Demand and Supply Network Planning rapid-deployment solution.
    Access this area directly via
    http://service.sap.com
    /rds-dpa
    In the configuration guide Demand Planning Settings, Macros and Chart
    Engine (DP3) read Appendix: Setting up Roles and
    Authorizations.
    BR Frank

  • What's s the best automated route from stateless session bean class to EJB?

    Hi,
    I have an application that generates stateless session bean classes.
    For any given stateless session bean class, I would like to build an EJB, moreover, I would like to automate the process as much as possible.
    I'd rather not rely on a full blown third party IDE.
    I reckon could write a set of java classes that could analyse the session bean class and generate the home and remote interface and a basic deployment descriptor.
    That said, I have no doubt that I would be renventing the wheel.
    But I am struggling to find a utility/class of the appropriate granularity in the public domain.
    I am wide open to any feedback on approaches people may have taken and the pros and pitfalls.
    I fully realise my question is quite unspecific, but I really wanted to get some feedback and start a discussion. Since, I am sure there is no 'correct' answer.
    Most kind regards,
    Simon.

    My best advice: surrender to use an IDE.
    You wonder sometimes at how much productivity (read as 'time') could be wasted by doing something that could be done automatically. For a learning experience or a once only exercise is fine but as a routine thing, not worth it.
    Cheers

Maybe you are looking for