Static Class JMS Listener

I am designing an EJB component (MessageDrivenBean) that requires
dynamic ("hot") configuration changes. As such, the bean must be
notified somehow of configuration changes in the DB (rather than have
to poll the DB for changes at every method call).
I'm thinking of implementing this functionality using a static class
instance (singleton) that is shared between the multiple instances of
the bean. This static instance would listen on a JMS topic for
configuration change events and update its internal cache accordingly
(by getting the configuration information from the DB). The beans
would then access this in-memory static instance everytime they need
configuration info instead of polling the database. By using the JMS
topic, I guarantee that clustered instances of Weblogic will all be
notified of the database changes (each instance would have its own
"cache" singleton).
I'm pretty sure all of this will work, but I'm equally sure that I'm
violating some EJB rules. Singletons and JMS listeners are generally
discouraged. Are there any alternatives to this design?

Hi Joost,
This all seems to be pretty complicated. Not to mention that you can not
guarantee that members of a cluster will be notified simultaneously.
Why don't you want using the database?
"Joost Ouwerkerk" <[email protected]> wrote in message
news:[email protected]..
I am designing an EJB component (MessageDrivenBean) that requires
dynamic ("hot") configuration changes. As such, the bean must be
notified somehow of configuration changes in the DB (rather than have
to poll the DB for changes at every method call).
I'm thinking of implementing this functionality using a static class
instance (singleton) that is shared between the multiple instances of
the bean. This static instance would listen on a JMS topic for
configuration change events and update its internal cache accordingly
(by getting the configuration information from the DB). The beans
would then access this in-memory static instance everytime they need
configuration info instead of polling the database. By using the JMS
topic, I guarantee that clustered instances of Weblogic will all be
notified of the database changes (each instance would have its own
"cache" singleton).
I'm pretty sure all of this will work, but I'm equally sure that I'm
violating some EJB rules. Singletons and JMS listeners are generally
discouraged. Are there any alternatives to this design?Regards,
Slava Imeshev

Similar Messages

  • Static class and clustering

              I have a static class that I use to cache some values during a batch process. The
              batch process uses a JMS queue to parcel our identical units of work to MDBs.
              I want this to scale using a cluster with the same MDBs on multiple machines.
              Everything works fine except that I can't figure out how to tell my cache to clear
              itself out on every node between batch runs. Is there a pattern or solution to
              this problem?
              What I've tried is to create a stateless session bean method that clears my cache.
              At the begining of my batch job, (which is a stateless session bean call) I call
              this method on each server in the cluster by getting the remote interface for
              the stateless bean via the different URLs of the servers. However, the session
              bean method always executes on the one server where I make the call. It's as if
              WebLogic gives me back a local interface instead of the remote interface that
              I asked for.
              Any ideas would be appreciated.
              Colin
              

    ... static class and static method.I have never heard of a thing called "static class". Perhaps you mean a class with only static members?
    My design approach (which is bound to needs of the moment and seldom to library-development or future re-use, since both is harder than most developers realize) is to develop straight without caring too much about static or not. When a method is done, debugged and works well, it happens that other objects access this method as well.
    It may happen that I just want to use this single method and almost nothing else of the object. If that is the case, I can start looking if it's a Good Thing(tm) to make the method static, so no object creation is needed just for the one method. Sometimes it can be done, sometimes not.
    But that's just me and you'll find quite a lot of coders that'll advice you to decide what's static and what not before you start coding. And that's as good an advice as most others you can get.
    In the end it's your decision, so start fiddling around and see what fits best for you.
    -T-

  • BPM for WebLogic 10.3 JMS listener problem: SecurityException

    Hi!
    I have a BPM 10.3 engine running on WebLogic 10.3 and a BPM process that uses JMS listener global automatic activity. The JMS queue is located in a WebLogic 8.1 server.
    The global activity receives a message and tries to create a new process instance. At runtime a strange error occurs (see below). If I just log the message and comment the process creation out, the message is successfully consumed, but with the creation part it is not. The process creation itself is not the problem because other message listeners that call other process activities fail with similar errors.
    Btw, it's working in Studio, but not in WL10.
    Could someone explain me what happens and how to fix it?
    Have I misconfigured something?
    Thanks in advance,
    Jaanus
    The BPM engine log:
    The task could not be successfully executed.
    Reason: 'fuego.papi.exception.ActivityFailedException: Activity '/MyProcess#Default-1.0/Begin[Begin]' task 'BeginIn' could not execute successfully.
    Detail:Method: 'BeginIn', Exception: 'Process execution engine execution error.'
    Caused by: Activity '/MyProcess#Default-1.0/Begin[Begin]' task 'BeginIn' could not execute successfully.
    Detail:Method: 'BeginIn', Exception: 'Process execution engine execution error.'
    Caused by: Process execution engine execution error.
    Caused by: Connector [TrinityEngine_J2EE_RUNTIME_FUEGOLABS_ARG:SQL:REMOTE_JDBC] caused an exception when getting a resource of type [0].
    Detail:Connector [TrinityEngine_J2EE_RUNTIME_FUEGOLABS_ARG:SQL:REMOTE_JDBC] caused an exception when getting a resource of type [0].
    Caused by: [Security:090398]Invalid Subject: principals=[weblogic, Administrators]
    fuego.lang.ComponentExecutionException: The task could not be successfully executed.
    Reason: 'fuego.papi.exception.ActivityFailedException: Activity '/MyProcess#Default-1.0/Begin[Begin]' task 'BeginIn' could not execute successfully.
    Detail:Method: 'BeginIn', Exception: 'Process execution engine execution error.'
         at fuego.server.execution.EngineExecutionContext.invokeMethodAsCil(EngineExecutionContext.java:1094)
         at fuego.server.execution.EngineExecutionContext.runCil(EngineExecutionContext.java:1280)
         at fuego.server.execution.GlobalAutomaticJMSListeningHelper.executeJmsListener(GlobalAutomaticJMSListeningHelper.java:94)
         at fuego.server.AbstractProcessBean$45.execute(AbstractProcessBean.java:3017)
         at fuego.server.execution.DefaultEngineExecution$AtomicExecutionTA.runTransaction(DefaultEngineExecution.java:304)
         at fuego.transaction.TransactionAction.startBaseTransaction(TransactionAction.java:470)
         at fuego.transaction.TransactionAction.startTransaction(TransactionAction.java:551)
         at fuego.transaction.TransactionAction.start(TransactionAction.java:212)
         at fuego.server.execution.DefaultEngineExecution.executeImmediate(DefaultEngineExecution.java:123)
         at fuego.server.execution.EngineExecution.executeImmediate(EngineExecution.java:66)
         at fuego.server.AbstractProcessBean.runGlobalJmsActivity(AbstractProcessBean.java:3023)
         at fuego.server.execution.GlobalJMSExecutor$1.run(GlobalJMSExecutor.java:113)
         at fuego.ejbengine.EJBProcessBean.executeTask(EJBProcessBean.java:147)
         at fuego.server.execution.GlobalJMSExecutor.execute(GlobalJMSExecutor.java:105)
         at fuego.ejbengine.EJBGlobalJMSExecutor.access$400(EJBGlobalJMSExecutor.java:43)
         at fuego.ejbengine.EJBGlobalJMSExecutor$JMSExecutorWorker.run(EJBGlobalJMSExecutor.java:213)
         at java.lang.Thread.run(Thread.java:619)
    Caused by: fuego.papi.exception.ActivityFailedException: Activity '/MyProcess#Default-1.0/Begin[Begin]' task 'BeginIn' could not execute successfully.
    Detail:Method: 'BeginIn', Exception: 'Process execution engine execution error.'
         at fuego.papi.exception.ActivityFailedException.create(ActivityFailedException.java:66)
         at fuego.server.AbstractProcessBean.createActivityFailedException(AbstractProcessBean.java:3690)
         at fuego.server.AbstractProcessBean.internalCreateInstance(AbstractProcessBean.java:4326)
         at fuego.server.AbstractProcessBean._doCreateInstance(AbstractProcessBean.java:3650)
         at fuego.server.AbstractProcessBean.createInstance(AbstractProcessBean.java:665)
         at fuego.server.AbstractProcessBean.createInstance(AbstractProcessBean.java:736)
         at fuego.components.Process.createInstance(Process.java:106)
         at fuego.components.ProcessInstance.create(ProcessInstance.java:392)
         at fuego.components.ProcessInstance.create(ProcessInstance.java:503)
         at oracle.MyProcess.Default_1_0.Instance.CIL_ootaJMSSonumit(Instance.xcdl:12)
         at sun.reflect.GeneratedMethodAccessor132.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at fuego.server.execution.EngineExecutionContext.invokeMethodAsCil(EngineExecutionContext.java:1085)
         ... 16 more
    Caused by: fuego.papi.impl.EngineExecutionException: Process execution engine execution error.
         at fuego.server.execution.DefaultEngineExecution.executeImmediate(DefaultEngineExecution.java:139)
         at fuego.server.execution.EngineExecution.executeImmediate(EngineExecution.java:66)
         at fuego.server.AbstractProcessBean.internalCreateInstance(AbstractProcessBean.java:4320)
         ... 27 more
    Caused by: class fuego.lang.RuntimeExceptionShell ->> fuego.connector.ConnectorException: Connector [TrinityEngine_J2EE_RUNTIME_FUEGOLABS_ARG:SQL:REMOTE_JDBC] caused an exception when getting a resource of type [0].
    Detail:Connector [TrinityEngine_J2EE_RUNTIME_FUEGOLABS_ARG:SQL:REMOTE_JDBC] caused an exception when getting a resource of type [0].
         at fuego.server.service.EngineConnectorService.getConnection(EngineConnectorService.java:581)
         at fuego.server.service.EngineConnectorService.getEngineConnection(EngineConnectorService.java:300)
         at fuego.transaction.TransactionAction.getEngineHandle(TransactionAction.java:179)
         at fuego.server.execution.EngineExecutionContext.getEngineHandle(EngineExecutionContext.java:443)
         at fuego.server.AbstractInstanceService.create(AbstractInstanceService.java:302)
         at fuego.server.execution.microactivity.BeginMicroActivity.createInstance(BeginMicroActivity.java:95)
         at fuego.server.AbstractProcessBean$53.execute(AbstractProcessBean.java:3642)
         at fuego.server.execution.DefaultEngineExecution$AtomicExecutionTA.runTransaction(DefaultEngineExecution.java:304)
         at fuego.transaction.TransactionAction.startNestedTransaction(TransactionAction.java:527)
         at fuego.transaction.TransactionAction.startTransaction(TransactionAction.java:548)
         at fuego.transaction.TransactionAction.start(TransactionAction.java:213)
         at fuego.server.execution.DefaultEngineExecution.executeImmediate(DefaultEngineExecution.java:125)
         at fuego.server.execution.EngineExecution.executeImmediate(EngineExecution.java:66)
         at fuego.server.AbstractProcessBean.internalCreateInstance(AbstractProcessBean.java:4320)
         at fuego.server.AbstractProcessBean._doCreateInstance(AbstractProcessBean.java:3650)
         at fuego.server.AbstractProcessBean.createInstance(AbstractProcessBean.java:665)
         at fuego.server.AbstractProcessBean.createInstance(AbstractProcessBean.java:736)
         at fuego.components.Process.createInstance(Process.java:106)
         at fuego.components.ProcessInstance.create(ProcessInstance.java:392)
         at fuego.components.ProcessInstance.create(ProcessInstance.java:503)
         at oracle.MyProcess.Default_1_0.Instance.CIL_ootaJMSSonumit(Instance.xcdl:12)
         at sun.reflect.GeneratedMethodAccessor132.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at fuego.server.execution.EngineExecutionContext.invokeMethodAsCil(EngineExecutionContext.java:1085)
         at fuego.server.execution.EngineExecutionContext.runCil(EngineExecutionContext.java:1280)
         at fuego.server.execution.GlobalAutomaticJMSListeningHelper.executeJmsListener(GlobalAutomaticJMSListeningHelper.java:94)
         at fuego.server.AbstractProcessBean$45.execute(AbstractProcessBean.java:3017)
         at fuego.server.execution.DefaultEngineExecution$AtomicExecutionTA.runTransaction(DefaultEngineExecution.java:304)
         at fuego.transaction.TransactionAction.startBaseTransaction(TransactionAction.java:472)
         at fuego.transaction.TransactionAction.startTransaction(TransactionAction.java:551)
         at fuego.transaction.TransactionAction.start(TransactionAction.java:213)
         at fuego.server.execution.DefaultEngineExecution.executeImmediate(DefaultEngineExecution.java:125)
         ... 8 more
    Caused by: fuego.connector.ConnectorException: Connector [TrinityEngine_J2EE_RUNTIME_FUEGOLABS_ARG:SQL:REMOTE_JDBC] caused an exception when getting a resource of type [0].
    Detail:Connector [TrinityEngine_J2EE_RUNTIME_FUEGOLABS_ARG:SQL:REMOTE_JDBC] caused an exception when getting a resource of type [0].
         at fuego.connector.ConnectorException.exceptionOnGetResource(ConnectorException.java:95)
         at fuego.connector.ConnectorTransaction.getResource(ConnectorTransaction.java:324)
         at fuego.connector.ConnectorTransaction.getResource(ConnectorTransaction.java:298)
         at fuego.connector.JDBCHelper.getConnection(JDBCHelper.java:41)
         at fuego.server.service.EngineConnectorService.getConnection(EngineConnectorService.java:578)
         at fuego.server.service.EngineConnectorService.getEngineConnection(EngineConnectorService.java:300)
         at fuego.transaction.TransactionAction.getEngineHandle(TransactionAction.java:179)
         at fuego.server.execution.EngineExecutionContext.getEngineHandle(EngineExecutionContext.java:443)
         at fuego.server.AbstractInstanceService.create(AbstractInstanceService.java:302)
         at fuego.server.execution.microactivity.BeginMicroActivity.createInstance(BeginMicroActivity.java:91)
         at fuego.server.AbstractProcessBean$53.execute(AbstractProcessBean.java:3642)
         at fuego.server.execution.DefaultEngineExecution$AtomicExecutionTA.runTransaction(DefaultEngineExecution.java:304)
         at fuego.transaction.TransactionAction.startNestedTransaction(TransactionAction.java:527)
         at fuego.transaction.TransactionAction.startTransaction(TransactionAction.java:548)
         at fuego.transaction.TransactionAction.start(TransactionAction.java:212)
         at fuego.server.execution.DefaultEngineExecution.executeImmediate(DefaultEngineExecution.java:123)
         at fuego.server.execution.EngineExecution.executeImmediate(EngineExecution.java:66)
         at fuego.server.AbstractProcessBean.internalCreateInstance(AbstractProcessBean.java:4320)
         at fuego.server.AbstractProcessBean._doCreateInstance(AbstractProcessBean.java:3650)
         at fuego.server.AbstractProcessBean.createInstance(AbstractProcessBean.java:665)
         at fuego.server.AbstractProcessBean.createInstance(AbstractProcessBean.java:736)
         at fuego.components.Process.createInstance(Process.java:106)
         at fuego.components.ProcessInstance.create(ProcessInstance.java:392)
         at fuego.components.ProcessInstance.create(ProcessInstance.java:503)
         at oracle.MyProcess.Default_1_0.Instance.CIL_ootaJMSSonumit(Instance.xcdl:12)
         at sun.reflect.GeneratedMethodAccessor132.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at fuego.server.execution.EngineExecutionContext.invokeMethodAsCil(EngineExecutionContext.java:1085)
         at fuego.server.execution.EngineExecutionContext.runCil(EngineExecutionContext.java:1280)
         at fuego.server.execution.GlobalAutomaticJMSListeningHelper.executeJmsListener(GlobalAutomaticJMSListeningHelper.java:94)
         at fuego.server.AbstractProcessBean$45.execute(AbstractProcessBean.java:3017)
         at fuego.server.execution.DefaultEngineExecution$AtomicExecutionTA.runTransaction(DefaultEngineExecution.java:304)
         at fuego.transaction.TransactionAction.startBaseTransaction(TransactionAction.java:470)
         at fuego.transaction.TransactionAction.startTransaction(TransactionAction.java:551)
         at fuego.transaction.TransactionAction.start(TransactionAction.java:212)
         at fuego.server.execution.DefaultEngineExecution.executeImmediate(DefaultEngineExecution.java:123)
         ... 8 more
    Caused by: java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[weblogic, Administrators]
         at weblogic.security.service.SecurityServiceManager.seal(Unknown Source)
         at weblogic.security.service.IdentityUtility.authenticatedSubjectToIdentity(Unknown Source)
         at weblogic.security.service.RoleManager.getRoles(Unknown Source)
         at weblogic.security.service.AuthorizationManager.isAccessAllowed(Unknown Source)
         at weblogic.jndi.internal.ServerNamingNode.checkPermission(ServerNamingNode.java:442)
         at weblogic.jndi.internal.ServerNamingNode.checkLookup(ServerNamingNode.java:423)
         at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:180)
         at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
         at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)
         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:380)
         at javax.naming.InitialContext.lookup(InitialContext.java:392)
         at fuego.connector.impl.BaseRemoteConnector.getReferencedObject(BaseRemoteConnector.java:116)
         at fuego.connector.impl.BaseRemoteConnector.getReferencedObject(BaseRemoteConnector.java:107)
         at fuego.connector.impl.RemoteJDBCConnector.getConnection(RemoteJDBCConnector.java:75)
         at fuego.connector.impl.RemoteJDBCConnector.getConnection(RemoteJDBCConnector.java:64)
         at fuego.connector.impl.RemoteJDBCConnector.getResource(RemoteJDBCConnector.java:147)
         at fuego.connector.ConnectorTransaction.getResource(ConnectorTransaction.java:319)
         ... 43 more

    I managed to solve the problem by configuring the domain's security settings on both WebLogic servers as follows:
    *) checked "Anonymous Admin Lookup Enabled",
    *) entered the same value to Advanced->Credential on both WLs.

  • Securing the Peoplesoft JMS listening connector URL

    In order to start or stop the JMS listening connector we execute a URL on the browser; the URL looks like..
    http://<WEBSERVER>:<PORT>/PSIGW/JMSListeningConnectorAdministrator?Activity=START
    http://<WEBSERVER>:<PORT>/PSIGW/JMSListeningConnectorAdministrator?Activity=STOP
    Problem with this is that any one who knows this can playaround with the listening connector of the production instance; and moreover if he can access the peoplesoft signon page, he can easily know the webserver URL.
    Is there any means that this can be secured; for example executing this URL should first take the user to an authentication page..
    -Sudripta

    on the webserver u can find the .class file here
    PS_HOME\webserv\domain_name\applications\peoplesoft\PSIGW\WEB-INF\classes\com\peoplesoft\pt\integrationgateway\listeningconnector
    u open this .class file u need a java compiler (or) hex editor to read the content.
    Thnks!

  • Purpose of static classes

    What is the purpose of making a class static?
    public static class December {
    }The only reason I can see is to access inner-classes without instantiating the outer-class? Are there any other?

    see these
    http://forum.java.sun.com/thread.jsp?forum=31&thread=277820
    http://forum.java.sun.com/thread.jsp?forum=31&thread=305260

  • Creation of a static class with private methods

    I'm new to java programming and am working on a project where I need to have a static class that does a postage calculation that must contain 2 private methods, one for first class and one for priority mail. I can't seem to figure out how to get the weight into the class to do the calculations or how to call the two private methods so that when one of my other classes calls on this class, it retrieves the correct postage. I've got all my other classes working correct and retrieving the information required. I need to use the weight from another class and return a "double". Help!!!
    Here's my code:
    * <p>Title: Order Control </p>
    * <p>Description: Order Control Calculator using methods and classes</p>
    * <p>Copyright: Copyright (c) 2002</p>
    * <p>Company: Info 250, sec 001, T/TH 0930</p>
    * @author Peggy Blake
    * @version 1.0, 10/29/02
    import javax.swing.*;
    public class ShippingCalculator
    static double firstClass, priorityMail;
    //how do I get my weight from another class into this method to use??? not sure I understand how it works.
    public static double ShippingCalculator(double weight)
    String responseFirstClass;
    double quantity, shippingCost;
    double totalFirstClass, firstClass, priorityMail, totalShipping;
    double priorityMail1 = 3.50d;//prioritymail fee up to 1 pound
    double priorityMail2 = 3.95d;//prioritymail fee up to 2 pounds
    double priorityMail3 = 5.20d;//prioritymail fee up to 3 pounds
    double priorityMail4 = 6.45d;//prioritymail fee up to 4 pounds
    double priorityMail5 = 7.70d;//prioritymail fee up to 5 pounds
    quantity = 0d;//ititialization of quantity
    // weight = 0d;//initialization of weight
    // shippingCost = 0d;
    //calculation of the number of items ordered..each item weights .75 ounces
    quantity = (weight/.75);
    if (quantity <= 30d)
    //add 1 ounce to quantities that weigh less than 30 ounces
    weight = (weight + 1);
    else
    //add 2 ounces to quantities that weigh more than 30 ounces
    weight = (weight + 2);
    if (weight > 80d)
    //message to orderclerk ..order over 5 lbs, cannot process
    JOptionPane.showMessageDialog(null, "Order exceeded 5 lbs, cannot process");
    //exit system, do not process anything else
    System.exit (0);
    else
    if (weight < 14d)
    //send message to customer: ship firstclass or priority, y or n
    responseFirstClass = JOptionPane.showInputDialog(null, "Ship first class? y or n?");
    if (responseFirstClass.equals("y"))
    //compute FirstClass shipping cost
    totalFirstClass = ((weight - 1) * .23d) + .34d;
    firstClass = totalFirstClass;
    else
    //compute PriorityMail cost for orders less than 14 ounces
    priorityMail = (priorityMail1);
    else
    if (weight <=16d)
    //compute totalshipping for orders up to 16 ounces
    priorityMail = (priorityMail1);
    else
    if (weight <=32d)
    //compute totalshipping for orders up to 32 ounces
    priorityMail = (priorityMail2);
    else
    if (weight <=48d)
    //compute totalshipping for orders up to 48 ounces
    priorityMail = (priorityMail3);
    else
    if (weight <= 64d)
    //compute totalshipping for orders up to 64 ounces
    priorityMail = (priorityMail4);
    else
    //compute totalshipping for orders up to 80 ounces
    priorityMail = (priorityMail5);
    priorityMail = 0d;
    firstClass = 0d;
    firstClassMail ();
    priorityMailCost ();
    //I think this is where I should be pulling the two methods below into my code, but can't figure out how to do it.
    shippingCost = priorityMail + firstClass;
    return (shippingCost);
    }//end method calculate shipping
    private static double firstClassMail()//method to get first class ship cost
    return (firstClass);
    }//end method firstclass shipping
    private static double priorityMailCost()//method to get priority mail cost
    return (priorityMail);
    }//end method priorityMail
    }//end class shipping calculator

    public class A {
    public String getXXX () {
    public class B {
    A a = new A();
    public void init () {
    a.getXXX();
    }

  • Alternative to Static Class Inherit

    Greetings,
    I’ve been using some code for years in a different number of applications but that involves a lot of copy paste and is a nightmare to maintain. For that reason I’ve took some time to re-organize some of my codes and that mainly involves
    splitting it into multiple projects for latter inclusion in a number of solutions.
    So far so good and I’d say 95% is done but I’m now stuck with a Static Class I need to use. I basically need a few “Global” parameters and settings to be available across every solution. I know I can’t Inherit a Static Class nor override
    a Field to return a different value unfortunately.
    In a nutshell:
    myFrameworkProject
    namespace
    myFramework.Classes{
                    //these contains general stuff
    used in every project
                    public static class Globals{
                                   public static
    XPTO veryImportantProperty = new XPTO()
                                   public static
    Settings Settings = new Settings();
    public void doSomethingImportant();
    Public class Settings{
                    Private
    string Username;
                    Private
    string Password;
                    Private
    string Whatever;
    myFancyProject
    namespace
    myFancyProject.Classes{
                    //these add specific stuff used
    in this project
                    public static class Globals : myFramework.Classes.
    Globals {
                                   public static
    override mySettings Settings = new mySettings();
    Public class mySettings: myFramework.Classes .Settings{
                    //some
    more specific settings I need
                    Private
    string SomethingElse;
    What are my options? I’ve been trying to play with Singletons but for some reason I just can’t seem to make it work the way I want to…probably because it’s just not the right way to do it in the first place.

    I think you are over thinking it a little bit. The example you have above would be great if you had multiple setting types you wanted to retrieve within the same application domain instance using keys or specific types. The way I understand your problem
    is you have one settings type per application that you run with various applications sharing a code base. Here is an example I created for you which better illustrates the solution I had in mind when I read your problem.
    There are 2 namespaces, the one for your custom project(s) named FancyProject and then the Core / framework. Hope this helps!
    namespace JF.FancyProject
    using JF.Framework.Classes;
    // in initialization of your default application domain (ie. in your application startup)
    // inject your MySingleton with your custom implementation of ISettingsBuilder
    // this can be done in many ways from hard coding in each startup routine to IoC / Dependency Injection
    // the end result is this
    public static class Console
    public static void Main(params string[] args)
    MySingleton.Initialize(new ConcreteSettingsBuilder());
    // now you can use it where ever
    var temp = MySingleton.SettingsConcreteInstance<ConcreteSettings>().SomethingCustom;
    // or base
    var temp1 = MySingleton.SettingsInstance.SomeBaseThing;
    public sealed class ConcreteSettings : JF.Framework.Classes.SettingsBase
    public string SomethingCustom { get; set; }
    public sealed class ConcreteSettingsBuilder : BaseSettingsBuilder, ISettingsBuilder
    public override SettingsBase CreateSettings()
    var settings = new ConcreteSettings();
    // call the base if you need to get standard settings populated
    base.populateBaseSettings(settings);
    // populate all of your custom settings
    return settings;
    namespace JF.Framework.Classes
    public abstract class SettingsBase
    public string SomeBaseThing { get; set; }
    // base settings and behavior that can be abstracted
    public static class MySingleton
    private static SettingsBase _settings;
    private static Lazy<SettingsBase> _lazyCreationMethod;
    public static void Initialize(ISettingsBuilder builder)
    _lazyCreationMethod = new Lazy<SettingsBase>(builder.CreateSettings);
    public static SettingsBase SettingsInstance
    get { return _lazyCreationMethod.Value; }
    public static T SettingsConcreteInstance<T>() where T : SettingsBase
    return (T) _lazyCreationMethod.Value;
    public abstract class BaseSettingsBuilder : ISettingsBuilder
    public abstract SettingsBase CreateSettings();
    protected virtual void populateBaseSettings(SettingsBase settings)
    // if you find many of your settings are created the same way use a base class
    public interface ISettingsBuilder
    SettingsBase CreateSettings();
    Edit:
    One more thought. I do agree with some of the other posters that  for bigger projects the use of a Singleton pattern is not a good idea. For little applications it does not matter too much because chances are there is not enough substance that it will
    hinder your code and the development cycles are generally very short.
    Should you want to reconsider the Singleton pattern then I recommend you look at something like
    Autofac, you could use this to inject instances of your ISettingsBuilder, or other concrete instances, directly into your dependent classes and you could take it further in developing self containing services that you could
    inject as well.
    Again, for small projects its not a big deal but if you ever start on something a bit more complex its worth looking into.
    -Igor

  • Deadlock in TopLink when using JMS listener on WebLogic

    I am experiencing a deadlock in TopLink 10.1.3 on WebLogic 9 in code that previously worked on TopLink 9.0.4 with WebLogic 8.1. As such, I'm not sure if it's due to the TopLink change, the WebLogic change or both. Anyway, we have a JMS listener (note, NOT a MessageDrivenBean) that is updating an existing TopLink cached domaing object. The JMS listener thread gets stuck when attempting to commit the transaction. The thread-dump shows that there is another thread which is blocked in the ConcurrencyManager waiting to obtain the lock on an object which is being updated by the listener thread. It appears to me that the root cause is that the Synchronization.afterCompletion() listener is running on a different thread than the one which owns the locks which were obtained beforeCompletion.
    See stack traces.
    First, the message listener thread which is waiting for participants in the transaction to commit:
    "[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=9 tid=0x3a4a4728 nid=0xa48 in Object.wait() [0x3a0cf000..0x3a0cfbec]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x0c7a0908> (a weblogic.transaction.internal.ServerTransactionImpl)
         at weblogic.transaction.internal.ServerTransactionImpl.globalRetryCommit(ServerTransactionImpl.java:2665)
         - locked <0x0c7a0908> (a weblogic.transaction.internal.ServerTransactionImpl)
         at weblogic.transaction.internal.ServerTransactionImpl.globalCommit(ServerTransactionImpl.java:2570)
         at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:277)
         at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:226)
         at weblogic.ejb.container.internal.BaseEJBObject.postInvoke1(BaseEJBObject.java:539)
         at weblogic.ejb.container.internal.StatelessEJBObject.postInvoke1(StatelessEJBObject.java:72)
         at weblogic.ejb.container.internal.BaseEJBObject.postInvokeTxRetry(BaseEJBObject.java:374)
         at com.avinamart.BusinessLogic.Bean.JobService.JobService_u1ylwo_EOImpl.submitJobAndRun(JobService_u1ylwo_EOImpl.java:1388)
         at com.avinamart.Framework.Event.Task.OptimizationTaskListener._submitAsAJob(OptimizationTaskListener.java:253)
         at com.avinamart.Framework.Event.Task.OptimizationTaskListener._submitAsAJob(OptimizationTaskListener.java:217)
         at com.avinamart.Framework.Event.Task.OptimizationTaskListener.processMessage(OptimizationTaskListener.java:344)
         at com.emptoris.base.event.EPASSMessageBaseListener.onMessage(EPASSMessageBaseListener.java:722)
         at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:3824)
         at weblogic.jms.client.JMSSession.execute(JMSSession.java:3738)
         at weblogic.jms.client.JMSSession.pushMessage(JMSSession.java:3253)
         at weblogic.jms.client.JMSSession.invoke(JMSSession.java:4195)
         at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:674)
         at weblogic.messaging.dispatcher.DispatcherServerRef.invoke(DispatcherServerRef.java:262)
         at weblogic.messaging.dispatcher.DispatcherServerRef.handleRequest(DispatcherServerRef.java:134)
         at weblogic.messaging.dispatcher.DispatcherServerRef.access$000(DispatcherServerRef.java:36)
         at weblogic.messaging.dispatcher.DispatcherServerRef$1.run(DispatcherServerRef.java:105)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    Next, the other thread which is participating in the transaction which is stuck:
    "[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=5 tid=0x3adb80a0 nid=0xb30 in Object.wait() [0x3c7af000..0x3c7afd6c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x0c7a0000> (a oracle.toplink.internal.helper.ConcurrencyManager)
         at java.lang.Object.wait(Object.java:474)
         at oracle.toplink.internal.helper.ConcurrencyManager.acquire(ConcurrencyManager.java:76)
         - locked <0x0c7a0000> (a oracle.toplink.internal.helper.ConcurrencyManager)
         at oracle.toplink.internal.identitymaps.CacheKey.acquire(CacheKey.java:80)
         at oracle.toplink.internal.identitymaps.FullIdentityMap.remove(FullIdentityMap.java:164)
         at oracle.toplink.internal.identitymaps.HardCacheWeakIdentityMap.remove(HardCacheWeakIdentityMap.java:82)
         at oracle.toplink.internal.helper.WriteLockManager.releaseAllAcquiredLocks(WriteLockManager.java:363)
         at oracle.toplink.publicinterface.UnitOfWork.afterTransaction(UnitOfWork.java:2123)
         at oracle.toplink.transaction.AbstractSynchronizationListener.afterCompletion(AbstractSynchronizationListener.java:135)
         at oracle.toplink.transaction.JTASynchronizationListener.afterCompletion(JTASynchronizationListener.java:66)
         at weblogic.transaction.internal.ServerSCInfo.callAfterCompletions(ServerSCInfo.java:862)
         at weblogic.transaction.internal.ServerTransactionImpl.callAfterCompletions(ServerTransactionImpl.java:2913)
         at weblogic.transaction.internal.ServerTransactionImpl.afterCommittedStateHousekeeping(ServerTransactionImpl.java:2806)
         at weblogic.transaction.internal.ServerTransactionImpl.setCommittedUnsync(ServerTransactionImpl.java:2857)
         at weblogic.transaction.internal.ServerTransactionImpl.ackCommit(ServerTransactionImpl.java:1097)
         - locked <0x0c7a0908> (a weblogic.transaction.internal.ServerTransactionImpl)
         at weblogic.transaction.internal.CoordinatorImpl.ackCommit(CoordinatorImpl.java:211)
         at weblogic.transaction.internal.CoordinatorImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:517)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:407)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:403)
         at weblogic.rmi.internal.BasicServerRef.access$300(BasicServerRef.java:56)
         at weblogic.rmi.internal.BasicServerRef$BasicExecuteRequest.run(BasicServerRef.java:934)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    Is this the same concurrency bug which was fixed in 10.1.3.1??? As I am writing this, I am attempting to build the application with the updated TopLink jar to test for myself. Has anyone else seen this scenario with WebLogic? I should also point out that the problem only occurs when the listener is running on a separate server than the one hosting the JMS queue it reads from. It may be that when the listener runs on the same server, it does not use multiple threads in the transaction.
    Any ideas are greatly appreciated.
    - Bruno

    We've got the same kind of issue with toplink 10.1.3.0.0 and bea weblogic 8.1 SP5.
    I 've not tried with 10.1.3.1.0, did you?
    Do you have a new status for this issue.
    Chris

  • Do static classes persist for the lifetime of the applet or the JRE in 1.4

    I have an application that runs in a web browser and uses several applets that share data between each other using a static class. This method works fine for version 1.3 but not in 1.4.x. Do static classes now only exist for the lifetime of the applet?

    I had a similar problem and solved it by setting the codebase attribute on the applet tags. The only documentation I have been able to find about this issue is here: http://java.sun.com/products/plugin/1.3.1_01a/new.html#classloader

  • Usage of non static members in a static class

    Can you explain the usage of nonstatic members in a static class?

    Skydev2u wrote:
    I just recently started learning Java so I probably know less than you do. But from what I've learned so far a static class is a class that you can only have one instance of, like the main method. As far as non static members in a static class I think it allows the user to modify some content of the class(variables) even though the class is static. A quick Google help should help though.Actually the idea behind a static class is that you dont have any instances of it at all, its more of a place holder for things that dont have anywhere to live.
    Non-static members in a static class wouldnt have much use

  • Attributes of private static class - private or package private?

    Consider the following code:
    public class Outer {
        // Remainder omitted
        private static class Nested {
            int someInt           = 10;
            String someString = "abc";
    }The nested class Nested is declared private, as it is only used by the Outer class... now I wonder... should I declare Nested's attributes private oder package private... either way, they can't be accessed from the outside... any ideas?

    stevops wrote:
    either way, they can't be accessed from the outsideThat is true. However, when in addition the members of class Nested are declared as private, you will not be able to access them also from within the class Outer as well, i.e. int i = Nested.someInt; will give you compliation errorsAs a matter of fact, at most it'll generate some warnings, for it (the compiler) will generate synthetic accessor methods for Nested's fields.
    All in all, if you plan to access private class members from an enclosing (or inner) class, you really only have two options: make them explicitly package-private, or make them implicitly so.

  • Releasing static classes in a browser environment

    Hi all, got a problem I can't seem to find a solution for, so hoping someone knows what to do with this!
    I'm running a Java applet in a browser, under Sun's JVM. It has a custom dynamic class loader, which queries our server and downloads patches to the software. However, this doesn't work entirely as planned. The JVM doesn't seem to want to clear the class cache until the browser is restarted. I'm also wondering about static class definitions and whether I'd have to do something different to refresh those too.
    Ideally, when the loader starts and downloads patches to files, it then completely wipes out its previous definitions of cached classes, and reloads them all again from disk. Is this possible, and how would I go about doing it?
    (The reason for this behaviour is my old old software ran on Java 1.1, and the MS Java plugin exhibits this behaviour, which our users were used to...)
    Thanks in advance!
    David

    Thanks for the quick reply :)
    The loader is not static, so it should be using a new
    instance each time already? Or is it not sufficient
    to simply make it not static?Not really sure how to answer that! It's not static, so presumably it's an instance field of some other class. Now, are you using a new instance of that object each time you download a new patch? If not, that'll probably be the problem. If so, then probably what's going on is, your classloader isn't loading the classes at all, but simply delegating to it's parent. If that's the case, you need to make that delegation fail, for example by not giving your classloader a parent

  • Can we create static class in actionscript 3.0

    Hi If yes please send me chunk of code .
    thanks

    Hi Prashanth,
    There is no specifically a Static class in Flex that you can declare it at the compile time. However you can have Static variables and methods in your class and you can call them using the class name itself without creating an instance of that class.
    Here is the chunk of code...
    package com.constants
    [Bindable]
    public class ConsumerMessageConstants
      public static const UNABLE_TO_ENROLL_PLANS_MESSAGE_ID:String = "10000";
      public static const MARITAL_STATUS_UPDATED_MESSAGE_ID:String = "10001";
      public static const ERROR_IN_EDITING_MARITALSTAUS_MESSAGE_ID:String = "10002";
      public static const SMOKER_STATUS_SAVED_SUCCESSFULLY_MESSAGE_ID:String = "10003";
      public static const PASSWORD_RESET_REQUIRED_MESSAGE_ID:String = "10004";
      public static const ADDRESS_UPDATED_SUCCESSFULLY_MESSAGE_ID:String = "10005";
      public static const UNABLE_TO_REMOVE_THIS_DEPENDENT_MESSAGE_ID:String = "10006";
      public static const EMPLOYEE_SALARY_UPDATED_SUCCESSFULLY_MESSAGE_ID:String = "10007";
      public static const ERROR_IN_EDITING_SALARY_MESSAGE_ID:String = "10008";
      public static const PLEASE_SELECT_A_CONSIDER_PLAN_MESSAGE_ID:String = "10009";
      public static const YOU_MUST_CHOOSE_A_PLAN_COVERAGE_LEVEL_MESSAGE_ID:String = "10010";
      public static const PLEASE_SELECT_PLAN_TO_LOCK_PORTFOLIO_MESSAGE_ID:String = "10011";
      public static const DEEPDIVE_INFORMATION_SAVED_SUCCESSFULLY_MESSAGE_ID:String = "10012";
      public static const NO_DATA_TO_DISPLAY_MESSAGE_ID:String = "10013";
      public static const NO_PLANS_AVAILABLE_TO_ENROLL_MESSAGE_ID:String = "10014";
      public static const NO_PLANS_TO_BE_ENROLLED_MESSAGE_ID:String = "10015";
      public static const PASSWORD_CHANGED_SUCCESSFULLY_MESSAGE_ID:String = "10016";
      public static const NEW_PASSWORD_AND_CONFIRM_PASSWORD_SAME_MESSAGE_ID:String = "10017";
      public static const YOUR_DATA_IS_UPDATED_SUCCESSFULLY_MESSAGE_ID:String = "10018";
      public static const HEALTH_PLAN_IS_UPDATED_SUCCESSFULLY_MESSAGE_ID:String = "10019";
      public static const HEALTH_PLAN_IS_ADDED_SUCCESSFULLY_MESSAGE_ID:String = "10020";
      public static const MONEY_PLAN_IS_UPDATED_SUCCESSFULLY_MESSAGE_ID:String = "10021";
      public static const MONEY_PLAN_IS_ADDED_SUCCESSFULLY_MESSAGE_ID:String = "10022";
      public static const PROTECTION_PLAN_IS_UPDATED_SUCCESSFULLY_MESSAGE_ID:String = "10023";
      public static const PROTECTION_PLAN_IS_ADDED_SUCCESSFULLY_MESSAGE_ID:String = "10024";
      public static const UNABLE_TO_RETRIEVE_PATHS_MESSAGE_ID:String = "10025";
      public static function func1():Void
      public static function func2():Void
      public function ConsumerMessageConstants()

  • JMS Listener within a workflow

    I have a JMS listener, waiting for new messages on a queue. Once there is a new message it uses that message which contains an object to begin the work flow process. The first step in the work flow calls an external engine we built that does quite a bit. At each critical point in the engine it adds a message to a topic. I want to have a listener for each one of the steps that will listen for the results to be added to the topic. Once it's there if everything is good go to the next listener and wait for the next result set. If it's bad I want to take the results and send the message to another queue and end that work flow. I'm not having much luck finding how to put a listener within the work flow. I have the listener that starts the process going fine using a Global Automatic event.
    I thought the best solution would be do a subflow process at each points of them listeners. Have another global automatic event listener waiting which will then start the subflow process which stores the results and then returns which step to take back to the original process. But that didn't work it was completing all of the subflow's w/o waiting for a listener to find a message. So nothing ended up happening.
    Any help?

    That's what I figured with that global interactive I was trying to access the instance variables before so it wasn't showing up under my user. Now instead of an error pop up the error message shows up at the bottom of the runtime UI.
    Error at bottom of page: (Followed by a bunch of package names)
    Unexpected Error
    javax.faces.el.EvaluationException: /jsf/menu/menuActionNormal.xhtml @24,147 onActivate="#{componentBean.doExecuteAction}": fuego.papi.exception.InvalidTaskNumberException: Invalid task number '0' for activity '/Manager#Default-1.0/Global'.
    Warning in the Log:
    There was an error when trying to obtain the environement information: null
    Application: Engine, Module: Main, Thread: <0> StartUpServerIt gives me the top error when I have the notification set up to receive an external notification and gives me the warning for both cases either external notification or internal event. Its an internal event but in the documentation it never covers internal event situations for NotificationWait so I tried both.
    Another thing is when I have 2 or more instances waiting at the wait how does it know which one to go too? In the real example it will be receiving an object from the thread that will have an id number. But in this little test set up how does it know which instance the global activity is for?

  • Static class garbage collection

    Can garbage collector can garbage collect static classes ?.
    My doubt is that when you access a static class , that class is loaded through its class loader ( when first time that class is referenced ).
    So when did the garbage collector collects this static class ( assume that static class no longer referred ).
    Please do more information,
    What are the ways to prevent garbage collector for a particular class ( Assume that i m implementing a singleton for my java runtime)
    thanks and regards
    Renjith.

    Can garbage collector can garbage collect static classes ?. Static classes are nothing special in terms of class loading - they are only different in visibility for linking.
    Perhaps you mean static members of classes?
    My doubt is that when you access a static class ,
    that class is loaded through its class loader ( when
    first time that class is referenced ). Classes are always loaded through classloaders. Objects of those classes are allocated from the heap, and the object instances refer to the class object.
    Objects (either instances, or classes themselves) are garbage collected when they are no longer live (i.e. no live object refers to them). (This is a somewhat recursive definition, and sometimes, you can have cyclic dependencies that make garbage collection tricky, but the GC, while it has to be conservative for correctness, usually gets it right).
    So for a static member to be garbage-collected, the class has to be garbage-collected first. The class cannot be GC'ed until all references to it go away (this includes all dynamically allocated objects of that type, and the class loader that loaded that class).
    And yes, class loaders can go away, but only if they are created by your program. The system class loader (which is the default classloader you get if you don't create any class loaders of your own) never goes away, so any class loaded from CLASSPATH will never be unloaded.
    (As an example, servlet containers - e.g. Tomcat, Weblogic, etc.) allocate one or more classloaders for each webapp. When the webapp is un-deployed, the classloaders are "orphaned", and they, and any classes loaded by them (from the WEB-INF/lib and WEB-INF/classes directories) are unloaded and garbage-collected. (After all the dynamic objects of those classes are GC'ed, of course).
    >
    So when did the garbage collector collects this
    static class ( assume that static class no longer
    referred ).
    Please do more information,
    What are the ways to prevent garbage collector for a
    particular class ( Assume that i m implementing a
    singleton for my java runtime)
    thanks and regards
    Renjith.

Maybe you are looking for

  • Pr link Ae not rendering correctly

    Hi, I'm relatively new to this type of workflow and will try to communicate the problem the best I can. My main goal is to trouble shoot where the glitch is. The Problem: I am editing 4K and 5K footage in Pr on a 1080p timeline and sending some clips

  • New Harddrive, Need to Import Library

    My old harddrive went out on me, new one installed, how do I put my library from my ipod to my new itunes?

  • Bank Chain development

    Hi, If somebody is having idea on bank chain development process or having documents on this, please share with me... Regards Harry

  • Brief hi-res screen review for MBP.

    I waited to get the high resolution screen when I got this MBP, mostly because I'd be working on photography during a journey. I appreciated it on a long trip, allowing me to let  watch end-of-season 49'ers and Giants' games, but had no idea how poor

  • Sub contracting and production time

    Hello Experts, My problem is related to sub contracting and how to reflect the time the subcontractor needs to produce the goods. My system works as follows.  I create a subcontacting for material A. This material has delivery time 5 days. I supply t